Skip to content

Commit

Permalink
Merge pull request #10316 from grisu48/docker-base
Browse files Browse the repository at this point in the history
Add docker base image test
  • Loading branch information
ge0r committed May 20, 2020
2 parents 78e0f62 + ea448b3 commit 0735551
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/main_common.pm
Expand Up @@ -1711,6 +1711,7 @@ sub load_extra_tests_docker {

loadtest "console/docker";
loadtest "console/docker_runc";
loadtest "console/docker_base_images";
if (is_sle(">=12-sp3")) {
loadtest "console/docker_image";
loadtest "console/docker_compose" if is_sle('15+');
Expand Down
55 changes: 55 additions & 0 deletions tests/console/docker_base_images.pm
@@ -0,0 +1,55 @@
# SUSE's openQA tests
#
# Copyright © 2020 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: Pull and test several base images for their functionality
# Maintainer: Felix Niederwanger <felix.niederwanger@suse.de>

use base 'consoletest';
use strict;
use warnings;
use testapi;
use utils;
use version_utils;
use containers::common;

# Test a given image. Takes the docker image name and version as argument
sub test_image {
my $name = $_[0];
my $version = $_[1] //= "latest";
# Pull the image
my $image = "$name:$version";
assert_script_run("docker image pull $image", timeout => 300);
assert_script_run("docker image ls | grep '$name' | grep '$version'");

my $container = "${name}_${version}_smoketest";
$container =~ s!/!.!g; # Slashes are not allowed as container names, but used for fetching images. Replace them with a dot
my $smoketest = "/bin/uname -r; /bin/echo \"Heartbeat from $image\"";
assert_script_run("docker container create --name '$container' '$image' /bin/sh -c '$smoketest'");
assert_script_run("docker container start '$container'");
assert_script_run("docker container logs '$container' > '/var/tmp/container_$container'");
assert_script_run("docker container rm '$container'");
assert_script_run("grep \"`uname -r`\" '/var/tmp/container_$container'");
assert_script_run("grep \"Heartbeat from $image\" '/var/tmp/container_$container'");
}

sub run {
select_console("root-console");
install_docker_when_needed();
# Test base images
test_image('alpine', 'latest');
test_image('opensuse/leap', 'latest');
test_image('opensuse/tumbleweed', 'latest');
test_image('debian', 'latest');
test_image('ubuntu', 'latest');
test_image('centos', 'latest');
test_image('fedora', 'latest');
clean_docker_host();
}

1;

0 comments on commit 0735551

Please sign in to comment.