Skip to content

Commit

Permalink
tests: update aws setup for retry auto-attach
Browse files Browse the repository at this point in the history
On AWS, we no longer try to run auto-attach if we run the
ua-auto-attach systemd job. Because of that, the setup
we are using for the retry auto-attach test no longer works
for AWS. We are now using a different setup for AWS
  • Loading branch information
lucasmoura committed Oct 23, 2024
1 parent 2a37b1a commit 70e073d
Showing 1 changed file with 119 additions and 5 deletions.
124 changes: 119 additions & 5 deletions features/retry_auto_attach.feature
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,136 @@ Feature: auto-attach retries periodically on failures

Examples: ubuntu release
| release | machine_type |
| xenial | aws.generic |
| xenial | azure.generic |
| xenial | gcp.generic |
| bionic | aws.generic |
| bionic | azure.generic |
| bionic | gcp.generic |
| focal | aws.generic |
| focal | azure.generic |
| focal | gcp.generic |
| jammy | aws.generic |
| jammy | azure.generic |
| jammy | gcp.generic |
| noble | aws.generic |
| noble | azure.generic |
| noble | gcp.generic |

Scenario Outline: auto-attach retries for a month and updates status
Given a `<release>` `<machine_type>` machine with ubuntu-advantage-tools installed
When I change contract to staging with sudo
And I create the file `/run/ubuntu-advantage/flags/auto-attach-failed` with the following:
"""
"""
And I create the file `/var/lib/ubuntu-advantage/retry-auto-attach-state.json` with the following:
"""
{"interval_index": 0, "failure_reason": "failure"}
"""
And I run `systemctl start ubuntu-advantage.service` with sudo
Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `0`
Then stdout matches regexp:
"""
Active: active \(running\)
"""
Then stdout matches regexp:
"""
mode: retry auto attach
"""
Then stdout does not match regexp:
"""
mode: poll for pro license
"""
When I run `run-parts /etc/update-motd.d/` with sudo
Then stdout matches regexp:
"""
Failed to automatically attach to an Ubuntu Pro subscription 1 time\(s\).
The failure was due to: failure.
The next attempt is scheduled for \d+-\d+-\d+T\d+:\d+:00.*.
You can try manually with `sudo pro auto-attach`.
"""
When I run `pro status` with sudo
Then stdout matches regexp:
"""
NOTICES
Failed to automatically attach to an Ubuntu Pro subscription 1 time\(s\).
The failure was due to: failure.
The next attempt is scheduled for \d+-\d+-\d+T\d+:\d+:00.*.
You can try manually with `sudo pro auto-attach`.
"""
# simulate a middle attempt with different reason
When I set `interval_index` = `10` in json file `/var/lib/ubuntu-advantage/retry-auto-attach-state.json`
When I set `failure_reason` = `"an unknown error"` in json file `/var/lib/ubuntu-advantage/retry-auto-attach-state.json`
When I run `systemctl restart ubuntu-advantage.service` with sudo
And I wait `5` seconds
Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `0`
Then stdout matches regexp:
"""
Active: active \(running\)
"""
Then stdout matches regexp:
"""
mode: retry auto attach
"""
Then stdout does not match regexp:
"""
mode: poll for pro license
"""
When I run `run-parts /etc/update-motd.d/` with sudo
Then stdout matches regexp:
"""
Failed to automatically attach to an Ubuntu Pro subscription 11 time\(s\).
The failure was due to: an unknown error.
The next attempt is scheduled for \d+-\d+-\d+T\d+:\d+:00.*.
You can try manually with `sudo pro auto-attach`.
"""
When I run `pro status` with sudo
Then stdout matches regexp:
"""
NOTICES
Failed to automatically attach to an Ubuntu Pro subscription 11 time\(s\).
The failure was due to: an unknown error.
The next attempt is scheduled for \d+-\d+-\d+T\d+:\d+:00.*.
You can try manually with `sudo pro auto-attach`.
"""
# simulate all attempts failing
When I set `interval_index` = `18` in json file `/var/lib/ubuntu-advantage/retry-auto-attach-state.json`
When I run `systemctl restart ubuntu-advantage.service` with sudo
And I wait `5` seconds
Then I verify that running `systemctl status ubuntu-advantage.service` `with sudo` exits `3`
Then stdout contains substring
"""
Active: inactive (dead)
"""
Then stdout matches regexp:
"""
mode: retry auto attach
"""
Then stdout does not match regexp:
"""
mode: poll for pro license
"""
When I run `run-parts /etc/update-motd.d/` with sudo
Then stdout matches regexp:
"""
Failed to automatically attach to an Ubuntu Pro subscription 19 time\(s\).
The most recent failure was due to: an unknown error.
Try re-launching the instance or report this issue by running `ubuntu-bug ubuntu-advantage-tools`
You can try manually with `sudo pro auto-attach`.
"""
When I run `pro status` with sudo
Then stdout matches regexp:
"""
NOTICES
Failed to automatically attach to an Ubuntu Pro subscription 19 time\(s\).
The most recent failure was due to: an unknown error.
Try re-launching the instance or report this issue by running `ubuntu-bug ubuntu-advantage-tools`
You can try manually with `sudo pro auto-attach`.
"""

Examples: ubuntu release
| release | machine_type |
| xenial | aws.generic |
| bionic | aws.generic |
| focal | aws.generic |
| jammy | aws.generic |
| noble | aws.generic |

Scenario Outline: auto-attach retries stop if manual auto-attach succeeds
Given a `<release>` `<machine_type>` machine with ubuntu-advantage-tools installed
When I create the file `/etc/ubuntu-advantage/uaclient.conf` with the following:
Expand Down

0 comments on commit 70e073d

Please sign in to comment.