Skip to content

Commit

Permalink
Merge pull request #233 from epinio/rancher-ui
Browse files Browse the repository at this point in the history
Rancher UI tests without Epinio icon
  • Loading branch information
thehejik authored Oct 7, 2022
2 parents 713bd7e + ba36ee2 commit 3c19811
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 26 deletions.
53 changes: 49 additions & 4 deletions .github/workflows/master_rancher_ui_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,54 @@ 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-rancher
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

# 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
path: cypress/videos
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 }}
env:
Expand All @@ -201,15 +247,14 @@ 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

Expand All @@ -218,13 +263,13 @@ jobs:
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: 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: 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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ make cypress-gui
```

## Scenario 1 - Using Chrome
In this first scenario, Epinio is deployed with default options. </br>
You can check all the things we test directly in the [file](./cypress/integration/scenarios/with_default_options.spec.ts).
In this first scenario, Epinio is deployed in Rancher with default options. </br>
And then basic UI test is performed [menu.spec.ts](./cypress/integration/unit_tests/menu.spec.ts).
<!-- You can check all the things we test directly in the [file](./cypress/integration/scenarios/with_default_options.spec.ts). -->

## Scenario 2 - Using Firefox
Second scenario tests Epinio installation with S3 and external registry configured. </br>
Unlike the first scenario, we only play a small bunch of [tests](./cypress/integration/scenarios/with_s3_and_external_registry.spec.ts).
Second scenario is the same as the first one just performed in Firefox. </br>
TODO: Get back installation with S3 and external registry configuration within rancher installation. Ref. [Issue#236](https://github.com/epinio/epinio-end-to-end-tests/issues/236)
<!-- Second scenario tests Epinio installation with S3 and external registry configured. </br>
Unlike the first scenario, we only play a small bunch of [tests](./cypress/integration/scenarios/with_s3_and_external_registry.spec.ts). -->

## Process explained in one chart
```mermaid
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}`);
});
});
});
});
});
56 changes: 44 additions & 12 deletions cypress/integration/unit_tests/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ describe('Menu testing', () => {
cy.login();
cy.visit('/');
});

it('Check Epinio menu', () => {
if (Cypress.env('ui') == "rancher") {
topLevelMenu.openIfClosed();

// Epinio's icon should appear in the side menu
epinio.epinioIcon().should('exist');

// Click on the Epinio's logo as well as your Epinio instance
// Click on the Epinio's logo as well as your Epinio instance
epinio.accessEpinioMenu(Cypress.env('cluster'));
}

Expand Down Expand Up @@ -68,7 +68,7 @@ describe('Menu testing', () => {

// Check all links work and match the expected version

// Verify amount of binaries in the page
// 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'];

Expand All @@ -80,7 +80,7 @@ describe('Menu testing', () => {

// 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
// 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);
Expand All @@ -106,10 +106,12 @@ describe('Menu testing', () => {
});
});
});
});
});
});

// // Note: this test may need to be adapted with Rancher Dashboard
// Note: this test needs to be adapted for Rancher Dashboard
// Currently we are good if the custom user is unable to login when chart installed over Rancher
// We'd need to apply values.yaml with the users first in Edit YAML
describe('Login with different users', () => {

it('Check login with admin user', () => {
Expand All @@ -132,23 +134,53 @@ describe('Login with different users', () => {
const user_epinio = "user1"
const pwd_epinio = "Hell@World"
cy.login(user_epinio, pwd_epinio);
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
if (Cypress.env('ui') == null ) {
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
}
// Login fails when installed from rancher
else if (Cypress.env('ui') == 'epinio-rancher' || Cypress.env('ui') == 'rancher') {
cy.contains('Invalid username or password. Please try again.').should('exist')
cy.exec('echo "Negative testing for users. This user not allowed to log in unless values-users.yaml is applied."')
}
else {
throw new Error('ERROR: Variable "ui" is set to an unexpected value.')
}
});

it('Check login with regular user "user2" and password with many special characters', () => {
const user_epinio = "user2"
const pwd_epinio = "Hell#@~%/=World"
cy.login(user_epinio, pwd_epinio);
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
if (Cypress.env('ui') == null ) {
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
}
// Login fails when installed from rancher
else if (Cypress.env('ui') == 'epinio-rancher' || Cypress.env('ui') == 'rancher') {
cy.contains('Invalid username or password. Please try again.').should('exist')
cy.exec('echo "Negative testing for users. This user not allowed to log in unless values-users.yaml is applied."')
}
else {
throw new Error('ERROR: Variable "ui" is set to an unexpected value.')
}
});

it('Check login with admin user name with special character (user@test) and password also with special characters', () => {
const user_epinio = "user@test"
const pwd_epinio = "Hell@World"
cy.login(user_epinio, pwd_epinio);
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
if (Cypress.env('ui') == null ) {
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
}
// Login fails when installed from rancher
else if (Cypress.env('ui') == 'epinio-rancher' || Cypress.env('ui') == 'rancher') {
cy.contains('Invalid username or password. Please try again.').should('exist')
cy.exec('echo "Negative testing for users. This user not allowed to log in unless values-users.yaml is applied."')
}
else {
throw new Error('ERROR: Variable "ui" is set to an unexpected value.')
}
});
})
5 changes: 4 additions & 1 deletion cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ Cypress.on('uncaught:exception', (err, runnable, promise) => {
if (err.message.includes('navigation guard')) {
return false;
}
if (err.message.includes('on cross-origin object')) {
return false;
}
if (promise) {
return false;
return false;
}
});

Expand Down

0 comments on commit 3c19811

Please sign in to comment.