From 1c88f96e59763a86ae02ff16efeb55b9acc6ec7e Mon Sep 17 00:00:00 2001 From: Klim Todrik Date: Mon, 12 Feb 2024 22:53:42 +0100 Subject: [PATCH] Fix/timeouts (#74) * Improve timeouts --------- Co-authored-by: djklim87 --- clt_tests/tests/base/init.recb | 2 +- clt_tests/tests/config-flexible-with-custom-conf.rec | 2 +- clt_tests/tests/config-flexible-with-default-conf.rec | 2 +- clt_tests/tests/plain-indexes-all.rec | 2 +- clt_tests/tests/plain-indexes-crontab.rec | 5 +++-- clt_tests/tests/plain-indexes-crontab2.rec | 5 +++-- clt_tests/tests/plain-indexes-desired.rec | 2 +- clt_tests/tests/plain-indexes-only-crontab.rec | 5 +++-- clt_tests/tests/query_log_to_stdout.rec | 2 +- clt_tests/tests/simple-with-network-host.rec | 2 +- clt_tests/tests/simple.rec | 2 +- clt_tests/tests/test-extra.rec | 6 +++--- clt_tests/tests/test-galera.rec | 6 +++--- 13 files changed, 23 insertions(+), 20 deletions(-) diff --git a/clt_tests/tests/base/init.recb b/clt_tests/tests/base/init.recb index 223d2a1..e605c03 100644 --- a/clt_tests/tests/base/init.recb +++ b/clt_tests/tests/base/init.recb @@ -2,7 +2,7 @@ (dockerd > /var/log/dockerd.log 2>&1 &) > /dev/null ––– output ––– ––– input ––– -timeout 60 tail -n 100 -f /var/log/dockerd.log | grep -qm1 'API listen on /var/run/docker.sock' && echo 'Done' || echo 'Timeout failed' +if timeout 60 grep -qm1 'API listen on /var/run/docker.sock' <(tail -n 0 -f /var/log/dockerd.log); then echo 'Done'; else echo 'Timeout failed'; fi ––– output ––– Done ––– input ––– diff --git a/clt_tests/tests/config-flexible-with-custom-conf.rec b/clt_tests/tests/config-flexible-with-custom-conf.rec index e250d7c..a850605 100644 --- a/clt_tests/tests/config-flexible-with-custom-conf.rec +++ b/clt_tests/tests/config-flexible-with-custom-conf.rec @@ -8,7 +8,7 @@ docker run --name manticore -v "/tmp/manticore.conf:/etc/manticoresearch/mantico ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -sleep 5;docker logs manticore | grep "accepting connections" +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Manticore failed to start properly in 10 seconds'; fi ––– output ––– accepting connections ––– input ––– diff --git a/clt_tests/tests/config-flexible-with-default-conf.rec b/clt_tests/tests/config-flexible-with-default-conf.rec index 5965dda..017a5a5 100644 --- a/clt_tests/tests/config-flexible-with-default-conf.rec +++ b/clt_tests/tests/config-flexible-with-default-conf.rec @@ -4,7 +4,7 @@ docker run -d -e searchd_max_packet_size=64m -e "common_lemmatizer_base=/usr/sha ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -sleep 5;docker logs manticore | grep "accepting connections" +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Manticore failed to start properly in 10 seconds'; fi ––– output ––– accepting connections ––– input ––– diff --git a/clt_tests/tests/plain-indexes-all.rec b/clt_tests/tests/plain-indexes-all.rec index 985d7d0..6e08638 100644 --- a/clt_tests/tests/plain-indexes-all.rec +++ b/clt_tests/tests/plain-indexes-all.rec @@ -4,7 +4,7 @@ docker run -d -e CREATE_PLAIN_TABLES=1 --name manticore -v $(pwd)/clt_tests/test ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -sleep 5;docker logs manticore | grep "accepting connections" +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Manticore failed to start properly in 10 seconds'; fi ––– output ––– accepting connections ––– input ––– diff --git a/clt_tests/tests/plain-indexes-crontab.rec b/clt_tests/tests/plain-indexes-crontab.rec index 555336d..337347e 100644 --- a/clt_tests/tests/plain-indexes-crontab.rec +++ b/clt_tests/tests/plain-indexes-crontab.rec @@ -4,7 +4,7 @@ docker run -d -e "CREATE_PLAIN_TABLES=idx1;idx2:* * * * *" --name manticore -v $ ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -timeout 5 docker logs -f manticore | grep -qm1 "accepting connections" && echo 'accepting connections' || echo 'Timeout failed' +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Timeout failed'; fi ––– output ––– accepting connections ––– input ––– @@ -34,8 +34,9 @@ idx1.spm idx1.spp idx1.spt ––– input ––– -sleep 65 +if timeout 65 grep -qm1 'Indexer_idx2: rotating tables: successfully sent SIGHUP to searchd' <(docker logs -f manticore); then echo 'Cron job done'; else echo 'Cron job not run in 65 seconds'; fi ––– output ––– +Cron job done ––– input ––– docker exec manticore ls | grep idx ––– output ––– diff --git a/clt_tests/tests/plain-indexes-crontab2.rec b/clt_tests/tests/plain-indexes-crontab2.rec index 1d326de..4f99332 100644 --- a/clt_tests/tests/plain-indexes-crontab2.rec +++ b/clt_tests/tests/plain-indexes-crontab2.rec @@ -4,7 +4,7 @@ docker run -d -e "CREATE_PLAIN_TABLES=idx1:* * * * *;idx2" --name manticore -v $ ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -timeout 5 docker logs -f manticore | grep -qm1 "accepting connections" && echo 'accepting connections' || echo 'Timeout failed' +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Timeout failed'; fi ––– output ––– accepting connections ––– input ––– @@ -34,8 +34,9 @@ idx2.spm idx2.spp idx2.spt ––– input ––– -sleep 65 +if timeout 65 grep -qm1 'Indexer_idx1: rotating tables: successfully sent SIGHUP to searchd' <(docker logs -f manticore); then echo 'Cron job done'; else echo 'Cron job not run in 65 seconds'; fi ––– output ––– +Cron job done ––– input ––– docker exec manticore ls | grep idx | sort ––– output ––– diff --git a/clt_tests/tests/plain-indexes-desired.rec b/clt_tests/tests/plain-indexes-desired.rec index 58669e4..500c7e2 100644 --- a/clt_tests/tests/plain-indexes-desired.rec +++ b/clt_tests/tests/plain-indexes-desired.rec @@ -4,7 +4,7 @@ docker run -d -e "CREATE_PLAIN_TABLES=idx1;idx2" --name manticore -v $(pwd)/clt_ ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -sleep 5;docker logs manticore | grep "accepting connections" +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Manticore failed to start properly in 10 seconds'; fi ––– output ––– accepting connections ––– input ––– diff --git a/clt_tests/tests/plain-indexes-only-crontab.rec b/clt_tests/tests/plain-indexes-only-crontab.rec index 36b94f3..60da751 100644 --- a/clt_tests/tests/plain-indexes-only-crontab.rec +++ b/clt_tests/tests/plain-indexes-only-crontab.rec @@ -4,15 +4,16 @@ docker run -d -e "CREATE_PLAIN_TABLES=idx1:* * * * *" --name manticore -v $(pwd) ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -timeout 5 docker logs -f manticore | grep -qm1 "accepting connections" && echo 'accepting connections' || echo 'Timeout failed' +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Timeout failed'; fi ––– output ––– accepting connections ––– input ––– docker exec manticore ls | grep idx | sort ––– output ––– ––– input ––– -sleep 65 +if timeout 65 grep -qm1 'Indexer_idx1: rotating tables: successfully sent SIGHUP to searchd' <(docker logs -f manticore); then echo 'Cron job done'; else echo 'Cron job not run in 65 seconds'; fi ––– output ––– +Cron job done ––– input ––– docker exec manticore ls | grep idx | sort ––– output ––– diff --git a/clt_tests/tests/query_log_to_stdout.rec b/clt_tests/tests/query_log_to_stdout.rec index 7c1dff1..26cbac9 100644 --- a/clt_tests/tests/query_log_to_stdout.rec +++ b/clt_tests/tests/query_log_to_stdout.rec @@ -4,7 +4,7 @@ docker run -d -e QUERY_LOG_TO_STDOUT=true --name manticore manticoresoftware/man ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -timeout 60 docker logs -f manticore | grep -qm1 "accepting connections" && echo 'accepting connections' || echo 'Timeout failed' +if timeout 60 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Timeout failed'; fi ––– output ––– accepting connections ––– input ––– diff --git a/clt_tests/tests/simple-with-network-host.rec b/clt_tests/tests/simple-with-network-host.rec index 6b65515..4027f4c 100644 --- a/clt_tests/tests/simple-with-network-host.rec +++ b/clt_tests/tests/simple-with-network-host.rec @@ -4,7 +4,7 @@ docker run --rm --name=manticore --network=host --quiet -d manticoresoftware/man ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -sleep 5;docker logs manticore | grep "accepting connections" +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Manticore failed to start properly in 10 seconds'; fi ––– output ––– accepting connections ––– input ––– diff --git a/clt_tests/tests/simple.rec b/clt_tests/tests/simple.rec index 812134d..1341368 100644 --- a/clt_tests/tests/simple.rec +++ b/clt_tests/tests/simple.rec @@ -4,7 +4,7 @@ docker run --rm --name=manticore --quiet -d manticoresoftware/manticore:current ––– output ––– #!/[0-9a-z]+/!# ––– input ––– -sleep 5;docker logs manticore | grep "accepting connections" +if timeout 5 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Timeout failed'; fi ––– output ––– accepting connections ––– input ––– diff --git a/clt_tests/tests/test-extra.rec b/clt_tests/tests/test-extra.rec index 2bf7aee..5fecdbc 100644 --- a/clt_tests/tests/test-extra.rec +++ b/clt_tests/tests/test-extra.rec @@ -4,13 +4,13 @@ docker run --rm -e EXTRA=0 --name manticore -d manticoresoftware/manticore:curre ––– output ––– #!/[0-9a-z]{40}$/!# ––– input ––– -timeout 10 docker logs -f manticore 2>1 | grep -qm1 "accepting connections" && echo 'accepting connections' || echo 'Docker failed to start properly in 10 seconds' +if timeout 10 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Docker failed to start properly in 10 seconds'; fi ––– output ––– accepting connections ––– input ––– docker exec manticore searchd --version ––– output ––– -Manticore %{SEMVER} #!/[a-z0-9]{7,9}@[0-9]{6}/!# dev +Manticore %{SEMVER} #!/[a-z0-9]{7,9}@[0-9]{8}/!# dev Copyright (c) 2001-2016, Andrew Aksyonoff Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) Copyright (c) 2017-%{YEAR}, Manticore Software LTD (https://manticoresearch.com) @@ -23,7 +23,7 @@ sleep 1;docker run --rm -e EXTRA=1 --name manticore -v /tmp/idx:/var/lib/mantico ––– output ––– #!/[0-9a-z]{40}$/!# ––– input ––– -timeout 60 docker logs -f manticore 2>&1 | grep -qEm1 "columnar.*?secondary.*?knn" && echo 'Done' || echo 'Not found' +if timeout 60 grep -qEm1 "columnar.*?secondary.*?knn" <(docker logs -f manticore 2>&1); then echo 'Done'; else echo 'Not found'; fi ––– output ––– Done ––– input ––– diff --git a/clt_tests/tests/test-galera.rec b/clt_tests/tests/test-galera.rec index 967180c..03e2da0 100644 --- a/clt_tests/tests/test-galera.rec +++ b/clt_tests/tests/test-galera.rec @@ -4,13 +4,13 @@ docker run --rm -e EXTRA=0 --name manticore -d manticoresoftware/manticore:curre ––– output ––– #!/[0-9a-z]{40}$/!# ––– input ––– -timeout 10 docker logs -f manticore 2>1 | grep -qm1 "accepting connections" && echo 'accepting connections' || echo 'Docker failed to start properly in 10 seconds' +if timeout 10 grep -qm1 'accepting connections' <(docker logs -f manticore); then echo 'accepting connections'; else echo 'Docker failed to start properly in 10 seconds'; fi ––– output ––– accepting connections ––– input ––– docker exec manticore mysql -e "create cluster abc" ––– output ––– -ERROR 1064 (42000) at line 1: failed to make cluster: replication init failed: 10 'feature not implemented' +ERROR 1064 (42000) at line 1: failed to make cluster: Wrong galera interface version. Got -1 ––– input ––– docker stop manticore ––– output ––– @@ -20,7 +20,7 @@ sleep 1;docker run --rm -e EXTRA=1 --name manticore -v /tmp/idx:/var/lib/mantico ––– output ––– #!/[0-9a-z]{40}$/!# ––– input ––– -timeout 60 docker logs -f manticore 2>&1 | grep -qEm1 "columnar.*?secondary.*?knn" && echo 'Done' || echo 'Not found' +if timeout 60 grep -qEm1 "columnar.*?secondary.*?knn" <(docker logs -f manticore 2>1); then echo 'Done'; else echo 'Not found'; fi ––– output ––– Done ––– input –––