Automate QA:Testcase_Zezere_Ignition

This is a bit complex to automate, because we cannot really use
the production Zezere server (provision.fedoraproject.org) as
the test case shows, as we'd have to solve authentication and
we also don't really want to constantly keep registering new
hosts to it that are going to disappear and never be seen again.

So, instead we'll do it by setting up our *own* Zezere, and
provisioning our IoT system in that. We run two tests. The
'ignition' test is the actual IoT 'device'; all it really does
is boot up, sit around, and wait to be provisioned. The 'server'
test first sets up a Zezere server, then logs into it, adds an
ssh key, claims the IoT device, provisions it, and connects to
it to create a special file which tells the 'ignition' test
everything worked and it can close out.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2020-07-15 14:56:32 -07:00
parent 72edbfe991
commit aa41fe4e4e
27 changed files with 333 additions and 1 deletions

View File

@ -455,6 +455,9 @@ sub setup_workaround_repo {
}
sub _repo_setup_compose {
# doesn't work for IoT, anything that hits this in an IoT path
# must work with default mirror config...
return if (get_var("SUBVARIANT") eq "IoT");
# Appropriate repo setup steps for testing a compose
# disable updates-testing and updates and use the compose location
# as the target for fedora and rawhide rather than mirrorlist, so

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 204,
"ypos": 213,
"width": 35,
"height": 16,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_claim_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"height": 16,
"type": "match",
"ypos": 213,
"width": 35,
"xpos": 205
}
],
"properties": [],
"tags": [
"zezere_claim_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 102,
"ypos": 158,
"width": 155,
"height": 12,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_claim_unowned"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 481,
"ypos": 159,
"width": 133,
"height": 12,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_device_management"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 21,
"ypos": 119,
"width": 44,
"height": 12,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_login"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 14,
"ypos": 214,
"width": 89,
"height": 13,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_provision_installed"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 27,
"ypos": 214,
"width": 12,
"height": 13,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_provision_menu"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 176,
"ypos": 214,
"width": 52,
"height": 13,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_provision_schedule"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 299,
"ypos": 157,
"width": 142,
"height": 15,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_ssh_key"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 26,
"ypos": 292,
"width": 185,
"height": 10,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_ssh_key_contents"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 377,
"ypos": 238,
"width": 67,
"height": 13,
"type": "match"
}
],
"properties": [],
"tags": [
"zezere_submit_provision"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1584,6 +1584,46 @@
"USER_LOGIN": "false"
}
},
"iot_zezere_ignition": {
"profiles": {
"fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20,
"fedora-IoT-dvd_ostree-iso-x86_64-*-64bit": 40
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0 zezere.url=http://172.16.2.118",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"NICTYPE": "tap",
"PARALLEL_WITH": "iot_zezere_server",
"POSTINSTALL": "iot_zezere_ignition",
"POST_STATIC": "172.16.2.119 zezere001.domain.local",
"ROOT_PASSWORD": "weakpassword",
"START_AFTER_TEST": "install_default_upload",
"USER_LOGIN": "false",
"WORKER_CLASS": "tap"
}
},
"iot_zezere_server": {
"profiles": {
"fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20,
"fedora-IoT-dvd_ostree-iso-x86_64-*-64bit": 40
},
"settings": {
"BOOTFROM": "c",
"GRUB_POSTINSTALL": "net.ifnames=0 biosdevname=0",
"HDD_1": "disk_f%CURRREL%_support_5_%ARCH%.img",
"NICTYPE": "tap",
"PARALLEL_CANCEL_WHOLE_CLUSTER": "0",
"POSTINSTALL": "_iot_zezere_server _setup_browser _iot_zezere_remote",
"POST_STATIC": "172.16.2.118 zezere002.domain.local",
"ROOT_PASSWORD": "weakpassword",
"START_AFTER_TEST": "install_default_upload",
"TEST_TARGET": "NONE",
"USER_LOGIN": "false",
"WORKER_CLASS": "tap"
}
},
"mediakit_fileconflicts": {
"profiles": {
"fedora-Server-dvd-iso-aarch64-*-aarch64": 10,

View File

@ -0,0 +1,58 @@
use base "installedtest";
use strict;
use lockapi;
use testapi;
use utils;
sub run {
my $self = shift;
# set up an ssh key
type_string "ssh-keygen\n";
sleep 2;
# confirm directory
send_key "ret";
sleep 2;
# empty passphrase
send_key "ret";
sleep 2;
# confirm empty passphrase
send_key "ret";
my $sshpub = script_output "cat /root/.ssh/id_rsa.pub";
# launch Firefox
type_string "startx /usr/bin/firefox -width 1024 -height 768 http://172.16.2.118\n";
# log in as admin
assert_screen "zezere_login";
type_string "admin";
send_key "tab";
type_string "weakpassword\n";
# add our ssh key
assert_and_click "zezere_ssh_key";
assert_and_click "zezere_ssh_key_contents";
type_string "$sshpub";
send_key "tab";
send_key "ret";
# claim the device
assert_and_click "zezere_claim_unowned";
assert_and_click "zezere_claim_button";
# provision it
assert_and_click "zezere_device_management";
assert_and_click "zezere_submit_provision";
assert_and_click "zezere_provision_menu";
send_key_until_needlematch("zezere_provision_installed", "down", 3, 3);
assert_and_click "zezere_provision_schedule";
# exit
quit_firefox;
# wait for the provision request to go through
sleep 30;
# ssh into iot host and create key file
assert_script_run 'ssh -o StrictHostKeyChecking=no root@172.16.2.119 touch /tmp/zezerekeyfile';
}
sub test_flags {
return { fatal => 1 };
}
1;
# vim: set sw=4 et:

View File

@ -0,0 +1,47 @@
use base "installedtest";
use strict;
use testapi;
use utils;
sub run {
my $self = shift;
# deploy a zezere (Fedora IoT provisioning server) instance
assert_script_run "dnf --enablerepo=updates-testing -y install zezere", 180;
# write config file
assert_script_run "printf '[global]\nsecret_key = SECRET_KEY\ndebug = yes\nallowed_hosts = localhost, localhost.localdomain, 172.16.2.118\nauth_method = local\n\n[oidc.rp]\nsign_algo = RS256\n\n[database]\nengine = django.db.backends.sqlite3\nname = /var/local/zezere.sqlite3' > /etc/zezere.conf";
# write systemd unit file
assert_script_run "printf '[Unit]\nDescription=Zezere provisioning server\n\n[Service]\nExecStart=/usr/bin/zezere-manage runserver 172.16.2.118:80\n\n[Install]\nWantedBy=multi-user.target' > /etc/systemd/system/zezere.service";
assert_script_run "systemctl daemon-reload";
# open firewall port
assert_script_run "firewall-cmd --add-service=http";
# update DB schema
assert_script_run "zezere-manage makemigrations";
assert_script_run "zezere-manage migrate";
# load DB fixtures
assert_script_run "zezere-manage loaddata fedora_iot_runreqs";
assert_script_run "zezere-manage loaddata fedora_installed";
# create admin user
assert_script_run 'zezere-manage createsuperuser --username admin --email zezere@domain.local --no-input';
# set admin password (can't find a non-interactive way sadly)
type_string "zezere-manage changepassword admin\n";
sleep 2;
type_string "weakpassword\n";
sleep 2;
type_string "weakpassword\n";
sleep 2;
# check DB exists
assert_script_run "ls -l /var/local/zezere.sqlite3";
# start server
assert_script_run "systemctl start zezere.service";
# check it seems to be running
assert_script_run "curl http://172.16.2.118";
}
sub test_flags {
return { fatal => 1 };
}
1;
# vim: set sw=4 et:

View File

@ -0,0 +1,19 @@
use base "installedtest";
use strict;
use testapi;
sub run {
my $self = shift;
# wait for the remote test to ssh in and create a file, that
# tells us we're done
assert_script_run "until test -f /tmp/zezerekeyfile; do sleep 1; done", 900;
}
sub test_flags {
return { fatal => 1 };
}
1;
# vim: set sw=4 et: