Skip to content

Commit 81e04ff

Browse files
(wip) tests
1 parent 2ac59d3 commit 81e04ff

File tree

13 files changed

+303
-23
lines changed

13 files changed

+303
-23
lines changed

.github/docker/admin.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"accessKey": "D4IT2AWSB588GO5J9T00",
3+
"secretKeyValue": "UEEu8tYlsOGGrgf4DAiSZD6apVNPUWqRiPG0nTB6"
4+
}

.github/docker/docker-compose.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ services:
2222
- DATA_HOST=0.0.0.0
2323
- METADATA_HOST=0.0.0.0
2424
- S3BACKEND
25+
- S3VAULT=scality
2526
- S3DATA
27+
- S3METADATA
2628
- MPU_TESTING
2729
- S3VAULT
2830
- S3_LOCATION_FILE
@@ -55,6 +57,26 @@ services:
5557
- ../../localMetadata:/usr/src/app/localMetadata
5658
environment:
5759
- S3_CONFIG_FILE=/conf/config.json
60+
- S3KMS=aws
61+
- S3VAULT=scality
62+
vault:
63+
# image: ${VAULT_IMAGE_BEFORE_SSE_MIGRATION}
64+
image: ${VAULT_IMAGE}
65+
command: sh -c "chmod 400 tests/utils/keyfile && yarn start > /artifacts/vault.log"
66+
network_mode: "host"
67+
volumes:
68+
- /tmp/artifacts/${JOB_NAME}:/artifacts
69+
- ./vault-config.json:/conf/config.json:ro
70+
- ./vault-db:/data
71+
environment:
72+
- VAULT_DB_BACKEND=LEVELDB
73+
- CI=true
74+
- ENABLE_LOCAL_CACHE=true
75+
- REDIS_HOST=0.0.0.0
76+
- REDIS_PORT=6379
77+
- KMS_BACKEND=aws
78+
depends_on:
79+
- redis
5880
redis:
5981
image: redis:alpine
6082
network_mode: "host"

.github/docker/local.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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+

.github/docker/vault-config.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"clusters": 1,
3+
"healthChecks": {
4+
"allowFrom": ["127.0.0.1/8", "::1"]
5+
},
6+
"interfaces": {
7+
"S3": {
8+
"address": "0.0.0.0",
9+
"port": 8500,
10+
"allowFrom": ["0.0.0.0/8", "::1"]
11+
},
12+
"administration": {
13+
"address": "0.0.0.0",
14+
"port": 8600
15+
},
16+
"sts": {
17+
"address": "127.0.0.1",
18+
"port": 8800
19+
}
20+
},
21+
"map": ["127.0.0.1:4300", "127.0.0.2:4301", "127.0.0.3:4302", "127.0.0.4:4303", "127.0.0.5:4304"],
22+
"keyFilePath": "./tests/utils/keyfile",
23+
"adminCredentialsFilePath": "./tests/utils/admincredentials.json.encrypted",
24+
"log": {
25+
"level": "info",
26+
"dump": "error"
27+
},
28+
"accountSeeds": [
29+
{
30+
"role": {
31+
"roleName": "scality-role1",
32+
"trustPolicy": {
33+
"Version": "2012-10-17",
34+
"Statement": [
35+
{
36+
"Effect": "Allow",
37+
"Principal": { "AWS": "arn:aws:iam::000000000000:user/root" },
38+
"Action": "sts:AssumeRole",
39+
"Condition": {}
40+
}
41+
]
42+
}
43+
},
44+
"permissionPolicy": {
45+
"policyName": "scality-policy1",
46+
"policyDocument": {
47+
"Version": "2012-10-17",
48+
"Statement": [
49+
{
50+
"Sid": "FullAccess",
51+
"Effect": "Allow",
52+
"Action": ["s3:*"],
53+
"Resource": ["*"]
54+
}
55+
]
56+
}
57+
}
58+
}
59+
],
60+
"utapi": {
61+
"host": "127.0.0.1",
62+
"port": 8100
63+
},
64+
"scuba": {
65+
"host": "127.0.0.1",
66+
"port": 8100
67+
},
68+
"kmsAWS": {
69+
"noAwsArn": true,
70+
"providerName": "local",
71+
"region": "us-east-1",
72+
"endpoint": "http://0:8080",
73+
"ak": "456",
74+
"sk": "123"
75+
}
76+
}

.github/docker/vault-db/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

