Skip to content

Commit

Permalink
Import CAPD cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Pinjani <chandan.pinjani@suse.com>
  • Loading branch information
cpinjani committed Dec 19, 2023
1 parent 244e8d6 commit 92bc2ff
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/master-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ jobs:
/workdir/e2e/unit_tests/turtles_plugin.spec.ts
/workdir/e2e/unit_tests/menu.spec.ts
/workdir/e2e/unit_tests/namespace.spec.ts
/workdir/e2e/unit_tests/capd_setup.spec.ts
/workdir/e2e/unit_tests/capd_cluster.spec.ts
UI_ACCOUNT: ${{ inputs.ui_account }}
UPGRADE_OS_CHANNEL: ${{ inputs.upgrade_os_channel }}
run: cd tests && make start-cypress-tests
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# rancher-turtles-e2e

What tests are doing:
1. Create the infra stack ( GCP runner, cert-manager, rancher )
2. Install the Turtles operator with locally built nightly chart
3. Deploy the Turtles UI extension
4. Test the Turtles menu, namespaces import features
5. Perform CAPD setup prerequisites
6. Create & Import CAPD cluster using fleet
7. Install App on imported cluster


[![UI-RM_head_2.7](https://github.com/rancher-sandbox/rancher-turtles-e2e/actions/workflows/ui-rm_head_2.7.yaml/badge.svg?branch=main)](https://github.com/rancher-sandbox/rancher-turtles-e2e/actions/workflows/ui-rm_head_2.7.yaml)

[![UI-RM_head_2.8](https://github.com/rancher-sandbox/rancher-turtles-e2e/actions/workflows/ui-rm_head_2.8.yaml/badge.svg?branch=main)](https://github.com/rancher-sandbox/rancher-turtles-e2e/actions/workflows/ui-rm_head_2.8.yaml)
94 changes: 94 additions & 0 deletions tests/cypress/latest/e2e/unit_tests/capd_cluster.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
Copyright © 2022 - 2023 SUSE LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import '~/support/commands';
import * as cypressLib from '@rancher-ecp-qa/cypress-library';
import { qase } from 'cypress-qase-reporter/dist/mocha';

Cypress.config();
describe('Import CAPD', () => {
const cluster = "cluster1-capi"
const repo = "https://github.com/rancher-sandbox/rancher-turtles-fleet-example.git"

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

qase(14,
it('Import CAPD cluster using fleet', () => {
cypressLib.checkNavIcon('cluster-management')
.should('exist');

// Click on the Continuous Delivery's icon
cypressLib.accesMenu('Continuous Delivery');
cypressLib.accesMenu('Git Repos');

// Change fleet namespace
cy.contains('fleet-default').click();
cy.contains('fleet-local').click();

// Add CAPD fleet repository
cy.clickButton('Add Repository');
cy.typeValue('Name', 'clusters');
cy.typeValue('Repository URL', repo);
cy.typeValue('Branch Name', 'main');

// Create Git repo
cy.clickButton('Next');
cy.clickButton('Create');
cy.contains('clusters').click();

// Check cluster is created and auto-imported
cypressLib.burgerMenuToggle();
cypressLib.checkClusterStatus(cluster, 'Pending', 120000);

// Check cluster is Active
cy.clickButton('Manage');
cy.contains('Active' + ' ' + cluster, {timeout: 120000});
})
);


qase(15,
it('Install App on imported cluster', () => {

// Click on imported CAPD cluster
cy.contains(cluster).click();
cy.get('.nav').contains('Apps')
.click();
cy.contains('Monitoring', {timeout:30000})
.click();
cy.contains('Charts: Monitoring', {timeout:30000});

// Install monitoring app
cy.clickButton('Install');
cy.contains('.outer-container > .header', 'Monitoring');
cy.clickButton('Next');
cy.clickButton('Install');

// Close the shell to avoid conflict
cy.get('.closer', {timeout:20000})
.click();
cy.contains('Only User Namespaces') // eslint-disable-line cypress/unsafe-to-chain-command
.click()
.type('cattle-monitoring-system{enter}{esc}');

// Resource should be deployed (green badge)
cy.get('.outlet').contains('Deployed rancher-monitoring', {timeout: 240000});

})
);

});
103 changes: 103 additions & 0 deletions tests/cypress/latest/e2e/unit_tests/capd_setup.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
Copyright © 2022 - 2023 SUSE LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import '~/support/commands';
import * as cypressLib from '@rancher-ecp-qa/cypress-library';
import { qase } from 'cypress-qase-reporter/dist/mocha';

Cypress.config();
describe('Enable CAPD provider', () => {
const namespace = "capd-system"
const deployment = "rancher-turtles-controller-manager"

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

qase(11,
it('CAPD prerequisites', () => {

// Open Rancher turtles deployment
cy.contains('local')
.click();
cy.get('.nav').contains('Workloads')
.click();
cy.get('.nav').contains('Deployments')
.click();
cy.contains('Only User Namespaces') // eslint-disable-line cypress/unsafe-to-chain-command
.click()
.type('rancher-turtles-system{enter}{esc}');

// Edit Rancher turtles deployment
cy.getBySel('sortable-table-1-action-button').click();
cy.contains('Edit Config')
.click();
cy.byLabel('Arguments').as('label')
cy.get('@label').type(' --insecure-skip-verify=true')
cy.clickButton('Save');
cy.contains('Active' + ' ' + deployment, {timeout: 20000});
cy.getBySel('namespaces-values-close-0')
.click();
cy.contains('Only User Namespaces')
.click();
})
);

qase(12,
it('Create CAPD namespace', () => {
cy.contains('local')
.click();
cypressLib.accesMenu('Projects/Namespaces');
cy.contains('Only User Namespaces') // eslint-disable-line cypress/unsafe-to-chain-command
.click()
.type('Not{enter}{esc}');

// Create CAPD namespace
cy.contains('Create Namespace')
.click();
cy.typeValue('Name', namespace);
cy.clickButton('Create');
cy.contains('Active' + ' ' + namespace);

cy.getBySel('namespaces-values').click();
cy.contains('Only User Namespaces')
.click();
})
);

qase(13,
it('Create CAPD provider', () => {
cypressLib.checkNavIcon('cluster-management')
.should('exist');
cypressLib.accesMenu('Cluster Management');

// Open Turtles menu
cypressLib.accesMenu('CAPI');

// Create CAPD Infrastructure provider
cy.contains('.nav', "Infrastructure Providers").click();
cy.clickButton('Create from YAML')
cy.readFile('./fixtures/capd-provider.yaml').then((data) => {
cy.get('.CodeMirror')
.then((editor) => {
editor[0].CodeMirror.setValue(data);
})
})
cy.clickButton('Create')
cy.contains('Active ' + 'docker');
})
);

});
8 changes: 8 additions & 0 deletions tests/cypress/latest/fixtures/capd-provider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: operator.cluster.x-k8s.io/v1alpha1
kind: InfrastructureProvider
metadata:
name: docker
namespace: capd-system
spec:
secretName: capi-env-variables
secretNamespace: capi-system
9 changes: 9 additions & 0 deletions tests/scripts/start-cypress-tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ pushd cypress/latest
# Needed to install Cypress plugins
npm install

# Create network for CAPD, TODO: find way to run via cy.exec()
docker network create \
--driver=bridge \
--subnet=172.19.0.0/16 \
--gateway=172.19.0.1 \
--opt "com.docker.network.bridge.enable_ip_masquerade"="true" \
--opt "com.docker.network.driver.mtu"="1500" \
kind

# Start Cypress tests with docker
docker run -v $PWD:/workdir -w /workdir \
-e CYPRESS_TAGS=$CYPRESS_TAGS \
Expand Down

0 comments on commit 92bc2ff

Please sign in to comment.