-
Notifications
You must be signed in to change notification settings - Fork 228
USHIFT-1312 Test: Rebooting healthy system should result in backing up the data #1866
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| *** Settings *** | ||
| Documentation Keywords for OSTree-based systems | ||
|
|
||
| Library SSHLibrary | ||
| Library DataFormats.py | ||
|
|
||
|
|
||
| *** Variables *** | ||
| ${BACKUP_STORAGE} /var/lib/microshift-backups | ||
| ${HEALTH_FILE} /var/lib/microshift-backups/health.json | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Get Booted Deployment Status | ||
| [Documentation] Get rpm-ostree status of booted deployment as a json | ||
|
|
||
| ${ostree_status} ${rc}= Execute Command | ||
| ... rpm-ostree status --booted --json | ||
| ... return_rc=True | ||
| Should Be Equal As Integers 0 ${rc} | ||
| ${status}= Json Parse ${ostree_status} | ||
| RETURN ${status} | ||
|
|
||
| Get Booted Deployment ID | ||
| [Documentation] Get ID of currently booted deployment | ||
|
|
||
| ${status}= Get Booted Deployment Status | ||
| RETURN ${status.deployments[0].id} | ||
|
|
||
| Get Booted Deployment Backup Prefix Path | ||
| [Documentation] Get backup path prefix for current deployment | ||
| ... | ||
| ... Prefix path is BACKUP_STORAGE/deployment-id. | ||
| ... Globbing directories starting with the prefix will yield | ||
| ... list of backups for the deployment. | ||
|
|
||
| ${current_deployment_id}= Get Booted Deployment ID | ||
| Should Not Be Empty ${current_deployment_id} | ||
| Should Not Be Empty ${BACKUP_STORAGE} | ||
| ${backup_path}= Catenate SEPARATOR=/ ${BACKUP_STORAGE} ${current_deployment_id} | ||
| RETURN ${backup_path} | ||
|
|
||
| Get System Health | ||
| [Documentation] Get system health information from health.json file | ||
|
|
||
| ${health} ${stderr} ${rc}= Execute Command | ||
| ... jq -r '.health' ${BACKUP_STORAGE}/health.json | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'Evaluate json.loads' was used above in keyword "Get Booted Deployment Status". Should we be consistent in the pattern we use to ingest and parse json?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a side note, 'jq' is used by scripts such as microshift_set_healthy.sh, so it's not a bad thing that we are also using it in our test scripts. My initial comment was just a reaction to seeing json parsed in the same PR using two different approaches.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point. Maybe we could create some helper keywords to slurping and modifying files as root and have flow consistent
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of keywords for grabbing files only readable by root. Save Default MicroShift Config uses |
||
| ... sudo=True return_rc=True return_stderr=True | ||
| Should Be Equal As Integers 0 ${rc} | ||
| RETURN ${health} | ||
|
|
||
| Does Backup For Booted Deployment Exist | ||
| [Documentation] Checks if any backup for current deployment exists | ||
| ... by finding paths starting with "backup prefix path" | ||
|
|
||
| ${deploy_id}= Get Booted Deployment ID | ||
| ${output} ${rc}= Execute Command | ||
| ... find ${BACKUP_STORAGE} -name '${deploy_id}*' | wc -l | ||
| ... sudo=True return_rc=True | ||
| Should Be Equal As Integers 0 ${rc} | ||
|
|
||
| IF "${output}" == "0" RETURN ${False} | ||
| RETURN ${True} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| *** Settings *** | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is in separate dir so e2e CI job doesn't try to run it against non-ostree system. |
||
| Documentation Tests related to MicroShift upgradeability on OSTree-based systems | ||
|
|
||
| Resource ../resources/common.resource | ||
| Resource ../resources/ostree.resource | ||
| Resource ../resources/systemd.resource | ||
| Resource ../resources/microshift-process.resource | ||
| Library Collections | ||
|
|
||
| Suite Setup Setup | ||
| Suite Teardown Teardown | ||
|
|
||
| Test Tags ostree | ||
|
|
||
|
|
||
| *** Variables *** | ||
| ${USHIFT_HOST} ${EMPTY} | ||
| ${USHIFT_USER} ${EMPTY} | ||
|
|
||
|
|
||
| *** Test Cases *** | ||
| Rebooting Healthy System Should Result In Data Backup | ||
| [Documentation] Check if rebooting healthy system will result in backing up of MicroShift data | ||
|
|
||
| Wait Until Greenboot Health Check Exited | ||
| System Should Be Healthy | ||
| Remove Existing Backup For Current Deployment | ||
|
|
||
| Reboot MicroShift Host | ||
| Wait For MicroShift Service | ||
|
|
||
| Backup For Booted Deployment Should Exist | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Setup | ||
| [Documentation] Test suite setup | ||
| Check Required Env Variables | ||
| Login MicroShift Host | ||
|
|
||
| Teardown | ||
| [Documentation] Test suite teardown | ||
| Logout MicroShift Host | ||
|
|
||
| Wait Until Greenboot Health Check Exited | ||
| [Documentation] Wait until greenboot healthchecks are done | ||
|
|
||
| Wait Until Keyword Succeeds 5m 15s | ||
| ... Greenboot Health Check Exited | ||
|
|
||
| Greenboot Health Check Exited | ||
| [Documentation] Checks if greenboot-healthcheck finished running | ||
|
|
||
| ${value}= Get Systemd Setting greenboot-healthcheck.service SubState | ||
| Should Be Equal As Strings ${value} exited | ||
|
|
||
| Remove Existing Backup For Current Deployment | ||
| [Documentation] Remove backups for current deployment | ||
|
|
||
| ${path}= Get Booted Deployment Backup Prefix Path | ||
| Should Not Be Empty ${path} | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we test path here with 'Should Not Be Empty'? I see that 'Get Booted Deployment Backup Prefix Path' has a check for empty values. However, if the code is changed to use a different key word at some point to get path we would not want to accidentally call 'rm -rf *' |
||
| ${rm_output} ${rm_stderr} ${rc}= Execute Command | ||
| ... rm -rf ${path}* | ||
| ... sudo=True return_stderr=True return_rc=True | ||
| Log ${rm_stderr} | ||
| Log ${rm_output} | ||
| Should Be Equal As Integers 0 ${rc} | ||
|
|
||
| Backup For Booted Deployment Should Exist | ||
| [Documentation] Asserts that backup for currently booted deployment exists | ||
| ${exists}= Does Backup For Booted Deployment Exist | ||
| Should Be True ${exists} | ||
|
|
||
| System Should Be Healthy | ||
| [Documentation] Asserts that persisted health information is "healthy" | ||
| ${health}= Get System Health | ||
| Should Be Equal As Strings healthy ${health} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be more robust if we looked for a different boot id after the reboot, to avoid any race condition with issuing the reboot command and sshd stopping. It doesn't seem like the most likely race, so let's make that change in another PR.