Skip to content

Commit

Permalink
Merge pull request openshift#11652 from jcaianirh/console-operator-e2e
Browse files Browse the repository at this point in the history
Bug 2094104: Demo dynamic plugin image tests should be skipped when testing console-operator
  • Loading branch information
openshift-merge-robot authored Jun 8, 2022
2 parents b26e094 + b723344 commit 8703892
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ module.exports = (on, config) => {
config.env.BRIDGE_HTPASSWD_USERNAME = process.env.BRIDGE_HTPASSWD_USERNAME;
config.env.BRIDGE_HTPASSWD_PASSWORD = process.env.BRIDGE_HTPASSWD_PASSWORD;
config.env.BRIDGE_KUBEADMIN_PASSWORD = process.env.BRIDGE_KUBEADMIN_PASSWORD;
config.env.OPENSHIFT_CI = process.env.OPENSHIFT_CI;
return config;
};
Original file line number Diff line number Diff line change
Expand Up @@ -96,99 +96,104 @@ const k8sAPINavTest = (apiID: string) => {
cy.get('test-k8api-error').should('not.exist');
cy.get(`test-k8s-${apiID}`).should('not.be.empty');
};
if (!Cypress.env('OPENSHIFT_CI') || Cypress.env('PLUGIN_PULL_SPEC')) {
describe('Demo dynamic plugin test', () => {
before(() => {
cy.login();
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(PLUGIN_NAME);
cy.readFile(`${PLUGIN_PATH}/oc-manifest.yaml`).then((textManifest) => {
const yamlManifest = safeLoadAll(textManifest);
const deployment = yamlManifest.find(({ kind }) => kind === 'Deployment');

describe('Demo dynamic plugin test', () => {
before(() => {
cy.login();
nav.sidenav.switcher.changePerspectiveTo('Administrator');
nav.sidenav.switcher.shouldHaveText('Administrator');
cy.createProject(PLUGIN_NAME);
cy.readFile(`${PLUGIN_PATH}/oc-manifest.yaml`).then((textManifest) => {
const yamlManifest = safeLoadAll(textManifest);
const deployment = yamlManifest.find(({ kind }) => kind === 'Deployment');
if (!isLocalDevEnvironment && PLUGIN_PULL_SPEC) {
console.log('this is not a local env, setting the pull spec for the deployment');
deployment.spec.template.spec.containers[0].image = PLUGIN_PULL_SPEC;
} else {
console.log('this IS A local env, not setting the pull spec for the deployment');
}
const service = yamlManifest.find(({ kind }) => kind === 'Service');
const consolePlugin = yamlManifest.find(({ kind }) => kind === 'ConsolePlugin');
cy.exec(` echo '${JSON.stringify(deployment)}' | oc create -f -`, {
failOnNonZeroExit: false,
})
.its('stdout')
.should('contain', 'created')
.then(() =>
cy
.exec(` echo '${JSON.stringify(service)}' | oc create -f -`, {
failOnNonZeroExit: false,
})
.then((result) => {
console.log('Error: ', result.stderr);
console.log('Success: ', result.stdout);
})
.its('stdout')
.should('contain', 'created'),
)
.then(() =>
cy
.exec(` echo '${JSON.stringify(consolePlugin)}' | oc create -f -`, {
failOnNonZeroExit: false,
})
.then((result) => {
console.log('Error: ', result.stderr);
console.log('Success: ', result.stdout);
})
.its('stdout')
.should('contain', 'created'),
)
.then(() => {
cy.visit(`/k8s/ns/${PLUGIN_NAME}/deployments`);
listPage.rows.shouldBeLoaded();
listPage.filter.byName(PLUGIN_NAME);
listPage.rows.shouldExist(PLUGIN_NAME);
enableDemoPlugin(true);
});
});
});

if (!isLocalDevEnvironment && PLUGIN_PULL_SPEC) {
console.log('this is not a local env, setting the pull spec for the deployment');
deployment.spec.template.spec.containers[0].image = PLUGIN_PULL_SPEC;
} else {
console.log('this IS A local env, not setting the pull spec for the deployment');
}
const service = yamlManifest.find(({ kind }) => kind === 'Service');
const consolePlugin = yamlManifest.find(({ kind }) => kind === 'ConsolePlugin');
cy.exec(` echo '${JSON.stringify(deployment)}' | oc create -f -`, {
failOnNonZeroExit: false,
})
.its('stdout')
.should('contain', 'created')
.then(() =>
cy
.exec(` echo '${JSON.stringify(service)}' | oc create -f -`, {
failOnNonZeroExit: false,
})
.then((result) => {
console.log('Error: ', result.stderr);
console.log('Success: ', result.stdout);
})
.its('stdout')
.should('contain', 'created'),
)
.then(() =>
cy
.exec(` echo '${JSON.stringify(consolePlugin)}' | oc create -f -`, {
failOnNonZeroExit: false,
})
.then((result) => {
console.log('Error: ', result.stderr);
console.log('Success: ', result.stdout);
})
.its('stdout')
.should('contain', 'created'),
)
.then(() => {
cy.visit(`/k8s/ns/${PLUGIN_NAME}/deployments`);
listPage.rows.shouldBeLoaded();
listPage.filter.byName(PLUGIN_NAME);
listPage.rows.shouldExist(PLUGIN_NAME);
enableDemoPlugin(true);
});
afterEach(() => {
checkErrors();
});
});

afterEach(() => {
checkErrors();
});
after(() => {
enableDemoPlugin(false);
cy.deleteProject(PLUGIN_NAME);
cy.logout();
});

after(() => {
enableDemoPlugin(false);
cy.deleteProject(PLUGIN_NAME);
cy.logout();
});
it(`test Dynamic Nav items`, () => {
const dynamicNavIDs = ['1', '2'];
dynamicNavIDs.forEach((id) => dynamicNavTest(id));
});

it(`test Dynamic Nav items`, () => {
const dynamicNavIDs = ['1', '2'];
dynamicNavIDs.forEach((id) => dynamicNavTest(id));
});
it(`test Test Utilities nav item`, () => {
nav.sidenav.clickNavLink(['Demo Plugin', 'Test Utilities']);
cy.byTestID('test-utilities-title').should('contain', 'Utilities from Dynamic Plugin SDK');
cy.byTestID('test-utility-card').should('contain', 'Utility: consoleFetchJSON');
cy.byTestID('test-utility-fetch').should('not.be.empty');
});

it(`test Test Utilities nav item`, () => {
nav.sidenav.clickNavLink(['Demo Plugin', 'Test Utilities']);
cy.byTestID('test-utilities-title').should('contain', 'Utilities from Dynamic Plugin SDK');
cy.byTestID('test-utility-card').should('contain', 'Utility: consoleFetchJSON');
cy.byTestID('test-utility-fetch').should('not.be.empty');
});
it(`test List Page nav item`, () => {
const podName = 'openshift-state-metrics';
nav.sidenav.clickNavLink(['Demo Plugin', 'List Page']);
listPage.titleShouldHaveText('OpenShift Pods List Page');
listPage.rows.shouldBeLoaded();
listPage.filter.byName(podName);
listPage.rows.shouldExist(podName);
});

it(`test List Page nav item`, () => {
const podName = 'openshift-state-metrics';
nav.sidenav.clickNavLink(['Demo Plugin', 'List Page']);
listPage.titleShouldHaveText('OpenShift Pods List Page');
listPage.rows.shouldBeLoaded();
listPage.filter.byName(podName);
listPage.rows.shouldExist(podName);
it(`test K8s API nav item`, () => {
const apiIDs = ['k8sCreate', 'k8sGet', 'k8sPatch', 'k8sUpdate', 'k8sList', 'k8sDelete'];
nav.sidenav.clickNavLink(['Demo Plugin', 'K8s API']);
cy.byTestID('test-k8sapi-title').should('contain', 'K8s API from Dynamic Plugin SDK');
apiIDs.forEach((id) => k8sAPINavTest(id));
});
});

it(`test K8s API nav item`, () => {
const apiIDs = ['k8sCreate', 'k8sGet', 'k8sPatch', 'k8sUpdate', 'k8sList', 'k8sDelete'];
nav.sidenav.clickNavLink(['Demo Plugin', 'K8s API']);
cy.byTestID('test-k8sapi-title').should('contain', 'K8s API from Dynamic Plugin SDK');
apiIDs.forEach((id) => k8sAPINavTest(id));
} else {
xdescribe('Skipping demo dynamic plugin tests', () => {
it('If we are running with a console-operator build, skip this test as we can not build the demo plugin', () => {});
});
});
}

0 comments on commit 8703892

Please sign in to comment.