Skip to content

Commit

Permalink
Issue 4507 - Improve csngen testing task (#4508)
Browse files Browse the repository at this point in the history
Description:  Once the csngen testing task is created, it will not stop for 10 minutes
              even if you attempt to stop the server.  This is adding 10 minutes to
              the CI testing runs.

              Improved this task to check for the server shutdown, an moved the csngen
              test to the bottom of the file so it is executed last so it does not
              interfere with other tests

Fixes: #4507

Reviewed by: tbordaz(Thanks!)
  • Loading branch information
mreynolds389 committed Jan 5, 2021
1 parent 0f38410 commit a161815
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
45 changes: 23 additions & 22 deletions dirsrvtests/tests/suites/replication/acceptance_test.py
Expand Up @@ -501,28 +501,6 @@ def test_warining_for_invalid_replica(topo_m4):
log.info('Check the error log for the error')
assert topo_m4.ms["master1"].ds_error_log.match('.*nsds5ReplicaBackoffMax.*10.*invalid.*')

@pytest.mark.skipif(ds_is_older('1.4.4'), reason="Not implemented")
def test_csngen_task(topo_m2):
"""Test csn generator test
:id: b976849f-dbed-447e-91a7-c877d5d71fd0
:setup: MMR with 2 masters
:steps:
1. Create a csngen_test task
2. Check that debug messages "_csngen_gen_tester_main" are in errors logs
:expectedresults:
1. Should succeeds
2. Should succeeds
"""
m1 = topo_m2.ms["master1"]
csngen_task = csngenTestTask(m1)
csngen_task.create(properties={
'ttl': '300'
})
time.sleep(10)
log.info('Check the error log contains strings showing csn generator is tested')
assert m1.searchErrorsLog("_csngen_gen_tester_main")

@pytest.mark.ds51082
def test_csnpurge_large_valueset(topo_m2):
"""Test csn generator test
Expand Down Expand Up @@ -642,6 +620,29 @@ def test_urp_trigger_substring_search(topo_m2):
assert not found


@pytest.mark.skipif(ds_is_older('1.4.4'), reason="Not implemented")
def test_csngen_task(topo_m2):
"""Test csn generator test
:id: b976849f-dbed-447e-91a7-c877d5d71fd0
:setup: MMR with 2 masters
:steps:
1. Create a csngen_test task
2. Check that debug messages "_csngen_gen_tester_main" are in errors logs
:expectedresults:
1. Should succeeds
2. Should succeeds
"""
m1 = topo_m2.ms["master1"]
csngen_task = csngenTestTask(m1)
csngen_task.create(properties={
'ttl': '300'
})
time.sleep(10)
log.info('Check the error log contains strings showing csn generator is tested')
assert m1.searchErrorsLog("_csngen_gen_tester_main")


if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
Expand Down
26 changes: 13 additions & 13 deletions ldap/servers/slapd/csngen.c
Expand Up @@ -486,7 +486,9 @@ csngen_test()

rc = _csngen_start_test_threads(gen);
if (rc == 0) {
DS_Sleep(PR_SecondsToInterval(TEST_TIME));
for (size_t i = 0; i < TEST_TIME && !slapi_is_shutting_down(); i++) {
DS_Sleep(PR_SecondsToInterval(1));
}
}

_csngen_stop_test_threads();
Expand Down Expand Up @@ -693,8 +695,8 @@ _csngen_adjust_local_time(CSNGen *gen, time_t cur_time)
#define DEFAULT_THREAD_STACKSIZE 0

#define GEN_TREAD_COUNT 20
int s_thread_count;
int s_must_exit;
static int s_thread_count;
static int s_must_exit;

static int
_csngen_start_test_threads(CSNGen *gen)
Expand Down Expand Up @@ -759,8 +761,8 @@ _csngen_stop_test_threads(void)
s_must_exit = 1;

while (s_thread_count > 0) {
/* sleep for 30 seconds */
DS_Sleep(PR_SecondsToInterval(20));
/* sleep for 5 seconds */
DS_Sleep(PR_SecondsToInterval(5));
}
}

Expand All @@ -775,7 +777,7 @@ _csngen_gen_tester_main(void *data)

PR_ASSERT(gen);

while (!s_must_exit) {
while (!s_must_exit && !slapi_is_shutting_down()) {
rc = csngen_new_csn(gen, &csn, PR_FALSE);
if (rc != CSN_SUCCESS) {
slapi_log_err(SLAPI_LOG_ERR, "_csngen_gen_tester_main",
Expand All @@ -787,7 +789,7 @@ _csngen_gen_tester_main(void *data)
csn_free(&csn);

/* sleep for 30 seconds */
DS_Sleep(PR_SecondsToInterval(10));
DS_Sleep(PR_SecondsToInterval(30));
}

PR_AtomicDecrement(&s_thread_count);
Expand All @@ -805,7 +807,7 @@ _csngen_remote_tester_main(void *data)

PR_ASSERT(gen);

while (!s_must_exit) {
while (!s_must_exit && !slapi_is_shutting_down()) {
rc = csngen_new_csn(gen, &csn, PR_FALSE);
if (rc != CSN_SUCCESS) {
slapi_log_err(SLAPI_LOG_ERR, "_csngen_remote_tester_main",
Expand All @@ -825,7 +827,7 @@ _csngen_remote_tester_main(void *data)
csn_free(&csn);

/* sleep for 30 seconds */
DS_Sleep(PR_SecondsToInterval(60));
DS_Sleep(PR_SecondsToInterval(30));
}

PR_AtomicDecrement(&s_thread_count);
Expand All @@ -839,15 +841,13 @@ _csngen_local_tester_main(void *data)

PR_ASSERT(gen);


while (!s_must_exit) {
while (!s_must_exit && !slapi_is_shutting_down()) {
/* sleep for 30 seconds */
DS_Sleep(PR_SecondsToInterval(60));
DS_Sleep(PR_SecondsToInterval(30));

/*
* g_sampled_time -= slapi_rand () % 100;
*/

csngen_dump_state(gen, SLAPI_LOG_INFO);
}

Expand Down

0 comments on commit a161815

Please sign in to comment.