Skip to content

Commit

Permalink
Merge pull request #2956 from jpuzz0/RHOAIENG-8566
Browse files Browse the repository at this point in the history
[RHOAIENG-8566] Duplicate run is not useful when its pipeline is disabled
  • Loading branch information
openshift-merge-bot[bot] authored Jul 2, 2024
2 parents 5adcba7 + f1bf75e commit 5274af0
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,21 @@ const initialMockRecurringRuns = [
}),
];

const visitLegacyRunsPage = (pipelineId?: string, versionId?: string) =>
pipelineRunsGlobal.visit(
projectName,
pipelineId || mockPipelineVersion.pipeline_id,
versionId || mockPipelineVersion.pipeline_version_id,
);

describe('Pipeline create runs', () => {
beforeEach(() => {
initIntercepts();
pipelineRunsGlobal.visit(
projectName,
mockPipelineVersion.pipeline_id,
mockPipelineVersion.pipeline_version_id,
);
});

it('renders the page with scheduled and active runs table data', () => {
visitLegacyRunsPage();

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunJobTable.getRowByName('Test job').find().should('exist');

Expand All @@ -74,6 +78,8 @@ describe('Pipeline create runs', () => {

describe('Runs', () => {
it('switches to scheduled runs from triggered', () => {
visitLegacyRunsPage();

// Mock experiments, pipelines & versions for form select dropdowns
createRunPage.mockGetExperiments(projectName, mockExperiments);
createRunPage.mockGetPipelines(projectName, [mockPipeline]);
Expand All @@ -92,6 +98,8 @@ describe('Pipeline create runs', () => {
});

it('creates an active run', () => {
visitLegacyRunsPage();

const createRunParams: Partial<PipelineRunKFv2> = {
display_name: 'New run',
description: 'New run description',
Expand Down Expand Up @@ -184,9 +192,10 @@ describe('Pipeline create runs', () => {
activeRunsTable.mockGetActiveRuns([...initialMockRuns, mockDuplicateRun], projectName);

// Navigate to clone run page for a given active run
cy.visitWithLogin(`/experiments/${projectName}/experiment-1/runs`);
pipelineRunsGlobal.findActiveRunsTab().click();
activeRunsTable.getRowByName(mockRun.display_name).findKebabAction('Duplicate').click();
verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/clone/${mockRun.run_id}`);
verifyRelativeURL(`/experiments/${projectName}/experiment-1/runs/clone/${mockRun.run_id}`);

// Verify pre-populated values & submit
cloneRunPage.findExperimentSelect().should('have.text', mockExperiment.display_name);
Expand Down Expand Up @@ -221,10 +230,12 @@ describe('Pipeline create runs', () => {
});

// Should redirect to the details of the newly cloned active run
verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/view/${mockDuplicateRun.run_id}`);
verifyRelativeURL(`/experiments/${projectName}/experiment-1/runs/${mockDuplicateRun.run_id}`);
});

it('create run with default and optional parameters', () => {
visitLegacyRunsPage();

const createRunParams: Partial<PipelineRunKFv2> = {
display_name: 'New run',
description: 'New run description',
Expand Down Expand Up @@ -348,6 +359,8 @@ describe('Pipeline create runs', () => {
});

it('create run with all parameter types', () => {
visitLegacyRunsPage();

const createRunParams: Partial<PipelineRunKFv2> = {
display_name: 'New run',
description: 'New run description',
Expand Down Expand Up @@ -475,11 +488,12 @@ describe('Pipeline create runs', () => {
experiment,
);
});

pipelineRunsGlobal.findSchedulesTab().click();
});

it('switches to scheduled runs from triggered', () => {
visitLegacyRunsPage();
pipelineRunsGlobal.findSchedulesTab().click();

// Mock experiments, pipelines & versions for form select dropdowns
createSchedulePage.mockGetExperiments(projectName, mockExperiments);
createSchedulePage.mockGetPipelines(projectName, [mockPipeline]);
Expand All @@ -498,6 +512,9 @@ describe('Pipeline create runs', () => {
});

it('creates a schedule', () => {
visitLegacyRunsPage();
pipelineRunsGlobal.findSchedulesTab().click();

const createRecurringRunParams: Partial<PipelineRunJobKFv2> = {
display_name: 'New job',
description: 'New job description',
Expand Down Expand Up @@ -593,12 +610,14 @@ describe('Pipeline create runs', () => {
cloneSchedulePage.mockGetExperiment(projectName, mockExperiment);

// Navigate to clone run page for a given schedule
cy.visitWithLogin(`/experiments/${projectName}/experiment-1/runs`);
pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunJobTable
.getRowByName(mockRecurringRun.display_name)
.findKebabAction('Duplicate')
.click();
verifyRelativeURL(
`/pipelines/${projectName}/pipelineRun/cloneJob/${mockRecurringRun.recurring_run_id}?runType=scheduled`,
`/experiments/${projectName}/experiment-1/schedules/clone/${mockRecurringRun.recurring_run_id}?runType=scheduled`,
);

// Verify pre-populated values & submit
Expand Down Expand Up @@ -644,11 +663,14 @@ describe('Pipeline create runs', () => {

// Should be redirected to the schedule details page
verifyRelativeURL(
`/pipelines/${projectName}/pipelineRunJob/view/${mockDuplicateRecurringRun.recurring_run_id}`,
`/experiments/${projectName}/experiment-1/schedules/${mockDuplicateRecurringRun.recurring_run_id}`,
);
});

it('shows cron & periodic fields', () => {
visitLegacyRunsPage();

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunsGlobal.findScheduleRunButton().click();

createSchedulePage.findScheduledRunTypeSelector().click();
Expand All @@ -663,6 +685,9 @@ describe('Pipeline create runs', () => {
});

it('should start concurrent at the max, 10', () => {
visitLegacyRunsPage();

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunsGlobal.findScheduleRunButton().click();

createSchedulePage.findMaxConcurrencyFieldMinus().should('be.enabled');
Expand All @@ -671,6 +696,9 @@ describe('Pipeline create runs', () => {
});

it('should allow the concurrency to update via +/-', () => {
visitLegacyRunsPage();

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunsGlobal.findScheduleRunButton().click();

createSchedulePage.findMaxConcurrencyFieldMinus().click();
Expand All @@ -682,6 +710,9 @@ describe('Pipeline create runs', () => {
});

it('should not allow concurrency to go under or above the bounds', () => {
visitLegacyRunsPage();

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunsGlobal.findScheduleRunButton().click();

createSchedulePage.findMaxConcurrencyFieldValue().fill('0');
Expand All @@ -692,6 +723,9 @@ describe('Pipeline create runs', () => {
});

it('should hide and show date toggles', () => {
visitLegacyRunsPage();

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunsGlobal.findScheduleRunButton().click();

createSchedulePage.findStartDatePickerDate().should('not.be.visible');
Expand All @@ -708,6 +742,9 @@ describe('Pipeline create runs', () => {
});

it('should see catch up is enabled by default', () => {
visitLegacyRunsPage();

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunsGlobal.findScheduleRunButton().click();

createSchedulePage.findCatchUpSwitchValue().should('be.checked');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
bulkRestoreRunModal,
archiveRunModal,
bulkArchiveRunModal,
cloneRunPage,
cloneSchedulePage,
} from '~/__tests__/cypress/cypress/pages/pipelines';
import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url';
import { be } from '~/__tests__/cypress/cypress/utils/should';
Expand Down Expand Up @@ -280,14 +282,15 @@ describe('Pipeline runs', () => {
describe('with data', () => {
beforeEach(() => {
activeRunsTable.mockGetActiveRuns(mockActiveRuns, projectName);
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');
});

it('renders the page with table data', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');
activeRunsTable.getRowByName('Test active run 1').find().should('exist');
});

it('archive a single run', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');
const [runToArchive] = mockActiveRuns;

activeRunsTable.mockArchiveRun(runToArchive.run_id, projectName);
Expand All @@ -303,6 +306,7 @@ describe('Pipeline runs', () => {
});

it('archive multiple runs', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');
mockActiveRuns.forEach((activeRun) => {
activeRunsTable.mockArchiveRun(activeRun.run_id, projectName);
activeRunsTable.getRowByName(activeRun.display_name).findCheckbox().click();
Expand All @@ -322,19 +326,28 @@ describe('Pipeline runs', () => {

describe('Navigation', () => {
it('navigate to create run page', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');
pipelineRunsGlobal.findCreateRunButton().click();
verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/create`);
});

it('navigate to clone run page', () => {
cloneRunPage.mockGetExperiments(projectName, mockExperiments);
cloneRunPage.mockGetExperiment(projectName, mockExperiments[0]);
cy.visitWithLogin(`/experiments/${projectName}/test-experiment-1/runs`);

activeRunsTable
.getRowByName(mockActiveRuns[0].display_name)
.findKebabAction('Duplicate')
.click();

verifyRelativeURL(
`/pipelines/${projectName}/pipelineRun/clone/${mockActiveRuns[0].run_id}`,
`/experiments/${projectName}/test-experiment-1/runs/clone/${mockActiveRuns[0].run_id}`,
);
});

it('navigate between tabs', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');
pipelineRunsGlobal.findArchivedRunsTab().click();
verifyRelativeURL(
`/pipelines/${projectName}/pipeline/runs/${pipelineId}/${pipelineVersionId}?runType=archived`,
Expand All @@ -348,7 +361,9 @@ describe('Pipeline runs', () => {
`/pipelines/${projectName}/pipeline/runs/${pipelineId}/${pipelineVersionId}?runType=scheduled`,
);
});

it('navigate to run details page', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');
activeRunsTable
.getRowByName(mockActiveRuns[0].display_name)
.findColumnName(mockActiveRuns[0].display_name)
Expand All @@ -362,6 +377,8 @@ describe('Pipeline runs', () => {

describe('Table filter', () => {
it('filter by name', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');

// Verify initial run rows exist
activeRunsTable.findRows().should('have.length', 3);

Expand All @@ -386,6 +403,8 @@ describe('Pipeline runs', () => {
});

it('filter by experiment', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');

// Mock initial list of experiments
pipelineRunFilterBar.mockExperiments(mockExperiments, projectName);

Expand Down Expand Up @@ -417,6 +436,8 @@ describe('Pipeline runs', () => {
});

it('filter by started', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');

// Verify initial run rows exist
activeRunsTable.findRows().should('have.length', 3);

Expand Down Expand Up @@ -460,6 +481,8 @@ describe('Pipeline runs', () => {
});

it('filter by status', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');

// Verify initial run rows exist
activeRunsTable.findRows().should('have.length', 3);

Expand Down Expand Up @@ -521,6 +544,8 @@ describe('Pipeline runs', () => {
});

it('Sort by Name', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'active');

pipelineRunFilterBar.findSortButtonForActive('Run').click();
pipelineRunFilterBar.findSortButtonForActive('Run').should(be.sortAscending);
pipelineRunFilterBar.findSortButtonForActive('Run').click();
Expand Down Expand Up @@ -919,17 +944,18 @@ describe('Pipeline runs', () => {
describe('with data', () => {
beforeEach(() => {
pipelineRunJobTable.mockGetJobs(mockJobs, projectName);
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'scheduled');
});

it('renders the page with table rows', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'scheduled');
pipelineRunJobTable.find().should('exist');
pipelineRunJobTable.getRowByName('test-pipeline').find().should('exist');
pipelineRunJobTable.getRowByName('other-pipeline').find().should('exist');
pipelineRunJobTable.getRowByName('another-pipeline').find().should('exist');
});

it('can disable a job', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'scheduled');
pipelineRunJobTable.mockDisableJob(mockJobs[0], projectName).as('disableJob');
pipelineRunJobTable
.getRowByName(mockJobs[0].display_name)
Expand All @@ -940,19 +966,30 @@ describe('Pipeline runs', () => {

describe('Navigation', () => {
it('navigate to create scheduled run page', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'scheduled');
pipelineRunsGlobal.findScheduleRunButton().click();
verifyRelativeURL(`/pipelines/${projectName}/pipelineRun/create?runType=scheduled`);
});

it('navigate to clone scheduled run page', () => {
cloneSchedulePage.mockGetExperiments(projectName, mockExperiments);
cloneSchedulePage.mockGetExperiment(projectName, mockExperiments[0]);
cy.visitWithLogin(`/experiments/${projectName}/test-experiment-1/runs`);

pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunJobTable
.getRowByName(mockJobs[0].display_name)
.findKebabAction('Duplicate')
.click();

verifyRelativeURL(
`/pipelines/${projectName}/pipelineRun/cloneJob/${mockJobs[0].recurring_run_id}?runType=scheduled`,
`/experiments/${projectName}/test-experiment-1/schedules/clone/${mockJobs[0].recurring_run_id}?runType=scheduled`,
);
});

it('navigate to scheduled run details page', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'scheduled');
pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunJobTable
.getRowByName(mockJobs[0].display_name)
.findColumnName(mockJobs[0].display_name)
Expand All @@ -965,6 +1002,9 @@ describe('Pipeline runs', () => {

describe('Table filter', () => {
it('filter by name', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'scheduled');
pipelineRunsGlobal.findSchedulesTab().click();

// Verify initial job rows exist
pipelineRunJobTable.findRows().should('have.length', 3);

Expand All @@ -984,6 +1024,9 @@ describe('Pipeline runs', () => {
});

it('Sort by Name', () => {
pipelineRunsGlobal.visit(projectName, pipelineId, pipelineVersionId, 'scheduled');
pipelineRunsGlobal.findSchedulesTab().click();

pipelineRunFilterBar.findSortButtonforSchedules('Schedule').click();
pipelineRunFilterBar.findSortButtonforSchedules('Schedule').should(be.sortAscending);
pipelineRunFilterBar.findSortButtonforSchedules('Schedule').click();
Expand Down
Loading

0 comments on commit 5274af0

Please sign in to comment.