Add tests for backup#588
Conversation
95d6d11 to
727cdd8
Compare
| name: postgresql.service | ||
| register: backup_postgres_status | ||
| until: backup_postgres_status.status.ActiveState == 'inactive' | ||
| until: backup_postgres_status.status.ActiveState in ['inactive', 'failed'] |
There was a problem hiding this comment.
Changed this to include failed as an acceptable state to continue with backup. This was happening in the CI test because postgresql.service was getting a SIGTERM and also makes sense for actual backup scenario where we may want to take a backup if state is failed.
359bea6 to
736e9d2
Compare
| BACKUP_DIR | ||
| ] | ||
|
|
||
| result = subprocess.run( |
There was a problem hiding this comment.
| result = subprocess.run( | |
| result = server.run( |
There was a problem hiding this comment.
The server.run runs it inside quadlet for quadlet based deploys like CI..We want the command to run locally hence the subprocess.run ..
| backup_dir = backup_result['backup_dir'] | ||
|
|
||
| expected_iop_dumps = [ | ||
| 'iop_advisor.dump', |
There was a problem hiding this comment.
We base these based on name :
foremanctl/src/vars/database.yml
Line 104 in e5e86e2
| """ | ||
| Test that foremanctl state directory is archived. | ||
|
|
||
| NOTE: This test is conditional because foremanctl-state.tar.gz is only |
There was a problem hiding this comment.
This test should not be conditional, that tells me there is a design flaw that should be fixed.
There was a problem hiding this comment.
I have updated backup to handle localhost and quadlet based deployments. Have kept it as a separate commit to isolate the change there..
| assert metadata['incremental'] is False, "Backup should not be incremental" | ||
| assert metadata['database_mode'] in ['internal', 'external'], "Database mode should be 'internal' or 'external'" | ||
|
|
||
| # Core databases should always be present |
There was a problem hiding this comment.
This will end up being wrong in the long run due to flavors.
574985c to
7a0eb4c
Compare
| path: "{{ obsah_state_path }}" | ||
| register: backup_state_path_stat | ||
|
|
||
| - name: Copy foremanctl state from controller to target (remote deployment) |
There was a problem hiding this comment.
I think you could consolidate remote vs. local by just always performing this action.
Why are you introducing these changes? (Problem description, related links)
Add tests for foremanctl backup
What are the changes introduced in this pull request?
How to test this pull request
The CI should run the new tests.
Steps to reproduce:
Checklist
PS: I had some issues with the OBSAH_STATE_PATH running these locally in a repo checkout. The backup is supposed to work on a host with services deployed and with path as /var/lib/foremanctl. The repo setup is different from production-like installs where the quadlet is mapped to localhost. On dev setup, quadlet is actual VM so the test finds OBSAH_STATE_PATH as /.var/lib/foremanctl inside the VM. Hence the conditional test for foremanctl state archive which archives this path.