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 a35c242 commit 7609837
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
23 changes: 23 additions & 0 deletions dirsrvtests/tests/suites/replication/acceptance_test.py
Expand Up @@ -621,6 +621,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 @@ -463,7 +463,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 @@ -670,8 +672,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 @@ -736,8 +738,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 @@ -752,7 +754,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 @@ -764,7 +766,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 @@ -782,7 +784,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 @@ -802,7 +804,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 @@ -816,15 +818,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);
}

Expand Down

0 comments on commit 7609837

Please sign in to comment.