Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use podman everywhere #85

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/openQAcoretest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ use base "basetest";
use testapi;


sub new {
my ($class, $args) = @_;
my $self = $class->SUPER::new($args);
$self->{cre} = get_var('CRE', 'podman');
return $self;
}

sub get_log {
my ($cmd, $name) = @_;
my $ret = script_run "$cmd | tee $name";
Expand Down
1 change: 1 addition & 0 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ sub ensure_unlocked_desktop {
#
sub wait_for_container_log {
my ($container, $text, $cmd, $timeout) = @_;
$cmd //= get_var('CRE', 'podman');
$timeout //= 50;
while ($timeout > 0) {
my $output = script_output("$cmd logs $container 2>&1");
Expand Down
6 changes: 3 additions & 3 deletions tests/containers/build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use testapi;
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);
assert_script_run("for i in {1..3}; do " . $self->{cre} . " build openQA/container/webui -t openqa_webui && break; done", timeout => 3600);
assert_script_run("for i in {1..3}; do " . $self->{cre} . " build openQA/container/worker -t openqa_worker && break; done", timeout => 3600);
assert_script_run("for i in {1..3}; do " . $self->{cre} . " build openQA/container/openqa_data -t openqa_data && break; done", timeout => 3600);
}

1;
28 changes: 12 additions & 16 deletions tests/containers/multiple_container_webui.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@ use testapi;
use utils;

sub test_component {
my ($name, $port, $volumes) = @_;
assert_script_run("docker run --rm -d --network testing -e MODE=$name -e MOJO_LISTEN=http://0.0.0.0:$port $volumes -p $port:$port --name $name openqa_webui");
wait_for_container_log($name, "Listening", "docker");
assert_script_run("docker logs $name");
assert_script_run("docker exec $name curl localhost:$port >/dev/null");
my ($self, $name, $port, $volumes) = @_;
assert_script_run($self->{cre} . " run --rm -d --network testing -e MODE=$name -e MOJO_LISTEN=http://0.0.0.0:$port $volumes -p $port:$port --name $name openqa_webui");
wait_for_container_log($name, "Listening");
assert_script_run($self->{cre} . " logs $name");
assert_script_run($self->{cre} . " exec $name curl localhost:$port >/dev/null");
record_info("$name working");
}

sub run {
my ($self) = @_;
my $volumes = '-v "/root/data/factory:/data/factory" -v "/root/data/tests:/data/tests" -v "/root/openQA/container/webui/conf:/data/conf:ro"';

test_component("webui", 9526, $volumes);
test_component("websockets", 9527, $volumes);
test_component("livehandler", 9528, $volumes);
test_component("scheduler", 9529, $volumes);
$self->test_component("webui", 9526, $volumes);
$self->test_component("websockets", 9527, $volumes);
$self->test_component("livehandler", 9528, $volumes);
$self->test_component("scheduler", 9529, $volumes);

assert_script_run("docker run -d --network testing -e MODE=gru $volumes --name gru openqa_webui");
wait_for_container_log("gru", "started", "docker");
assert_script_run($self->{cre} . " run -d --network testing -e MODE=gru $volumes --name gru openqa_webui");
wait_for_container_log("gru", "started");

assert_script_run("docker rm -f webui");
assert_script_run("docker rm -f websockets");
assert_script_run("docker rm -f livehandler");
assert_script_run("docker rm -f scheduler");
assert_script_run("docker rm -f gru");
assert_script_run($self->{cre} . ' rmi -f gru livehandler scheduler websockets');
}

1;
7 changes: 4 additions & 3 deletions tests/containers/setup_env.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ use utils;
sub run {
my ($self) = @_;

assert_script_run("echo unqualified-search-registries = ['registry.opensuse.org'] > /etc/containers/registries.conf");
assert_script_run("mkdir -p /root/data/factory/{iso,hdd,other} /root/data/tests");
assert_script_run("docker network create testing");
assert_script_run("for i in {1..3}; do docker run --rm -d --network testing -e POSTGRES_PASSWORD=openqa -e POSTGRES_USER=openqa -e POSTGRES_DB=openqa --net-alias=db --name db postgres && break; done", timeout => 600);
wait_for_container_log("db", "database system is ready to accept connections", "docker");
assert_script_run($self->{cre} . " network create testing");
assert_script_run($self->{cre} . " run --rm -d --network testing -e POSTGRES_PASSWORD=openqa -e POSTGRES_USER=openqa -e POSTGRES_DB=openqa --network-alias=db --name db docker.io/library/postgres:latest", timeout => 600);
Comment on lines -10 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems you are reverting the retrying you added just recently?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see it in the diff, but likely this was a timeout I mistakenly added when I didn't know where it was timing out

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But … you removed the retrying, see the diff please. The for i in {1..3}; … is gone

wait_for_container_log("db", "database system is ready to accept connections");
}

1;
11 changes: 6 additions & 5 deletions tests/containers/single_container_webui.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ sub run {

assert_script_run("openssl req -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -subj '/CN=www.mydom.com/O=My Company Name LTD./C=DE' -out server.crt -keyout server.key");

assert_script_run("docker run -d --network testing $volumes $certificates -p 80:80 --name openqa_webui openqa_webui");
wait_for_container_log("openqa_webui", "Web application available at", "docker");
assert_script_run($self->{cre} . " run -d --network testing $volumes $certificates -p 80:80 --name openqa_webui openqa_webui");
wait_for_container_log("openqa_webui", "Web application available at");

assert_script_run("curl http://localhost");
assert_script_run("docker rm -f openqa_webui");
assert_script_run($self->{cre} . " rm -f openqa_webui");
}

sub post_fail_hook {
script_run("docker logs openqa_webui");
script_run("docker rm -f openqa_webui");
my ($self) = @_;
script_run($self->{cre} . " logs openqa_webui");
script_run($self->{cre} . " rm -f openqa_webui");
}

1;
4 changes: 2 additions & 2 deletions tests/containers/worker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ sub run {
my ($self) = @_;
my $volumes = '-v "/root/data/factory:/data/factory" -v "/root/data/tests:/data/tests" -v "/root/openQA/container/openqa_data/data.template/conf/:/data/conf:ro"';

assert_script_run("docker run -d --network testing $volumes --name openqa_worker openqa_worker");
wait_for_container_log("openqa_worker", "API key and secret are needed", "docker");
assert_script_run($self->{cre} . " run -d --network testing $volumes --name openqa_worker openqa_worker");
wait_for_container_log("openqa_worker", "API key and secret are needed");
clear_root_console;
}

Expand Down
3 changes: 1 addition & 2 deletions tests/install/openqa_webui.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ EOF
}

sub install_containers {
assert_script_run("zypper --non-interactive install docker git", timeout => 600);
assert_script_run("systemctl start docker");
assert_script_run("zypper --non-interactive install git podman", timeout => 600);
}

sub run {
Expand Down