Skip to content

Commit

Permalink
Use script_retry instead of shell for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
kalikiana committed May 11, 2022
1 parent 2a028a4 commit c267ba8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions tests/containers/build.pm
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use strict;
use base "openQAcoretest";
use testapi;
use utils;

sub run {
my ($self) = @_;
assert_script_run("git clone https://github.com/os-autoinst/openQA.git", timeout => 300);
assert_script_run('for i in {1..3}; do docker build openQA/container/webui -t openqa_webui && break; done', timeout => 3600);
assert_script_run('for i in {1..3}; do docker build openQA/container/worker -t openqa_worker && break; done', timeout => 3600);
assert_script_run('for i in {1..3}; do docker build openQA/container/openqa_data -t openqa_data && break; done', timeout => 3600);
script_retry('docker build openQA/container/webui -t openqa_webui', retry => 3, delay => 60, timeout => 3600);
script_retry('docker build openQA/container/worker -t openqa_worker', retry => 3, delay => 60, timeout => 3600);
script_retry('docker build openQA/container/openqa_data -t openqa_data', retry => 3, delay => 60, timeout => 3600);
}

1;
2 changes: 1 addition & 1 deletion tests/containers/setup_env.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sub run {

assert_script_run("mkdir -p /root/data/factory/{iso,hdd,other} /root/data/tests");
assert_script_run("docker network create testing");
assert_script_run("docker run --rm -d --network testing -e POSTGRES_PASSWORD=openqa -e POSTGRES_USER=openqa -e POSTGRES_DB=openqa --net-alias=db --name db postgres", timeout => 600);
script_retry("docker run --rm -d --network testing -e POSTGRES_PASSWORD=openqa -e POSTGRES_USER=openqa -e POSTGRES_DB=openqa --net-alias=db --name db postgres", retry => 3, delay => 60, timeout => 600);
wait_for_container_log("db", "database system is ready to accept connections", "docker");
}

Expand Down
2 changes: 1 addition & 1 deletion tests/osautoinst/test_running.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use utils;

sub run {
assert_script_run 'command -v ack >/dev/null || zypper --no-refresh -n in ack';
assert_script_run 'ret=false; for i in {1..5} ; do openqa-cli api jobs state=running state=done | ack --passthru --color "running|done" && ret=true && break ; sleep 30 ; done ; [ "$ret" = "true" ]', 300;
script_retry('openqa-cli api jobs state=running state=done | ack --passthru --color "running|done"', retry => 5, delay => 30, timeout => 300);
save_screenshot;
clear_root_console;
}
Expand Down

0 comments on commit c267ba8

Please sign in to comment.