#181 Automate QA:Testcase_Zezere_Ignition
Merged 3 years ago by adamwill. Opened 3 years ago by adamwill.

file modified
+3
@@ -455,6 +455,9 @@ 

  }

  

  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

@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 204,

+       "ypos": 213,

+       "width": 35,

+       "height": 16,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_claim_button"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "height": 16,

+       "type": "match",

+       "ypos": 213,

+       "width": 35,

+       "xpos": 205

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_claim_button"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 102,

+       "ypos": 158,

+       "width": 155,

+       "height": 12,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_claim_unowned"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 481,

+       "ypos": 159,

+       "width": 133,

+       "height": 12,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_device_management"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 21,

+       "ypos": 119,

+       "width": 44,

+       "height": 12,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_login"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 14,

+       "ypos": 214,

+       "width": 89,

+       "height": 13,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_provision_installed"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 27,

+       "ypos": 214,

+       "width": 12,

+       "height": 13,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_provision_menu"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 176,

+       "ypos": 214,

+       "width": 52,

+       "height": 13,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_provision_schedule"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 299,

+       "ypos": 157,

+       "width": 142,

+       "height": 15,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_ssh_key"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 26,

+       "ypos": 292,

+       "width": 185,

+       "height": 10,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_ssh_key_contents"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
@@ -0,0 +1,15 @@ 

+ {

+   "area": [

+     {

+       "xpos": 377,

+       "ypos": 238,

+       "width": 67,

+       "height": 13,

+       "type": "match"

+     }

+   ],

+   "properties": [],

+   "tags": [

+     "zezere_submit_provision"

+   ]

+ } 

\ No newline at end of file

empty or binary file added
file modified
+41 -1
@@ -1570,7 +1570,7 @@ 

                  "START_AFTER_TEST": "install_default_upload"

              }

          },

- 	"iot_rpmostree_rebase": {

+         "iot_rpmostree_rebase": {

                  "profiles": {

                  "fedora-IoT-dvd_ostree-iso-aarch64-*-aarch64": 20,

                  "fedora-IoT-dvd_ostree-iso-x86_64-*-64bit": 40
@@ -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,

@@ -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:

@@ -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:

@@ -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:

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

note this branch is actually running in production right now. it worked last I tried it. The iot_zezere_remote and support_server tests are leftovers from earlier approaches.

rebased onto 9bda5e5f060a91a4ba14d021756df9377c45016e

3 years ago

few notes:

  • we just sorta rely on timing between the 'ignition' and 'sever' tests working out. I think this should be okay, but we could have the 'ignition' test set a mutex after it's booted and have the 'server' test wait for that before trying to provision it
  • typing in that whole ssh key is kinda scary but I haven't seen it fail yet. any way I can think of to copy/paste it would be more fragile...
  • the thirty second sleep is kinda magic but, again, haven't seen it fail yet. not sure if there's a convenient indicator that the provision request has gone through that we could have the server look for in the logs or whatever instead of just that 30 second sleep, @pbrobinson ? @puiterwijk ?
  • the _repo_setup_compose thing is very slightly a hack but I don't think it's ever gonna be wrong (he said foolishly); basically we hit it in the _setup_browser module in the server test. we could word the check in a few different ways but i think this one is okay
  • I think the reason we need two versions of the 'claim' button needle because the text kerning can vary depending on the IoT device's MAC address :/

Build succeeded.

rebased onto bfc009c0de03634c6b07320d81021de84cd3f68c

3 years ago

Build succeeded.

rebased onto 59b77011e81fef8e37460fdd778545572998b57e

3 years ago

Build succeeded.

rebased onto 7337b7cdef030f28ac40807b31bdd9ddebd1140a

3 years ago

Build succeeded.

rebased onto 0533a33e38e7532fd6c26fe257dee7b1de59d07c

3 years ago

Build succeeded.

rebased onto aa41fe4

3 years ago

Build succeeded.

Pull-Request has been merged by adamwill

3 years ago
Metadata
Changes Summary 27
+3 -0
file changed
lib/utils.pm
+15
file added
needles/iot/zezere_claim_button-20200721.json
+0
file added
needles/iot/zezere_claim_button-20200721.png
+15
file added
needles/iot/zezere_claim_button-alt-20200721.json
+0
file added
needles/iot/zezere_claim_button-alt-20200721.png
+15
file added
needles/iot/zezere_claim_unowned-20200721.json
+0
file added
needles/iot/zezere_claim_unowned-20200721.png
+15
file added
needles/iot/zezere_device_management-20200721.json
+0
file added
needles/iot/zezere_device_management-20200721.png
+15
file added
needles/iot/zezere_login-20200721.json
+0
file added
needles/iot/zezere_login-20200721.png
+15
file added
needles/iot/zezere_provision_installed-20200721.json
+0
file added
needles/iot/zezere_provision_installed-20200721.png
+15
file added
needles/iot/zezere_provision_menu-20200721.json
+0
file added
needles/iot/zezere_provision_menu-20200721.png
+15
file added
needles/iot/zezere_provision_schedule-20200721.json
+0
file added
needles/iot/zezere_provision_schedule-20200721.png
+15
file added
needles/iot/zezere_ssh_key-20200721.json
+0
file added
needles/iot/zezere_ssh_key-20200721.png
+15
file added
needles/iot/zezere_ssh_key_contents-20200721.json
+0
file added
needles/iot/zezere_ssh_key_contents-20200721.png
+15
file added
needles/iot/zezere_submit_provision-20200721.json
+0
file added
needles/iot/zezere_submit_provision-20200721.png
+41 -1
file changed
templates.fif.json
+58
file added
tests/_iot_zezere_remote.pm
+47
file added
tests/_iot_zezere_server.pm
+19
file added
tests/iot_zezere_ignition.pm