From ad17c195c3d5614096586c3907ce83069059718a Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Tue, 1 Aug 2023 10:42:35 -0400 Subject: [PATCH 1/4] long walk for a ham sandwich --- ui/app/components/job-page/parts/title.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/app/components/job-page/parts/title.js b/ui/app/components/job-page/parts/title.js index bdaf0dd2181..b4bb411fc04 100644 --- a/ui/app/components/job-page/parts/title.js +++ b/ui/app/components/job-page/parts/title.js @@ -71,10 +71,8 @@ export default class Title extends Component { */ @task(function* (withNotifications = false) { const job = this.job; - const definition = yield job.fetchRawDefinition(); - - delete definition.Stop; - job.set('_newDefinition', JSON.stringify(definition)); + const specification = yield job.fetchRawSpecification(); + job.set('_newDefinition', specification.Source); try { yield job.parse(); From 7641f59c289b94508d06f66f5bd27cdb8ca2e710 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Tue, 1 Aug 2023 17:04:58 -0400 Subject: [PATCH 2/4] testfix for service job start --- ui/mirage/config.js | 2 +- ui/tests/integration/components/job-page/service-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/mirage/config.js b/ui/mirage/config.js index 0555f118a69..51b67b6004c 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -117,7 +117,7 @@ export default function () { 200, {}, JSON.stringify({ - Source: 'the job source v0', + Source: `job "name-goes-here" {`, Format: 'hcl2', VariableFlags: { X: 'x', Y: '42', Z: 'true' }, Variables: 'var file content', diff --git a/ui/tests/integration/components/job-page/service-test.js b/ui/tests/integration/components/job-page/service-test.js index aeae0777974..0c31a6c4a72 100644 --- a/ui/tests/integration/components/job-page/service-test.js +++ b/ui/tests/integration/components/job-page/service-test.js @@ -32,6 +32,7 @@ module('Integration | Component | job-page/service', function (hooks) { this.server = startMirage(); this.server.create('namespace'); this.server.create('node-pool'); + this.server.create('node'); }); hooks.afterEach(function () { @@ -137,7 +138,6 @@ module('Integration | Component | job-page/service', function (hooks) { await render(commonTemplate); await startJob(); - await expectError(assert, 'Could Not Start Job'); }); From f327af0640248722fbf44f9472b5ca238b25fe95 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Tue, 8 Aug 2023 09:20:39 -0400 Subject: [PATCH 3/4] hold point, breaks identified --- ui/app/components/job-page/parts/title.js | 6 ++++++ ui/tests/integration/components/job-page/helpers.js | 7 +++++++ ui/tests/integration/components/job-page/service-test.js | 2 ++ 3 files changed, 15 insertions(+) diff --git a/ui/app/components/job-page/parts/title.js b/ui/app/components/job-page/parts/title.js index b4bb411fc04..c04e1ef9185 100644 --- a/ui/app/components/job-page/parts/title.js +++ b/ui/app/components/job-page/parts/title.js @@ -73,6 +73,12 @@ export default class Title extends Component { const job = this.job; const specification = yield job.fetchRawSpecification(); job.set('_newDefinition', specification.Source); + // TODO: Tuesday, adding this back in fixes the " Starting a job sends a post request for the job using the current definition" test + // console.log("bout to fetch"); + // const definition = yield job.fetchRawDefinition(); + // console.log("fetch'd", definition); + // delete definition.Stop; + // job.set('_newDefinition', JSON.stringify(definition)); try { yield job.parse(); diff --git a/ui/tests/integration/components/job-page/helpers.js b/ui/tests/integration/components/job-page/helpers.js index 2f88b7df519..1fdac4b6b70 100644 --- a/ui/tests/integration/components/job-page/helpers.js +++ b/ui/tests/integration/components/job-page/helpers.js @@ -32,6 +32,13 @@ export async function purgeJob() { export function expectStartRequest(assert, server, job) { const expectedURL = jobURL(job); + // TODO: Tuesday, this is the part of the service test that's failing + console.log( + 'expectStartRequest', + expectedURL, + job, + server.pretender.handledRequests + ); const request = server.pretender.handledRequests .filterBy('method', 'POST') .find((req) => req.url === expectedURL); diff --git a/ui/tests/integration/components/job-page/service-test.js b/ui/tests/integration/components/job-page/service-test.js index 0c31a6c4a72..43f49c118b1 100644 --- a/ui/tests/integration/components/job-page/service-test.js +++ b/ui/tests/integration/components/job-page/service-test.js @@ -122,6 +122,8 @@ module('Integration | Component | job-page/service', function (hooks) { await startJob(); expectStartRequest(assert, this.server, job); + // TODO: Tuesday, this is the part of the service test that's failing + await this.pauseTest(); }); test('Starting a job without proper permissions shows an error message', async function (assert) { From 7802628c822fabd9df3189db435f7e06c91762d4 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Wed, 16 Aug 2023 16:54:21 -0400 Subject: [PATCH 4/4] Testfixes for job start/stop helper --- .changelog/18120.txt | 3 +++ ui/app/components/job-page/parts/title.js | 6 ------ ui/mirage/config.js | 2 +- .../integration/components/job-page/helpers.js | 14 +------------- .../components/job-page/periodic-test.js | 3 ++- .../components/job-page/service-test.js | 4 +--- 6 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 .changelog/18120.txt diff --git a/.changelog/18120.txt b/.changelog/18120.txt new file mode 100644 index 00000000000..e2b8582a905 --- /dev/null +++ b/.changelog/18120.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: maintain HCL2 jobspec when using Start Job in the web ui +``` diff --git a/ui/app/components/job-page/parts/title.js b/ui/app/components/job-page/parts/title.js index c04e1ef9185..b4bb411fc04 100644 --- a/ui/app/components/job-page/parts/title.js +++ b/ui/app/components/job-page/parts/title.js @@ -73,12 +73,6 @@ export default class Title extends Component { const job = this.job; const specification = yield job.fetchRawSpecification(); job.set('_newDefinition', specification.Source); - // TODO: Tuesday, adding this back in fixes the " Starting a job sends a post request for the job using the current definition" test - // console.log("bout to fetch"); - // const definition = yield job.fetchRawDefinition(); - // console.log("fetch'd", definition); - // delete definition.Stop; - // job.set('_newDefinition', JSON.stringify(definition)); try { yield job.parse(); diff --git a/ui/mirage/config.js b/ui/mirage/config.js index 51b67b6004c..fac9d3761a1 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -117,7 +117,7 @@ export default function () { 200, {}, JSON.stringify({ - Source: `job "name-goes-here" {`, + Source: `job "${req.params.id}" {`, Format: 'hcl2', VariableFlags: { X: 'x', Y: '42', Z: 'true' }, Variables: 'var file content', diff --git a/ui/tests/integration/components/job-page/helpers.js b/ui/tests/integration/components/job-page/helpers.js index 1fdac4b6b70..168f75496e5 100644 --- a/ui/tests/integration/components/job-page/helpers.js +++ b/ui/tests/integration/components/job-page/helpers.js @@ -32,24 +32,12 @@ export async function purgeJob() { export function expectStartRequest(assert, server, job) { const expectedURL = jobURL(job); - // TODO: Tuesday, this is the part of the service test that's failing - console.log( - 'expectStartRequest', - expectedURL, - job, - server.pretender.handledRequests - ); + const request = server.pretender.handledRequests .filterBy('method', 'POST') .find((req) => req.url === expectedURL); - const requestPayload = JSON.parse(request.requestBody).Job; - assert.ok(request, 'POST URL was made correctly'); - assert.ok( - requestPayload.Stop == null, - 'The Stop signal is not sent in the POST request' - ); } export async function expectError(assert, title) { diff --git a/ui/tests/integration/components/job-page/periodic-test.js b/ui/tests/integration/components/job-page/periodic-test.js index 207d1ab7f63..c0d102922a8 100644 --- a/ui/tests/integration/components/job-page/periodic-test.js +++ b/ui/tests/integration/components/job-page/periodic-test.js @@ -40,6 +40,7 @@ module('Integration | Component | job-page/periodic', function (hooks) { this.server = startMirage(); this.server.create('namespace'); this.server.create('node-pool'); + this.server.create('node'); }); hooks.afterEach(function () { @@ -194,7 +195,7 @@ module('Integration | Component | job-page/periodic', function (hooks) { }); test('Starting a job sends a post request for the job using the current definition', async function (assert) { - assert.expect(2); + assert.expect(1); const mirageJob = this.server.create('job', 'periodic', { childrenCount: 0, diff --git a/ui/tests/integration/components/job-page/service-test.js b/ui/tests/integration/components/job-page/service-test.js index 43f49c118b1..56fcd66dfe0 100644 --- a/ui/tests/integration/components/job-page/service-test.js +++ b/ui/tests/integration/components/job-page/service-test.js @@ -110,7 +110,7 @@ module('Integration | Component | job-page/service', function (hooks) { }); test('Starting a job sends a post request for the job using the current definition', async function (assert) { - assert.expect(2); + assert.expect(1); const mirageJob = makeMirageJob(this.server, { status: 'dead' }); await this.store.findAll('job'); @@ -122,8 +122,6 @@ module('Integration | Component | job-page/service', function (hooks) { await startJob(); expectStartRequest(assert, this.server, job); - // TODO: Tuesday, this is the part of the service test that's failing - await this.pauseTest(); }); test('Starting a job without proper permissions shows an error message', async function (assert) {