ctdb-tests: Limit red-black tree test to 5s of random inserts
authorMartin Schwenke <mschwenke@ddn.com>
Thu, 29 Feb 2024 02:30:04 +0000 (13:30 +1100)
committerVolker Lendecke <vl@samba.org>
Thu, 29 Feb 2024 13:20:40 +0000 (13:20 +0000)
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 <vl@samba.org>
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Feb 29 13:20:40 UTC 2024 on atb-devel-224

ctdb/tests/UNIT/cunit/rb_test_001.sh
ctdb/tests/src/rb_test.c

index 25d3ceb8ed0f114d3498bbf5fa10f00b68bf9567..a2cf2571f9809ed1a33d23702cd7aa6afaf0ec20 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+timeout=5
+
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
 output="\
@@ -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"
index d712c9a80adff1b2c484f0f3968e3f936067123d..aaab459477fc518dc3101b524ff6e09dfdcc3290 100644 (file)
@@ -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;
@@ -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);
@@ -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);
 
@@ -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++;