mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
Fix recommendation test to ensure CPU exists (#10004)
This fixes a flaky test, as seen in this failure: https://app.circleci.com/pipelines/github/hashicorp/nomad/14726/workflows/f4ae0bf2-0699-4d18-b55e-5221aafe393c/jobs/137128 One part of the test involves toggling off all memory recommendations and then accepting, but it’s not possible to accept when there are no CPU recommendations to begin with, which can happen because there’s a 10% chance of not creating a corresponding recommendation in the task factory. Since two tasks are created for this module, it’s only a 1% chance of no CPU task, but that means 1% flakiness!
This commit is contained in:
@@ -63,11 +63,26 @@ module('Acceptance | optimize', function(hooks) {
|
||||
});
|
||||
|
||||
test('lets recommendations be toggled, reports the choices to the recommendations API, and displays task group recommendations serially', async function(assert) {
|
||||
await Optimize.visit();
|
||||
|
||||
const currentTaskGroup = this.job1.taskGroups.models[0];
|
||||
const nextTaskGroup = this.job2.taskGroups.models[0];
|
||||
|
||||
const currentTaskGroupHasCPURecommendation = currentTaskGroup.tasks.models
|
||||
.mapBy('recommendations.models')
|
||||
.flat()
|
||||
.find(r => r.resource === 'CPU');
|
||||
|
||||
// If no CPU recommendation, will not be able to accept recommendation with all memory recommendations turned off
|
||||
|
||||
if (!currentTaskGroupHasCPURecommendation) {
|
||||
const currentTaskGroupTask = currentTaskGroup.tasks.models[0];
|
||||
this.server.create('recommendation', {
|
||||
task: currentTaskGroupTask,
|
||||
resource: 'CPU',
|
||||
});
|
||||
}
|
||||
|
||||
await Optimize.visit();
|
||||
|
||||
assert.equal(Layout.breadcrumbFor('optimize').text, 'Recommendations');
|
||||
|
||||
assert.equal(
|
||||
|
||||
Reference in New Issue
Block a user