Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove global org and global project from tests #2858

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cypress/CYPRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ End-to-End tests for our project are located in the `cypress/e2e` directory. The

- Each test should be independent and capable of running on its own without relying on the state created by previous tests.
- Ideally, tests should not rely on a previously created resource, and whenever possible, the test should create the resources it needs.
- There are several tests using `Global Organization` and `Global Project` that are created as part of the `login` process. This should be avoided whenever possible, as it was identified as a possible source of flakiness in the tests.
- Create the resources in the test itself or in a `before` block, and clean them up in an `after` block.
- If certain resources were created during deployment, those should not be deleted as part of the test runs.
- Avoid tests that require execution in a specific order.
Expand Down
4 changes: 0 additions & 4 deletions cypress/support/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Cypress.Commands.add('login', () => {
switch (devBaseUrlPort) {
case '4101':
cy.awxLogin();
cy.createGlobalOrganization();
cy.createGlobalProject();
break;
case '4102':
cy.hubLogin();
Expand All @@ -33,8 +31,6 @@ Cypress.Commands.add('login', () => {
switch (Cypress.env('E2E_MODE')) {
case 'AWX':
cy.awxLogin();
cy.createGlobalOrganization();
cy.createGlobalProject();
break;
case 'HUB':
cy.hubLogin();
Expand Down
44 changes: 0 additions & 44 deletions cypress/support/awx-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,50 +1355,6 @@ Cypress.Commands.add('cancelJob', (job: Job) => {
cy.requestPost<Job>(`${job.url}cancel/`, {});
});

const GLOBAL_PROJECT_NAME = 'Global Project';
const GLOBAL_PROJECT_DESCRIPTION = 'Global Read Only Project for E2E tests';
const GLOBAL_PROJECT_SCM_URL = 'https://github.com/ansible/ansible-ui';
const GLOBAL_ORG_NAME = 'Global Platform Level Organization';
const GLOBAL_ORG_DESCRIPTION = 'DO NOT DELETE: Global Organization';

/** Create a global organization if it doesn't exist. */
Cypress.Commands.add('createGlobalOrganization', function () {
cy.requestGet<AwxItemsResponse<Organization>>(awxAPI`/organizations?name=${GLOBAL_ORG_NAME}`)
.its('results')
.then((orgResults: Organization[]) => {
if (orgResults.length === 0) {
cy.requestPost<AwxItemsResponse<Organization>, Partial<Organization>>(
awxAPI`/organizations/`,
{ name: GLOBAL_ORG_NAME, description: GLOBAL_ORG_DESCRIPTION }
);
cy.wait(100).then(() => cy.createGlobalOrganization());
} else {
cy.wrap(orgResults[0]).as('globalAwxOrganization');
}
});
});

/** Create a global project if it doesn't exist. */
Cypress.Commands.add('createGlobalProject', function () {
const globalAwxOrganization = this.globalAwxOrganization as Organization;
cy.requestGet<AwxItemsResponse<Project>>(awxAPI`/projects?name=${GLOBAL_PROJECT_NAME}`)
.its('results')
.then((projectResults: Project[]) => {
if (projectResults.length === 0) {
cy.requestPost<AwxItemsResponse<Project>, Partial<Project>>(awxAPI`/projects/`, {
name: GLOBAL_PROJECT_NAME,
description: GLOBAL_PROJECT_DESCRIPTION,
organization: globalAwxOrganization.id,
scm_type: 'git',
scm_url: GLOBAL_PROJECT_SCM_URL,
});
cy.wait(100).then(() => cy.createGlobalProject());
} else {
cy.wrap(projectResults[0]).as('globalProject');
}
});
});

Cypress.Commands.add(
'createCustomAWXApplicationFromUI',
(
Expand Down
2 changes: 0 additions & 2 deletions cypress/support/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,6 @@ declare global {
): Chainable<InstanceGroup>;
createAwxInstance(hostname: string, listener_port?: number): Chainable<Instance>;
createAwxLabel(label: Partial<Omit<Label, 'id'>>): Chainable<Label>;
createGlobalOrganization(): Chainable<void>;
createGlobalProject(): Chainable<void>;

deleteAwxOrganization(
organization: Organization,
Expand Down
Loading