Skip to content

Commit

Permalink
ci/ui: create function to create cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
juadk committed Sep 8, 2023
1 parent 220d427 commit 3f52fd9
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 113 deletions.
58 changes: 2 additions & 56 deletions tests/cypress/latest/e2e/unit_tests/machine_inventory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ limitations under the License.

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

Expand Down Expand Up @@ -81,61 +81,7 @@ describe('Machine inventory testing', () => {
filterTests(['main', 'upgrade'], () => {
qase(30,
it('Create Elemental cluster', () => {
cy.getBySel('button-create-elemental-cluster')
.click();
cy.getBySel('name-ns-description-name')
.type(clusterName);
cy.getBySel('name-ns-description-description')
.type('My Elemental testing cluster');
cy.contains('Show deprecated Kubernetes')
.click();
cy.contains('Kubernetes Version')
.click();
cy.contains(k8sVersion)
.click();
// Configure proxy if proxy is set to elemental
if ( Cypress.env('proxy') == "elemental") {
cy.contains('Agent Environment Vars')
.click();
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get('.key > input')
.type('HTTP_PROXY');
cy.get('.no-resize')
.type(proxy);
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get(':nth-child(7) > input')
.type('HTTPS_PROXY');
if (isRancherManagerVersion('-head')) {
cy.get(':nth-child(8) > > [data-testid="text-area-auto-grow"]').type(proxy);
} else {
cy.get(':nth-child(8) > .no-resize').type(proxy);
}
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get(':nth-child(10) > input')
.type('NO_PROXY');
if (isRancherManagerVersion('-head')) {
cy.get(':nth-child(11) > > [data-testid="text-area-auto-grow"]')
.type('localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local');
} else {
cy.get(':nth-child(11) > .no-resize')
.type('localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local');
}
}
cy.clickButton('Create');
// This wait can be replaced by something cleaner
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(3000);
cypressLib.checkClusterStatus(clusterName, 'Updating', 300000);
cypressLib.checkClusterStatus(clusterName, 'Active', 600000);
// Ugly but needed unfortunately to make sure the cluster stops switching status
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(240000);
utils.createCluster(clusterName, k8sVersion, proxy);
})
);
});
Expand Down
59 changes: 3 additions & 56 deletions tests/cypress/latest/e2e/unit_tests/reset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ limitations under the License.
*/
import '~/support/commands';
import filterTests from '~/support/filterTests.js';
import * as utils from "~/support/utils";
import * as cypressLib from '@rancher-ecp-qa/cypress-library';
import { qase } from 'cypress-qase-reporter/dist/mocha';

Expand Down Expand Up @@ -53,61 +54,7 @@ filterTests(['main'], () => {
}));

it('Create Elemental cluster', () => {
cy.getBySel('button-create-elemental-cluster')
.click();
cy.getBySel('name-ns-description-name')
.type(clusterName);
cy.getBySel('name-ns-description-description')
.type('My Elemental testing cluster');
cy.contains('Show deprecated Kubernetes')
.click();
cy.contains('Kubernetes Version')
.click();
cy.contains(k8sVersion)
.click();
// Configure proxy if proxy is set to elemental
if ( Cypress.env('proxy') == "elemental") {
cy.contains('Agent Environment Vars')
.click();
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get('.key > input')
.type('HTTP_PROXY');
cy.get('.no-resize')
.type(proxy);
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get(':nth-child(7) > input')
.type('HTTPS_PROXY');
if (isRancherManagerVersion('-head')) {
cy.get(':nth-child(8) > > [data-testid="text-area-auto-grow"]').type(proxy);
} else {
cy.get(':nth-child(8) > .no-resize').type(proxy);
}
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get(':nth-child(10) > input')
.type('NO_PROXY');
if (isRancherManagerVersion('-head')) {
cy.get(':nth-child(11) > > [data-testid="text-area-auto-grow"]')
.type('localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local');
} else {
cy.get(':nth-child(11) > .no-resize')
.type('localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local');
}
}
cy.clickButton('Create');
// This wait can be replaced by something cleaner
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(3000);
cypressLib.checkClusterStatus(clusterName, 'Updating', 300000);
cypressLib.checkClusterStatus(clusterName, 'Active', 600000);
// Ugly but needed unfortunately to make sure the cluster stops switching status
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(240000);
})
utils.createCluster(clusterName, k8sVersion, proxy);
});
});
});
62 changes: 61 additions & 1 deletion tests/cypress/latest/support/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as cypressLib from '@rancher-ecp-qa/cypress-library';

// Check the Cypress tags
// Implemented but not used yet
export const isCypressTag = (tag: string) => {
Expand Down Expand Up @@ -28,4 +30,62 @@ export const isUIVersion = (version: string) => {
// Check the upgrade target
export const isUpgradeOsChannel = (channel: string) => {
return (new RegExp(channel)).test(Cypress.env("upgrade_os_channel"));
}
}

export const createCluster = (clusterName: string, k8sVersion: string, proxy: string) => {
cy.getBySel('button-create-elemental-cluster')
.click();
cy.getBySel('name-ns-description-name')
.type(clusterName);
cy.getBySel('name-ns-description-description')
.type('My Elemental testing cluster');
cy.contains('Show deprecated Kubernetes')
.click();
cy.contains('Kubernetes Version')
.click();
cy.contains(k8sVersion)
.click();
// Configure proxy if proxy is set to elemental
if ( Cypress.env('proxy') == "elemental") {
cy.contains('Agent Environment Vars')
.click();
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get('.key > input')
.type('HTTP_PROXY');
cy.get('.no-resize')
.type(proxy);
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get(':nth-child(7) > input')
.type('HTTPS_PROXY');
if (isRancherManagerVersion('-head')) {
cy.get(':nth-child(8) > > [data-testid="text-area-auto-grow"]').type(proxy);
} else {
cy.get(':nth-child(8) > .no-resize').type(proxy);
}
cy.get('#agentEnv > .key-value')
.contains('Add')
.click();
cy.get(':nth-child(10) > input')
.type('NO_PROXY');
if (isRancherManagerVersion('-head')) {
cy.get(':nth-child(11) > > [data-testid="text-area-auto-grow"]')
.type('localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local');
} else {
cy.get(':nth-child(11) > .no-resize')
.type('localhost,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.svc,.cluster.local');
}
}
cy.clickButton('Create');
// This wait can be replaced by something cleaner
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(3000);
cypressLib.checkClusterStatus(clusterName, 'Updating', 300000);
cypressLib.checkClusterStatus(clusterName, 'Active', 600000);
// Ugly but needed unfortunately to make sure the cluster stops switching status
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(240000);
}

0 comments on commit 3f52fd9

Please sign in to comment.