-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathhooks.ts
More file actions
116 lines (100 loc) · 3.53 KB
/
hooks.ts
File metadata and controls
116 lines (100 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import {
Before,
After,
setParallelCanAssign,
parallelCanAssignHelpers,
ITestCaseHookParameter,
} from '@cucumber/cucumber';
import Zenko from '../world/Zenko';
import { CacheHelper, Identity } from 'cli-testing';
import { prepareQuotaScenarios, teardownQuotaScenarios } from 'steps/quotas/quotas';
import { prepareUtilizationScenarios } from 'steps/utilization/utilizationAPI';
import { cleanS3Bucket } from './common';
import { cleanAzureContainer, cleanZenkoLocation } from 'steps/azureArchive';
import { displayDebuggingInformation, preparePRA } from 'steps/pra';
import {
cleanupAccount,
} from './utils';
import 'cli-testing/hooks/KeycloakSetup';
import 'cli-testing/hooks/Logger';
import 'cli-testing/hooks/versionTags';
// HTTPS should not cause any error for CTST
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
const { atMostOnePicklePerTag } = parallelCanAssignHelpers;
export const replicationLockTags = [
'@Lockawsbackendreplicationctstfail',
];
const noParallelRun = atMostOnePicklePerTag([
'@AfterAll',
'@PRA',
'@ColdStorage',
...replicationLockTags
]);
setParallelCanAssign(noParallelRun);
Before(async function (this: Zenko, scenario: ITestCaseHookParameter) {
this.resetSaved();
Identity.resetIdentity();
// Store scenario tags for access in step definitions
const scenarioTags = scenario.pickle.tags?.map(tag => tag.name) || [];
this.addToSaved('scenarioTags', scenarioTags);
await Zenko.init(this.parameters);
});
Before({ tags: '@PRA' }, function () {
preparePRA(this as Zenko);
});
After({ tags: '@PRA' }, async function (this, results) {
if (results.result?.status === 'FAILED') {
await displayDebuggingInformation(this as Zenko);
}
});
Before({ tags: '@Quotas', timeout: 1200000 }, async function (scenarioOptions) {
await prepareQuotaScenarios(this as Zenko, scenarioOptions);
});
Before({ tags: '@UtilizationAPI', timeout: 1200000 }, async function (scenarioOptions) {
await prepareUtilizationScenarios(this as Zenko, scenarioOptions);
});
After(async function (this: Zenko, results) {
// Reset any configuration set on the endpoint (ssl, port)
CacheHelper.parameters.ssl = this.parameters.ssl;
CacheHelper.parameters.port = this.parameters.port;
if (results.result?.status === 'FAILED') {
this.logger.warn('bucket was not cleaned for test', {
bucket: this.getSaved<string>('bucketName'),
});
return;
}
await cleanS3Bucket(
this,
this.getSaved<string>('bucketName'),
);
});
After({ tags: '@Quotas' }, async function (this: Zenko, results) {
if (results.result?.status === 'FAILED') {
this.logger.warn('quota was not cleaned for test', {
bucket: this.getSaved<string>('bucketName'),
});
return;
}
await teardownQuotaScenarios(this as Zenko);
});
After({ tags: '@AzureArchive' }, async function (this: Zenko) {
await cleanZenkoLocation(
this,
this.getSaved<string>('locationName'),
);
await cleanAzureContainer(
this,
this.getSaved<string>('bucketName'),
);
});
After({ tags: '@BP-ASSUME_ROLE_USER_CROSS_ACCOUNT'}, async function (this: Zenko, results) {
const crossAccountName = this.getSaved<string>('crossAccountName');
if (results.result?.status === 'FAILED' || !crossAccountName) {
this.logger.warn('cross account was not cleaned for test', {
crossAccountName,
});
return;
}
await cleanupAccount(this, crossAccountName);
});
export default Zenko;