Skip to content

Commit

Permalink
Test RClone sync Swift for Harbor and Thanos
Browse files Browse the repository at this point in the history
  • Loading branch information
simonklb committed Nov 17, 2023
1 parent 7673dc7 commit 57986d6
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions pipeline/update-ips.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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() {
Expand Down

0 comments on commit 57986d6

Please sign in to comment.