Skip to content

Commit

Permalink
[ADD] Add two e2e test for restore and archive
Browse files Browse the repository at this point in the history
Signed-off-by: poyaz <pooya_azarpour@yahoo.com>
  • Loading branch information
poyaz committed Apr 10, 2024
1 parent dc9f803 commit 7d121ff
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
35 changes: 35 additions & 0 deletions e2e/test-10-restore-self-signed-tls.bats
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}"
}
50 changes: 50 additions & 0 deletions e2e/test-11-archive-self-signed-tls.bats
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" ]
}

0 comments on commit 7d121ff

Please sign in to comment.