forked from k8up-io/k8up
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Add two e2e test for restore and archive
Signed-off-by: poyaz <pooya_azarpour@yahoo.com>
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,35 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "lib/utils" | ||
load "lib/detik" | ||
load "lib/k8up" | ||
|
||
# shellcheck disable=SC2034 | ||
DETIK_CLIENT_NAME="kubectl" | ||
# shellcheck disable=SC2034 | ||
DETIK_CLIENT_NAMESPACE="k8up-e2e-subject" | ||
# shellcheck disable=SC2034 | ||
DEBUG_DETIK="true" | ||
|
||
@test "Given an existing Restic repository, When creating a Restore (mTLS), Then Restore to S3 (mTLS) - using self-signed issuer" { | ||
# Backup | ||
expected_content="Old content for mtls: $(timestamp)" | ||
expected_filename="old_file.txt" | ||
given_a_running_operator | ||
given_a_clean_ns | ||
given_s3_storage | ||
give_self_signed_issuer | ||
given_an_existing_mtls_backup "${expected_filename}" "${expected_content}" | ||
|
||
# Restore | ||
kubectl apply -f definitions/secrets | ||
yq e '.spec.podSecurityContext.fsGroup='$(id -u)' | .spec.podSecurityContext.runAsUser='$(id -u)'' definitions/restore/s3-mtls-restore-mtls.yaml | kubectl apply -f - | ||
|
||
try "at most 10 times every 1s to get Restore named 'k8up-s3-mtls-restore-mtls' and verify that '.status.started' is 'true'" | ||
try "at most 10 times every 1s to get Job named 'k8up-s3-mtls-restore-mtls' and verify that '.status.active' is '1'" | ||
|
||
wait_until restore/k8up-s3-mtls-restore-mtls completed | ||
verify "'.status.conditions[?(@.type==\"Completed\")].reason' is 'Succeeded' for Restore named 'k8up-s3-mtls-restore-mtls'" | ||
|
||
expect_dl_file_in_container 'deploy/subject-dl-deployment' 'subject-container' "/data/${expected_filename}" "${expected_content}" | ||
} |
This file contains 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 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "lib/utils" | ||
load "lib/detik" | ||
load "lib/k8up" | ||
|
||
# shellcheck disable=SC2034 | ||
DETIK_CLIENT_NAME="kubectl" | ||
# shellcheck disable=SC2034 | ||
DETIK_CLIENT_NAMESPACE="k8up-e2e-subject" | ||
# shellcheck disable=SC2034 | ||
DEBUG_DETIK="true" | ||
|
||
@test "Given an existing Restic repository, When creating a Archive (mTLS), Then Restore to S3 (mTLS) - using self-signed issuer" { | ||
# Backup | ||
expected_content="Old content for mtls: $(timestamp)" | ||
expected_filename="old_file.txt" | ||
given_a_running_operator | ||
given_a_clean_ns | ||
given_s3_storage | ||
give_self_signed_issuer | ||
given_an_existing_mtls_backup "${expected_filename}" "${expected_content}" | ||
given_a_clean_archive archive | ||
|
||
# Archive | ||
kubectl apply -f definitions/secrets | ||
yq e '.spec.podSecurityContext.fsGroup='$(id -u)' | .spec.podSecurityContext.runAsUser='$(id -u)'' definitions/archive/s3-mtls-archive-mtls.yaml | kubectl apply -f - | ||
|
||
try "at most 10 times every 1s to get Archive named 'k8up-s3-mtls-archive-mtls' and verify that '.status.started' is 'true'" | ||
try "at most 10 times every 1s to get Job named 'k8up-s3-mtls-archive-mtls' and verify that '.status.active' is '1'" | ||
|
||
wait_until archive/k8up-s3-mtls-archive-mtls completed | ||
verify "'.status.conditions[?(@.type==\"Completed\")].reason' is 'Succeeded' for Archive named 'k8up-s3-mtls-archive-mtls'" | ||
|
||
run restic list snapshots | ||
|
||
echo "---BEGIN total restic snapshots output---" | ||
total_snapshots=$(echo -e "${output}" | wc -l) | ||
echo "${total_snapshots}" | ||
echo "---END---" | ||
|
||
run mc ls minio/archive | ||
|
||
echo "---BEGIN total archives output---" | ||
total_archives=$(echo -n -e "${output}" | wc -l) | ||
echo "${total_archives}" | ||
echo "---END---" | ||
|
||
[ "$total_snapshots" -eq "$total_archives" ] | ||
} |