Skip to content

Commit

Permalink
Use the elemental plugin in the UI CI (#468)
Browse files Browse the repository at this point in the history
* Use Elemental plugin in UI CI
  • Loading branch information
juadk authored Oct 27, 2022
1 parent 9321436 commit bdde5dc
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 41 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/e2e-obs-Dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
with:
iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Dev:/Teal53/media/iso/elemental-teal.x86_64.iso
cluster_name: cluster-k3s
dashboard_version: latest
k8s_version_to_provision: v1.24.4+k3s1
rancher_channel: stable
rancher_version: latest
Expand All @@ -34,7 +33,6 @@ jobs:
with:
iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Dev:/Teal53/media/iso/elemental-teal.x86_64.iso
cluster_name: cluster-rke2
dashboard_version: latest
k8s_version_to_provision: v1.24.4+rke2r1
rancher_channel: stable
rancher_version: latest
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/e2e-obs-Stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
with:
iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Stable:/Teal53/media/iso/elemental-teal.x86_64.iso
cluster_name: cluster-k3s
dashboard_version: latest
k8s_version_to_provision: v1.24.4+k3s1
rancher_channel: stable
rancher_version: latest
Expand All @@ -34,7 +33,6 @@ jobs:
with:
iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Stable:/Teal53/media/iso/elemental-teal.x86_64.iso
cluster_name: cluster-rke2
dashboard_version: latest
k8s_version_to_provision: v1.24.4+rke2r1
rancher_channel: stable
rancher_version: latest
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/e2e-obs-Staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
with:
iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Staging:/Teal53/media/iso/elemental-teal.x86_64.iso
cluster_name: cluster-k3s
dashboard_version: latest
k8s_version_to_provision: v1.24.4+k3s1
rancher_channel: stable
rancher_version: latest
Expand All @@ -34,7 +33,6 @@ jobs:
with:
iso_to_test: https://download.opensuse.org/repositories/isv:/Rancher:/Elemental:/Staging:/Teal53/media/iso/elemental-teal.x86_64.iso
cluster_name: cluster-rke2
dashboard_version: latest
k8s_version_to_provision: v1.24.4+rke2r1
rancher_channel: stable
rancher_version: latest
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
credentials: ${{ secrets.GCP_CREDENTIALS }}
with:
cluster_name: cluster-k3s
dashboard_version: latest
k8s_version_to_provision: v1.24.4+k3s1
rancher_channel: stable
rancher_version: latest
Expand All @@ -38,7 +37,6 @@ jobs:
credentials: ${{ secrets.GCP_CREDENTIALS }}
with:
cluster_name: cluster-rke2
dashboard_version: latest
k8s_version_to_provision: v1.24.4+rke2r1
rancher_channel: stable
rancher_version: latest
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/master-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ on:
description: Name of the provisioned cluster
required: true
type: string
dashboard_version:
description: Version of the dashboard UI to use
required: true
type: string
iso_to_test:
description: ISO to test (default built one is empty)
required: false
Expand Down Expand Up @@ -136,7 +132,6 @@ jobs:
# Looks a little bit weird but we have to keep the ISO in build!
mv -f elemental-*.iso build/
- name: Clean local Helm repositories
if: ${{ inputs.test_type == 'cli' }}
run: |
# Clean Helm repo
HELM_REPO=$(helm repo list 2>/dev/null | awk '(NR>1) { print $1 }')
Expand All @@ -158,6 +153,7 @@ jobs:
RANCHER_USER: admin
SPEC: |
cypress/e2e/unit_tests/first_connection.spec.ts
cypress/e2e/unit_tests/elemental_plugin.spec.ts
cypress/e2e/unit_tests/menu.spec.ts
cypress/e2e/unit_tests/machine_registration.spec.ts
run: make -f tests/Makefile start-cypress-tests
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ui-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ jobs:
credentials: ${{ secrets.GCP_CREDENTIALS }}
with:
cluster_name: cluster-k3s
dashboard_version: elemental-dev
k8s_version_to_provision: v1.24.4+k3s1
rancher_channel: stable
rancher_version: latest
rancher_channel: latest
rancher_version: devel
runner: elemental-e2e-ci-runner-spot-x86-64-1
start_condition: success
test_type: ui
Expand Down
40 changes: 40 additions & 0 deletions cypress/e2e/unit_tests/elemental_plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { TopLevelMenu } from '~/cypress/support/toplevelmenu';
import '~/cypress/support/functions';
import { Elemental } from '../../support/elemental';

Cypress.config();
describe('Install Elemental plugin', () => {
const topLevelMenu = new TopLevelMenu();
const elemental = new Elemental();

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

it('Add elemental-ui repo', () => {
topLevelMenu.openIfClosed();
cy.contains('local').click();
cy.addHelmRepo({repoName: 'elemental-ui', repoUrl: 'https://github.com/rancher/elemental-ui.git', repoType: 'git'});
});

it('Enable extension support', () => {
topLevelMenu.openIfClosed();
cy.contains('Extensions').click();
cy.clickButton('Enable');
cy.contains('Enable Extension Support?')
cy.clickButton('OK');
cy.contains('No Extensions installed', {timeout: 40000});
});

it('Install Elemental plugin', () => {
topLevelMenu.openIfClosed();
cy.contains('Extensions').click();
cy.contains('elemental');
cy.get('.plugin').contains('Install').click();
cy.contains('Install Extension elemental');
cy.clickButton('Install');
cy.contains('Installing');
cy.wait(20000);
});
});
2 changes: 2 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare global {
confirmDelete(): Chainable<Element>;
clickNavMenu(listLabel: string[],): Chainable<Element>;
clickElementalMenu(label: string,): Chainable<Element>;
clickClusterMenu(listLabel: string[],): Chainable<Element>;
typeValue(label: string, value: string, noLabel?: boolean, log?: boolean): Chainable<Element>;
typeKeyValue(key: string, value: string,): Chainable<Element>;
getDetail(name: string, type: string, namespace?: string): Chainable<Element>;
Expand All @@ -22,6 +23,7 @@ declare global {
checkMachRegAnnotation(machRegName: string, annotationName: string, annotationValue: string):Chainable<Element>;
addMachRegAnnotation(annotationName: string, annotationValue: string):Chainable<Element>;
editMachReg(machRegName: string, addLabel?: boolean, addAnnotation?: boolean, withYAML?: boolean): Chainable<Element>;
addHelmRepo(repoName: string, repoUrl: string, repoType?: string,): Chainable<Element>;
}
}}

