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
Closed
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
1 change: 1 addition & 0 deletions .circleci/ci-packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,4 @@ python3-setuptools-40.5.0
python3-yamllint-1.22.1
ShellCheck-0.7.1
sqlite3-3.28.0
docker
28 changes: 28 additions & 0 deletions t/46-worker-container.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env perl
# Copyright (C) 2020 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

use Test::Most;
use Test::Warnings ':report_warnings';
use File::Copy;
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');
Comment on lines +20 to +26
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;
}


done_testing();