]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
tests: Reduce testsuite run-time
authorPhil Sutter <phil@nwl.cc>
Thu, 27 Jun 2024 08:18:18 +0000 (10:18 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Thu, 27 Jun 2024 13:55:26 +0000 (15:55 +0200)
Where acceptable, batch add set element calls to avoid overhead of
excessive 'ipset' program spawns. On my (slow) testing VM, this patch
reduces a full run of tests/runtest.sh from ~70min down to ~11min.

This might eliminate the situation being tested: resize.sh might be such
a case so batch only 255 'ipset add' calls and continue to repeat these
batched calls 32 times in hopes that it still qualifies as the resizing
stress test tests/hash:ip.t calls it.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
tests/resize.sh
tests/resizec.sh
tests/resizen.sh
tests/resizet.sh
tests/setlist_resize.sh

index 19b93fb01876cc1d82299745fdda1b6bd0dcc649..9069b4970e92d7b9a53e7fb7dd439c7229c30255 100755 (executable)
@@ -9,6 +9,6 @@ set -e
 $ipset n resize-test hash:ip hashsize 64
 for x in `seq 1 32`; do
    for y in `seq 1 255`; do
-      $ipset a resize-test 192.168.$x.$y
-   done
+      echo "a resize-test 192.168.$x.$y"
+   done | $ipset restore
 done
index 28d674769f76f9309afe62b2f94ff794645952c5..781acf74c38dd9f49b74922415611f31c86a4365 100755 (executable)
@@ -25,65 +25,65 @@ case "$2" in
        $ipset n test hash:ip $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y comment "text $ip$x$sep$y"
+               echo "a test $ip$x$sep$y comment \"text $ip$x$sep$y\""
            done
-       done
+       done | $ipset restore
        ;;
     ipport)
        $ipset n test hash:ip,port $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023 "text $ip$x$sep$y,1023"
+               echo "a test $ip$x$sep$y,1023 \"text $ip$x$sep$y,1023\""
            done
-       done
+       done | $ipset restore
        ;;
     ipportip)
        $ipset n test hash:ip,port,ip $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023,$ip2 comment "text $ip$x$sep$y,1023,$ip2"
+               echo "a test $ip$x$sep$y,1023,$ip2 comment \"text $ip$x$sep$y,1023,$ip2\""
            done
-       done
+       done | $ipset restore
        ;;
     ipportnet)
        $ipset n test hash:ip,port,net $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023,$ip2/$net comment "text $ip$x$sep$y,1023,$ip2/$net"
+               echo "a test $ip$x$sep$y,1023,$ip2/$net comment \"text $ip$x$sep$y,1023,$ip2/$net\""
            done
-       done
+       done | $ipset restore
        ;;
     net)
        $ipset n test hash:net $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net comment "text $ip$x$sep$y/$net"
+               echo "a test $ip$x$sep$y/$net comment \"text $ip$x$sep$y/$net\""
            done
-       done
+       done | $ipset restore
        ;;
     netnet)
        $ipset n test hash:net,net $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,$ip$y$sep$x/$net comment "text $ip$x$sep$y/$net,$ip$y$sep$x/$net"
+               echo "a test $ip$x$sep$y/$net,$ip$y$sep$x/$net comment \"text $ip$x$sep$y/$net,$ip$y$sep$x/$net\""
            done
-       done
+       done | $ipset restore
        ;;
     netport)
        $ipset n test hash:net,port $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,1023 comment "text $ip$x$sep$y/$net,1023"
+               echo "a test $ip$x$sep$y/$net,1023 comment \"text $ip$x$sep$y/$net,1023\""
            done
-       done
+       done | $ipset restore
        ;;
     netiface)
        $ipset n test hash:net,iface $1 hashsize 64 comment
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,eth0 comment "text $ip$x$sep$y/$net,eth0"
+               echo "$ipset a test $ip$x$sep$y/$net,eth0 comment \"text $ip$x$sep$y/$net,eth0\""
            done
-       done
+       done | $ipset restore
        ;;
 esac
 $ipset l test | grep ^$ip | while read x y z; do
index 9322bd2a2cfcecf00fd371a3b62434125b3b9308..13221f7b0894aa303b5aa703121de322c218d565 100755 (executable)
@@ -25,80 +25,79 @@ case "$2" in
        $ipset n test hash:ip,port,net $1 hashsize 64
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023,$ip2/$net nomatch
+               echo "a test $ip$x$sep$y,1023,$ip2/$net nomatch"
            done
-       done
+       done | $ipset restore
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset t test $ip$x$sep$y,1023,$ip2/$net nomatch 2>/dev/null
+               echo "t test $ip$x$sep$y,1023,$ip2/$net nomatch"
            done
-       done
+       done | $ipset restore 2>/dev/null
        ;;
     netportnet)
        $ipset n test hash:net,port,net $1 hashsize 64
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023,$ip2/$net nomatch
+               echo "a test $ip$x$sep$y,1023,$ip2/$net nomatch"
            done
-       done
+       done | $ipset restore
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset t test $ip$x$sep$y,1023,$ip2/$net nomatch 2>/dev/null
+               echo "t test $ip$x$sep$y,1023,$ip2/$net nomatch"
            done
-       done
+       done | $ipset restore 2>/dev/null
        ;;
     net)
        $ipset n test hash:net $1 hashsize 64
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net nomatch
+               echo "a test $ip$x$sep$y/$net nomatch"
            done
-       done
+       done | $ipset restore
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset t test $ip$x$sep$y/$net nomatch 2>/dev/null
+               echo "t test $ip$x$sep$y/$net nomatch"
            done
-       done
+       done | $ipset restore 2>/dev/null
        ;;
     netnet)
        $ipset n test hash:net,net $1 hashsize 64
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,$ip$y$sep$x/$net nomatch
+               echo "a test $ip$x$sep$y/$net,$ip$y$sep$x/$net nomatch"
            done
-       done
+       done | $ipset restore
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset t test $ip$x$sep$y/$net,$ip$y$sep$x/$net nomatch \
-               2>/dev/null
+               echo "t test $ip$x$sep$y/$net,$ip$y$sep$x/$net nomatch"
            done
-       done
+       done | $ipset restore 2>/dev/null
        ;;
     netport)
        $ipset n test hash:net,port $1 hashsize 64
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,1023 nomatch
+               echo "a test $ip$x$sep$y/$net,1023 nomatch"
            done
-       done
+       done | $ipset restore
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset t test $ip$x$sep$y/$net,1023 nomatch 2>/dev/null
+               echo "t test $ip$x$sep$y/$net,1023 nomatch"
            done
-       done
+       done | $ipset restore 2>/dev/null
        ;;
     netiface)
        $ipset n test hash:net,iface $1 hashsize 64
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,eth0 nomatch
+               echo "a test $ip$x$sep$y/$net,eth0 nomatch"
            done
-       done
+       done | $ipset restore
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset t test $ip$x$sep$y/$net,eth0 nomatch 2>/dev/null
+               echo "t test $ip$x$sep$y/$net,eth0 nomatch"
            done
-       done
+       done | $ipset restore 2>/dev/null
        ;;
 esac
 $ipset x
index eed4abf2bd86e13884c0473be3760ab4e2d7c638..e8fdd732435ab42bf4571c961c37a0ef62e8abc6 100755 (executable)
@@ -25,81 +25,81 @@ case "$2" in
        $ipset n test hash:ip $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y
+               echo "a test $ip$x$sep$y"
            done
-       done
+       done | $ipset restore
        ;;
     ipmark)
        $ipset n test hash:ip,mark $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023
+               echo "a test $ip$x$sep$y,1023"
            done
-       done
+       done | $ipset restore
        ;;
     ipport)
        $ipset n test hash:ip,port $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023
+               echo "a test $ip$x$sep$y,1023"
            done
-       done
+       done | $ipset restore
        ;;
     ipportip)
        $ipset n test hash:ip,port,ip $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023,$ip2
+               echo "a test $ip$x$sep$y,1023,$ip2"
            done
-       done
+       done | $ipset restore
        ;;
     ipportnet)
        $ipset n test hash:ip,port,net $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y,1023,$ip2/$net
+               echo "a test $ip$x$sep$y,1023,$ip2/$net"
            done
-       done
+       done | $ipset restore
        ;;
     netportnet)
        $ipset n test hash:net,port,net $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 128`; do
-               $ipset a test $ip$x$sep$y/$net,1023,$ip$y$sep$x/$net
+               echo "a test $ip$x$sep$y/$net,1023,$ip$y$sep$x/$net"
            done
-       done
+       done | $ipset restore
        ;;
     net)
        $ipset n test hash:net $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net
+               echo "a test $ip$x$sep$y/$net"
            done
-       done
+       done | $ipset restore
        ;;
     netnet)
        $ipset n test hash:net,net $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,$ip$y$sep$x/$net
+               echo "a test $ip$x$sep$y/$net,$ip$y$sep$x/$net"
            done
-       done
+       done | $ipset restore
        ;;
     netport)
        $ipset n test hash:net,port $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,1023
+               echo "a test $ip$x$sep$y/$net,1023"
            done
-       done
+       done | $ipset restore
        ;;
     netiface)
        $ipset n test hash:net,iface $1 hashsize 64 timeout 100
        for x in `seq 0 16`; do
            for y in `seq 0 255`; do
-               $ipset a test $ip$x$sep$y/$net,eth0
+               echo "a test $ip$x$sep$y/$net,eth0"
            done
-       done
+       done | $ipset restore
        ;;
 esac
 $ipset l test | grep ^$ip | while read x y z; do
index 1c2be327b841a6956d243e3601610298766d94a7..acb33e3ba0f080060fced9f79ed5d8558ce8b9a5 100755 (executable)
@@ -25,9 +25,9 @@ rmmod ip_set >/dev/null 2>&1
 create() {
     n=$1
     while [ $n -le 1024 ]; do
-      $ipset c test$n hash:ip
+      echo "c test$n hash:ip"
        n=$((n+2))
-    done
+    done | $ipset restore
 }
 
 for x in `seq 1 $loop`; do