From 3b2144c39d084c0b61192b456e51ed2c8168f5c4 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Mon, 6 Jun 2022 13:25:54 +0800 Subject: [PATCH] test: Add zun e2e test 1. create zun container test 2. start zun container test 3. pause zun container test 4. unpause zun container test 5. reboot zun container test 6. stop zun container test 7. delete zun container test 8. create zun capsule test 9. delete zun capsule test Change-Id: If291bbfd1dde4a73b5e14c171e3bb885d687f480 --- .zuul.yaml | 10 ++ playbooks/devstack/other/run-e2etests.yaml | 1 + test/e2e/config/config-other.yaml | 4 + test/e2e/config/config.yaml | 4 + test/e2e/fixtures/zunCapsuleTemplate.yaml | 45 +++++++++ .../e2e/integration/pages/zun/capsule.spec.js | 36 +++++++ .../integration/pages/zun/container.spec.js | 95 +++++++++++++++++++ test/e2e/support/constants.js | 4 + 8 files changed, 199 insertions(+) create mode 100644 test/e2e/fixtures/zunCapsuleTemplate.yaml create mode 100644 test/e2e/integration/pages/zun/capsule.spec.js create mode 100644 test/e2e/integration/pages/zun/container.spec.js diff --git a/.zuul.yaml b/.zuul.yaml index 4e9b330d..c81e66f1 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -314,6 +314,7 @@ - openstack/devstack - openstack/glance - openstack/heat + - openstack/zun - openstack/keystone - openstack/neutron - openstack/nova @@ -568,11 +569,14 @@ - ^src/pages/management/.*$ - ^src/pages/user-center/.*$ - ^src/stores/heat/.*$ + - ^src/stores/zun/.*$ - ^src/stores/keystone/.*$ - ^src/resources/heat/.*$ + - ^src/resources/zun/.*$ - ^src/resources/keystone/.*$ - ^test/e2e/integration/pages/configuration/.*$ - ^test/e2e/integration/pages/heat/.*$ + - ^test/e2e/integration/pages/zun/.*$ - ^test/e2e/integration/pages/identity/.*$ - ^test/e2e/integration/pages/error.spec.js - ^test/e2e/integration/pages/login.spec.js @@ -614,11 +618,14 @@ - ^src/pages/management/.*$ - ^src/pages/user-center/.*$ - ^src/stores/heat/.*$ + - ^src/stores/zun/.*$ - ^src/stores/keystone/.*$ - ^src/resources/heat/.*$ + - ^src/resources/zun/.*$ - ^src/resources/keystone/.*$ - ^test/e2e/integration/pages/configuration/.*$ - ^test/e2e/integration/pages/heat/.*$ + - ^test/e2e/integration/pages/zun/.*$ - ^test/e2e/integration/pages/identity/.*$ - ^test/e2e/integration/pages/error.spec.js - ^test/e2e/integration/pages/login.spec.js @@ -697,11 +704,14 @@ - ^src/pages/management/.*$ - ^src/pages/user-center/.*$ - ^src/stores/heat/.*$ + - ^src/stores/zun/.*$ - ^src/stores/keystone/.*$ - ^src/resources/heat/.*$ + - ^src/resources/zun/.*$ - ^src/resources/keystone/.*$ - ^test/e2e/integration/pages/configuration/.*$ - ^test/e2e/integration/pages/heat/.*$ + - ^test/e2e/integration/pages/zun/.*$ - ^test/e2e/integration/pages/identity/.*$ - ^test/e2e/integration/pages/error.spec.js - ^test/e2e/integration/pages/login.spec.js diff --git a/playbooks/devstack/other/run-e2etests.yaml b/playbooks/devstack/other/run-e2etests.yaml index 340ba7df..d8f29526 100644 --- a/playbooks/devstack/other/run-e2etests.yaml +++ b/playbooks/devstack/other/run-e2etests.yaml @@ -15,6 +15,7 @@ cp test/e2e/config/config-other.yaml $config_file sed -i "s#baseUrl.*#baseUrl: https://127.0.0.1:9999#" $config_file sed -i "s/- heat/# - heat/" $config_file + sed -i "s/- zun/# - zun/" $config_file sed -i "s#username:.*#username: admin#" $config_file sed -i "s#password:.*#password: secretadmin#" $config_file sed -i "s#usernameAdmin:.*#usernameAdmin: admin#" $config_file diff --git a/test/e2e/config/config-other.yaml b/test/e2e/config/config-other.yaml index 2d0c528a..4515e6bd 100644 --- a/test/e2e/config/config-other.yaml +++ b/test/e2e/config/config-other.yaml @@ -14,6 +14,7 @@ env: imageCanChangePassword: false extensions: - heat + - zun testFiles: - pages/login.spec.js - pages/error.spec.js @@ -29,3 +30,6 @@ testFiles: - pages/configuration/setting.spec.js # heat - pages/heat/stack.spec.js + # zun + - pages/zun/container.spec.js + - pages/zun/capsule.spec.js diff --git a/test/e2e/config/config.yaml b/test/e2e/config/config.yaml index 2bcab8f4..0d9f1586 100644 --- a/test/e2e/config/config.yaml +++ b/test/e2e/config/config.yaml @@ -21,6 +21,7 @@ env: - heat - ironic - swift + - zun testFiles: - pages/login.spec.js - pages/error.spec.js @@ -65,3 +66,6 @@ testFiles: - pages/configuration/setting.spec.js # heat - pages/heat/stack.spec.js + # zun + - pages/zun/container.spec.js + - pages/zun/capsule.spec.js diff --git a/test/e2e/fixtures/zunCapsuleTemplate.yaml b/test/e2e/fixtures/zunCapsuleTemplate.yaml new file mode 100644 index 00000000..d4741de3 --- /dev/null +++ b/test/e2e/fixtures/zunCapsuleTemplate.yaml @@ -0,0 +1,45 @@ +kind: capsule +spec: + restartPolicy: Always + initContainers: + - workDir: / + command: + - wget + - '-O' + - /work-dir/index.html + - 'https://www.openstack.org/' + env: + ENV1: env1-value1 + image: busybox + volumeMounts: + - mountPath: /work-dir + name: workdir + resources: + requests: + cpu: 0.1 + memory: 128 + containers: + - workDir: / + env: + ENV2: env2-value + image: nginx + volumeMounts: + - mountPath: /usr/share/nginx/html + name: workdir + ports: + - protocol: TCP + containerPort: 80 + resources: + requests: + cpu: 0.5 + memory: 512 + volumes: + - cinder: + size: 1 + name: workdir +metadata: + labels: + app: web + name: e2e-zun-capsule + annotations: + key1: value1 diff --git a/test/e2e/integration/pages/zun/capsule.spec.js b/test/e2e/integration/pages/zun/capsule.spec.js new file mode 100644 index 00000000..ffb0d05a --- /dev/null +++ b/test/e2e/integration/pages/zun/capsule.spec.js @@ -0,0 +1,36 @@ +import { onlyOn } from '@cypress/skip-test'; +import { zunCapsuleListUrl } from '../../../support/constants'; + +const zunServiceEnabled = (Cypress.env('extensions') || []).includes('zun'); + +onlyOn(!zunServiceEnabled, () => { + describe('Skip The zunCapsule Page', () => { + it('successfully skip', () => {}); + }); +}); + +onlyOn(zunServiceEnabled, () => { + describe('The zunCpsule Page', () => { + const listUrl = zunCapsuleListUrl; + const filename = 'zunCapsuleTemplate.yaml'; + const zunCapsuleName = 'e2e-zun-capsule'; + + beforeEach(() => { + cy.login(listUrl); + }); + + it('successfully create', () => { + cy.clickHeaderButton(1) + .formAttachFile('template_file', filename) + .clickModalActionSubmitButton(); + }); + + it('successfully delete', () => { + cy.tableSimpleSearchText(zunCapsuleName) + .checkTableFirstRow(zunCapsuleName) + .clickFirstActionButton() + .clickConfirmActionSubmitButton() + .checkEmptyTable(); + }); + }); +}); diff --git a/test/e2e/integration/pages/zun/container.spec.js b/test/e2e/integration/pages/zun/container.spec.js new file mode 100644 index 00000000..6e578b50 --- /dev/null +++ b/test/e2e/integration/pages/zun/container.spec.js @@ -0,0 +1,95 @@ +import { onlyOn } from '@cypress/skip-test'; +import { zunContainerListUrl } from '../../../support/constants'; + +const zunServiceEnabled = (Cypress.env('extensions') || []).includes('zun'); + +onlyOn(!zunServiceEnabled, () => { + describe('Skip The zunContainer Page', () => { + it('successfully skip', () => {}); + }); +}); + +onlyOn(zunServiceEnabled, () => { + describe('The zunContainer Page', () => { + const listUrl = zunContainerListUrl; + const uuid = Cypress._.random(0, 1e6); + const zunContainerName = `e2e-zunContainer-${uuid}`; + + beforeEach(() => { + cy.login(listUrl); + }); + + it('successfully create', () => { + cy.clickHeaderButton(1) + .url() + .should('include', `${listUrl}/create`) + .wait(5000) + .formInput('containerName', zunContainerName) + .formInput('image', 'cirros') + .clickStepActionNextButton() + .wait(2000) + .clickStepActionNextButton() + .wait(2000) + .clickStepActionNextButton() + .wait(2000) + .clickStepActionNextButton() + .wait(2000) + .clickStepActionNextButton() + .waitFormLoading() + .url() + .should('include', listUrl) + .closeNotice() + .waitStatusTextByFresh('Created'); + }); + + it('successfully start', () => { + cy.tableSimpleSearchText(zunContainerName) + .checkTableFirstRow(zunContainerName) + .clickActionInMore('Start') + .clickConfirmActionSubmitButton() + .waitStatusTextByFresh('Running'); + }); + + it('successfully pause', () => { + cy.tableSimpleSearchText(zunContainerName) + .checkTableFirstRow(zunContainerName) + .clickActionInMore('Pause') + .clickConfirmActionSubmitButton() + .waitStatusTextByFresh('Paused'); + }); + + it('successfully unpause', () => { + cy.tableSimpleSearchText(zunContainerName) + .checkTableFirstRow(zunContainerName) + .clickActionButtonByTitle('Unpause') + .clickConfirmActionSubmitButton() + .waitStatusTextByFresh('Running'); + }); + + it('successfully reboot', () => { + cy.tableSimpleSearchText(zunContainerName) + .checkTableFirstRow(zunContainerName) + .clickActionInMore('Reboot') + .clickConfirmActionSubmitButton() + .waitStatusTextByFresh('Restarting') + .wait(5000) + .waitStatusTextByFresh('Running'); + }); + + it('successfully stop', () => { + cy.tableSimpleSearchText(zunContainerName) + .checkTableFirstRow(zunContainerName) + .clickActionInMore('Stop') + .clickConfirmActionSubmitButton() + .waitStatusTextByFresh('Stopped'); + }); + + it('successfully delete', () => { + cy.tableSimpleSearchText(zunContainerName) + .checkTableFirstRow(zunContainerName) + .clickFirstActionButton() + .clickConfirmActionSubmitButton() + .checkEmptyTable(); + }); + }); +}); diff --git a/test/e2e/support/constants.js b/test/e2e/support/constants.js index 36fcd61b..ebbdb668 100644 --- a/test/e2e/support/constants.js +++ b/test/e2e/support/constants.js @@ -61,6 +61,10 @@ export const settingUrl = '/configuration-admin/setting'; // stack export const stackListUrl = '/heat/stack'; +// zun +export const zunContainerListUrl = '/container/containers'; +export const zunCapsuleListUrl = '/container/capsules'; + export default { // compute instance: instanceListUrl,