|
| 1 | +#!/bin/bash |
| 2 | +set -e -o pipefail |
| 3 | + |
| 4 | +# run kms migration tests locally |
| 5 | +# in .github/docker |
| 6 | + |
| 7 | +export S3BACKEND=file |
| 8 | +export S3METADATA=file |
| 9 | +export S3VAULT=scality |
| 10 | +export MPU_TESTING="yes" |
| 11 | + |
| 12 | +export CLOUDSERVER_IMAGE_BEFORE_SSE_MIGRATION=ghcr.io/scality/cloudserver:9.0.8 |
| 13 | +export CLOUDSERVER_IMAGE_ORIGINAL=ghcr.io/scality/cloudserver:9.0.16 |
| 14 | + |
| 15 | +export VAULT_IMAGE_BEFORE_SSE_MIGRATION=ghcr.io/scality/vault:7.70.31 |
| 16 | +export VAULT_IMAGE_ORIGINAL=ghcr.io/scality/vault:7.70.32 |
| 17 | +export KMS_IMAGE=nsmithuk/local-kms:3.11.7 |
| 18 | + |
| 19 | +export S3_CONFIG_FILE="$(pwd)/../../tests/functional/sse-kms-migration/config.json" |
| 20 | + |
| 21 | +export kmsContainer=localkms |
| 22 | +export kmsProvider=aws |
| 23 | +export kmsPort=8080 |
| 24 | + |
| 25 | +# export kmsContainer=pykmip |
| 26 | +# export kmsProvider=kmip |
| 27 | +# export kmsPort=5696 |
| 28 | + |
| 29 | +export kmsHideScalityArn=true |
| 30 | +export globalEncryptionEnabled=true |
| 31 | + |
| 32 | +export JOB_NAME=sse-kms-migration-tests-$kmsHideScalityArn-$kmsProvider |
| 33 | + |
| 34 | +mkdir -p /tmp/artifacts/$JOB_NAME |
| 35 | +mkdir -p /tmp/ssl-kmip |
| 36 | + |
| 37 | +export CLOUDSERVER_IMAGE=$CLOUDSERVER_IMAGE_BEFORE_SSE_MIGRATION |
| 38 | +export VAULT_IMAGE=$VAULT_IMAGE_BEFORE_SSE_MIGRATION |
| 39 | + |
| 40 | +export KMS_AWS_SECRET_ACCESS_KEY=123 |
| 41 | +export KMS_AWS_ACCESS_KEY_ID=456 |
| 42 | + |
| 43 | +export COMPOSE_FILE=docker-compose.yaml:docker-compose.sse.yaml |
| 44 | + |
| 45 | +function stop_all() { |
| 46 | + docker compose -p docker down |
| 47 | +} |
| 48 | + |
| 49 | +function rm_all() { |
| 50 | + sudo rm -rf ./vault-db/ |
| 51 | + sudo rm -rf ../../localData/* |
| 52 | + sudo rm -rf ../../localMetadata/* |
| 53 | +} |
| 54 | + |
| 55 | +function start_all_before_migration() { |
| 56 | + cd ../../tests/functional/sse-kms-migration |
| 57 | + pwd |
| 58 | + cp configs/base.json config.json |
| 59 | + cd ../../../.github/docker |
| 60 | + |
| 61 | + docker compose up -d redis vault-sse-before-migration cloudserver-sse-before-migration |
| 62 | + bash ../../wait_for_local_port.bash 8500 40 |
| 63 | + bash ../../wait_for_local_port.bash 8000 40 |
| 64 | + # HAVE vaultclient bin in your PATH or an alias |
| 65 | + # alias vaultclient="~/scality/vaultclient/bin/vaultclient" |
| 66 | + export PATH="$PATH:~/scality/vaultclient/bin/" |
| 67 | + vaultclient --config admin.json delete-account --name test || true |
| 68 | + vaultclient --config admin.json create-account --name test --email test@scality.com |
| 69 | + vaultclient --config admin.json generate-account-access-key --name test --accesskey TESTAK00000000000000 --secretkey TESTSK0000000000000000000000000000000000 |
| 70 | + vaultclient --config admin.json get-account --account-name test |
| 71 | +} |
| 72 | + |
| 73 | +function run_before_migration() { |
| 74 | + echo ===== RUN BEFORE MIGRATION ===== |
| 75 | + cd ../.. |
| 76 | + |
| 77 | + AWS_ENDPOINT_URL=http://0:8000 AWS_DEFAULT_REGION=us-east-1 AWS_ACCESS_KEY_ID=TESTAK00000000000000 AWS_SECRET_ACCESS_KEY=TESTSK0000000000000000000000000000000000 aws s3 ls |
| 78 | + yarn run ft_sse_before_migration | tee /tmp/artifacts/$JOB_NAME/beforeMigration.log |
| 79 | +} |
| 80 | + |
| 81 | +function run_latest_images() { |
| 82 | + export CLOUDSERVER_IMAGE=$CLOUDSERVER_IMAGE_ORIGINAL |
| 83 | + export VAULT_IMAGE=$VAULT_IMAGE_ORIGINAL |
| 84 | + export S3KMS=$kmsProvider # S3 |
| 85 | + export KMS_BACKEND=$([[ "$kmsProvider" == "aws" ]] && echo "aws") # vault only aws is supported |
| 86 | + |
| 87 | + cd tests/functional/sse-kms-migration |
| 88 | + jq -s " |
| 89 | + .[0] * .[1] * .[2] * |
| 90 | + { kmsHideScalityArn: $kmsHideScalityArn } * |
| 91 | + { globalEncryptionEnabled: $globalEncryptionEnabled } |
| 92 | + " \ |
| 93 | + configs/base.json \ |
| 94 | + configs/$kmsProvider.json \ |
| 95 | + configs/sseMigration.json \ |
| 96 | + > config.json |
| 97 | + cd ../../../ |
| 98 | + cd .github/docker |
| 99 | + # copy kmip certs |
| 100 | + sudo cp -r ../pykmip/certs/* /tmp/ssl-kmip |
| 101 | + |
| 102 | + docker compose down cloudserver-sse-before-migration vault-sse-before-migration |
| 103 | + docker compose up -d $kmsContainer vault-sse-migration cloudserver-sse-migration |
| 104 | + |
| 105 | + bash ../../wait_for_local_port.bash $kmsPort 40 |
| 106 | + bash ../../wait_for_local_port.bash 8500 40 |
| 107 | + bash ../../wait_for_local_port.bash 8000 40 |
| 108 | +} |
| 109 | + |
| 110 | +function run_migration() { |
| 111 | + echo ==== RUN MIGRATION ==== |
| 112 | + cd ../.. |
| 113 | + export S3KMS=$kmsProvider # S3 |
| 114 | + export KMS_BACKEND=$([[ "$kmsProvider" == "aws" ]] && echo "aws") # vault only aws is supported |
| 115 | + yarn run ft_sse_migration | tee /tmp/artifacts/$JOB_NAME/migration.log |
| 116 | +} |
| 117 | + |
| 118 | +function run_after_migration() { |
| 119 | + sleep 1 |
| 120 | + export S3KMS=$kmsProvider # S3 |
| 121 | + export KMS_BACKEND=$([[ "$kmsProvider" == "aws" ]] && echo "aws") # vault only aws is supported |
| 122 | + yarn run ft_sse_arn | tee /tmp/artifacts/$JOB_NAME/arnPrefix.log |
| 123 | +} |
| 124 | + |
| 125 | +stop_all |
| 126 | +rm_all |
| 127 | +start_all_before_migration |
| 128 | +run_before_migration |
| 129 | +run_latest_images |
| 130 | +run_migration |
| 131 | +run_after_migration |
0 commit comments