Skip to content

Commit 182699d

Browse files
committed
Tests fixes
Signed-off-by: Aayush Chouhan <[email protected]>
1 parent cdf9e4f commit 182699d

File tree

4 files changed

+44
-25
lines changed

4 files changed

+44
-25
lines changed

src/server/object_services/md_store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ class MDStore {
669669
$lt: new Date(moment.unix(max_create_time).toISOString()),
670670
$exists: true
671671
} : undefined,
672-
tagging: tagging ? {
672+
tagging: (tagging && tagging.length) ? {
673673
$all: tagging,
674674
} : undefined,
675675
size: (max_size || min_size) ?

src/test/lifecycle/common.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ function size_gt_lt_lifecycle_configuration(Bucket, gt, lt) {
162162
Date: midnight,
163163
},
164164
Filter: {
165-
ObjectSizeLessThan: lt,
166-
ObjectSizeGreaterThan: gt
165+
And: {
166+
ObjectSizeLessThan: lt,
167+
ObjectSizeGreaterThan: gt,
168+
},
167169
},
168170
Status: 'Enabled',
169171
}, ],
@@ -368,7 +370,7 @@ function duplicate_id_lifecycle_configuration(Bucket, Key) {
368370
Bucket,
369371
LifecycleConfiguration: {
370372
Rules: [{
371-
ID1,
373+
ID: ID1,
372374
Expiration: {
373375
Days: 17,
374376
},
@@ -378,7 +380,7 @@ function duplicate_id_lifecycle_configuration(Bucket, Key) {
378380
Status: 'Enabled',
379381
},
380382
{
381-
ID2,
383+
ID: ID2,
382384
Expiration: {
383385
Days: 18,
384386
},
@@ -622,7 +624,7 @@ exports.test_rule_id_length = async function(Bucket, Key, s3) {
622624
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
623625
assert.fail(`Expected error for ID length exceeding maximum allowed characters ${s3_const.MAX_RULE_ID_LENGTH}, but request was successful`);
624626
} catch (error) {
625-
assert(error.code === 'InvalidArgument', `Expected InvalidArgument: id length exceeding ${s3_const.MAX_RULE_ID_LENGTH} characters`);
627+
assert(error.Code === 'InvalidArgument', `Expected InvalidArgument: id length exceeding ${s3_const.MAX_RULE_ID_LENGTH} characters`);
626628
}
627629
};
628630

@@ -633,7 +635,8 @@ exports.test_rule_duplicate_id = async function(Bucket, Key, s3) {
633635
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
634636
assert.fail('Expected error for duplicate rule ID, but request was successful');
635637
} catch (error) {
636-
assert(error.code === 'InvalidArgument', 'Expected InvalidArgument: duplicate ID found in the rules');
638+
console.log("Received error: ", error);
639+
assert(error.Code === 'InvalidArgument', 'Expected InvalidArgument: duplicate ID found in the rules');
637640
}
638641
};
639642

@@ -647,49 +650,49 @@ exports.test_rule_status_value = async function(Bucket, Key, s3) {
647650
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
648651
assert.fail('Expected MalformedXML error due to wrong status value, but received a different response');
649652
} catch (error) {
650-
assert(error.code === 'MalformedXML', `Expected MalformedXML error: due to invalid status value`);
653+
assert(error.Code === 'MalformedXML', `Expected MalformedXML error: due to invalid status value`);
651654
}
652655
};
653656

654657
exports.test_invalid_filter_format = async function(Bucket, Key, s3) {
655-
const putLifecycleParams = id_lifecycle_configuration(Bucket, Key);
658+
const putLifecycleParams = tags_lifecycle_configuration(Bucket, Key);
656659

657660
// append prefix for invalid filter: "And" condition is missing, but multiple filters are present
658-
putLifecycleParams.LifecycleConfiguration.Rules[0].Filter[0].Prefix = 'test-prefix';
661+
putLifecycleParams.LifecycleConfiguration.Rules[0].Filter.Prefix = 'test-prefix';
659662

660663
try {
661664
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
662665
assert.fail('Expected MalformedXML error due to missing "And" condition for multiple filters');
663666
} catch (error) {
664-
assert(error.code === 'MalformedXML', 'Expected MalformedXML error: due to missing "And" condition');
667+
assert(error.Code === 'MalformedXML', 'Expected MalformedXML error: due to missing "And" condition');
665668
}
666669
};
667670

668671
exports.test_invalid_expiration_date_format = async function(Bucket, Key, s3) {
669672
const putLifecycleParams = date_lifecycle_configuration(Bucket, Key);
670673

671674
// set expiration with a Date that is not at midnight UTC (incorrect time specified)
672-
putLifecycleParams.LifecycleConfiguration.Rules[0].Expiration[0].Date = '2025-01-01T15:30:00Z';
675+
putLifecycleParams.LifecycleConfiguration.Rules[0].Expiration.Date = new Date('2025-01-01T15:30:00Z');
673676

674677
try {
675678
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
676679
assert.fail('Expected error due to incorrect date format (not at midnight UTC), but request was successful');
677680
} catch (error) {
678-
assert(error.code === 'InvalidArgument', 'Expected InvalidArgument error: date must be at midnight UTC');
681+
assert(error.Code === 'InvalidArgument', 'Expected InvalidArgument error: date must be at midnight UTC');
679682
}
680683
};
681684

682685
exports.test_expiration_multiple_fields = async function(Bucket, Key, s3) {
683686
const putLifecycleParams = days_lifecycle_configuration(Bucket, Key);
684687

685688
// append ExpiredObjectDeleteMarker for invalid expiration with multiple fields
686-
putLifecycleParams.LifecycleConfiguration.Rules[0].Expiration[0].ExpiredObjectDeleteMarker = false;
689+
putLifecycleParams.LifecycleConfiguration.Rules[0].Expiration.ExpiredObjectDeleteMarker = false;
687690

688691
try {
689692
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
690693
assert.fail('Expected MalformedXML error due to multiple expiration fields');
691694
} catch (error) {
692-
assert(error.code === 'MalformedXML', 'Expected MalformedXML error: due to multiple expiration fields');
695+
assert(error.Code === 'MalformedXML', 'Expected MalformedXML error: due to multiple expiration fields');
693696
}
694697
};
695698

@@ -705,7 +708,7 @@ exports.test_abortincompletemultipartupload_with_tags = async function(Bucket, K
705708
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
706709
assert.fail('Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with tags');
707710
} catch (error) {
708-
assert(error.code === 'InvalidArgument', 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with tags');
711+
assert(error.Code === 'InvalidArgument', 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with tags');
709712
}
710713
};
711714

@@ -721,6 +724,6 @@ exports.test_abortincompletemultipartupload_with_sizes = async function(Bucket,
721724
await s3.putBucketLifecycleConfiguration(putLifecycleParams);
722725
assert.fail('Expected InvalidArgument error due to AbortIncompleteMultipartUpload specified with object size');
723726
} catch (error) {
724-
assert(error.code === 'InvalidArgument', 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with object size');
727+
assert(error.Code === 'InvalidArgument', 'Expected InvalidArgument: AbortIncompleteMultipartUpload cannot be specified with object size');
725728
}
726729
};

src/test/system_tests/test_lifecycle.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ async function main() {
5454
await commonTests.test_rule_id(Bucket, Key, s3);
5555
await commonTests.test_filter_size(Bucket, s3);
5656
await commonTests.test_and_prefix_size(Bucket, Key, s3);
57-
await commonTests.test_rule_id_length(Bucket, Key, s3);
58-
await commonTests.test_rule_duplicate_id(Bucket, Key, s3);
59-
await commonTests.test_rule_status_value(Bucket, Key, s3);
60-
await commonTests.test_invalid_filter_format(Bucket, Key, s3);
61-
await commonTests.test_invalid_expiration_date_format(Bucket, Key, s3);
62-
await commonTests.test_expiration_multiple_fields(Bucket, Key, s3);
63-
await commonTests.test_abortincompletemultipartupload_with_tags(Bucket, Key, s3);
64-
await commonTests.test_abortincompletemultipartupload_with_sizes(Bucket, Key, s3);
6557

6658
const getObjectParams = {
6759
Bucket,

src/test/unit_tests/test_lifecycle.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,30 @@ mocha.describe('lifecycle', () => {
104104
mocha.it('test multipath', async () => {
105105
await commonTests.test_multipart(Bucket, Key, s3);
106106
});
107+
mocha.it('test rule ID length', async () => {
108+
await commonTests.test_rule_id_length(Bucket, Key, s3);
109+
});
110+
mocha.it('test rule duplicate ID', async () => {
111+
await commonTests.test_rule_duplicate_id(Bucket, Key, s3);
112+
});
113+
mocha.it('test rule status value', async () => {
114+
await commonTests.test_rule_status_value(Bucket, Key, s3);
115+
});
116+
mocha.it('test invalid filter format', async () => {
117+
await commonTests.test_invalid_filter_format(Bucket, Key, s3);
118+
});
119+
mocha.it('test invalid expiration date format', async () => {
120+
await commonTests.test_invalid_expiration_date_format(Bucket, Key, s3);
121+
});
122+
mocha.it('test expiration with multiple fields', async () => {
123+
await commonTests.test_expiration_multiple_fields(Bucket, Key, s3);
124+
});
125+
mocha.it('test AbortIncompleteMultipartUpload with tags', async () => {
126+
await commonTests.test_abortincompletemultipartupload_with_tags(Bucket, Key, s3);
127+
});
128+
mocha.it('test AbortIncompleteMultipartUpload with object sizes', async () => {
129+
await commonTests.test_abortincompletemultipartupload_with_sizes(Bucket, Key, s3);
130+
});
107131
});
108132

109133
mocha.describe('bucket-lifecycle-bg-worker', function() {

0 commit comments

Comments
 (0)