.github/workflows/tests.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,12 @@ jobs:
363363
needs: build
364364
env:
365365
S3BACKEND: file
366-
S3VAULT: mem
366+
S3VAULT: scality
367367
CLOUDSERVER_IMAGE_BEFORE_SSE_MIGRATION: ghcr.io/${{ github.repository }}:7.70.21-11
368+
VAULT_IMAGE_BEFORE_SSE_MIGRATION: ghcr.io/scality/vault:7.70.15-5
368369
CLOUDSERVER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
370+
VAULT_IMAGE: ghcr.io/scality/vault:e8c0fa2890c131581efd13ad3fd1ade7dcbd0968
371+
KMS_IMAGE: nsmithuk/local-kms:3.11.7
369372
MPU_TESTING: "yes"
370373
JOB_NAME: ${{ matrix.job-name }}
371374
steps:

tests/functional/aws-node-sdk/lib/json/mem_credentials.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
"lisa": {
77
"accessKey": "accessKey2",
88
"secretKey": "verySecretKey2"
9+
},
10+
"vault": {
11+
"accessKey": "SCUBAINTERNAL0000000",
12+
"secretKey": "SCUBAINTERNAL000000000000000000000000000"
913
}
1014
}

tests/functional/sse-kms-migration/arnPrefix.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ const testCases = [
5858
];
5959
const testCasesObj = testCases.filter(tc => !tc.deleteSSE);
6060

61-
const s3config = getConfig('default', { signatureVersion: 'v4' });
61+
const s3config = getConfig('vault', { signatureVersion: 'v4' });
6262
const s3 = new S3(s3config);
63-
const bucketUtil = new BucketUtility();
63+
const bucketUtil = new BucketUtility('vault');
6464

6565
kms.client._supportsDefaultKeyPerAccount = false; // To generate keys without vault account side effect
6666

@@ -139,7 +139,7 @@ async function cleanup(Bucket) {
139139
const bucketInfo = new BucketInfo('enc-bucket-test', 'OwnerId',
140140
'OwnerDisplayName', new Date().toJSON());
141141

142-
describe('SSE KMS arnPrefix', () => {
142+
describe.only('SSE KMS arnPrefix', () => {
143143
/** Bucket to test CopyObject from and to */
144144
const copyBkt = 'enc-bkt-copy';
145145
const copyObj = 'copy-obj';
@@ -195,7 +195,12 @@ describe('SSE KMS arnPrefix', () => {
195195
? obj.kmsKeyInfo.masterKeyArn
196196
: obj.kmsKeyInfo.masterKeyId;
197197
}
198-
return await putEncryptedObject(bkt.name, obj.name, objConf, obj.kmsKey, obj.body);
198+
try {
199+
return await putEncryptedObject(bkt.name, obj.name, objConf, obj.kmsKey, obj.body);
200+
} catch (err) {
201+
console.log('ERR', err, err && err.toString(), bktConf.name, obj.name, objConf.algo, obj.kmsKeyInfo)
202+
throw err;
203+
}
199204
}));
200205
};
201206

tests/functional/sse-kms-migration/beforeMigration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ const testCases = [
5050
];
5151
const testCasesObj = testCases.filter(tc => !tc.deleteSSE);
5252

53-
const config = getConfig('default', { signatureVersion: 'v4' });
53+
const config = getConfig('vault', { signatureVersion: 'v4' });
5454
const s3 = new S3(config);
55-
const bucketUtil = new BucketUtility();
55+
const bucketUtil = new BucketUtility('vault');
5656

5757
// Fix for before migration run
5858
Object.defineProperty(kms, 'arnPrefix', { get() { return ''; } });

tests/functional/sse-kms-migration/cleanup.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ const testCases = [
4444
},
4545
];
4646

47-
const config = getConfig('default', { signatureVersion: 'v4' });
47+
const config = getConfig('vault', { signatureVersion: 'v4' });
4848
const s3 = new S3(config);
49-
const bucketUtil = new BucketUtility();
49+
const bucketUtil = new BucketUtility('vault');
5050

5151
async function cleanup(Bucket) {
5252
try {
@@ -63,6 +63,7 @@ describe('SSE KMS Cleanup', () => {
6363
const mpuCopyBkt = 'enc-bkt-mpu-copy';
6464

6565
it('Empty and delete buckets for SSE KMS Migration', async () => {
66+
console.log('cleanup');
6667
void await promisify(metadata.setup.bind(metadata))();
6768

6869
try {

0 commit comments

Comments
 (0)