Skip to content

Commit

Permalink
Rancher UI tests without Epinio icon
Browse files Browse the repository at this point in the history
  • Loading branch information
thehejik committed Sep 27, 2022
1 parent f73eb8a commit 3b399f7
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 10 deletions.
45 changes: 40 additions & 5 deletions .github/workflows/master_rancher_ui_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,44 @@ jobs:
cypress-epinio-tests:
needs:
- installation
- cypress-epinio-installation
- epinio-patching
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.cypress_image }}
env:
CLUSTER_NAME: local
RANCHER_USER: admin
RANCHER_PASSWORD: password
RANCHER_URL: https://epinio.${{ needs.installation.outputs.MY_IP }}.omg.howdoi.website
SYSTEM_DOMAIN: ${{ needs.installation.outputs.MY_IP }}.omg.howdoi.website
# set UI value to something else than 'rancher'
UI: epinio
options: --add-host ${{ needs.installation.outputs.MY_HOSTNAME}}:${{ needs.installation.outputs.MY_IP }} --ipc=host ${{ inputs.docker_options }}
steps:
- name: Cypress run
uses: cypress-io/github-action@v2
with:
browser: ${{ inputs.browser }}
headless: true
spec: |
cypress/integration/unit_tests/${{ inputs.cypress_test }}
config-file: cypress-with-epinio-cert.json

- name: Upload Cypress screenshots
uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots-tests
path: cypress/screenshots
retention-days: 7

cypress-epinio-uninstall:
needs:
- installation
- cypress-epinio-installation
- epinio-patching
- cypress-epinio-tests
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.cypress_image }}
Expand All @@ -201,30 +238,28 @@ jobs:
browser: ${{ inputs.browser }}
headless: true
spec: |
cypress/integration/scenarios/${{ inputs.cypress_test }}
cypress/integration/unit_tests/uninstall.spec.ts
config-file: cypress-with-epinio-cert.json

- name: Upload Cypress screenshots
uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots-tests
name: cypress-screenshots-uninstall
path: cypress/screenshots
retention-days: 7

# Test run video was always captured, so this action uses "always()" condition
- name: Upload Cypress videos
uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-videos-tests
name: cypress-videos-uninstall
path: cypress/videos
retention-days: 7

delete-cluster:
if: always()
needs: [installation, cypress-epinio-installation, epinio-patching, cypress-epinio-tests]
needs: [installation, cypress-epinio-installation, epinio-patching, cypress-epinio-tests, cypress-epinio-uninstall]
runs-on: ${{ inputs.runner }}
steps:

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scenario_1_chrome_rancher_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
browser: chrome
cypress_image: cypress/browsers:node16.13.2-chrome97-ff96
cypress_install_test: installation.spec.ts
cypress_test: with_default_options.spec.ts
# cypress_test: with_default_options.spec.ts
cypress_test: rancher-menu.spec.ts
runner: ui-e2e-0
secrets:
ext_reg_user: secrets.EPINIO_DOCKER_USER
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/scenario_2_firefox_rancher_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ jobs:
browser: firefox
cypress_image: cypress/browsers:node16.13.2-chrome97-ff96
cypress_install_test: installation.spec.ts
cypress_test: with_s3_and_external_registry.spec.ts
# cypress_test: with_s3_and_external_registry.spec.ts
cypress_test: rancher-menu.spec.ts
# Due to security reason, Firefox can't be started as root
# https://github.com/cypress-io/github-action#firefox
docker_options: '--user 1000'
runner: ui-e2e-2
ext_reg: '1'
# ext_reg: '1'
secrets:
ext_reg_user: secrets.EPINIO_DOCKER_USER
ext_reg_password: secrets.EPINIO_DOCKER_PASSWORD
s3_key_id: secrets.AWS_ACCESS_KEY_ID
s3_key_secret: secrets.AWS_SECRET_ACCESS_KEY
# s3_key_id: secrets.AWS_ACCESS_KEY_ID
# s3_key_secret: secrets.AWS_SECRET_ACCESS_KEY
1 change: 1 addition & 0 deletions cypress-with-epinio-cert.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"unit_tests/first_connexion.spec.ts",
"unit_tests/installation.spec.ts",
"unit_tests/menu.spec.ts",
"unit_tests/rancher-menu.spec.ts",
"unit_tests/applications.spec.ts",
"unit_tests/configurations.spec.ts",
"unit_tests/namespaces.spec.ts",
Expand Down
19 changes: 19 additions & 0 deletions cypress/integration/unit_tests/installation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,23 @@ describe('Epinio installation testing', () => {
// Boolean must be forced to false otherwise code is failing
cy.epinioInstall({s3: false, extRegistry: false});
});

