Skip to content

Conversation

benzekrimaha
Copy link
Contributor

Issue: CLDSRV-724

Copy link

codecov bot commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.04%. Comparing base (adb7ac5) to head (55803c6).

Additional details and impacted files

Impacted file tree graph
see 74 files with indirect coverage changes

@@                            Coverage Diff                             @@
##           improvement/CLDSRV-724-sur-utapi-tests    #5951      +/-   ##
==========================================================================
- Coverage                                   79.61%   72.04%   -7.57%     
==========================================================================
  Files                                         191      191              
  Lines                                       12233    12233              
==========================================================================
- Hits                                         9739     8813     -926     
- Misses                                       2494     3420     +926     
Flag Coverage Δ
ceph-backend-test 19.78% <ø> (-44.82%) ⬇️
file-ft-tests 22.27% <ø> (ø)
kmip-ft-tests 27.19% <ø> (ø)
mongo-v0-ft-tests 28.14% <ø> (ø)
mongo-v1-ft-tests 28.14% <ø> (ø)
multiple-backend 19.81% <ø> (ø)
sur-tests 34.76% <ø> (-0.86%) ⬇️
sur-tests-inflights 36.70% <ø> (ø)
unit 68.32% <ø> (ø)
utapi-v2-tests 33.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-724-kms-tests-migration branch from d6238a4 to 0bd90df Compare September 25, 2025 06:28
// ensure versioned bucket is empty
await helpers.bucketUtil.empty(bkt.vname);
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }).promise();
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }) || [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Versions can then be undefined ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be like this to ensure we do not have an error trying to access Versions from an array that has no fields

Suggested change
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }) || [];
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }) || { Versions: [] };

console.log('Run cleanup',
{ profile: helpers.credsProfile, accessKeyId: helpers.s3.config.credentials.accessKeyId });
const allBuckets = (await helpers.s3.listBuckets().promise()).Buckets.map(b => b.Name);
const allBuckets = ((await helpers.s3.listBuckets()).Buckets || []).map(b => b.Name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have same stuff for other tests (for example in beforeMigration). Seems like a debug ? Should we keep it ? Check the length ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by the same stuff , are you referring to the console logs ? as they have been there before they're being kept

}

async function getBucketSSEError(Bucket) {
await assert.rejects(helpers.s3.getBucketEncryption({ Bucket }).promise(), err => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don't keep the reject assertion ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the try-catch approach provides clearer information in this case thus the replacement

// check MPU headers against the MPU overview MD
// because there is no migration for ongoing MPU
function assertMPUSSEHeaders(actual, expected, algo) {
// eslint-disable-next-line no-console
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be deleted 🙏


// before has no headers to assert
async function mpuComplete({ UploadId, Bucket, Key }, { existingParts, newParts }, mpuOverviewMDSSE, algo, testCase) {
const extractETag = part => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are in a test, we should prefer assert instead of throw ? Also return part.CopyPartResult?.ETag || part.ETag || undefined is better with a check that the result is not undefined ?

const s3config = getConfig(credsProfile, { signatureVersion: 'v4' });
const s3 = new S3(s3config);

// Create custom agents with specific pooling settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Create custom agents with specific pooling settings

if you want to make it clear, you can change the name of the var httpAgent with httpAgentWithSpecificPooling if this is important when we read tests


const bucketUtil = new BucketUtility(credsProfile);

// Wrapper for SDK v3 commands to return promises directly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Wrapper for SDK v3 commands to return promises directly

Your code is clear enough


const s3Client = new S3Client(s3config);

// Remove logger middleware if present
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Remove logger middleware if present

.Rules[0]
.ApplyServerSideEncryptionByDefault;
try {
const sse = await s3Client.send(new GetBucketEncryptionCommand({ Bucket }));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you use your wrapper instead of s3Client ?

action: 'copyObject', detail: ' when getting from source', kmsAction: 'Decrypt',
fct: async () =>
helpers.s3.copyObject({ Bucket, Key: 'copy', CopySource: `${Bucket}/${Key}` }).promise(),
helpers.s3.copyObject({ Bucket, Key: 'copy', CopySource: `${Bucket}/${Key}` }) ,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
helpers.s3.copyObject({ Bucket, Key: 'copy', CopySource: `${Bucket}/${Key}` }) ,
helpers.s3.copyObject({ Bucket, Key: 'copy', CopySource: `${Bucket}/${Key}` }),

You have some other iterations of that in your file

// ensure versioned bucket is empty
await helpers.bucketUtil.empty(bkt.vname);
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }).promise();
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }) || [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be like this to ensure we do not have an error trying to access Versions from an array that has no fields

Suggested change
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }) || [];
let { Versions } = await helpers.s3.listObjectVersions({ Bucket: bkt.vname }) || { Versions: [] };

httpAgent,
httpsAgent,
}),
maxAttempts: 8,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we can keep 3, this should be enough (and one could argue it should be 1 for a test suite, as if we hide transient errors, we might miss real bugs; and in such case we could just remove the retry logic)

@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-724-sur-utapi-tests branch 4 times, most recently from 1f24c59 to adb7ac5 Compare October 10, 2025 15:10
@benzekrimaha benzekrimaha force-pushed the improvement/CLDSRV-724-kms-tests-migration branch from a8406fa to 55803c6 Compare October 13, 2025 07:07

const s3Client = new S3Client(s3config);

if (s3Client.middlewareStack.identify().includes('loggerMiddleware')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it deserves a comment, why are we doing this ? Is this removing some logs to make the test less verbose ?

},
"homepage": "https://github.com/scality/S3#readme",
"dependencies": {
"@aws-sdk/client-s3": "^3.705.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 705 is ~11 months old, you can use 910 if you want

Copy link
Contributor

@SylvainSenechal SylvainSenechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing much to change here, but tests are failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants