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

Basic functional test #3

Closed
wants to merge 56 commits into from

Conversation

dcermak
Copy link
Collaborator

@dcermak dcermak commented Nov 6, 2020

This is my current state of the openQA tests for the kiwi staging area.
This fixes #2, #5, #6

What it does:

  • iso images are booted, login is tested and either the vm is turned off, if this is an installation iso or rebooted and reloged in, if it is a live iso
  • disk images are booted, user is logged in, rebooted, user logs in again and then the VM is turned off
  • the created hard drive of an installation iso is saved and goes through the same test as any other kiwi disk image

what currently does not work:

  • login on the openstack qcow2 image is broken, the default credentials do not work (fixed by @schaefi, the image had its root console deactivated)
  • all the raw disk images appear not to work, for some reason openQA cannot create a working disk image from these
  • kiwi-test-image-disk-legacy.x86_64.iso and kiwi-test-image-custom-partitions.x86_64.iso hang during the installation and never reach a login prompt
  • the hackery that I added to select the correct entry in the boot menu is not really that great and does only appear to work by accident

What still needs to be done:

  • documentation what is going on and how to configure openqa (external settings are necessary)
  • [ ] add some actually meaningful testing, currently we just test whether this image boots
  • test other distributions as well
  • reconsider whether we should include the build id of the images in the schedule command: calling them by their static link means that openQA does not download newer versions if the old asset stays around (this should be done)

@schaefi
Copy link
Contributor

schaefi commented Nov 10, 2020

@dcermak I added the "do not merge" label since you are still working on it. Please drop the label when you are done. Thanks

tests/boot.pm Outdated Show resolved Hide resolved
tests/boot.pm Outdated
Comment on lines 22 to 27
assert_screen("kiwi_bootloader");

