Skip to content

Commit

Permalink
Automate CAPG (#86)
Browse files Browse the repository at this point in the history
Signed-off-by: Chandan Pinjani <chandan.pinjani@suse.com>
  • Loading branch information
cpinjani authored Dec 6, 2024
1 parent d4561c6 commit 1d0714c
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/master-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ jobs:
e2e/unit_tests/capa_rke2_cluster.spec.ts
e2e/unit_tests/capa_eks_cluster.spec.ts
e2e/unit_tests/capz_cluster.spec.ts
e2e/unit_tests/capg_cluster.spec.ts
UI_ACCOUNT: ${{ inputs.ui_account }}
UPGRADE_OS_CHANNEL: ${{ inputs.upgrade_os_channel }}
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: turtles-qa
spec:
clusterNetwork:
pods:
cidrBlocks: [192.168.0.0/16]
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedCluster
name: turtles-qa
controlPlaneRef:
kind: GCPManagedControlPlane
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
name: turtles-qa-control-plane
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedCluster
metadata:
name: turtles-qa
spec:
project: ei-container-eco
region: asia-south2
network:
name: hosted-providers-ci
---
kind: GCPManagedControlPlane
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
metadata:
name: turtles-qa-control-plane
spec:
project: ei-container-eco
location: asia-south2
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: turtles-qa-mp-0
annotations:
"helm.sh/resource-policy": keep
spec:
clusterName: turtles-qa
replicas: 1
template:
spec:
bootstrap:
dataSecretName: ""
clusterName: turtles-qa
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedMachinePool
name: turtles-qa-mp-0
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedMachinePool
metadata:
name: turtles-qa-mp-0
spec:
nodeLocations:
- asia-south2-c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace: default
83 changes: 83 additions & 0 deletions tests/cypress/latest/e2e/unit_tests/capg_cluster.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import '~/support/commands';
import * as cypressLib from '@rancher-ecp-qa/cypress-library';
import { qase } from 'cypress-qase-reporter/dist/mocha';

Cypress.config();
describe('Import CAPG GKE', { tags: '@full' }, () => {
const timeout = 1200000
const repoName = 'clusters'
const clusterName = 'turtles-qa'
const branch = 'main'
const path = '/tests/assets/rancher-turtles-fleet-example/gcp_gke'
const repoUrl = 'https://github.com/rancher/rancher-turtles-e2e.git'

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

it('Setup the namespace for importing', () => {
cy.namespaceAutoImport('Enable');
})

qase(34,
it('Add CAPG cluster fleet repo', () => {
cypressLib.checkNavIcon('cluster-management')
.should('exist');

// Add CAPG fleet repository
cy.addFleetGitRepo(repoName, repoUrl, branch, path);

// Go to Cluster Management > CAPI > Clusters and check if the cluster has started provisioning
cy.checkCAPIMenu();
cy.contains(new RegExp('Provisioned.*' + clusterName), { timeout: timeout });
})
);

qase(36,
it('Auto import child CAPG cluster', () => {
// Check child cluster is created and auto-imported
cy.goToHome();
cy.contains(new RegExp('Pending.*' + clusterName));

// Check cluster is Active
cy.searchCluster(clusterName);
cy.contains(new RegExp('Active.*' + clusterName), { timeout: 300000 });
})
);

qase(37,
it('Install App on imported cluster', { retries: 1 }, () => {
// Click on imported CAPG cluster
cy.contains(clusterName).click();

// Install App
cy.installApp('Monitoring', 'cattle-monitoring');
})
);

qase(38,
it('Remove imported CAPG cluster from Rancher Manager', { retries: 1 }, () => {

// Check cluster is not deleted after removal
cy.deleteCluster(clusterName);
cy.goToHome();
// kubectl get clusters.cluster.x-k8s.io
// This is checked by ensuring the cluster is not available in navigation menu
cy.contains(clusterName).should('not.exist');
cy.checkCAPIClusterProvisioned(clusterName);
})
);

qase(39,
it('Delete the CAPG cluster fleet repo', () => {

// Remove the fleet git repo
cy.removeFleetGitRepo(repoName)
// Wait until the following returns no clusters found
// This is checked by ensuring the cluster is not available in CAPI menu
cy.checkCAPIClusterDeleted(clusterName, timeout);
})
);

});

0 comments on commit 1d0714c

Please sign in to comment.