Skip to content

Commit

Permalink
ZENKO-4833: wait for stable zenko in azure location creation steps
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed Jun 25, 2024
1 parent 3ba19c0 commit 032cb7e
Showing 1 changed file with 53 additions and 49 deletions.
102 changes: 53 additions & 49 deletions tests/ctst/steps/azureArchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AzureHelper, S3, Constants, Utils } from 'cli-testing';
import util from 'util';
import { exec } from 'child_process';
import Zenko from 'world/Zenko';
import { waitForDataServicesToStabilize, waitForZenkoToStabilize } from './utils/kubernetes';

type manifestEntry = {
'archive-id': string,
Expand Down Expand Up @@ -418,59 +419,62 @@ Given('that lifecycle is {string} for the {string} location',
await request(options, undefined);
});

Given('an azure archive location {string}', async function (this: Zenko, locationName: string) {
const locationConfig = {
name: locationName,
locationType: 'location-azure-archive-v1',
details: {
endpoint: AZURE_STORAGE_BLOB_URL,
bucketName: this.parameters.AzureArchiveContainer,
queue: {
type: 'location-azure-storage-queue-v1',
queueName: this.parameters.AzureArchiveQueue,
endpoint: AZURE_STORAGE_QUEUE_URL,
Given('an azure archive location {string}', { timeout: 15 * 60 * 1000 },
async function (this: Zenko, locationName: string) {
const locationConfig = {
name: locationName,
locationType: 'location-azure-archive-v1',
details: {
endpoint: AZURE_STORAGE_BLOB_URL,
bucketName: this.parameters.AzureArchiveContainer,
queue: {
type: 'location-azure-storage-queue-v1',
queueName: this.parameters.AzureArchiveQueue,
endpoint: AZURE_STORAGE_QUEUE_URL,
},
auth: {
type: 'location-azure-shared-key',
accountName: this.parameters.AzureAccountName,
accountKey: this.parameters.AzureAccountKey,
},
},
auth: {
type: 'location-azure-shared-key',
accountName: this.parameters.AzureAccountName,
accountKey: this.parameters.AzureAccountKey,
},
},
};
const result = await this.managementAPIRequest('POST', `/config/${this.parameters.InstanceID}/location`, {},
locationConfig);
assert.strictEqual(result.statusCode, 201);
this.addToSaved('locationName', locationName);
await Utils.sleep(60000); // Wait for location to be updated TODO: CTST-35
});

When('i change azure archive location {string} container target', async function (this: Zenko, locationName: string) {
const result = await this.managementAPIRequest('GET', `/config/overlay/view/${this.parameters.InstanceID}`);
if ('err' in result) {
assert.ifError(result.err);
} else {
const { locations } = result.data as { locations: Record<string, unknown> };
assert(locations[locationName]);
const locationConfig = locations[locationName] as Record<string, unknown>;
const details = locationConfig.details as { bucketName: string, auth: { accountKey: string } };
const auth = details.auth;
details.bucketName = this.parameters.AzureArchiveContainer2;
auth.accountKey = this.parameters.AzureAccountKey;
const putResult = await this.managementAPIRequest('PUT',
`/config/${this.parameters.InstanceID}/location/${locationName}`,
{},
};
const result = await this.managementAPIRequest('POST', `/config/${this.parameters.InstanceID}/location`, {},
locationConfig);
if ('err' in putResult) {
assert.ifError(putResult.err);
assert.strictEqual(result.statusCode, 201);
this.addToSaved('locationName', locationName);
await waitForZenkoToStabilize(this, true);
await waitForDataServicesToStabilize(this);
});

When('i change azure archive location {string} container target', { timeout: 15 * 60 * 1000 },
async function (this: Zenko, locationName: string) {
const result = await this.managementAPIRequest('GET', `/config/overlay/view/${this.parameters.InstanceID}`);
if ('err' in result) {
assert.ifError(result.err);
} else {
assert.strictEqual((putResult.data as { details: { bucketName: string }}).details.bucketName,
this.parameters.AzureArchiveContainer2);
assert.strictEqual(putResult.statusCode, 200);
const { locations } = result.data as { locations: Record<string, unknown> };
assert(locations[locationName]);
const locationConfig = locations[locationName] as Record<string, unknown>;
const details = locationConfig.details as { bucketName: string, auth: { accountKey: string } };
const auth = details.auth;
details.bucketName = this.parameters.AzureArchiveContainer2;
auth.accountKey = this.parameters.AzureAccountKey;
const putResult = await this.managementAPIRequest('PUT',
`/config/${this.parameters.InstanceID}/location/${locationName}`,
{},
locationConfig);
if ('err' in putResult) {
assert.ifError(putResult.err);
} else {
assert.strictEqual((putResult.data as { details: { bucketName: string } }).details.bucketName,
this.parameters.AzureArchiveContainer2);
assert.strictEqual(putResult.statusCode, 200);
}
}
}
// This could be checked to see pods status with kubectl TODO: CTST-35
await Utils.sleep(60000); // Wait for location to be updated
});
await waitForZenkoToStabilize(this, true);
await waitForDataServicesToStabilize(this);
});

Then('i can get the {string} location details', async function (this: Zenko, locationName: string) {
const result = await this.managementAPIRequest('GET', `/config/overlay/view/${this.parameters.InstanceID}`);
Expand Down

0 comments on commit 032cb7e

Please sign in to comment.