it('Verify Epinio over ingress URL', () => {
// WORKAROUND until Epinio icon will be present again in Rancher UI
cy.contains('More Resources').click();
cy.contains('Networking').click();
cy.contains('Ingresses').click();
cy.contains('.ingress-target .target > a', 'epinio-ui')
.prevAll('a')
.invoke('attr', 'href').then( (href) => {
cy.origin(href, (href) => {
cy.visit('/');
cy.get('h1').contains('Welcome to Epinio').should('be.visible')
cy.url().then(url => {
const tempUrl= url.replace(/^(https:\/\/.*?)\/.*$/, "$1");
cy.log(`Epinio URL from ingress: ${tempUrl}`);
});
});
});
});
});
99 changes: 99 additions & 0 deletions cypress/integration/unit_tests/rancher-menu.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { Epinio } from '~/cypress/support/epinio';
import { TopLevelMenu } from '~/cypress/support/toplevelmenu';
import '~/cypress/support/functions';

Cypress.config();
describe('Simplyfied menu testing for Epinio installed in Rancher', () => {
const topLevelMenu = new TopLevelMenu();
const epinio = new Epinio();

beforeEach(() => {
cy.login();
cy.visit('/');
});

it('Check Epinio menu', () => {
epinio.checkEpinioNav();
});

it('Verify Welcome Screen without Namespaces', () => {
cy.clickEpinioMenu('Namespaces');
// Deletes all namespaces if detected
cy.get("body").then(($body) => {
if ($body.text().includes('Delete')) {
cy.deleteAllNamespaces()
}
}
)
cy.clickEpinioMenu('Applications');
cy.get('h1').contains('Welcome to Epinio').should('be.visible')
// Verify creating namespace from Get Started button works
cy.get('a.btn.role-secondary').contains('Get started').click()
cy.clickButton('Create');
const defaultNamespace = 'workspace'
cy.typeValue({label: 'Name', value: defaultNamespace});
cy.clickButton('Create');
// Check that the namespace has effectively been created
cy.contains(defaultNamespace).should('be.visible');
});

it('Check binary links from version in menu', () => {
// Check link in main page is present and works after clicking
cy.get('.version.text-muted > a').should('have.attr', 'href').and('include', '/epinio/about');
cy.get('.version.text-muted > a').click();

// Test in ABOUT page starts here
cy.get('table > tr > td:nth-child(2)').eq(0).invoke('text').then(version => {
cy.log(`Epinio version in ABOUT PAGE is ${version}`);
// Check "Go back" link
cy.get('.back-link').should('exist').click();
cy.get('span.label.no-icon').eq(0).contains('Applications').should('be.visible');
// Checks version displayed in about page is the same as in main page
// Later returns to About page
cy.get('.version.text-muted > a').invoke('text').should('contains', version).then(version_main => {
cy.log(`Epinio version in MAIN UI is ${version_main}`);
cy.visit('/epinio/about');
});

// Check all links work and match the expected version

// Verify amount of binaries in the page
cy.get('tr.link > td > a').should('have.length', 3);
const binOsNames = ['darwin-arm64', 'linux-arm64', 'windows-x86_64.zip'];

for (let i = 0; i < binOsNames.length; i++) {

// Verify binaries names and version match the one in the page
cy.get('tr.link > td > a').contains(binOsNames[i]).and('have.attr', 'href')
.and('include', `https://github.com/epinio/epinio/releases/download/${version}/epinio-${binOsNames[i]}`);

// Download binaries
// This is added to workaround Cypress error waiting for a page instead of downloading
// Source: https://github.com/cypress-io/cypress/issues/14857#issuecomment-785717474
cy.window().document().then(function (doc) {
doc.addEventListener('click', () => {
setTimeout(function () { doc.location.reload(); }, 5000);
});
// Now we can download
cy.get("tr.link > td > a").eq(i).click({ force: true });
// Adding a bit of wait prior executing command to ensure file is downloaded
cy.wait(1500);
});

// Verify files are downloaded in cypress/download and its stdout output
cy.exec(`find "cypress/downloads/" -name "epinio-${binOsNames[i]}*"`).its('stdout').should('contain', `${binOsNames[i]}`);
}

// Check link "See all packages" and visit binary page
// Check version number in binary page matches the one in Epinio
cy.get('.mt-5').contains('See all packages').invoke('attr', 'href').as('href_repo').then(() => {
cy.get('@href_repo').should('eq', `https://github.com/epinio/epinio/releases/tag/${version}`)
cy.origin('https://github.com', { args: { version } }, ({ version }) => {
cy.visit(`/epinio/epinio/releases/tag/${version}`);
cy.get('.d-inline.mr-3').should('contain', `${version}`);
cy.screenshot(`epinio-bin-repo-${version}`);
});
});
});
});
});

0 comments on commit 3b399f7

Please sign in to comment.