-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(3242): Unable to force start a frozen job that is part of a pipel…
…ine stage
- Loading branch information
Showing
4 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1766,6 +1766,105 @@ describe('build plugin test', () => { | |
}); | ||
}); | ||
|
||
it('triggers the startFrom job after the stage setup job even if the startFrom job is within freeze window', () => { | ||
const status = 'SUCCESS'; | ||
const options = { | ||
method: 'PUT', | ||
url: `/builds/${id}`, | ||
auth: { | ||
credentials: { | ||
username: id, | ||
scope: ['build'] | ||
}, | ||
strategy: ['token'] | ||
}, | ||
payload: { | ||
status | ||
} | ||
}; | ||
|
||
jobMock = { | ||
id: 110, | ||
name: 'stage@alpha:setup', | ||
pipelineId, | ||
permutations: [ | ||
{ | ||
settings: { | ||
email: '[email protected]' | ||
} | ||
} | ||
], | ||
pipeline: sinon.stub().resolves(pipelineMock)(), | ||
getLatestBuild: sinon.stub().resolves(buildMock) | ||
}; | ||
buildMock.job = sinon.stub().resolves(jobMock)(); | ||
buildMock.parentBuilds = { | ||
123: { eventId: '8888', jobs: { '~commit': 7777, C: 7778, D: 7779 } } | ||
}; | ||
eventMock.getBuilds.resolves([ | ||
{ | ||
id: 1, | ||
eventId: '8888', | ||
jobId: 1, | ||
status: 'FAILURE' | ||
}, | ||
{ | ||
id: 7777, | ||
eventId: '8888', | ||
jobId: 4, | ||
status: 'SUCCESS' | ||
}, | ||
{ | ||
id: 7778, | ||
eventId: '8888', | ||
jobId: 5, | ||
status: 'SUCCESS' | ||
}, | ||
{ | ||
id: 7779, | ||
eventId: '8888', | ||
jobId: 6, | ||
status: 'SUCCESS' | ||
} | ||
]); | ||
|
||
const causeMessage = '[force start] Starting frozen build from the middle of a stage'; | ||
|
||
eventMock.workflowGraph = testWorkflowGraphWithStages; | ||
eventMock.startFrom = 'alpha-certify'; | ||
eventMock.causeMessage = causeMessage; | ||
eventFactoryMock.get.resolves(eventMock); | ||
|
||
const jobAlphaCertify = { | ||
id: 113, | ||
name: 'alpha-certify', | ||
pipelineId, | ||
state: 'ENABLED', | ||
permutations: [ | ||
{ | ||
settings: { | ||
email: '[email protected]' | ||
} | ||
} | ||
] | ||
}; | ||
|
||
jobFactoryMock.get.withArgs(jobAlphaCertify.id).resolves(jobAlphaCertify); | ||
jobFactoryMock.get.withArgs({ pipelineId, name: 'alpha-certify' }).resolves(jobAlphaCertify); | ||
|
||
buildFactoryMock.get.withArgs({ eventId: eventMock.id, jobId: jobAlphaCertify.id }).returns(null); | ||
|
||
return server.inject(options).then(reply => { | ||
assert.equal(reply.statusCode, 200); | ||
assert.calledWith(jobFactoryMock.get, { | ||
name: eventMock.startFrom, | ||
pipelineId | ||
}); | ||
assert.calledOnce(buildFactoryMock.create); | ||
assert.strictEqual(buildFactoryMock.create.getCall(0).args[0].causeMessage, causeMessage); | ||
}); | ||
}); | ||
|
||
it('triggers the startFrom job after the stage setup job if the startFrom job is a non-setup job in a different stage', () => { | ||
const status = 'SUCCESS'; | ||
const options = { | ||
|