From 44ec3d84c38250a398ab3a88058e360f4b3ceb12 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 20 Sep 2016 11:41:12 -0700 Subject: [PATCH] add a base_update_cli test Summary: this uses a couple of test repos with fake packages to test the basic dnf mechanisms are working, then messes around with the python3-kickstart package a bit to try and test the default repo configuration is working, keys are in place and so on. We use python3-kickstart because we should be able to rely on the copy of that package in the 'stable' repo being installable (or else the compose would have failed), but it shouldn't be vital to the operation of the system. Test Plan: Run the test, see if it works. Reviewers: jskladan, garretraziel Reviewed By: garretraziel Subscribers: tflink Differential Revision: https://phab.qadevel.cloud.fedoraproject.org/D1006 --- lib/packagetest.pm | 37 +++++++++++++++++++++++++++++++++++ templates | 42 ++++++++++++++++++++++++++++++++++++++++ tests/base_update_cli.pm | 38 ++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 lib/packagetest.pm create mode 100644 tests/base_update_cli.pm diff --git a/lib/packagetest.pm b/lib/packagetest.pm new file mode 100644 index 00000000..4e62ba01 --- /dev/null +++ b/lib/packagetest.pm @@ -0,0 +1,37 @@ +package packagetest; + +use strict; + +use base 'Exporter'; +use Exporter; + +use testapi; +our @EXPORT = qw/prepare_test_packages verify_installed_packages verify_updated_packages/; + +# enable the openqa test package repositories and install the main +# test packages, remove python3-kickstart and install the fake one +sub prepare_test_packages { + # remove python3-kickstart if installed (we don't use assert + # here in case it's not) + script_run 'dnf -y remove python3-kickstart'; + # grab the test repo definitions + assert_script_run 'curl -o /etc/yum.repos.d/openqa-testrepo-1.repo https://fedorapeople.org/groups/qa/openqa-repos/openqa-testrepo-1.repo'; + # install the test packages from repo1 + assert_script_run 'dnf -y --disablerepo=* --enablerepo=openqa-testrepo-1 install python3-kickstart'; +} + +# check our test packages installed correctly (this is a test that dnf +# actually does what it claims) +sub verify_installed_packages { + validate_script_output 'rpm -q python3-kickstart', sub { $_ =~ m/^python3-kickstart-1.1.noarch$/ }; + assert_script_run 'rpm -V python3-kickstart'; +} + +# check updating the test packages and the fake python3-kickstart work +# as expected +sub verify_updated_packages { + # we don't know what version of python3-kickstart we'll actually + # get, so just check it's *not* the fake one + validate_script_output 'rpm -q python3-kickstart', sub { $_ !~ m/^python3-kickstart-1-1.noarch$/ }; + assert_script_run 'rpm -V python3-kickstart'; +} diff --git a/templates b/templates index 7cd6d4a3..c2972b5a 100755 --- a/templates +++ b/templates @@ -270,6 +270,39 @@ }, test_suite => { name => "base_service_manipulation" }, }, + { + machine => { name => "64bit" }, + prio => 40, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "Workstation-live-iso", + version => "*", + }, + test_suite => { name => "base_update_cli" }, + }, + { + machine => { name => "64bit" }, + prio => 40, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "Server-dvd-iso", + version => "*", + }, + test_suite => { name => "base_update_cli" }, + }, + { + machine => { name => "64bit" }, + prio => 42, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "KDE-live-iso", + version => "*", + }, + test_suite => { name => "base_update_cli" }, + }, { machine => { name => "64bit" }, prio => 30, @@ -1896,6 +1929,15 @@ { key => "HDD_1", value => "disk_%FLAVOR%_%MACHINE%.qcow2" }, ], }, + { + name => "base_update_cli", + settings => [ + { key => "ENTRYPOINT", value => "base_update_cli" }, + { key => "START_AFTER_TEST", value => "install_default_upload" }, + { key => "BOOTFROM", value => "c" }, + { key => "HDD_1", value => "disk_%FLAVOR%_%MACHINE%.qcow2" }, + ], + }, { name => "install_kickstart_firewall_disabled", settings => [ diff --git a/tests/base_update_cli.pm b/tests/base_update_cli.pm new file mode 100644 index 00000000..641e3fb2 --- /dev/null +++ b/tests/base_update_cli.pm @@ -0,0 +1,38 @@ +use base "installedtest"; +use strict; +use testapi; +use packagetest; + +sub run { + my $self = shift; + # wait for boot to complete + $self->boot_to_login_screen("", 30); + # switch to TTY3 for both, graphical and console tests + $self->root_console(tty=>3); + # enable test repos and install test packages + prepare_test_packages; + # check rpm agrees they installed good + verify_installed_packages; + # update the fake python3-kickstart (should come from the real repo) + # this can take a long time if we get unlucky with the metadata refresh + assert_script_run 'dnf -y --disablerepo=openqa-testrepo* --disablerepo=updates-testing update python3-kickstart', 600; + # check we got the updated version + verify_updated_packages; + # now remove python3-kickstart, and see if we can do a straight + # install from the default repos + assert_script_run 'dnf -y remove python3-kickstart'; + assert_script_run 'dnf -y --disablerepo=openqa-testrepo* --disablerepo=updates-testing install python3-kickstart', 120; + assert_script_run 'rpm -V python3-kickstart'; +} + +sub test_flags { + # without anything - rollback to 'lastgood' snapshot if failed + # 'fatal' - whole test suite is in danger if this fails + # 'milestone' - after this test succeeds, update 'lastgood' + # 'important' - if this fails, set the overall state to 'fail' + return { fatal => 1 }; +} + +1; + +# vim: set sw=4 et: