Skip to content

Commit 7325ac2

Browse files
add tests for crr existing objects
Issue : ZENKO-5030
1 parent f25f532 commit 7325ac2

File tree

9 files changed

+91
-2
lines changed

9 files changed

+91
-2
lines changed

.github/scripts/end2end/configure-e2e.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ kubectl run ${POD_NAME} \
9696
--env=AWS_SECRET_KEY=${AWS_SECRET_KEY} \
9797
--env=AWS_ENDPOINT=${AWS_ENDPOINT} \
9898
--env=AWS_FAIL_BUCKET_NAME=${AWS_FAIL_BUCKET_NAME} \
99+
--env=AWS_REPLICATION_CTST_BUCKET_NAME=${AWS_REPLICATION_CTST_BUCKET_NAME} \
99100
--env=AZURE_BACKEND_DESTINATION_LOCATION=${AZURE_BACKEND_DESTINATION_LOCATION} \
100101
--env=AZURE_BACKEND_ENDPOINT=${AZURE_BACKEND_ENDPOINT} \
101102
--env=AZURE_BACKEND_QUEUE_ENDPOINT=${AZURE_BACKEND_QUEUE_ENDPOINT} \

.github/scripts/end2end/patch-coredns.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ corefile="
1414
rewrite name exact ci-zenko-aws-crr-target-bucket.aws-mock.zenko.local ingress-nginx-controller.ingress-nginx.svc.cluster.local
1515
rewrite name exact ci-zenko-aws-fail-target-bucket.aws-mock.zenko.local ingress-nginx-controller.ingress-nginx.svc.cluster.local
1616
rewrite name exact ci-zenko-aws-target-bucket.aws-mock.zenko.local ingress-nginx-controller.ingress-nginx.svc.cluster.local
17+
rewrite name exact ci-zenko-aws-replication-ctst-bucket.aws-mock.zenko.local ingress-nginx-controller.ingress-nginx.svc.cluster.local
1718
rewrite name exact aws-mock.zenko.local ingress-nginx-controller.ingress-nginx.svc.cluster.local
1819
rewrite name exact azure-mock.zenko.local ingress-nginx-controller.ingress-nginx.svc.cluster.local
1920
rewrite name exact blob.azure-mock.zenko.local ingress-nginx-controller.ingress-nginx.svc.cluster.local

.github/scripts/end2end/run-e2e-ctst.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,20 @@ SORBETD_RESTORE_TIMEOUT=$(kubectl get zenko ${ZENKO_NAME} -o jsonpath='{.spec.so
7878
UTILIZATION_SERVICE_HOST=$(kubectl get zenko ${ZENKO_NAME} -o jsonpath='{.spec.scuba.api.ingress.hostname}')
7979
UTILIZATION_SERVICE_PORT="80"
8080

81+
MONGODB_REPLICASET=$(kubectl get secrets -l app.kubernetes.io/name=connector-cloudserver-config -o jsonpath='{.items[0].data.config\.json}' | base64 -di | jq -r .mongodb.replicaSetHosts)
82+
MONGODB_AUTH_USERNAME=$(kubectl get secrets -l app.kubernetes.io/name=connector-cloudserver-config -o jsonpath='{.items[0].data.config\.json}' | base64 -di | jq -r .mongodb.authCredentials.username)
83+
MONGODB_AUTH_PASSWORD=$(kubectl get secrets -l app.kubernetes.io/name=connector-cloudserver-config -o jsonpath='{.items[0].data.config\.json}' | base64 -di | jq -r .mongodb.authCredentials.password)
84+
MONGODB_DATABASE=$(kubectl get secrets -l app.kubernetes.io/name=connector-cloudserver-config -o jsonpath='{.items[0].data.config\.json}' | base64 -di | jq -r .mongodb.database)
85+
86+
S3_UTILS_TAG=$(yq eval ".s3utils.tag" ../../../solution/deps.yaml)
87+
88+
LOCATION_CONFIGS=$(kubectl get secrets -l app.kubernetes.io/name=connector-cloudserver-config -o jsonpath='{.items[0].data.locationConfig\.json}' | base64 -di | jq -r .)
89+
AWS_REPLICATION_ENDPOINT="http://$(echo "$LOCATION_CONFIGS" | jq -r --arg loc "$AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION" '.[$loc].details.awsEndpoint')"
90+
AWS_REPLICATION_ACCESS_KEY=$(echo "$LOCATION_CONFIGS" | jq -r --arg loc "$AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION" '.[$loc].details.credentials.accessKey')
91+
AWS_REPLICATION_SECRET_KEY=$(echo "$LOCATION_CONFIGS" | jq -r --arg loc "$AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION" '.[$loc].details.credentials.secretKey')
92+
AWS_REPLICATION_LOCATION_TYPE=$(echo "$LOCATION_CONFIGS" | jq -r --arg loc "$AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION" '.[$loc].type')
93+
AWS_REPLICATION_REGION=$(echo "$LOCATION_CONFIGS" | jq -r --arg loc "$AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION" '.[$loc].details.region')
94+
8195
# Setting CTST world params
8296
WORLD_PARAMETERS="$(jq -c <<EOF
8397
{
@@ -128,7 +142,19 @@ WORLD_PARAMETERS="$(jq -c <<EOF
128142
"DRAdminAccessKey":"${DR_ADMIN_ACCESS_KEY_ID}",
129143
"DRAdminSecretKey":"${DR_ADMIN_SECRET_ACCESS_KEY}",
130144
"UtilizationServiceHost":"${UTILIZATION_SERVICE_HOST}",
131-
"UtilizationServicePort":"${UTILIZATION_SERVICE_PORT}"
145+
"UtilizationServicePort":"${UTILIZATION_SERVICE_PORT}",
146+
"AwsBackendDestinationReplicationLocation":"${AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION}",
147+
"AwsReplicationBucketName":"${AWS_REPLICATION_CTST_BUCKET_NAME}",
148+
"AwsReplicationEndpoint":"${AWS_REPLICATION_ENDPOINT}",
149+
"AwsReplicationAccessKey":"${AWS_REPLICATION_ACCESS_KEY}",
150+
"AwsReplicationSecretKey":"${AWS_REPLICATION_SECRET_KEY}",
151+
"AwsReplicationLocationType":"${AWS_REPLICATION_LOCATION_TYPE}",
152+
"AwsReplicationRegion":"${AWS_REPLICATION_REGION}",
153+
"MongodbReplicaSet":"${MONGODB_REPLICASET}",
154+
"MongodbAuthUsername":"${MONGODB_AUTH_USERNAME}",
155+
"MongodbAuthPassword":"${MONGODB_AUTH_PASSWORD}",
156+
"MongodbDatabase":"${MONGODB_DATABASE}",
157+
"S3UtilsTag":"${S3_UTILS_TAG}"
132158
}
133159
EOF
134160
)"

.github/workflows/end2end.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ env:
5757
AWS_BACKEND_SOURCE_LOCATION: awsbackend
5858
AWS_BACKEND_DESTINATION_LOCATION: awsbackendmismatch
5959
AWS_BACKEND_DESTINATION_FAIL_LOCATION: awsbackendfail
60+
AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION: awsbackendreplicationctst
6061
GCP_BACKEND_DESTINATION_LOCATION: gcpbackendmismatch
6162
AZURE_BACKEND_DESTINATION_LOCATION: azurebackendmismatch
6263
COLD_BACKEND_DESTINATION_LOCATION: e2e-cold
@@ -66,6 +67,7 @@ env:
6667
AWS_BUCKET_NAME: ci-zenko-aws-target-bucket
6768
AWS_CRR_BUCKET_NAME: ci-zenko-aws-crr-target-bucket
6869
AWS_FAIL_BUCKET_NAME: ci-zenko-aws-fail-target-bucket
70+
AWS_REPLICATION_CTST_BUCKET_NAME: ci-zenko-aws-replication-ctst-bucket
6971
AZURE_CRR_BUCKET_NAME: ci-zenko-azure-crr-target-bucket
7072
AZURE_ARCHIVE_BUCKET_NAME: ci-zenko-azure-archive-target-bucket
7173
AZURE_ARCHIVE_BUCKET_NAME_2: ci-zenko-azure-archive-target-bucket-2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Feature: Replication
2+
This feature tests replication using the script crrExistingObjects.js from S3utils,
3+
that replicates objects created before the replication was enabled on source the bucket.
4+
5+
@2.7.0
6+
@PreMerge
7+
@ReplicationTest
8+
Scenario Outline: Replicate objects created before creating the replication rule
9+
Given an existing bucket "<sourceBucket>" "with" versioning, "without" ObjectLock "without" retention mode
10+
And an object "<sourceObject>" that "exists"
11+
And a replication configuration from "<sourceBucket>" bucket to "<replicationLocation>" location
12+
When I run the job to replicate existing objects with status "<sourceObjStatus>" from bucket "<sourceBucket>" to location "<replicationLocation>"
13+
Then the object "<sourceObject>" should be replicated within 60 seconds from "<sourceBucket>" bucket
14+
And the replicated object "<sourceObject>" from "<sourceBucket>" bucket to "<replicationBucket>" bucket with location "<replicationLocation>" should be the same as its source object
15+
16+
Examples:
17+
| sourceBucket | sourceObjStatus | replicationBucket | sourceObject | replicationLocation |
18+
| source-bucket | NEW | ci-zenko-aws-replication-ctst-bucket | source-object-1 | awsbackendreplicationctst |

tests/ctst/steps/utils/utils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { extractPropertyFromResults, s3FunctionExtraParams, safeJsonParse } from
1313
import Zenko from 'world/Zenko';
1414
import assert from 'assert';
1515
import constants from 'common/constants';
16+
<<<<<<< HEAD
1617
import { getLocationConfigs } from './kubernetes';
18+
=======
19+
>>>>>>> c06fc489 (add tests for crr existing objects)
1720
import { S3Client } from '@aws-sdk/client-s3';
1821

1922
enum AuthorizationType {
@@ -427,6 +430,11 @@ async function putBucketReplication(
427430
srcBucket: string,
428431
replicationLocation: string
429432
) {
433+
<<<<<<< HEAD
434+
=======
435+
const { storageClass, destinationBucket } = getReplicationLocationConfig(this, replicationLocation);
436+
437+
>>>>>>> c06fc489 (add tests for crr existing objects)
430438
this.resetCommand();
431439
this.addCommandParameter({ bucket: srcBucket });
432440
this.addCommandParameter({
@@ -436,11 +444,16 @@ async function putBucketReplication(
436444
{
437445
Prefix: '',
438446
Destination: {
447+
<<<<<<< HEAD
439448
// Source bucket is not a typo :
440449
// eslint-disable-next-line max-len
441450
// https://documentation.scality.com/Artesca/4.0.1/data_management/bucket_operations/replication_workflow/create_a_replication_workflow.html
442451
Bucket: `arn:aws:s3:::${srcBucket}`,
443452
StorageClass: replicationLocation,
453+
=======
454+
Bucket: `arn:aws:s3:::${destinationBucket}`,
455+
StorageClass: storageClass,
456+
>>>>>>> c06fc489 (add tests for crr existing objects)
444457
},
445458
Status: 'Enabled',
446459
},
@@ -453,7 +466,11 @@ async function putBucketReplication(
453466
if (res.err) {
454467
this.logger.error('Failed to put bucket replication', {
455468
srcBucket,
469+
<<<<<<< HEAD
456470
replicationLocation,
471+
=======
472+
storageClass,
473+
>>>>>>> c06fc489 (add tests for crr existing objects)
457474
error: res.err,
458475
});
459476
throw new Error(`Failed to put bucket replication, err : ${res.err}`);

tests/ctst/world/Zenko.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ export interface ZenkoWorldParameters extends ClientOptions {
8989
SorbetdRestoreTimeout: string;
9090
UtilizationServiceHost: string;
9191
UtilizationServicePort: string;
92+
AwsBackendDestinationReplicationLocation: string;
93+
AwsReplicationBucketName: string;
94+
AwsReplicationEndpoint: string;
95+
AwsReplicationAccessKey: string;
96+
AwsReplicationSecretKey: string;
97+
AwsReplicationLocationType: string;
98+
AwsReplicationRegion: string;
99+
MongodbReplicaSet: string;
100+
MongodbAuthUsername: string;
101+
MongodbAuthPassword: string;
102+
MongodbDatabase: string;
103+
S3UtilsTag: string;
92104
[key: string]: unknown;
93105
}
94106

tests/zenko_tests/create_buckets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ def create_aws_buckets():
116116
VERIFY_CERTIFICATES = get_env('VERIFY_CERTIFICATES', False)
117117
AWS_ACCESS_KEY = get_env('AWS_ACCESS_KEY')
118118
AWS_SECRET_KEY = get_env('AWS_SECRET_KEY')
119-
AWS_FAIL_BUCKET_NAME = get_env('AWS_FAIL_BUCKET_NAME')
120119
AWS_ENDPOINT = get_env('AWS_ENDPOINT')
120+
AWS_FAIL_BUCKET_NAME = get_env('AWS_FAIL_BUCKET_NAME')
121+
AWS_REPLICATION_CTST_BUCKET_NAME = get_env('AWS_REPLICATION_CTST_BUCKET_NAME')
121122

122123
s3c = Session(aws_access_key_id=AWS_ACCESS_KEY,
123124
aws_secret_access_key=AWS_SECRET_KEY)
@@ -127,7 +128,9 @@ def create_aws_buckets():
127128
## Creating AWS buckets
128129
_log.info('Creating AWS buckets...')
129130
bucket_safe_create(aws_s3c_client.Bucket(AWS_FAIL_BUCKET_NAME))
131+
bucket_safe_create(aws_s3c_client.Bucket(AWS_REPLICATION_CTST_BUCKET_NAME))
130132
aws_s3c_client.Bucket(AWS_FAIL_BUCKET_NAME).Versioning().enable()
133+
aws_s3c_client.Bucket(AWS_REPLICATION_CTST_BUCKET_NAME).Versioning().enable()
131134

132135
def create_azure_containers():
133136
AZURE_BACKEND_ENDPOINT = get_env("AZURE_BACKEND_ENDPOINT")

tests/zenko_tests/e2e-config.yaml.template

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ locations:
3030
secretKey: "${AWS_SECRET_KEY}"
3131
bucketMatch: yes
3232
repoId: []
33+
- name: "${AWS_BACKEND_DESTINATION_REPLICATION_CTST_LOCATION}"
34+
locationType: "location-aws-s3-v1"
35+
details:
36+
bucketName: "${AWS_REPLICATION_CTST_BUCKET_NAME}"
37+
endpoint: "${AWS_ENDPOINT}"
38+
accessKey: "${AWS_ACCESS_KEY}"
39+
secretKey: "${AWS_SECRET_KEY}"
40+
bucketMatch: no
41+
repoId: []
3342
- name: ${AZURE_BACKEND_DESTINATION_LOCATION}
3443
locationType: location-azure-v1
3544
details:

0 commit comments

Comments
 (0)