Skip to content

Commit

Permalink
Batch jobs added to detail-restart test loop
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Feb 24, 2025
1 parent 1e9644e commit e4bff43
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ui/app/templates/components/job-page/parts/title.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
/>
{{else if
(and
(or (eq this.job.type "batch") (eq this.job.type "system") (eq this.job.type "sysbatch"))
(not this.job.hasVersionStability)
this.job.latestVersion
)
}}
Expand Down
29 changes: 29 additions & 0 deletions ui/mirage/scenarios/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,15 @@ export function createRestartableJobs(server) {
type: 'service',
});

const revertableBatchJob = server.create('job', {
name: 'revertable-batch-job',
stopped: false,
status: 'dead',
noDeployments: true,
shallow: true,
type: 'batch',
});

// So it shows up as "Failed" instead of "Scaled Down"
restartableJob.taskGroups.models[0].update({
count: 1,
Expand All @@ -1274,6 +1283,10 @@ export function createRestartableJobs(server) {
.all()
.filter((v) => v.jobId === nonRevertableJob.id)
.models.forEach((v) => v.destroy());
server.schema.jobVersions
.all()
.filter((v) => v.jobId === revertableBatchJob.id)
.models.forEach((v) => v.destroy());

server.create('job-version', {
job: revertableJob,
Expand Down Expand Up @@ -1324,6 +1337,22 @@ export function createRestartableJobs(server) {
noActiveDeployment: true,
});

server.create('job-version', {
job: revertableBatchJob,
namespace: revertableBatchJob.namespace,
version: 0,
stable: false, // <--- ignored by the UI by way of job.hasVersionStability
noActiveDeployment: true,
});

server.create('job-version', {
job: revertableBatchJob,
namespace: revertableBatchJob.namespace,
version: 1,
stable: false, // <--- ignored by the UI by way of job.hasVersionStability
noActiveDeployment: true,
});

server.schema.jobVersions
.all()
.filter((v) => v.jobId === revertableJob.id)
Expand Down
9 changes: 9 additions & 0 deletions ui/tests/acceptance/job-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,15 @@ module('Job Start/Stop/Revert/Edit and Resubmit', function (hooks) {
assert.ok(JobDetail.editAndResubmit.isPresent);
});

test('A batch job with a previous version can be reverted', async function (assert) {
const revertableSystemJob = server.db.jobs.findBy(
(j) => j.name === 'revertable-batch-job'
);
await JobDetail.visit({ id: revertableSystemJob.id });
assert.ok(JobDetail.revert.isPresent);
assert.equal(JobDetail.revert.text, 'Revert to last stable version (v0)');
});

test('Clicking the resubmit button navigates to the job definition page in edit mode', async function (assert) {
const job = server.db.jobs.findBy((j) => j.name === 'non-revertable-job');
await JobDetail.visit({ id: job.id });
Expand Down

0 comments on commit e4bff43

Please sign in to comment.