|
| 1 | +#!/bin/bash |
| 2 | +set -e -o pipefail |
| 3 | +#in .github/docker |
| 4 | + |
| 5 | +export S3BACKEND=file |
| 6 | +export S3METADATA=scality |
| 7 | +export S3VAULT=scality |
| 8 | +export CLOUDSERVER_IMAGE_BEFORE_SSE_MIGRATION=ghcr.io/scality/cloudserver:7.70.21-11 |
| 9 | +export CLOUDSERVER_IMAGE_ORIGINAL=ghcr.io/scality/cloudserver:50db1ada69a394cf877bd3486d4d0e318158e338 |
| 10 | +export MPU_TESTING="yes" |
| 11 | +export JOB_NAME=sse-kms-migration-tests-show-arn |
| 12 | +export kmsHideScalityArn=showArn |
| 13 | + |
| 14 | +export VAULT_IMAGE_BEFORE_SSE_MIGRATION=ghcr.io/scality/vault:7.70.15-5 |
| 15 | +export VAULT_IMAGE_ORIGINAL=ghcr.io/scality/vault:e8c0fa2890c131581efd13ad3fd1ade7dcbd0968 |
| 16 | +export KMS_IMAGE=nsmithuk/local-kms:3.11.7 |
| 17 | + |
| 18 | +# IMAGE IS HARDCODED FOR OKMS TO HIDE |
| 19 | +export JOB_NAME=sse-kms-migration-tests-hide-arn |
| 20 | +export kmsHideScalityArn=hideArn |
| 21 | +# export JOB_NAME=sse-kms-migration-tests-show-arn |
| 22 | +# export kmsHideScalityArn=showArn |
| 23 | + |
| 24 | +mkdir -p /tmp/artifacts/$JOB_NAME |
| 25 | + |
| 26 | +export CLOUDSERVER_IMAGE=$CLOUDSERVER_IMAGE_BEFORE_SSE_MIGRATION |
| 27 | +export VAULT_IMAGE=$VAULT_IMAGE_BEFORE_SSE_MIGRATION |
| 28 | +export SSE_CONF=before |
| 29 | + |
| 30 | +export KMS_AWS_SECRET_ACCESS_KEY=123 |
| 31 | +export KMS_AWS_ACCESS_KEY_ID=456 |
| 32 | + |
| 33 | +# START KMS |
| 34 | +docker run -d -p 8080:8080 $KMS_IMAGE || true |
| 35 | + |
| 36 | + echo "waiting for local AWS KMS service on port 8080 to be available." |
| 37 | + |
| 38 | + timeout 300 bash -c 'until curl -sS 0:8080 > /dev/null; do |
| 39 | + echo "service not ready on port 8080. Retrying in 2 seconds." |
| 40 | + sleep 2 |
| 41 | + done' |
| 42 | + echo "local AWS KMS service is up and running on port 8080." |
| 43 | + |
| 44 | + AWS_ENDPOINT_URL=http://0:8080 AWS_DEFAULT_REGION=us-east-1 AWS_ACCESS_KEY_ID=456 AWS_SECRET_ACCESS_KEY=123 aws kms list-keys --max-items 1 |
| 45 | +# END KMS |
| 46 | + |
| 47 | +# Start all before migration |
| 48 | +docker compose up -d |
| 49 | + bash ../../wait_for_local_port.bash 8500 40 |
| 50 | + bash ../../wait_for_local_port.bash 8000 40 |
| 51 | +# HAVE vaultclient bin in your PATH or an alias |
| 52 | +alias vaultclient="~/scality/vaultclient/bin/vaultclient" |
| 53 | +export PATH="$PATH:~/scality/vaultclient/bin/" |
| 54 | +vaultclient --config admin.json delete-account --name mick || true |
| 55 | +vaultclient --config admin.json create-account --name mick --email [email protected] |
| 56 | +vaultclient --config admin.json generate-account-access-key --name mick --accesskey SCUBAINTERNAL0000000 --secretkey SCUBAINTERNAL000000000000000000000000000 |
| 57 | +vaultclient --config admin.json get-account --account-name mick |
| 58 | + |
| 59 | +cd ../.. |
| 60 | + |
| 61 | +echo ===== RUN BEFORE MIGRATION ===== |
| 62 | +export S3_CONFIG_FILE=config.before.json |
| 63 | + |
| 64 | + set -o pipefail; |
| 65 | + |
| 66 | + |
| 67 | + echo Ensures the expected version of cloudserver is old one: |
| 68 | + VERSION=$(docker compose -f .github/docker/docker-compose.yaml \ |
| 69 | + exec cloudserver cat package.json | jq -r .version) |
| 70 | + if [[ "$VERSION" != "7.70.21-11" ]]; then |
| 71 | + echo "bad version of container. Should be 7.70.21-11. Was $VERSION" >&2 |
| 72 | + exit 1 |
| 73 | + else |
| 74 | + echo OK $VERSION |
| 75 | + fi |
| 76 | + |
| 77 | + yarn run ft_sse_before_migration | tee /tmp/artifacts/$JOB_NAME/beforeMigration.log |
| 78 | + |
| 79 | +# RUN latest images |
| 80 | +cd .github/docker |
| 81 | +export SSE_CONF=sseMigration.$kmsHideScalityArn |
| 82 | +export CLOUDSERVER_IMAGE=$CLOUDSERVER_IMAGE_ORIGINAL |
| 83 | +export VAULT_IMAGE=$VAULT_IMAGE_ORIGINAL |
| 84 | + |
| 85 | +docker compose down cloudserver vault && docker compose up -d vault # cloudserver-sse-migration |
| 86 | + |
| 87 | +echo ==== RUN MIGRATION ==== |
| 88 | +cd ../.. |
| 89 | +yarn start_migration > s3.log & |
| 90 | +export S3_CONFIG_FILE=config.sseMigration.$kmsHideScalityArn.json |
| 91 | +export S3KMS=aws |
| 92 | + |
| 93 | + set -o pipefail; |
| 94 | + bash wait_for_local_port.bash 8500 40 |
| 95 | + bash wait_for_local_port.bash 8000 40 |
| 96 | + |
| 97 | + # echo Ensures the expected version of cloudserver is NOT old one |
| 98 | + # VERSION=$(docker compose -f .github/docker/docker-compose.yaml \ |
| 99 | + # exec cloudserver-sse-migration cat package.json | jq -r .version) |
| 100 | + # if [[ "$VERSION" == "7.70.21-11" ]]; then |
| 101 | + # echo "bad version of container. Should NOT be 7.70.21-11. Was $VERSION" >&2 |
| 102 | + # exit 1 |
| 103 | + # else |
| 104 | + # echo OK $VERSION |
| 105 | + # fi |
| 106 | + |
| 107 | + yarn run ft_sse_migration # | tee /tmp/artifacts/$JOB_NAME/migration.log |
| 108 | + sleep 10 |
| 109 | + yarn run ft_sse_arn # | tee /tmp/artifacts/$JOB_NAME/migration.log |
| 110 | + |
0 commit comments