diff --git a/features/daemon.feature b/features/daemon.feature index 5546c3f33e..7f46bae256 100644 --- a/features/daemon.feature +++ b/features/daemon.feature @@ -1,8 +1,6 @@ -Feature: UA daemon starts and stops jobs appropriately +Feature: Pro Upgrade Daemon only runs in environments where necessary - # TODO: Replace this as soon as the daemon does something real @series.all - @uses.config.machine_type.lxd.container Scenario Outline: Check daemon starts and restarts Given a `` machine with ubuntu-advantage-tools installed Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `3` @@ -35,3 +33,124 @@ Feature: UA daemon starts and stops jobs appropriately | focal | | hirsute | | impish | + + + @series.lts + @uses.config.contract_token + @uses.config.machine_type.gcp.generic + Scenario Outline: license_check job should run periodically on gcp generic lts + Given a `` machine with ubuntu-advantage-tools installed + # verify its enabled + Then I verify the `ua-license-check` systemd timer is scheduled to run within `10` minutes + # run it and verify that it didn't disable itself + When I run `systemctl start ua-license-check.service` with sudo + When I wait `5` seconds + Then I verify the `ua-license-check` systemd timer is scheduled to run within `10` minutes + # verify attach disables it + When I wait `5` seconds + When I attach `contract_token` with sudo + Then I verify the `ua-license-check` systemd timer is disabled + # verify detach enables it + When I run `ua detach --assume-yes` with sudo + And I wait `5` seconds + Then I verify the `ua-license-check` systemd timer is scheduled to run within `10` minutes + # verify stopping and deleting marker file and stopping disables it + # We need to call stop both before and after rm-ing the marker file + # because at least one version of systemd requires it before (245.4-4ubuntu3.11 + # on focal gcp), and every other tested version of systemd requires it after + # But this is only necessary when manually running the steps or in this test. + # `disable_license_checks_if_applicable` works fine with only calling stop after, + # as evidenced by the "verify attach disables it" steps above passing on focal gcp. + When I run `systemctl stop ua-license-check.timer` with sudo + When I run `rm /var/lib/ubuntu-advantage/marker-license-check` with sudo + When I run `systemctl stop ua-license-check.timer` with sudo + Then I verify the `ua-license-check` systemd timer is disabled + # verify creating marker file enables it + When I run `touch /var/lib/ubuntu-advantage/marker-license-check` with sudo + Then I verify the `ua-license-check` systemd timer is scheduled to run within `10` minutes + Examples: version + | release | + | xenial | + | bionic | + | focal | + + @series.impish + @uses.config.contract_token + @uses.config.machine_type.gcp.generic + Scenario Outline: daemon is disabled gcp generic non lts + Given a `` machine with ubuntu-advantage-tools installed + Then I verify the `ua-license-check` systemd timer is disabled + # verify creating marker file enables it, but it disables itself + When I run `touch /var/lib/ubuntu-advantage/marker-license-check` with sudo + Then I verify the `ua-license-check` systemd timer either ran within the past `5` seconds OR is scheduled to run within `10` minutes + When I run `systemctl start ua-license-check.service` with sudo + When I wait `5` seconds + Then I verify the `ua-license-check` systemd timer is disabled + # verify attach and detach does not enable it + When I wait `5` seconds + When I attach `contract_token` with sudo + When I run `ua detach --assume-yes` with sudo + When I wait `5` seconds + Then I verify the `ua-license-check` systemd timer is disabled + Examples: version + | release | + | impish | + + @series.all + @uses.config.contract_token + @uses.config.machine_type.lxd.container + @uses.config.machine_type.lxd.vm + @uses.config.machine_type.aws.generic + @uses.config.machine_type.azure.generic + Scenario Outline: daemon is disabled everywhere but gcp generic + Given a `` machine with ubuntu-advantage-tools installed + Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `3` + Then stdout matches regexp: + """ + Active: inactive \(dead\) + Condition: start condition failed + """ + When I run `cat /var/log/ubuntu-advantage-daemon.log` with sudo + Then stdout does not match regexp: + """ + daemon started + """ + # TODO attach and detach and reboot + When I reboot the `` machine + # TODO verify still no started + # TODO something like this for logs + And I verify that running `grep "Disabling gcp_auto_attach job" /var/log/ubuntu-advantage-license-check.log` `with sudo` exits `0` + Examples: version + | release | + | xenial | + | bionic | + | focal | + | impish | + | jammy | + + @series.lts + @uses.config.machine_type.aws.pro + @uses.config.machine_type.azure.pro + @uses.config.machine_type.gcp.pro + Scenario Outline: daemon is disabled everywhere but gcp generic + Given a `` machine with ubuntu-advantage-tools installed + When I create the file `/etc/ubuntu-advantage/uaclient.conf` with the following: + """ + contract_url: 'https://contracts.canonical.com' + data_dir: /var/lib/ubuntu-advantage + log_level: debug + log_file: /var/log/ubuntu-advantage.log + """ + When I run `ua auto-attach` with sudo + Then I verify the `ua-license-check` systemd timer is disabled + # verify creating marker file enables it, but it disables itself + When I run `touch /var/lib/ubuntu-advantage/marker-license-check` with sudo + Then I verify the `ua-license-check` systemd timer either ran within the past `5` seconds OR is scheduled to run within `10` minutes + When I run `systemctl start ua-license-check.service` with sudo + When I wait `5` seconds + Then I verify the `ua-license-check` systemd timer is disabled + Examples: version + | release | + | xenial | + | bionic | + | focal |