From c0dddc9eca48dd324c249ce31fc9a3a5b4b17585 Mon Sep 17 00:00:00 2001 From: ededals Date: Wed, 18 Sep 2019 06:48:36 +0300 Subject: [PATCH 1/5] adds built-in/succeed smoketest --- .../tooling/src/smoketest/checks/succeed.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 infrastructure/tooling/src/smoketest/checks/succeed.js diff --git a/infrastructure/tooling/src/smoketest/checks/succeed.js b/infrastructure/tooling/src/smoketest/checks/succeed.js new file mode 100644 index 00000000000..a91eafa9a9e --- /dev/null +++ b/infrastructure/tooling/src/smoketest/checks/succeed.js @@ -0,0 +1,31 @@ +const taskcluster = require('taskcluster-client'); + +exports.tasks = []; +exports.tasks.push({ + title: 'Built-in/succeed task check', + requires: [], + provides: [ + 'built-in/succeed', + ], + run: async () => { + let task = { + provisionerId: 'built-in', + workerType: 'succeed', + created: (new Date()).toJSON(), + deadline: (new Date()).toJSON(), + payload: {}, + metadata: { + name: 'Smoketest built-in/succeed', + description: 'A task for built-in/succeed worker type', + owner: 'none@taskcluster.com', + source: 'https://tools.taskcluster.net/tasks/create', + }, + }; + async ()=> { + let taskId = taskcluster.slugid(); + let queue = new taskcluster.Queue(); + let result = await queue.createTask(taskId, task); + return result; + }; + }, +}); From b66a970ce31374d17c202a91180a7d52f0c27b48 Mon Sep 17 00:00:00 2001 From: ededals Date: Mon, 30 Sep 2019 21:33:00 +0300 Subject: [PATCH 2/5] fixes test --- .../tooling/src/smoketest/checks/succeed.js | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/infrastructure/tooling/src/smoketest/checks/succeed.js b/infrastructure/tooling/src/smoketest/checks/succeed.js index a91eafa9a9e..5fe2f7c7365 100644 --- a/infrastructure/tooling/src/smoketest/checks/succeed.js +++ b/infrastructure/tooling/src/smoketest/checks/succeed.js @@ -7,25 +7,40 @@ exports.tasks.push({ provides: [ 'built-in/succeed', ], - run: async () => { + run: async (requirements, utils) => { let task = { provisionerId: 'built-in', workerType: 'succeed', created: (new Date()).toJSON(), - deadline: (new Date()).toJSON(), - payload: {}, + deadline: taskcluster.fromNowJSON('2 minutes'), metadata: { - name: 'Smoketest built-in/succeed', - description: 'A task for built-in/succeed worker type', - owner: 'none@taskcluster.com', - source: 'https://tools.taskcluster.net/tasks/create', + name: "Smoketest built-in/succeed", + description: "built-in/succeed task created during smoketest", + owner: "smoketest@taskcluster.net", + source: "https://taskcluster.net", }, + payload: {}, }; - async ()=> { - let taskId = taskcluster.slugid(); - let queue = new taskcluster.Queue(); - let result = await queue.createTask(taskId, task); - return result; - }; + let taskId = taskcluster.slugid(); + let queue = new taskcluster.Queue({ + rootUrl: process.env.TASKCLUSTER_ROOT_URL, + credentials: { + clientId: process.env.TASKCLUSTER_CLIENT_ID, + accessToken: process.env.TASKCLUSTER_ACCESS_TOKEN, + }, + }); + let result = await queue.createTask(taskId, task); + while (1){ + let status = await queue.status(taskId); + if (status.state === 'pending'){ + await new Promise(resolve => setTimeout(resolve, 2000)); + } else { + return { + ['built-in/succeed']: result.state, + }; + + } + } + return result; }, }); From 72c0e649611ce8a7fa5c0a6f37c03903653ef150 Mon Sep 17 00:00:00 2001 From: ededals Date: Wed, 2 Oct 2019 07:06:13 +0300 Subject: [PATCH 3/5] Fixing comments --- .../tooling/src/smoketest/checks/succeed.js | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/infrastructure/tooling/src/smoketest/checks/succeed.js b/infrastructure/tooling/src/smoketest/checks/succeed.js index 5fe2f7c7365..fa41f0d206a 100644 --- a/infrastructure/tooling/src/smoketest/checks/succeed.js +++ b/infrastructure/tooling/src/smoketest/checks/succeed.js @@ -22,25 +22,35 @@ exports.tasks.push({ payload: {}, }; let taskId = taskcluster.slugid(); - let queue = new taskcluster.Queue({ - rootUrl: process.env.TASKCLUSTER_ROOT_URL, - credentials: { - clientId: process.env.TASKCLUSTER_CLIENT_ID, - accessToken: process.env.TASKCLUSTER_ACCESS_TOKEN, - }, - }); - let result = await queue.createTask(taskId, task); - while (1){ + utils.status({message: 'built-in/succeed taskId: ' + taskId}); + let queue = new taskcluster.Queue(taskcluster.fromEnvVars()); + await queue.createTask(taskId, task); + let pollForStatus = true; + setTimeout(function () { + pollForStatus = false; + }, 12000); + while (pollForStatus){ let status = await queue.status(taskId); - if (status.state === 'pending'){ - await new Promise(resolve => setTimeout(resolve, 2000)); - } else { + if (status.status.state === 'pending' || status.status.state === 'running'){ + utils.status({ + message: 'Polling built-in/succeed task. Current status: ' + status.status.state, + }); + await new Promise(resolve => setTimeout(resolve, 1000)); + } else if (status.status.state === 'completed') { return { - ['built-in/succeed']: result.state, + ['built-in/succeed']: status.status.state, }; - + } else { + return utils.skip({ + [`built-in/succeed`]: status.status.state, + reason: 'Task finished with status ' + status.status.state, + }); } } - return result; + return utils.skip({ + [`built-in/succeed`]: 'deadline exceeded', + reason: 'Deadline exceeded', + }); + }, }); From 8d430243805f7a12b2480f2475c0d349c79a2db8 Mon Sep 17 00:00:00 2001 From: ededals Date: Thu, 3 Oct 2019 06:19:24 +0300 Subject: [PATCH 4/5] fixes timing, error returns --- .../tooling/src/smoketest/checks/succeed.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/infrastructure/tooling/src/smoketest/checks/succeed.js b/infrastructure/tooling/src/smoketest/checks/succeed.js index fa41f0d206a..db3667dbb3f 100644 --- a/infrastructure/tooling/src/smoketest/checks/succeed.js +++ b/infrastructure/tooling/src/smoketest/checks/succeed.js @@ -28,7 +28,7 @@ exports.tasks.push({ let pollForStatus = true; setTimeout(function () { pollForStatus = false; - }, 12000); + }, 120000); while (pollForStatus){ let status = await queue.status(taskId); if (status.status.state === 'pending' || status.status.state === 'running'){ @@ -41,16 +41,9 @@ exports.tasks.push({ ['built-in/succeed']: status.status.state, }; } else { - return utils.skip({ - [`built-in/succeed`]: status.status.state, - reason: 'Task finished with status ' + status.status.state, - }); + throw new Error('Task finished with status ' + status.status.state); } } - return utils.skip({ - [`built-in/succeed`]: 'deadline exceeded', - reason: 'Deadline exceeded', - }); - + throw new Error('Deadline exceeded'); }, }); From 9b231ec346263f01b77b1c8b9cf96e55dd4e9824 Mon Sep 17 00:00:00 2001 From: ededals Date: Fri, 4 Oct 2019 06:52:38 +0300 Subject: [PATCH 5/5] removes timeout --- infrastructure/tooling/src/smoketest/checks/succeed.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/infrastructure/tooling/src/smoketest/checks/succeed.js b/infrastructure/tooling/src/smoketest/checks/succeed.js index db3667dbb3f..a12f09bd66c 100644 --- a/infrastructure/tooling/src/smoketest/checks/succeed.js +++ b/infrastructure/tooling/src/smoketest/checks/succeed.js @@ -25,11 +25,8 @@ exports.tasks.push({ utils.status({message: 'built-in/succeed taskId: ' + taskId}); let queue = new taskcluster.Queue(taskcluster.fromEnvVars()); await queue.createTask(taskId, task); - let pollForStatus = true; - setTimeout(function () { - pollForStatus = false; - }, 120000); - while (pollForStatus){ + let pollForStatusStart = new Date(); + while((new Date() - pollForStatusStart) < 120000){ let status = await queue.status(taskId); if (status.status.state === 'pending' || status.status.state === 'running'){ utils.status({