# for some live images the default selected boot entry is the "Boot from Hard Disk" entry
# we don't want that, so we need to select the correct entry that says "Install $NAME"
# to achieve that, we just try to spam first up and then down until we get a needle match
if (check_screen("kiwi_bootloader_boot_from_hdd") && defined(get_var("PUBLISH_HDD_1"))) {
Copy link

Choose a reason for hiding this comment

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

These both assert_screen … check_screen calls can likely be combined
with a multi-tag assert_screen with match_has_tag instead of check_screen with non-zero timeout to prevent introducing any timing dependant behaviour, to save test execution time as well as state more explicitly from the testers point of view what are the expected alternatives. A common simple example that I supply should explain it:

assert_screen([qw(yast2_console-finished yast2_missing_package)]);
if (match_has_tag('yast2_missing_package')) {
    send_key 'alt-o';  # confirm package installation
    assert_screen 'yast2_console-finished';
}

so let me try to suggest what you could here, e.g. like this:

assert_screen [qw(kiwi_bootloader kiwi_bootloader_boot_from_hdd)];
if match_has_tag 'kiwi_bootloader_boot_from_hdd' && defined(get_var("PUBLISH_HDD_1")) {
…

tests/login.pm Outdated
sub run {
assert_screen("login_prompt");
type_string("root");
send_key("ret", wait_screen_change => 1);
Copy link

Choose a reason for hiding this comment

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

While using wait_screen_change and wait_still_screen sound simpler in some cases they often either waste time or introduce timing behaviour dependant problems. wait_screen_change means that this line finishes as soon as any screen change is seen, which might before the system is ready to accept the next line where you type the password.

It is often better to be explicit and have a proper needle check in the middle:

assert_screen 'login_prompt';
type_string 'root';
send_key 'ret';
assert_screen 'password_prompt';
type_string 'linux';
send_key 'ret';
assert_screen 'textmode_logged_in';

I see that you have added code further down to handle "grub stuff on the screen". Likely your needle for 'textmode_logged_in' is too big and hence too restrictive as it might fail to be detected due to the "grub stuff". If that is the case think like a human. What do you really look for on the screen to detect that the "textmode is logged in"? Likely it is just something like the prompt sign and some free space to the right of it, e.g. # and nothing else :) This is what is included in the corresponding needle within os-autoinst-distri-opensuse

tests/reboot.pm Outdated
Comment on lines 22 to 27
assert_screen("textmode_logged_in");
assert_script_run("reboot");

assert_screen("kiwi_bootloader");

assert_screen("login_prompt");
Copy link

Choose a reason for hiding this comment

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

just a matter of taste. I would write no parentheses for such simple code and use single ticks to prevent accidental variable expansion where not explicitly desired, e.g.:

    assert_screen 'textmode_logged_in';
    assert_script_run 'reboot';
    assert_screen 'kiwi_bootloader';
    assert_screen 'login_prompt';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The single tick backticks are a good idea, thank you!

But unless @schaefi insists on leaving out the parenthesis, I'd really like to keep them (I just don't like this shell like parameter passing convention in perl).

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with you on the parenthesis. As I come from python and formerly from C and also wrote perl in the C style syntax I'm used to parenthesis for function parameter lists. Nevertheless I have no super strong opinion about it if we do it consistently. So parenthesis everywhere or nowhere but no mix please :)

I also checked on perlcritic in --brutal mode and it does not complain if you use parenthesis or not. On the other side it does complain if you use builtin methods like e.g print with parenthesis. This means if you want to handle this topic in a consistent way and perlcritic --brutal clean code you are forced to prevent parenthesis unless a custom .perlcritic file configures the desired behavior.

In the end this is personal taste and I only want consistency if that makes sense to you too

tests/reboot.pm Outdated
assert_screen('textmode_logged_in');
assert_script_run('reboot');

assert_screen('kiwi_bootloader');
Copy link

Choose a reason for hiding this comment

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

If this is only temporarily shown, e.g. due to an automatic timeout I recommend to not have that check at all due to the possibility that the test system might "miss" the screen and then fail when the SUT already continues booting. This happened in other cases hence I am sharing that problem from the past. A good hint how to design openQA tests in this regard: Think about how a manual tester would type in "reboot" and then goes away to get a cup of coffee. After return the test would see the 'login_prompt' only, not the intermediate state. If you ask the overly stupid tester to "check for kiwi_bootloader" that tester would say the test failed as the login prompt is shown instead of the expected "kiwi_bootloader" screen :)

By the way, openQA automatically records screenshots if the screen changes more than a defined threshold so it's likely that the bootloader screen would show up as intermediate screenshot anyway regardless of an explicit check or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, this makes sense, but then again, not checking for the bootloader could also result in the situation that you just press ctrl+d and never reboot. The test would then still pass, as it only checks that the login screen is present and newer for the bootloader. But not sure whether it really makes sense to worry about that.

Copy link

Choose a reason for hiding this comment

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

If you want to be explicit then disable the grub timeout before reboot, trigger reboot, wait for grub menu, and explicitly call send_key 'ret'.

Basically I see three options:

  1. leave it as is
  2. Add the explicit grub menu check with disabled timeout and explicit boot confirmation action needed
  3. reboot, wait for login and check afterwards that a reboot actually happened, e.g. in logs or uptime
  4. just remove the check and not know if the system actually rebooted

I am just providing the options and of course I am in no position to "block" your PR for this repo here :) But based on my experience I just advise against 1. and invest the effort to go for 2., 3. or 4. because I am convinced that sooner or later 1. will cause more pain and time wasted to understand what is going on than what one would consider worth the effort :)

@dcermak dcermak force-pushed the basic_functional_test branch 4 times, most recently from f677342 to 5f266ee Compare November 30, 2020 22:09
@dcermak dcermak force-pushed the basic_functional_test branch 2 times, most recently from a322948 to 0b776f6 Compare December 11, 2020 12:31
settings.py Outdated Show resolved Hide resolved
@dcermak dcermak force-pushed the basic_functional_test branch 9 times, most recently from d3a203f to 14d1a3e Compare April 29, 2021 12:37
@dcermak dcermak force-pushed the basic_functional_test branch 7 times, most recently from 12930a6 to bbaaa10 Compare April 30, 2021 12:03
Currently we publish HDD images from different isos under the same name, which
can probably cause all kinds of failures. We now insert the kiwi package name,
which should result in a unique qcow2 disk image name.
@dcermak dcermak force-pushed the basic_functional_test branch 2 times, most recently from dd98927 to 01b2056 Compare October 27, 2021 08:26
@okurz
Copy link

okurz commented Nov 9, 2021

@dcermak as over the past months you have updated this PR but it does not look like you update to have it merged I will unsubscribe from the PR to not get repeated notifications. Feel free to ping me again as soon as you updated the PR for actual review.

@dcermak
Copy link
Collaborator Author

dcermak commented Nov 13, 2021

@okurz we have decided during this week's kiwi community meeting that we are going to drop this PR and just merge the whole thing via #10 as soon as the tests succeed on my local box so that others can collaborate and help get them to run on o3.

@dcermak dcermak closed this Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add initial test
4 participants