Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderchan-scality committed Feb 28, 2023
1 parent fc0c3e1 commit 325fbb4
Showing 1 changed file with 63 additions and 9 deletions.
72 changes: 63 additions & 9 deletions tests/functional/lifecycle/LifecycleTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const FUTURE = new Date(CURRENT);
FUTURE.setDate(FUTURE.getDate() + 5);

const OWNER = 'testOwner';
const ncd = 'NoncurrentDays';

class S3Helper {
constructor(client) {
Expand Down Expand Up @@ -394,6 +395,7 @@ class LifecycleBucketProcessorMock {
this._producer = new ProducerMock();
this._kafkaBacklogMetrics = new KafkaBacklogMetricsMock();
this._kafkaBacklogMetrics.setProducer(this._producer);
this.ncvHeap = new Map();

// set test topic name
ReplicationAPI.setDataMoverTopic('data-mover');
Expand Down Expand Up @@ -421,12 +423,14 @@ class LifecycleBucketProcessorMock {
objectTasksTopic: 'object-tasks',
kafkaBacklogMetrics: this._kafkaBacklogMetrics,
log: this._log,
ncvHeap: this.ncvHeap,
};
}

reset() {
this._producer.reset();
this._kafkaBacklogMetrics.reset();
this.ncvHeap.clear();
}

// NOTE: for triggering snapshot
Expand Down Expand Up @@ -949,7 +953,7 @@ describe('lifecycle task functional tests', function dF() {
async.waterfall([
next => s3Helper.setAndCreateBucket('test-bucket', next),
next => s3Helper.setBucketLifecycleConfigurations([
new LifecycleRule().addID('task-1').addNCVExpiration(2).build(),
new LifecycleRule().addID('task-1').addNCVExpiration(ncd, 2).build(),
], next),
(data, next) => s3Helper.createVersions(2, next),
next => s3.getBucketLifecycleConfiguration({
Expand All @@ -968,7 +972,7 @@ describe('lifecycle task functional tests', function dF() {
});
},
next => s3Helper.setBucketLifecycleConfigurations([
new LifecycleRule().addNCVExpiration(1).build(),
new LifecycleRule().addNCVExpiration(ncd, 1).build(),
], next),
(data, next) => s3.getBucketLifecycleConfiguration({
Bucket: 'test-bucket',
Expand Down Expand Up @@ -1347,7 +1351,7 @@ describe('lifecycle task functional tests', function dF() {
message: 'should verify that NoncurrentVersionExpiration rule' +
' applies to each versioned object, no pagination',
bucketLCRules: [
new LifecycleRule().addID('task-1').addNCVExpiration(1).build(),
new LifecycleRule().addID('task-1').addNCVExpiration(ncd, 1).build(),
],
scenarioFxn: 'createVersions',
scenario: 2,
Expand All @@ -1370,11 +1374,11 @@ describe('lifecycle task functional tests', function dF() {
message: 'should verify that NoncurrentVersionExpiration rule' +
' applies to correct versions with pagination and prefix',
bucketLCRules: [
new LifecycleRule().addID('task-1').addNCVExpiration(3).build(),
new LifecycleRule().addID('task-1').addNCVExpiration(ncd, 3).build(),
new LifecycleRule().addID('task-2').addPrefix('test/')
.addNCVExpiration(1).build(),
.addNCVExpiration(ncd, 1).build(),
new LifecycleRule().addID('task-3').addPrefix('src/')
.addNCVExpiration(2).build(),
.addNCVExpiration(ncd, 2).build(),
],
scenarioFxn: 'createVersions',
scenario: 3,
Expand All @@ -1398,9 +1402,9 @@ describe('lifecycle task functional tests', function dF() {
' applies to correct versions with tagging and pagination',
bucketLCRules: [
new LifecycleRule().addID('task-1').addTag('key1', 'value1')
.addPrefix('src/').addNCVExpiration(1).build(),
.addPrefix('src/').addNCVExpiration(ncd, 1).build(),
new LifecycleRule().addID('task-2').addTag('key2', 'value2')
.addNCVExpiration(2).build(),
.addNCVExpiration(ncd, 2).build(),
],
scenarioFxn: 'createVersions',
scenario: 3,
Expand All @@ -1423,7 +1427,7 @@ describe('lifecycle task functional tests', function dF() {
message: 'should verify that NoncurrentVersionExpiration rule' +
' applies to delete markers as well with pagination',
bucketLCRules: [
new LifecycleRule().addID('task-1').addNCVExpiration(1).build(),
new LifecycleRule().addID('task-1').addNCVExpiration(ncd, 1).build(),
],
scenarioFxn: 'createDeleteMarkers',
scenario: 2,
Expand All @@ -1441,6 +1445,56 @@ describe('lifecycle task functional tests', function dF() {
objectCount: 5,
},
},
// ncve: 1 day rule should expire with NewerNoncurrentVersion, no pagination
// should expire some
{
message: 'should verify that NoncurrentVersionExpiration rule' +
' applies to each versioned object, no pagination',
bucketLCRules: [
new LifecycleRule().addID('task-1').addNCVExpiration(ncd, 1).build(),
],
scenarioFxn: 'createVersions',
scenario: 2,
bucketEntry: {
action: 'testing-ncve',
target: {
bucket: 'test-ncve',
owner: OWNER,
},
details: {},
},
expected: {
objects: ['version-1', 'version-1'],
bucketCount: 0,
objectCount: 2,
},
},
// ncve: NewerNoncurrentVersion, pagination, tagging, should expire some
{
message: 'should verify that NoncurrentVersionExpiration rule' +
' applies to correct versions with tagging and pagination',
bucketLCRules: [
new LifecycleRule().addID('task-1').addTag('key1', 'value1')
.addPrefix('src/').addNCVExpiration(ncd, 1).build(),
new LifecycleRule().addID('task-2').addTag('key2', 'value2')
.addNCVExpiration(ncd, 2).build(),
],
scenarioFxn: 'createVersions',
scenario: 3,
bucketEntry: {
action: 'testing-ncve',
target: {
bucket: 'test-ncve',
owner: OWNER,
},
details: {},
},
expected: {
objects: Array(2).fill('src/obj-2'),
bucketCount: 5,
objectCount: 2,
},
},
].forEach(item => {
it(item.message, done => {
const params = {
Expand Down

0 comments on commit 325fbb4

Please sign in to comment.