Skip to content

Commit

Permalink
Rancher UI tests without Epinio icon
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Hehejik <[email protected]>
  • Loading branch information
thehejik committed Sep 27, 2022
1 parent 713bd7e commit 5cc5f64
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 27 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: 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
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}`);
});
});
});
});
});
49 changes: 32 additions & 17 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,49 +106,64 @@ 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', () => {
const user_epinio = "admin"
const pwd_epinio = "password"
cy.login(user_epinio, pwd_epinio);
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
});

it('Check login with regular user and simple password', () => {
const user_epinio = "epinio"
const pwd_epinio = "password"
cy.login(user_epinio, pwd_epinio);
cy.contains('Invalid username or password. Please try again.').should('not.exist')
cy.contains('Applications').should('be.visible')
});

it('Check login with regular user "user1" and password with special characters', () => {
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' || Cypress.env('ui') == 'rancher') {
cy.contains('Invalid username or password. Please try again.').should('exist')
}
});

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' || Cypress.env('ui') == 'rancher') {
cy.contains('Invalid username or password. Please try again.').should('exist')
}
});

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' || Cypress.env('ui') == 'rancher') {
cy.contains('Invalid username or password. Please try again.').should('exist')
}
});
})

0 comments on commit 5cc5f64

Please sign in to comment.