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

docker: Add a test for openQA workers containers #3634

Closed
wants to merge 1 commit into from

Conversation

ilausuch
Copy link
Contributor

@ilausuch ilausuch commented Dec 10, 2020

This PR add a test for the openQA workers containers

The current execution with an appropriate environment and configuration
is

[info] [pid:21] worker 1:
 - config file:           /etc/openqa/workers.ini
 - worker hostname:       f2fa029ca2ae
 - isotovideo version:    20
 - websocket API version: 1
 - web UI hosts:          http://localhost:9526
 - class:                 qemu_i386,qemu_x86_64
 - no cleanup:            no
 - pool directory:        /var/lib/openqa/pool/1
API key and secret are needed for the worker connecting
http://localhost:9526

The test probes that the container image can be build and can be used
deploying a worker. But because the is not a web UI is going to fail
in the execution. The test checks that show some part of this information

https://progress.opensuse.org/issues/80682

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

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

As can be seen in CI output this does not work because there is no docker aemon running:

[16:35:42] t/46-worker-container.t ................................... 1/? 
#   Failed test 'worker container image can be built'
#   at t/46-worker-container.t line 20.
#          got: '256'
#     expected: '0'
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

#   Failed test 'worker container starts'
#   at t/46-worker-container.t line 21.
#          got: '256'
#     expected: '0'
# Looks like you failed 2 tests of 3.
                                                                            [16:35:42] t/46-worker-container.t ................................... Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/3 subtests

There were already many other related comments. Please take them into consideration. It seems like you created another PR without addressing all the comments we already provided.

#3623 is where reviewers have already provided many comments. Please don't disregard them, close the PR and create a new one which does not address these points. This can become tedious and frustrating for reviewers.

use Test::Warnings ':report_warnings';

is(system('docker', 'build', '-t', 'openqa_worker', 'docker/worker'), 0, 'worker container image can be built');
is(system('docker run -t -v $(pwd)/t/data/workers.ini:/data/conf/workers.ini openqa_worker | grep "worker connecting"'), 0, 'worker container starts');
Copy link
Member

Choose a reason for hiding this comment

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

Better not rely on the current directory being the root of the working copy. Better use FindBin as in other tests.

This PR add a test for the openQA workers containers

The current execution with an appropriate environment and configuration
is

----
[info] [pid:21] worker 1:
 - config file:           /etc/openqa/workers.ini
 - worker hostname:       f2fa029ca2ae
 - isotovideo version:    20
 - websocket API version: 1
 - web UI hosts:          http://localhost:9526
 - class:                 qemu_i386,qemu_x86_64
 - no cleanup:            no
 - pool directory:        /var/lib/openqa/pool/1
API key and secret are needed for the worker connecting
http://localhost:9526
----

The test probes that the container image can be build and can be used
deploying a worker. But because the is not a web UI is going to fail
in the execution. The test checks that show some part of this information

progress.opensuse.org/issues/80682
Comment on lines +20 to +26
use File::Temp qw/ tempdir /;

my $dir = tempdir( CLEANUP => 1 );
copy("./t/data/workers.ini", "$dir/workers.ini") or die "Copy failed: $!";

is(system('docker', 'build', '-t', 'openqa_worker', 'docker/worker'), 0, 'worker container image can be built');
is(system("docker run -t -v $dir/workers.ini:/data/conf/workers.ini openqa_worker | grep 'worker connecting'"), 0, 'worker container starts');
Copy link
Member

Choose a reason for hiding this comment

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

As discussed you don't need the tempdir at all. I would not care if etc/workers.ini is changed by the worker as it should not happen anyway.

As you asked in video chat regarding waiting for something in logs you could do more or less the following pseudo-code:

for (1 .. timeout) {
  last if grep 'my expected string' $logfile;
  sleep .1;
}

@ilausuch
Copy link
Contributor Author

This problem is covered by os-autoinst/os-autoinst-distri-openQA#60

@ilausuch ilausuch closed this Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants