-
Notifications
You must be signed in to change notification settings - Fork 232
USHIFT-1372: Backing up the data is top priority #1993
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
Merged
openshift-merge-robot
merged 1 commit into
openshift:main
from
pmtk:1372-backup-after-rollback
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import json | ||
| import libostree | ||
| from robot.libraries.BuiltIn import BuiltIn | ||
|
|
||
| _log = BuiltIn().log | ||
|
|
||
| CONFIG_PATH = "/var/lib/microshift-test-agent.json" | ||
|
|
||
| # Example config | ||
| # { | ||
| # "deploy-id": { | ||
| # "every": [ "prevent_backup" ], | ||
| # "1": [ "fail_greenboot" ], | ||
| # "2": [ "..." ], | ||
| # "3": [ "..." ] | ||
| # } | ||
| # } | ||
|
|
||
|
|
||
| class TestAgent: | ||
| def __init__(self): | ||
| self.cfg = dict() | ||
|
|
||
| def add_action(self, deployment: str, boot: str, action: str) -> None: | ||
| if deployment not in self.cfg: | ||
| self.cfg[deployment] = {boot: [action]} | ||
|
|
||
| elif boot not in self.cfg[deployment]: | ||
| self.cfg[deployment][boot] = [action] | ||
|
|
||
| elif action not in self.cfg[deployment][boot]: | ||
| self.cfg[deployment][boot].append(action) | ||
|
|
||
| _log(f"TestAgent Config: {self.cfg}") | ||
|
|
||
| def add_action_for_next_deployment(self, boot: str, action: str) -> None: | ||
| self.add_action("next", boot, action) | ||
|
|
||
| def substitute_staged(self) -> None: | ||
| if "next" not in self.cfg: | ||
| _log("'next' deployment not found") | ||
| return | ||
| id = libostree.get_staged_deployment_id() | ||
| self.cfg[id] = self.cfg["next"] | ||
| del self.cfg["next"] | ||
|
|
||
| def write(self) -> None: | ||
| self.substitute_staged() | ||
| j = json.dumps(self.cfg) | ||
| BuiltIn().should_not_be_empty(j) | ||
| libostree.remote_sudo( | ||
| f"echo '{j}' | sudo tee /var/lib/microshift-test-agent.json" | ||
| ) | ||
|
|
||
| def remove(self) -> None: | ||
| self.cfg = {} | ||
| libostree.remote_sudo("rm /var/lib/microshift-test-agent.json") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| *** Settings *** | ||
| Documentation Keywords for OSTree-based systems | ||
|
|
||
| Resource systemd.resource | ||
| Resource microshift-process.resource | ||
| Library libostree.py | ||
|
|
||
|
|
||
| *** Variables *** | ||
| ${DATA_DIR} "/var/lib/microshift" | ||
| ${BACKUP_STORAGE} "/var/lib/microshift-backups" | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Get Future Backup Name For Current Boot | ||
| [Documentation] Provides a name for future backup: | ||
| ... "4.13" for MicroShift 4.13, otherwise deployment ID + boot ID | ||
|
|
||
| # When system is upgrading from 4.13, there is no metadata regarding previous boot, | ||
| # therefore, when naming backup for existing data, "4.13" will be used as deployment ID, | ||
| # i.e. it should reside in `/var/lib/microshift-backups/4.13` | ||
| ${version}= MicroShift Version | ||
| IF ${version.minor} == 13 RETURN 4.13 | ||
|
|
||
| ${deploy_id}= Get Booted Deployment ID | ||
| ${boot_id}= Get Current Boot Id | ||
| ${backup_name}= Catenate SEPARATOR=_ ${deploy_id} ${boot_id} | ||
| RETURN ${backup_name} | ||
|
|
||
| Backup Should Exist | ||
| [Documentation] Checks if backup identified by deployment ID | ||
| ... and (optionally) boot ID exists | ||
| [Arguments] ${deployment_id} ${boot_id}=${EMPTY} | ||
| ${exists}= Does Backup Exist ${deployment_id} ${boot_id} | ||
| Should Be True ${exists} | ||
|
|
||
| Remove Existing Backup For Current Deployment | ||
| [Documentation] Remove any existing backup for currently running deployment | ||
| ${deploy_id}= Get Booted Deployment Id | ||
| Remove Backups For Deployment ${deploy_id} | ||
|
|
||
| MicroShift 413 Should Not Have Upgrade Artifacts | ||
| [Documentation] Verifies that host running MicroShift 4.13 | ||
| ... does not have upgrade related artifacts. | ||
|
|
||
| ${version}= MicroShift Version | ||
| IF ${version.minor} == 13 | ||
| Path Should Not Exist ${BACKUP_STORAGE} | ||
| Path Should Not Exist /var/lib/microshift/version | ||
| END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| *** Settings *** | ||
| Documentation Keywords for OSTree-based systems | ||
|
|
||
| Resource systemd.resource | ||
| Resource microshift-process.resource | ||
| Resource ostree-data.resource | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Wait Until Greenboot Health Check Exited | ||
| [Documentation] Wait until greenboot healthchecks are done | ||
|
|
||
| Wait Until Keyword Succeeds 10m 15s | ||
| ... Greenboot Health Check Exited | ||
|
|
||
| Greenboot Health Check Exited | ||
| [Documentation] Checks if greenboot-healthcheck finished running successfully (exited) | ||
|
|
||
| ${value}= Get Systemd Setting greenboot-healthcheck.service SubState | ||
| Should Be Equal As Strings ${value} exited | ||
|
|
||
| Wait For Healthy System | ||
| [Documentation] Waits for greenboot healthchecks and checks health.json | ||
| Wait Until Greenboot Health Check Exited | ||
| System Should Be Healthy | ||
|
|
||
| System Should Be Healthy | ||
| [Documentation] Verifies if system is healthy by looking at health.json. | ||
| ... If this runs after greenboot-healthcheck finishes, it verifies | ||
| ... health of current boot. | ||
|
|
||
| # Health of system with MicroShift 4.13 is implicitly checked by "Greenboot Health Check Exited" | ||
| ${version}= MicroShift Version | ||
| IF ${version.minor} == 13 RETURN | ||
|
|
||
| ${health}= Get Persisted System Health | ||
| Should Be Equal As Strings ${health} healthy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| *** Settings *** | ||
| Documentation Tests related to upgrading MicroShift | ||
|
|
||
| Resource ../resources/common.resource | ||
| Resource ../resources/ostree.resource | ||
| Library Collections | ||
|
|
||
| Suite Setup Setup | ||
| Suite Teardown Teardown | ||
|
|
||
| Test Tags ostree | ||
|
|
||
|
|
||
| *** Variables *** | ||
| ${USHIFT_HOST} ${EMPTY} | ||
| ${USHIFT_USER} ${EMPTY} | ||
|
|
||
| ${FAILING_REF} ${EMPTY} | ||
|
dhellmann marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| *** Test Cases *** | ||
| Staged Deployment Consistently Fails To Back Up The Data | ||
| [Documentation] Verifies that instructions to back up the data | ||
| ... ("healthy" system) is not lost if staged deployment fails | ||
| ... to back up and it is performed after rolling back. | ||
|
|
||
| Wait For Healthy System | ||
| ${backup}= Get Future Backup Name For Current Boot | ||
|
|
||
| TestAgent.Add Action For Next Deployment every prevent_backup | ||
| Deploy Commit Expecting A Rollback ${FAILING_REF} | ||
| Backup Should Exist ${backup} | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Setup | ||
| [Documentation] Test suite setup | ||
| Check Required Env Variables | ||
| Should Not Be Empty ${FAILING_REF} FAILING_REF variable is required | ||
| Login MicroShift Host | ||
|
|
||
| Teardown | ||
| [Documentation] Test suite teardown | ||
| Logout MicroShift Host | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.