From 57986d6b0086542d5e7f146702f430e0c09a992d Mon Sep 17 00:00:00 2001 From: Simon Kollberg Date: Fri, 17 Nov 2023 17:41:41 +0100 Subject: [PATCH] Test RClone sync Swift for Harbor and Thanos --- pipeline/update-ips.bats | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/pipeline/update-ips.bats b/pipeline/update-ips.bats index dc86b4726a..e4ee3dde9f 100644 --- a/pipeline/update-ips.bats +++ b/pipeline/update-ips.bats @@ -233,7 +233,7 @@ _test_swift_requires_username_or_application_credential_id() { _test_swift_requires_username_or_application_credential_id '.objectStorage.sync.buckets.[0].sourceType' } -_test_apply_swift_username() { +_setup_swift() { _setup_basic yq4 -i "${1}"' = "swift"' "${CK8S_CONFIG_PATH}/sc-config.yaml" @@ -247,6 +247,10 @@ _test_apply_swift_username() { mock_set_output "${mock_curl}" '\n\n\n\n\n\n\n\n\n\n\n\n\n\n[{"catalog":[{"type": "object-store", "name": "swift", "endpoints": [{"interface":"public", "region": "swift-region", "url": "https://swift.foo.dev-ck8s.com:91011"}]}]}]' 1 mock_set_output "${mock_curl}" "" 2 # DELETE /auth/tokens mock_set_output "${mock_dig}" "127.0.0.5" 5 # $swift_endpoint +} + +_test_apply_swift_username() { + _setup_swift "${1}" run ck8s update-ips both apply @@ -437,10 +441,6 @@ _test_apply_rclone_sync_s3_add_swift() { # _test_apply_rclone_sync_swift_requires_swift_endpoint() { - _setup_rclone - - yq4 -i "${1}"' = "swift"' "${CK8S_CONFIG_PATH}/sc-config.yaml" - run ck8s update-ips both apply assert_failure assert_output --partial ".objectStorage.sync.swift.authUrl is not configured" @@ -450,12 +450,30 @@ _test_apply_rclone_sync_swift_requires_swift_endpoint() { assert_equal "$(mock_get_call_num "${mock_curl}")" 0 } -@test "rclone sync - swift requires swift endpoint - buckets destination type" { - _test_apply_rclone_sync_swift_requires_swift_endpoint '.objectStorage.sync.buckets.[0].destinationType' +@test "rclone sync - swift - requires swift endpoint - buckets destination type" { + _setup_rclone + yq4 -i '.objectStorage.sync.buckets.[0].destinationType = "swift"' "${CK8S_CONFIG_PATH}/sc-config.yaml" + _test_apply_rclone_sync_swift_requires_swift_endpoint +} + +@test "rclone sync - swift - requires swift endpoint - sync destination type" { + _setup_rclone + yq4 -i '.objectStorage.sync.destinationType = "swift"' "${CK8S_CONFIG_PATH}/sc-config.yaml" + _test_apply_rclone_sync_swift_requires_swift_endpoint } -@test "rclone sync - swift requires swift endpoint - sync destination type" { - _test_apply_rclone_sync_swift_requires_swift_endpoint '.objectStorage.sync.destinationType' +@test "rclone sync - swift - requires swift endpoint - harbor" { + _setup_swift '.harbor.persistence.type' + _setup_rclone + yq4 -i '.objectStorage.sync.syncDefaultBuckets = true' "${CK8S_CONFIG_PATH}/sc-config.yaml" + _test_apply_rclone_sync_swift_requires_swift_endpoint +} + +@test "rclone sync - swift - requires swift endpoint - thanos" { + _setup_swift '.thanos.objectStorage.type' + _setup_rclone + yq4 -i '.objectStorage.sync.syncDefaultBuckets = true' "${CK8S_CONFIG_PATH}/sc-config.yaml" + _test_apply_rclone_sync_swift_requires_swift_endpoint } _setup_rclone_sync_swift() {