From e9a498d2357f4a785097bf80391b40a84ccb9f97 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Thu, 15 Aug 2024 21:05:27 -0400 Subject: [PATCH] Add backup tests for foreman-proxy --- bats/fb-test-backup.bats | 32 +++++++++++++++++++++++++++++ bats/foreman_helper.bash | 4 ++++ pipelines/install/05-tests.yml | 1 + pipelines/vars/forklift_katello.yml | 3 +++ pipelines/vars/forklift_luna.yml | 3 +++ 5 files changed, 43 insertions(+) diff --git a/bats/fb-test-backup.bats b/bats/fb-test-backup.bats index 14b6597ef..da2b4952a 100644 --- a/bats/fb-test-backup.bats +++ b/bats/fb-test-backup.bats @@ -58,6 +58,24 @@ BACKUP_ONLINE_DIR="${BACKUP_BASE_DIR}/online" tFileExists "${BACKUP_OFFLINE_DIR}/pulp_data.tar" } +@test "check offline backup contents for Foreman Proxy Content" { + tForemanMaintainAvailable + + if ! tPackageExists foreman && tPackageExists foreman-installer-katello; then + tFileExists "${BACKUP_OFFLINE_DIR}/pulp_data.tar" + tar -tvf "${BACKUP_OFFLINE_DIR}/config_files.tar.gz" | grep "${HOSTNAME}.tar.gz" + + FOREMAN_VERSION=$(tForemanVersion) + if tIsVersionNewer "${FOREMAN_VERSION}" 3.12; then + tFileExists "${BACKUP_OFFLINE_DIR}/pulpcore.dump" + else + tFileExists "${BACKUP_OFFLINE_DIR}/pgsql_data.tar.gz" + fi + else + skip "Stand-alone foreman-proxy with content test" + fi +} + @test "perform online backup" { tForemanMaintainAvailable @@ -66,6 +84,7 @@ BACKUP_ONLINE_DIR="${BACKUP_BASE_DIR}/online" @test "check online backup contests for Foreman" { tForemanMaintainAvailable + tForemanAvailable tFileExists "${BACKUP_ONLINE_DIR}/config_files.tar.gz" tFileExists "${BACKUP_ONLINE_DIR}/metadata.yml" @@ -74,6 +93,7 @@ BACKUP_ONLINE_DIR="${BACKUP_BASE_DIR}/online" @test "check online backup contents for Katello" { tForemanMaintainAvailable + tForemanAvailable if ! tPackageExists foreman-installer-katello; then skip "Katello specific test" @@ -83,3 +103,15 @@ BACKUP_ONLINE_DIR="${BACKUP_BASE_DIR}/online" tFileExists "${BACKUP_ONLINE_DIR}/candlepin.dump" tFileExists "${BACKUP_ONLINE_DIR}/pulpcore.dump" } + +@test "check online backup contents for Foreman Proxy Content" { + tForemanMaintainAvailable + + if ! tPackageExists foreman && tPackageExists foreman-installer-katello; then + tFileExists "${BACKUP_ONLINE_DIR}/pulp_data.tar" + tFileExists "${BACKUP_ONLINE_DIR}/pulpcore.dump" + tar -tvf "${BACKUP_ONLINE_DIR}/config_files.tar.gz" | grep "${HOSTNAME}.tar.gz" + else + skip "Stand-alone foreman-proxy with content test" + fi +} diff --git a/bats/foreman_helper.bash b/bats/foreman_helper.bash index 0605e6da3..e4421b2cf 100644 --- a/bats/foreman_helper.bash +++ b/bats/foreman_helper.bash @@ -163,3 +163,7 @@ tHammerPing() { [[ "$status" -eq 0 ]] } + +tForemanAvailable() { + tPackageExists foreman || skip 'foreman package is not available' +} diff --git a/pipelines/install/05-tests.yml b/pipelines/install/05-tests.yml index bf8c4de8b..98355e71f 100644 --- a/pipelines/install/05-tests.yml +++ b/pipelines/install/05-tests.yml @@ -2,6 +2,7 @@ - name: run tests hosts: - "{{ forklift_server_name }}" + - "{{ forklift_proxy_name }}" become: true vars_files: - ../vars/install_base.yml diff --git a/pipelines/vars/forklift_katello.yml b/pipelines/vars/forklift_katello.yml index 2dc629352..8b897bff2 100644 --- a/pipelines/vars/forklift_katello.yml +++ b/pipelines/vars/forklift_katello.yml @@ -28,5 +28,8 @@ proxy_box: - "foreman-installer-katello" foreman_installer_options: - "--foreman-proxy-content-enable-ostree true" + bats_tests: + - fb-test-backup.bats + bats_teardown: [] forklift_boxes: "{{ {forklift_server_name: server_box, forklift_proxy_name: proxy_box, forklift_smoker_name: smoker_box} }}" diff --git a/pipelines/vars/forklift_luna.yml b/pipelines/vars/forklift_luna.yml index 5dc89b4d4..775975768 100644 --- a/pipelines/vars/forklift_luna.yml +++ b/pipelines/vars/forklift_luna.yml @@ -85,5 +85,8 @@ proxy_box: - "--enable-foreman-proxy-plugin-openscap" - "--enable-foreman-proxy-plugin-remote-execution-script" - "--foreman-proxy-content-enable-ostree true" + bats_tests: + - fb-test-backup.bats + bats_teardown: [] forklift_boxes: "{{ {forklift_server_name: server_box, forklift_proxy_name: proxy_box, forklift_smoker_name: smoker_box} }}"