Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianG committed Jul 22, 2024
1 parent 7261d9a commit efa024d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 57 deletions.
3 changes: 1 addition & 2 deletions tests/ctst/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ When('i restore object {string} for {int} days', async function (this: Zenko, ob
});

// wait for object to transition to a location or get restored from it
Then('object {string} should be {string} and have the storage class {string}', { timeout: 130000 }, verifyObjectLocation
);
Then('object {string} should be {string} and have the storage class {string}', { timeout: 130000 }, verifyObjectLocation);

Check failure on line 240 in tests/ctst/common/common.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

This line has a length of 122. Maximum allowed is 120

When('i delete object {string}', async function (this: Zenko, objectName: string) {
const objName = getObjectNameWithBackendFlakiness.call(this, objectName) || this.getSaved<string>('objectName');
Expand Down
17 changes: 7 additions & 10 deletions tests/ctst/steps/pra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export function preparePRA(world: Zenko) {
world.zenkoDrCtl = new ZenkoDrctl(world);
}

export function teardownPRA(world: Zenko) {
// in case of error
}

export async function displayDebuggingInformation(world: Zenko) {
await displayCRStatus(world);
await displayDRSinkStatus(world);
Expand All @@ -41,11 +37,12 @@ Given('a DR installed', { timeout: 130000 }, async function (this: Zenko) {

Then('object {string} should be {string} and have the storage class {string} on {string} site',
async function (this: Zenko, objName: string, objectTransitionStatus: string, storageClass: string, site: string) {
this.resetCommand();
if (site === 'DR')
this.useSite("sink");
else
this.useSite("source");
this.resetCommand();
if (site === 'DR') {
this.useSite('sink');
} else {
this.useSite('source');
}

await verifyObjectLocation.call(this, objName, objectTransitionStatus, storageClass);
await verifyObjectLocation.call(this, objName, objectTransitionStatus, storageClass);
});

Check failure on line 48 in tests/ctst/steps/pra.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 4 spaces but found 0
81 changes: 41 additions & 40 deletions tests/ctst/steps/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
AWSVersionObject,
Command,
} from 'cli-testing';
import { extractPropertyFromResults, s3FunctionExtraParams } from 'common/utils';
import { extractPropertyFromResults, s3FunctionExtraParams, safeJsonParse } from 'common/utils';
import Zenko from 'world/Zenko';
import assert from 'assert';

Expand Down Expand Up @@ -253,47 +253,48 @@ async function emptyVersionedBucket(world: Zenko) {
}));
}

async function verifyObjectLocation(this: Zenko, objectName: string, objectTransitionStatus: string, storageClass: string) {
const objName =
getObjectNameWithBackendFlakiness.call(this, objectName) || this.getSaved<string>('objectName');
this.resetCommand();
this.addCommandParameter({ bucket: this.getSaved<string>('bucketName') });
this.addCommandParameter({ key: objName });
const versionId = this.getSaved<Map<string, string>>('createdObjects')?.get(objName);
if (versionId) {
this.addCommandParameter({ versionId });
}
let conditionOk = false;
while (!conditionOk) {
const res = await S3.headObject(this.getCommandParameters());
if (res.err) {
break;
}
assert(res.stdout);
const parsed = safeJsonParse(res.stdout);
assert(parsed.ok);
const head = parsed.result as {
StorageClass: string | undefined,
Restore: string | undefined,
};
const expectedClass = storageClass !== '' ? storageClass : undefined;
if (head?.StorageClass === expectedClass) {
conditionOk = true;
async function verifyObjectLocation(this: Zenko, objectName: string,
objectTransitionStatus: string, storageClass: string) {
const objName =

Check failure on line 258 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 4 spaces but found 8
getObjectNameWithBackendFlakiness.call(this, objectName) || this.getSaved<string>('objectName');
this.resetCommand();

Check failure on line 260 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 4 spaces but found 8
this.addCommandParameter({ bucket: this.getSaved<string>('bucketName') });

Check failure on line 261 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 4 spaces but found 8
this.addCommandParameter({ key: objName });

Check failure on line 262 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 4 spaces but found 8
const versionId = this.getSaved<Map<string, string>>('createdObjects')?.get(objName);

Check failure on line 263 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 4 spaces but found 8
if (versionId) {

Check failure on line 264 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 4 spaces but found 8
this.addCommandParameter({ versionId });

Check failure on line 265 in tests/ctst/steps/utils/utils.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-ctst

Expected indentation of 8 spaces but found 12
}
if (objectTransitionStatus == 'restored') {
const isRestored = !!head?.Restore &&
head.Restore.includes('ongoing-request="false", expiry-date=');
// if restore didn't get initiated fail immediately
const isPendingRestore = !!head?.Restore &&
head.Restore.includes('ongoing-request="true"');
assert(isRestored || isPendingRestore, 'Restore didn\'t get initiated');
conditionOk = conditionOk && isRestored;
} else if (objectTransitionStatus == 'cold') {
conditionOk = conditionOk && !head?.Restore;
let conditionOk = false;
while (!conditionOk) {
const res = await S3.headObject(this.getCommandParameters());
if (res.err) {
break;
}
assert(res.stdout);
const parsed = safeJsonParse(res.stdout);
assert(parsed.ok);
const head = parsed.result as {
StorageClass: string | undefined,
Restore: string | undefined,
};
const expectedClass = storageClass !== '' ? storageClass : undefined;
if (head?.StorageClass === expectedClass) {
conditionOk = true;
}
if (objectTransitionStatus == 'restored') {
const isRestored = !!head?.Restore &&
head.Restore.includes('ongoing-request="false", expiry-date=');
// if restore didn't get initiated fail immediately
const isPendingRestore = !!head?.Restore &&
head.Restore.includes('ongoing-request="true"');
assert(isRestored || isPendingRestore, 'Restore didn\'t get initiated');
conditionOk = conditionOk && isRestored;
} else if (objectTransitionStatus == 'cold') {
conditionOk = conditionOk && !head?.Restore;
}
await Utils.sleep(1000);
}
await Utils.sleep(1000);
}
assert(conditionOk);
assert(conditionOk);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/ctst/world/Zenko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,22 @@ export default class Zenko extends World<ZenkoWorldParameters> {
accessKeyId: this.parameters.AdminAccessKey,
secretAccessKey: this.parameters.AdminSecretKey,
});
this.sites["source"] = {
this.sites['source'] = {
subdomain: this.parameters.DRSubdomain,
identityName: 'admin',
};
}

if (this.parameters.DRAdminAccessKey && this.parameters.DRAdminSecretKey && this.parameters.DRSubdomain &&
!Identity.hasIdentity(IdentityEnum.ADMIN, 'dradmin')) {
this.sites["sink"] = {
subdomain: this.parameters.DRSubdomain,
identityName: 'dradmin',
};
Identity.addIdentity(IdentityEnum.ADMIN, 'dradmin', {
accessKeyId: this.parameters.DRAdminAccessKey,
secretAccessKey: this.parameters.DRAdminSecretKey,
});
this.sites['sink'] = {
subdomain: this.parameters.DRSubdomain,
identityName: 'dradmin',
};
}
}

Expand Down

0 comments on commit efa024d

Please sign in to comment.