From fb29974bb1ae59decbe536dc8db43a35e8bc107b Mon Sep 17 00:00:00 2001 From: Tiffany K Date: Fri, 20 Aug 2021 10:46:44 -0700 Subject: [PATCH] feat(1961): Use screwdriver-request package (#167) --- index.js | 84 ++++++++++++++++----------- package.json | 23 ++++---- test/index.test.js | 138 ++++++++++++++++++++------------------------- 3 files changed, 123 insertions(+), 122 deletions(-) diff --git a/index.js b/index.js index 276ffa6..c4c9de3 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const fs = require('fs'); const hoek = require('@hapi/hoek'); const path = require('path'); const randomstring = require('randomstring'); -const requestretry = require('requestretry'); +const request = require('screwdriver-request'); const handlebars = require('handlebars'); const yaml = require('js-yaml'); const _ = require('lodash'); @@ -246,7 +246,7 @@ class K8sExecutor extends Executor { this.automountServiceAccountToken = this.kubernetes.automountServiceAccountToken === 'true' || false; this.terminationGracePeriodSeconds = this.kubernetes.terminationGracePeriodSeconds || 30; this.podsUrl = `https://${this.host}/api/v1/namespaces/${this.jobsNamespace}/pods`; - this.breaker = new Fusebox(requestretry, options.fusebox); + this.breaker = new Fusebox(request, options.fusebox); this.retryDelay = this.requestretryOptions.retryDelay || DEFAULT_RETRYDELAY; this.maxAttempts = this.requestretryOptions.maxAttempts || DEFAULT_MAXATTEMPTS; this.maxCpu = hoek.reach(options, 'kubernetes.resources.cpu.max', { default: 12 }); @@ -276,8 +276,8 @@ class K8sExecutor extends Executor { this.annotations = hoek.reach(options, 'kubernetes.annotations'); this.privileged = hoek.reach(options, 'kubernetes.privileged', { default: false }); this.secrets = hoek.reach(options, 'kubernetes.buildSecrets', { default: {} }); - this.scheduleStatusRetryStrategy = (err, response, body) => { - const conditions = hoek.reach(body, 'status.conditions'); + this.scheduleStatusRetryStrategy = (response, retryWithMergedOptions) => { + const conditions = hoek.reach(response, 'body.status.conditions'); let scheduled = false; if (conditions) { @@ -286,12 +286,20 @@ class K8sExecutor extends Executor { scheduled = String(scheduledStatus) === 'True'; } - return err || !scheduled; + if (!scheduled) { + retryWithMergedOptions({}); + } + + return response; }; - this.pendingStatusRetryStrategy = (err, response, body) => { - const status = hoek.reach(body, 'status.phase'); + this.pendingStatusRetryStrategy = (response, retryWithMergedOptions) => { + const status = hoek.reach(response, 'body.status.phase'); - return err || !status || status.toLowerCase() === 'pending'; + if (!status || status.toLowerCase() === 'pending') { + retryWithMergedOptions({}); + } + + return response; }; } @@ -309,22 +317,23 @@ class K8sExecutor extends Executor { updateBuild(config) { const { apiUri, buildId, statusMessage, token, stats } = config; const options = { - json: true, method: 'PUT', - uri: `${apiUri}/v4/builds/${buildId}`, + url: `${apiUri}/v4/builds/${buildId}`, headers: { Authorization: `Bearer ${token}` }, - strictSSL: false, - maxAttempts: this.maxAttempts, - retryDelay: this.retryDelay, - body: {} + https: { rejectUnauthorized: false }, + retry: { + limit: this.maxAttempts, + calculateDelay: ({ computedValue }) => (computedValue ? this.retryDelay : 0) + }, + json: {} }; if (statusMessage) { - options.body.statusMessage = statusMessage; + options.json.statusMessage = statusMessage; } if (stats) { - options.body.stats = stats; + options.json.stats = stats; } return this.breaker.runCommand(options); @@ -347,13 +356,13 @@ class K8sExecutor extends Executor { const { buildId, token } = config; const podConfig = this.createPodConfig(config); const options = { - uri: this.podsUrl, + url: this.podsUrl, method: 'POST', json: podConfig, headers: { Authorization: `Bearer ${this.token}` }, - strictSSL: false + https: { rejectUnauthorized: false } }; try { @@ -398,15 +407,19 @@ class K8sExecutor extends Executor { logger.info(`Get pod status for ${podName} and buildId: ${buildId}`); const statusOptions = { - uri: `${this.podsUrl}/${podName}/status`, + url: `${this.podsUrl}/${podName}/status`, method: 'GET', headers: { Authorization: `Bearer ${this.token}` }, - strictSSL: false, - maxAttempts: this.maxAttempts, - retryDelay: this.retryDelay, - retryStrategy: this.scheduleStatusRetryStrategy, - json: true + https: { rejectUnauthorized: false }, + retry: { + limit: this.maxAttempts, + calculateDelay: ({ computedValue }) => (computedValue ? this.retryDelay : 0) + }, + hooks: { + afterResponse: [this.scheduleStatusRetryStrategy] + } }; + const resp = await this.breaker.runCommand(statusOptions); logger.debug(`Build ${buildId} pod response: ${JSON.stringify(resp.body)}`); @@ -603,15 +616,15 @@ class K8sExecutor extends Executor { */ async _stop(config) { const options = { - uri: this.podsUrl, + url: this.podsUrl, method: 'DELETE', - qs: { + searchParams: { labelSelector: `sdbuild=${this.prefix}${config.buildId}` }, headers: { Authorization: `Bearer ${this.token}` }, - strictSSL: false + https: { rejectUnauthorized: false } }; try { @@ -698,15 +711,18 @@ class K8sExecutor extends Executor { logger.info(`Get pod status for and buildId: ${buildId}`); const statusOptions = { - uri: this.podsUrl, + url: this.podsUrl, method: 'GET', headers: { Authorization: `Bearer ${this.token}` }, - strictSSL: false, - maxAttempts: this.maxAttempts, - retryDelay: this.retryDelay, - retryStrategy: this.pendingStatusRetryStrategy, - json: true, - qs: { + https: { rejectUnauthorized: false }, + retry: { + limit: this.maxAttempts, + calculateDelay: ({ computedValue }) => (computedValue ? this.retryDelay : 0) + }, + hooks: { + afterResponse: [this.pendingStatusRetryStrategy] + }, + searchParams: { labelSelector: `sdbuild=${this.prefix}${buildId}` } }; diff --git a/package.json b/package.json index 7f976bf..5a8de4c 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,9 @@ }, "devDependencies": { "chai": "^3.5.0", - "eslint": "^7.7.0", - "eslint-config-screwdriver": "^5.0.4", - "mocha": "^8.2.1", + "eslint": "^7.32.0", + "eslint-config-screwdriver": "^5.0.7", + "mocha": "^8.4.0", "mocha-multi-reporters": "^1.5.1", "mocha-sonarqube-reporter": "^1.0.2", "mockery": "^2.0.0", @@ -51,18 +51,19 @@ "sinon": "^5.0.10" }, "dependencies": { - "@hapi/hoek": "^9.0.4", - "circuit-fuses": "^4.0.3", - "handlebars": "^4.7.6", - "js-yaml": "^3.11.0", + "@hapi/hoek": "^9.2.0", + "circuit-fuses": "^4.1.0", + "handlebars": "^4.7.7", + "js-yaml": "^3.14.1", "jsonwebtoken": "^8.5.1", - "lodash": "^4.17.20", + "lodash": "^4.17.21", "node-gyp": "^7.1.2", - "randomstring": "^1.1.5", + "randomstring": "^1.2.1", "request": "^2.88.0", "requestretry": "^4.0.0", - "screwdriver-executor-base": "^8.0.0", - "screwdriver-logger": "^1.0.1", + "screwdriver-executor-base": "^8.4.0", + "screwdriver-logger": "^1.1.0", + "screwdriver-request": "^1.0.2", "tinytim": "^0.1.1" } } diff --git a/test/index.test.js b/test/index.test.js index 2857f01..d76c846 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -32,7 +32,6 @@ command: const SMALLEST_FLOAT64 = 2.2250738585072014e-308; const MAXATTEMPTS = 5; -const RETRYDELAY = 3000; describe('index', function() { // Time not important. Only life important. @@ -160,7 +159,7 @@ describe('index', function() { fusebox: { retry: { minTimeout: 1 } }, prefix: 'beta_' }; - requestRetryMock = sinon.stub(); + requestRetryMock = sinon.stub().yieldsAsync(null); fsMock = { existsSync: sinon.stub(), @@ -173,7 +172,7 @@ describe('index', function() { fsMock.readFileSync.withArgs(sinon.match(/config\/pod.yaml.hbs/)).returns(TEST_TIM_YAML); mockery.registerMock('fs', fsMock); - mockery.registerMock('requestretry', requestRetryMock); + mockery.registerMock('screwdriver-request', requestRetryMock); /* eslint-disable global-require */ Executor = require('../index'); /* eslint-enable global-require */ @@ -295,19 +294,19 @@ describe('index', function() { } }; const deleteConfig = { - uri: podsUrl, + url: podsUrl, method: 'DELETE', - qs: { + searchParams: { labelSelector: `sdbuild=beta_${testBuildId}` }, headers: { Authorization: 'Bearer api_key' }, - strictSSL: false + https: { rejectUnauthorized: false } }; beforeEach(() => { - requestRetryMock.yieldsAsync(null, fakeStopResponse, fakeStopResponse.body); + requestRetryMock.yieldsAsync(null, fakeStopResponse); }); it('calls breaker with correct config', () => @@ -350,7 +349,7 @@ describe('index', function() { const returnMessage = `Failed to delete pod:${JSON.stringify(fakeStopErrorResponse.body)}`; - requestRetryMock.yieldsAsync(null, fakeStopErrorResponse, fakeStopErrorResponse.body); + requestRetryMock.yieldsAsync(null, fakeStopErrorResponse); return executor .stop({ @@ -378,7 +377,7 @@ describe('index', function() { beforeEach(() => { postConfig = { - uri: podsUrl, + url: podsUrl, method: 'POST', json: { metadata: { @@ -401,31 +400,31 @@ describe('index', function() { headers: { Authorization: 'Bearer api_key' }, - strictSSL: false + https: { rejectUnauthorized: false } }; getConfig = { - uri: `${podsUrl}/testpod/status`, + url: `${podsUrl}/testpod/status`, method: 'GET', headers: { Authorization: 'Bearer api_key' }, - strictSSL: false, - maxAttempts: MAXATTEMPTS, - retryDelay: RETRYDELAY, - // eslint-disable-next-line - retryStrategy: executor.scheduleStatusRetryStrategy + https: { rejectUnauthorized: false }, + retry: { + limit: MAXATTEMPTS + }, + hooks: {} }; putConfig = { - uri: `${testApiUri}/v4/builds/${testBuildId}`, + url: `${testApiUri}/v4/builds/${testBuildId}`, method: 'PUT', headers: { Authorization: `Bearer ${testToken}` }, - body: {}, - strictSSL: false, - json: true, - maxAttempts: MAXATTEMPTS, - retryDelay: RETRYDELAY + json: {}, + https: { rejectUnauthorized: false }, + retry: { + limit: MAXATTEMPTS + } }; fakeStartConfig = { annotations: {}, @@ -461,15 +460,9 @@ describe('index', function() { } }; - requestRetryMock - .withArgs(sinon.match({ method: 'POST' })) - .yieldsAsync(null, fakeStartResponse, fakeStartResponse.body); - requestRetryMock - .withArgs(sinon.match({ method: 'GET' })) - .yieldsAsync(null, fakeGetResponse, fakeGetResponse.body); - requestRetryMock - .withArgs(sinon.match({ method: 'PUT' })) - .yieldsAsync(null, fakePutResponse, fakePutResponse.body); + requestRetryMock.withArgs(sinon.match({ method: 'POST' })).yieldsAsync(null, fakeStartResponse); + requestRetryMock.withArgs(sinon.match({ method: 'GET' })).yieldsAsync(null, fakeGetResponse); + requestRetryMock.withArgs(sinon.match({ method: 'PUT' })).yieldsAsync(null, fakePutResponse); }); it('successfully calls start', () => { @@ -487,7 +480,7 @@ describe('index', function() { shouldAdvanceTime: true }); - putConfig.body.stats = { + putConfig.json.stats = { hostname: 'node1.my.k8s.cluster.com', imagePullStartTime: isoTime }; @@ -496,7 +489,7 @@ describe('index', function() { assert.equal(requestRetryMock.callCount, 3); assert.calledWith(requestRetryMock.firstCall, postConfig); assert.calledWith(requestRetryMock.secondCall, sinon.match(getConfig)); - assert.calledWith(requestRetryMock.thirdCall, putConfig); + assert.calledWith(requestRetryMock.thirdCall, sinon.match(putConfig)); clock.restore(); }); }); @@ -536,7 +529,6 @@ describe('index', function() { return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); - delete getConfig.retryStrategy; assert.calledWith(requestRetryMock.secondCall, sinon.match(getConfig)); }); }); @@ -550,7 +542,6 @@ describe('index', function() { return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); - delete getConfig.retryStrategy; assert.calledWith(requestRetryMock.secondCall, sinon.match(getConfig)); }); }); @@ -653,7 +644,7 @@ describe('index', function() { executor = new Executor(options); postConfig.json.metadata.annotations = testAnnotations.annotations; - getConfig.retryStrategy = executor.scheduleStatusRetryStrategy; + getConfig.hooks = { afterResponse: [executor.scheduleStatusRetryStrategy] }; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); @@ -682,7 +673,7 @@ describe('index', function() { executor = new Executor(options); postConfig.json.spec = _.assign({}, postConfig.json.spec, testLifecycleHooksSpec); - getConfig.retryStrategy = executor.scheduleStatusRetryStrategy; + getConfig.hooks = { afterResponse: [executor.scheduleStatusRetryStrategy] }; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); @@ -699,7 +690,7 @@ describe('index', function() { executor = new Executor(options); postConfig.json.metadata.labels = testLabels; - getConfig.retryStrategy = executor.scheduleStatusRetryStrategy; + getConfig.hooks = { afterResponse: [executor.scheduleStatusRetryStrategy] }; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); @@ -716,7 +707,7 @@ describe('index', function() { executor = new Executor(options); postConfig.json.spec = _.assign({}, postConfig.json.spec, testSpec); - getConfig.retryStrategy = executor.scheduleStatusRetryStrategy; + getConfig.hooks = { afterResponse: [executor.scheduleStatusRetryStrategy] }; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); @@ -733,7 +724,7 @@ describe('index', function() { executor = new Executor(options); postConfig.json.spec = _.assign({}, postConfig.json.spec, testPreferredSpec); - getConfig.retryStrategy = executor.scheduleStatusRetryStrategy; + getConfig.hooks = { afterResponse: [executor.scheduleStatusRetryStrategy] }; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); @@ -752,7 +743,7 @@ describe('index', function() { executor = new Executor(options); postConfig.json.spec = _.assign({}, postConfig.json.spec, spec); - getConfig.retryStrategy = executor.scheduleStatusRetryStrategy; + getConfig.hooks = { afterResponse: [executor.scheduleStatusRetryStrategy] }; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); @@ -763,12 +754,12 @@ describe('index', function() { it('update build status message when pod status is pending', () => { fakeGetResponse.body.status.phase = 'pending'; fakeGetResponse.body.spec = {}; - putConfig.body.statusMessage = 'Waiting for resources to be available.'; + putConfig.json.statusMessage = 'Waiting for resources to be available.'; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); assert.calledWith(requestRetryMock.secondCall, sinon.match(getConfig)); - assert.calledWith(requestRetryMock.thirdCall, putConfig); + assert.calledWith(requestRetryMock.thirdCall, sinon.match(putConfig)); }); }); @@ -797,7 +788,7 @@ describe('index', function() { }; const returnMessage = `Failed to get pod status:${JSON.stringify(returnResponse.body)}`; - requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse, returnResponse.body); + requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse); return executor.start(fakeStartConfig).then( () => { @@ -823,7 +814,7 @@ describe('index', function() { }; const returnMessage = 'Failed to create pod. Pod status is: failed'; - requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse, returnResponse.body); + requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse); return executor.start(fakeStartConfig).then( () => { @@ -860,12 +851,11 @@ describe('index', function() { } }; - requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse, returnResponse.body); + requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse); return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); assert.calledWith(requestRetryMock.secondCall, sinon.match(getConfig)); - assert.calledWith(requestRetryMock.lastCall, sinon.match(putConfig)); }); }); @@ -893,7 +883,7 @@ describe('index', function() { } }; - requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse, returnResponse.body); + requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse); return executor.start(fakeStartConfig).then( () => {}, @@ -927,7 +917,7 @@ describe('index', function() { const returnMessage = 'Failed to create pod. Pod status is: failed'; - requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse, returnResponse.body); + requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse); return executor.start(fakeStartConfig).then( () => { @@ -953,7 +943,7 @@ describe('index', function() { }; const returnMessage = 'Failed to create pod. Pod status is: failed'; - requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse, returnResponse.body); + requestRetryMock.withArgs(getConfig).yieldsAsync(null, returnResponse); return executor.start(fakeStartConfig).then( () => { @@ -978,7 +968,7 @@ describe('index', function() { }; const returnMessage = `Failed to create pod:${JSON.stringify(returnResponse.body)}`; - requestRetryMock.withArgs(postConfig).yieldsAsync(null, returnResponse, returnResponse.body); + requestRetryMock.withArgs(postConfig).yieldsAsync(null, returnResponse); return executor.start(fakeStartConfig).then( () => { @@ -999,9 +989,8 @@ describe('index', function() { }); executor = new Executor(options); - getConfig.retryDelay = 1000; - getConfig.maxAttempts = 1; - getConfig.retryStrategy = executor.scheduleStatusRetryStrategy; + getConfig.retry.limit = 1; + getConfig.hooks = { afterResponse: [executor.scheduleStatusRetryStrategy] }; return executor.start(fakeStartConfig).then(() => { assert.calledWith(requestRetryMock.firstCall, postConfig); @@ -1126,7 +1115,7 @@ describe('index', function() { }); }); - describe.only('verify', async () => { + describe('verify', async () => { let fakeVerifyConfig; let getPodsConfig; let fakeGetPodsResponse; @@ -1140,16 +1129,15 @@ describe('index', function() { apiUri: testApiUri }; getPodsConfig = { - uri: `${podsUrl}`, + url: `${podsUrl}`, method: 'GET', headers: { Authorization: 'Bearer api_key' }, - strictSSL: false, - maxAttempts: MAXATTEMPTS, - retryDelay: RETRYDELAY, - retryStrategy: executor.pendingStatusRetryStrategy, - qs: { + https: { rejectUnauthorized: false }, + hooks: { afterResponse: [executor.pendingStatusRetryStrategy] }, + retry: { limit: MAXATTEMPTS }, + searchParams: { labelSelector: `sdbuild=beta_${testBuildId}` } }; @@ -1171,9 +1159,7 @@ describe('index', function() { ] } }; - requestRetryMock - .withArgs(sinon.match({ method: 'GET' })) - .yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(sinon.match({ method: 'GET' })).yieldsAsync(null, fakeGetPodsResponse); }); it('gets all pods for given buildid', async () => { await executor.verify(fakeVerifyConfig); @@ -1202,7 +1188,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please reach out to your cluster admin for help.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1230,7 +1216,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please reach out to your cluster admin for help.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1258,7 +1244,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please reach out to your cluster admin for help.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1286,7 +1272,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please check if your image is valid.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1314,7 +1300,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please check if your image is valid.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1342,7 +1328,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please check if your image is valid.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1370,7 +1356,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please reach out to your cluster admin for help.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1397,7 +1383,7 @@ describe('index', function() { const expectedMessage = 'Failed to create pod. Pod status is: failed'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1414,7 +1400,7 @@ describe('index', function() { fakeGetPodsResponse.body.items.push(pod); const expectedMessage = 'Failed to create pod. Pod status is: failed'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); const actualMessage = await executor.verify(fakeVerifyConfig); @@ -1440,7 +1426,7 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Pod is still intializing.'; fakeGetPodsResponse.body.items.push(pod); - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); try { await executor.verify(fakeVerifyConfig); @@ -1493,15 +1479,13 @@ describe('index', function() { const expectedMessage = 'Build failed to start. Please check if your image is valid.'; - requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse, fakeGetPodsResponse.body); + requestRetryMock.withArgs(getPodsConfig).yieldsAsync(null, fakeGetPodsResponse); try { const actualMessage = await executor.verify(fakeVerifyConfig); assert.equal(expectedMessage, actualMessage); } catch (error) { - console.log(error); - throw new Error('should not fail'); } });