Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Feb 22, 2024
1 parent c319a24 commit 58cc578
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
14 changes: 10 additions & 4 deletions dist/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ async function pollForStatus(vendorPortalApi, clusterId, expectedStatus, timeout
console.debug(`Cluster status is ${clusterDetails.status}, sleeping for ${sleeptime} seconds`);
}
catch (err) {
if (!(err instanceof StatusError) || err.statusCode < 500) {
throw err;
if (err instanceof StatusError) {
if (err.statusCode >= 500) {
// 5xx errors are likely transient, so we should retry
console.debug(`Got HTTP error with status ${err.statusCode}, sleeping for ${sleeptime} seconds`);
}
else {
console.debug(`Got HTTP error with status ${err.statusCode}, exiting`);
throw err;
}
}
else {
// 5xx errors are likely transient, so we should retry
console.debug(`Got HTTP error with status ${err.statusCode}, sleeping for ${sleeptime} seconds`);
throw err;
}
}
await new Promise(f => setTimeout(f, sleeptime * 1000));
Expand Down
8 changes: 4 additions & 4 deletions dist/clusters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ describe('upgradeCluster', () => {
const mockServer = mockttp.getLocal();
const apiClient = new configuration_1.VendorPortalApi();
apiClient.apiToken = "abcd1234";
apiClient.endpoint = "http://localhost:8080";
apiClient.endpoint = "http://localhost:30880";
beforeEach(async () => {
mockServer.start(8080);
mockServer.start(30880);
});
afterEach(async () => {
mockServer.stop();
Expand All @@ -151,9 +151,9 @@ describe('pollForCluster', () => {
const mockServer = mockttp.getLocal();
const apiClient = new configuration_1.VendorPortalApi();
apiClient.apiToken = "abcd1234";
apiClient.endpoint = "http://localhost:8080";
apiClient.endpoint = "http://localhost:30880";
beforeEach(async () => {
mockServer.start(8080);
mockServer.start(30880);
});
afterEach(async () => {
mockServer.stop();
Expand Down
8 changes: 4 additions & 4 deletions src/clusters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ describe('upgradeCluster', () => {
const mockServer = mockttp.getLocal();
const apiClient = new VendorPortalApi();
apiClient.apiToken = "abcd1234";
apiClient.endpoint = "http://localhost:8080";
apiClient.endpoint = "http://localhost:30880";


beforeEach(async () => {
mockServer.start(8080);
mockServer.start(30880);
});

afterEach(async () => {
Expand All @@ -174,10 +174,10 @@ describe('pollForCluster', () => {
const mockServer = mockttp.getLocal();
const apiClient = new VendorPortalApi();
apiClient.apiToken = "abcd1234";
apiClient.endpoint = "http://localhost:8080";
apiClient.endpoint = "http://localhost:30880";

beforeEach(async () => {
mockServer.start(8080);
mockServer.start(30880);
});

afterEach(async () => {
Expand Down
13 changes: 9 additions & 4 deletions src/clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ export async function pollForStatus(vendorPortalApi: VendorPortalApi, clusterId:

console.debug(`Cluster status is ${clusterDetails.status}, sleeping for ${sleeptime} seconds`);
} catch (err) {
if (!(err instanceof StatusError) || err.statusCode < 500) {
throw err;
if (err instanceof StatusError) {
if (err.statusCode >= 500) {
// 5xx errors are likely transient, so we should retry
console.debug(`Got HTTP error with status ${err.statusCode}, sleeping for ${sleeptime} seconds`);
} else {
console.debug(`Got HTTP error with status ${err.statusCode}, exiting`);
throw err;
}
} else {
// 5xx errors are likely transient, so we should retry
console.debug(`Got HTTP error with status ${err.statusCode}, sleeping for ${sleeptime} seconds`);
throw err;
}
}

Expand Down

0 comments on commit 58cc578

Please sign in to comment.