Skip to content

Commit

Permalink
ctdb-tests: Limit red-black tree test to 5s of random inserts
Browse files Browse the repository at this point in the history
rb_test_001.sh runs for 60s even though rb_tree.c is almost never
modified.  This generally extends test time by an unreasonable amount
of time.

Add an optional timeout (in seconds) argument to rb_test, defaulting
to 60, and pass 5 from rb_test_001.sh.  If anyone ever significantly
updates rb_tree.c then they can run rb_test directly with its default
60s timeout... or for as long as they like.

Reported-by: Volker Lendecke <[email protected]>
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Volker Lendecke <[email protected]>

Autobuild-User(master): Volker Lendecke <[email protected]>
Autobuild-Date(master): Thu Feb 29 13:20:40 UTC 2024 on atb-devel-224
  • Loading branch information
mschwenke-ddn authored and vlendec committed Feb 29, 2024
1 parent 0c1ac19 commit 667265b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions ctdb/tests/UNIT/cunit/rb_test_001.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

timeout=5

. "${TEST_SCRIPTS_DIR}/unit.sh"

output="\
Expand All @@ -22,10 +24,10 @@ traverse data:3
deleting key1
run random insert and delete for 60 seconds
run random insert and delete for ${timeout} seconds
deleting all entries"

ok "$output"

unit_test rb_test
unit_test rb_test "$timeout"
14 changes: 11 additions & 3 deletions ctdb/tests/src/rb_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static int count_traverse_abort(void *p, void *d)
*/
int main(int argc, const char *argv[])
{
unsigned int timeout = 0;
int traverse_count;
int i,j,k;
trbt_tree_t *tree;
Expand All @@ -118,6 +119,13 @@ int main(int argc, const char *argv[])
uint32_t **u32array;
uint32_t checksum;

if (argc >= 2) {
timeout = atoi(argv[1]);
}
if (timeout == 0) {
timeout = 60;
}

/* testing trbt_insert32_callback for num_records */
memctx = talloc_new(NULL);
assert(memctx != NULL);
Expand Down Expand Up @@ -252,7 +260,7 @@ int main(int argc, const char *argv[])
talloc_free(memctx);


printf("\nrun random insert and delete for 60 seconds\n");
printf("\nrun random insert and delete for %u seconds\n", timeout);
memctx = talloc_new(NULL);
assert(memctx != NULL);

Expand All @@ -262,12 +270,12 @@ int main(int argc, const char *argv[])
i=0;
start_timer();
checksum = 0;
/* Add and delete nodes from a 3 level tree for 60 seconds.
/* Add and delete nodes from a 3 level tree for <timeout> seconds.
Each time a node is added or deleted, traverse the tree and
compute a checksum over the data stored in the tree and compare this
with a checksum we keep which contains what the checksum should be
*/
while(end_timer() < 60.0){
while(end_timer() < (double)timeout){
char *str;

i++;
Expand Down

0 comments on commit 667265b

Please sign in to comment.