Skip to content

Commit

Permalink
basic pipeline test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket committed Jan 8, 2020
1 parent f625b90 commit df26495
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/integration-tests/protractor.conf.ts
Expand Up @@ -89,6 +89,7 @@ const testSuites = {
'tests/performance.scenario.ts',
'tests/monitoring.scenario.ts',
'tests/crd-extensions.scenario.ts',
'tests/devconsole/pipeline.scenario.ts',
]),
release: suite([
'tests/crud.scenario.ts',
Expand All @@ -115,6 +116,7 @@ const testSuites = {
'tests/monitoring.scenario.ts',
'tests/devconsole/dev-perspective.scenario.ts',
'tests/devconsole/git-import-flow.scenario.ts',
'tests/devconsole/pipeline.scenario.ts',
'tests/crd-extensions.scenario.ts',
]),
clusterSettings: suite(['tests/cluster-settings.scenario.ts']),
Expand Down
@@ -0,0 +1,110 @@
import { execSync } from 'child_process';
import { browser, ExpectedConditions as until, by, element } from 'protractor';
import {
appHost,
checkLogs,
checkErrors,
testName,
retry,
} from '../../../../integration-tests/protractor.conf';
import { switchPerspective, Perspective, sideHeader } from '../views/dev-perspective.view';
import {
pipelinecheckStatus,
pageSidebar,
pipelinePage,
pipelineScriptRunner,
createPipelineYamlError,
pipelineOverviewName,
pipelineTable,
pipelineTableBody,
} from '../views/pipeline.view';
import * as sidenavView from '../../../../integration-tests/views/sidenav.view';
import * as crudView from '../../../../integration-tests/views/crud.view';
import * as catalogView from '../../../../integration-tests/views/catalog.view';
import * as catalogPageView from '../../../../integration-tests/views/catalog-page.view';
import * as operatorView from '../../../operator-lifecycle-manager/integration-tests/views/operator.view';
import * as operatorHubView from '../../../operator-lifecycle-manager/integration-tests/views/operator-hub.view';

describe('Pipeline', async () => {
beforeAll(async () => {
await browser.get(`${appHost}/k8s/cluster/projects`);
await browser.wait(until.presenceOf(sidenavView.navSectionFor('Operators')));
await sidenavView.clickNavLink(['Operators', 'OperatorHub']);
await crudView.isLoaded();
});

afterEach(() => {
checkLogs();
checkErrors();
});

it('displays subscription creation form for selected Operator', async () => {
await catalogView.categoryTabsPresent();
await catalogView.categoryTabs.get(0).click();
await catalogPageView.catalogTileFor('Pipelines Operator').click();
await browser.wait(until.visibilityOf(operatorHubView.operatorModal));
await browser.wait(until.presenceOf(element(by.id('confirm-action'))));
await element(by.id('confirm-action')).click();
await operatorHubView.operatorModalInstallBtn.click();
await operatorHubView.createSubscriptionFormLoaded();

expect(operatorHubView.createSubscriptionFormName.getText()).toEqual(
'OpenShift Pipelines Operator',
);
await browser.wait(until.visibilityOf(operatorHubView.createSubscriptionFormInstallMode));
await operatorHubView.allNamespacesInstallMode.click();
expect(operatorHubView.createSubscriptionError.isPresent()).toBe(false);
expect(operatorHubView.createSubscriptionFormBtn.getAttribute('disabled')).toEqual(null);
await operatorHubView.createSubscriptionFormBtn.click();
await crudView.isLoaded();
await browser.get(`${appHost}/operatorhub/ns/${testName}`);
await crudView.isLoaded();
await catalogPageView.clickFilterCheckbox('installState-installed');

expect(catalogPageView.catalogTileFor('OpenShift Pipelines Operator').isDisplayed()).toBe(true);
});

it(`displays Operator in "Cluster Service Versions" view for "${testName}" namespace`, async () => {
await retry(() => catalogPageView.catalogTileFor('OpenShift Pipelines Operator').click());
await operatorHubView.operatorModalIsLoaded();
await element(by.id('confirm-action')).click();
await operatorHubView.viewInstalledOperator();
await crudView.isLoaded();

await browser.wait(
until.visibilityOf(operatorView.rowForOperator('OpenShift Pipelines Operator')),
);
expect(operatorView.rowForOperator('OpenShift Pipelines Operator').isDisplayed()).toBe(true);
});

it('pipeline is installed', async () => {
await switchPerspective(Perspective.Developer);
expect(sideHeader.getText()).toContain('Developer');
await browser.wait(until.visibilityOf(pageSidebar));
expect(pageSidebar.getText()).toContain('Pipelines');
});

it('pipeline tab scenario', async () => {
await switchPerspective(Perspective.Developer);
expect(sideHeader.getText()).toContain('Developer');
await browser.wait(until.visibilityOf(pageSidebar));
expect(pageSidebar.getText()).toContain('Pipelines');
await pipelinecheckStatus();
expect(pipelinePage.getText()).toContain('Pipelines');
await pipelineScriptRunner();
expect(createPipelineYamlError.isPresent()).toBe(false);
await browser.wait(until.visibilityOf(pipelineOverviewName));
expect(pipelineOverviewName.getText()).toContain('new-pipeline');
await execSync(
`oc create -f ./packages/dev-console/integration-tests/views/simple-pipeline-demo.yaml -n ${testName}`,
);
await pipelinecheckStatus();
await browser.wait(until.visibilityOf(pipelineTable));
expect(pipelineTableBody.element(by.css('[data-test-id="simple-pipeline"]')).isPresent()).toBe(
true,
);
expect(pipelineTableBody.element(by.css('[data-test-id="new-pipeline"]')).isPresent()).toBe(
true,
);
});
});
@@ -0,0 +1,30 @@
import { browser, ExpectedConditions as until, by, element, $ } from 'protractor';

export const pageSidebar = element(by.id('page-sidebar'));
export const pipelineTab = element(by.css('[data-test-id="pipeline-header"]'));
export const pipelinePage = element(by.css('[data-test-id="resource-title"]'));
export const createPipelineYaml = element(by.id('yaml-create'));
export const yamlPipeline = element(by.className('lines-content monaco-editor-background'));
export const saveChangesYamlPipeline = element(by.id('save-changes'));
export const createPipelineYamlError = $('.pf-c-alert.pf-m-danger');
export const pipelineTable = element(
by.className('ReactVirtualized__VirtualGrid ReactVirtualized__List'),
);
export const pipelineTableBody = element(
by.className('ReactVirtualized__VirtualGrid__innerScrollContainer'),
);
export const pipelineGraph = $('.odc-pipeline-vis-graph__stages');
export const pipelineOverviewName = element(by.css('[data-test-id="resource-title"]'));

export const pipelineScriptRunner = async function() {
await browser.wait(until.presenceOf(createPipelineYaml));
await createPipelineYaml.click();
await browser.wait(until.presenceOf(saveChangesYamlPipeline));
await saveChangesYamlPipeline.click();
await browser.wait(until.visibilityOf(pipelineGraph), 5000);
};

export const pipelinecheckStatus = async function() {
await pipelineTab.click();
await browser.wait(until.textToBePresentInElement(pipelinePage, 'Pipelines'));
};
@@ -0,0 +1,34 @@
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: simple-pipeline
spec:
tasks:
- name: push
taskRef:
name: echo-hello-world
- name: build-1
taskRef:
name: echo-hello-world
runAfter:
- push
- name: build-2
taskRef:
name: echo-hello-world
runAfter:
- push
- name: deploy
taskRef:
name: echo-hello-world
runAfter:
- build-2
- name: test-1
taskRef:
name: echo-hello-world
runAfter:
- deploy
- name: test-2
taskRef:
name: echo-hello-world
runAfter:
- deploy

0 comments on commit df26495

Please sign in to comment.