Expand Down
14 changes: 6 additions & 8 deletions cypress/support/elemental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ export class Elemental {
firstLogin() {
cy.get('input').type(Cypress.env('password'), {log: false});
cy.clickButton('Log in with Local User');
cy.contains('I agree').click('left');
cy.contains('By checking').click('left');
cy.clickButton('Continue');
cy.contains("Getting Started", {timeout: 10000});
cy.get('[data-testid="banner-title"]').contains('Welcome to Rancher');
}

elementalIcon() {
Expand All @@ -24,15 +24,13 @@ export class Elemental {

// Check all listed options once accordion is opened
cy.get('li.child.nav-type').should(($lis) => {
expect($lis).to.have.length(8);
expect($lis).to.have.length(6);
expect($lis.eq(0)).to.contain('Dashboard');
expect($lis.eq(1)).to.contain('Machine Registrations');
expect($lis.eq(2)).to.contain('Machine Inventories');
expect($lis.eq(3)).to.contain('Mach. Inv. Selectors');
expect($lis.eq(4)).to.contain('Mach. Inv. Selec. Templates');
expect($lis.eq(5)).to.contain('Managed OS Versions');
expect($lis.eq(6)).to.contain('Managed OS Version Channels');
expect($lis.eq(7)).to.contain('OS Image Upgrades');
expect($lis.eq(3)).to.contain('Managed OS Versions');
expect($lis.eq(4)).to.contain('Managed OS Version Channels');
expect($lis.eq(5)).to.contain('OS Image Upgrades');
})
}

Expand Down
38 changes: 33 additions & 5 deletions cypress/support/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Cypress.Commands.add('login', (username = Cypress.env('username'), password = Cy

cy.get('button').click();
cy.wait('@loginReq');
cy.contains("Getting Started", {timeout: 10000}).should('be.visible');
cy.get('[data-testid="banner-title"]').contains('Welcome to Rancher');
}

if (cacheSession) {
Expand Down Expand Up @@ -60,6 +60,13 @@ Cypress.Commands.add('typeValue', ({label, value, noLabel, log=true}) => {
}
});

// Make sure we are in the desired menu inside a cluster (local by default)
// You can access submenu by giving submenu name in the array
// ex: cy.clickClusterMenu(['Menu', 'Submenu'])
Cypress.Commands.add('clickClusterMenu', (listLabel: string[]) => {
listLabel.forEach(label => cy.get('nav').contains(label).click());
});

// Insert a key/value pair
Cypress.Commands.add('typeKeyValue', ({key, value}) => {
cy.get(key).clear().type(value);
Expand Down Expand Up @@ -87,6 +94,27 @@ for (const command of ['visit', 'click', 'trigger', 'type', 'clear', 'reload', '
});
};

// Add Helm repo
Cypress.Commands.add('addHelmRepo', ({repoName, repoUrl, repoType}) => {
cy.clickClusterMenu(['Apps', 'Repositories'])

// Make sure we are in the 'Repositories' screen (test failed here before)
cy.contains('header', 'Repositories', {timeout: 8000}).should('be.visible');
cy.contains('Create').should('be.visible');

cy.clickButton('Create');
cy.contains('Repository: Create').should('be.visible');
cy.typeValue({label: 'Name', value: repoName});
if (repoType === 'git') {
cy.contains('Git repository').click();
cy.typeValue({label: 'Git Repo URL', value: repoUrl});
cy.typeValue({label: 'Git Branch', value: 'main'});
} else {
cy.typeValue({label: 'Index URL', value: repoUrl});
}
cy.clickButton('Create');
});

// Machine registration functions

// Create a machine registration
Expand All @@ -105,16 +133,16 @@ Cypress.Commands.add('createMachReg', ({machRegName, namespace='fleet-default',
if (checkLabels) {
cy.clickButton('Add Label');
cy.contains('.row', 'Labels').within(() => {
cy.get('.kv-item.key').type('myLabel1');
cy.get('.kv-item.value').type('myLabelValue1');
cy.get(':nth-child(2) > [data-layer="Content"]').type('myLabel1');
cy.get(':nth-child(1) > .key-value > .kv-container > .value > .no-resize').type('myLabelValue1');
})
}

if (checkAnnotations) {
cy.clickButton('Add Annotation')
cy.contains('.row', 'Annotations').within(() => {
cy.get('.kv-item.key').type('myAnnotation1');
cy.get('.kv-item.value').type('myAnnotationValue1');
cy.get(':nth-child(3) > [data-layer="Content"]').type('myAnnotation1');
cy.get(':nth-child(3) > .key-value > .kv-container > .value > .no-resize').type('myAnnotationValue1');
})
}

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "epinio-end-to-end-tests",
"name": "elemental-ui-e2e",
"version": "1.0.0",
"description": "Cypress tests to test the Epinio UI",
"description": "Cypress tests to test the Elemental UI",
"main": "index.js",
"directories": {
"doc": "docs"
Expand All @@ -11,15 +11,15 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/epinio/epinio-end-to-end-tests.git"
"url": "git+https://github.com/rancher/elemental.git"
},
"keywords": [],
"author": "Epinio team",
"author": "Elemental team",
"license": "ISC",
"bugs": {
"url": "https://github.com/epinio/epinio-end-to-end-tests/issues"
"url": "https://github.com/rancher/elemental/issues"
},
"homepage": "https://github.com/epinio/epinio-end-to-end-tests#readme",
"homepage": "https://github.com/rancher/elemental#readme",
"dependencies": {
"cy-verify-downloads": "^0.1.8",
"cypress": "^10.0.0",
Expand Down
11 changes: 5 additions & 6 deletions tests/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ var _ = Describe("E2E - Install Rancher Manager", Label("install"), func() {

// Set flags for Rancher Manager installation
hostname := os.Getenv("HOSTNAME")
uiVersion := os.Getenv("DASHBOARD_VERSION")
flags := []string{
"upgrade", "--install", "rancher", "rancher/rancher",
"--namespace", "cattle-system",
Expand All @@ -119,16 +118,16 @@ var _ = Describe("E2E - Install Rancher Manager", Label("install"), func() {
"--set", "extraEnv[0].value=https://" + hostname,
"--set", "extraEnv[1].name=CATTLE_BOOTSTRAP_PASSWORD",
"--set", "extraEnv[1].value=rancherpassword",
"--set", "extraEnv[2].name=CATTLE_UI_DASHBOARD_INDEX",
"--set", "extraEnv[2].value=https://releases.rancher.com/dashboard/" + uiVersion + "/index.html",
"--set", "extraEnv[3].name=CATTLE_UI_OFFLINE_PREFERRED",
"--set", "extraEnv[3].value=Remote",
"--set", "replicas=1",
}

// Set specified version if needed
if rancherVersion != "" && rancherVersion != "latest" {
flags = append(flags, "--version", rancherVersion)
if rancherVersion == "devel" {
flags = append(flags, "--devel")
} else {
flags = append(flags, "--version", rancherVersion)
}
}

err = kubectl.RunHelmBinaryWithCustomErr(flags...)
Expand Down

0 comments on commit bdde5dc

Please sign in to comment.