diff --git a/cypress/e2e/awx/resources/hosts.cy.ts b/cypress/e2e/awx/resources/hosts.cy.ts index 37b0e780a3..078c39558e 100644 --- a/cypress/e2e/awx/resources/hosts.cy.ts +++ b/cypress/e2e/awx/resources/hosts.cy.ts @@ -5,7 +5,7 @@ import { checkFactsInHost, checkHostGroup, createAndEditAndDeleteHost, - createHostAndLaunchJob, + launchHostJob, createHostAndCancelJob, } from '../../../support/hostsfunctions'; @@ -46,7 +46,10 @@ describe('Host Tests', () => { }); it('can see and launch jobs from host jobs tab', () => { - createHostAndLaunchJob(inventory, organization.id, project.id); + cy.createInventoryHost(organization, '').then((result) => { + launchHostJob(result.inventory, result.host, organization.id, project.id, 'Host'); + cy.deleteAwxInventory(result.inventory, { failOnStatusCode: false }); + }); }); it('can cancel jobs from host jobs tab', () => { diff --git a/cypress/e2e/awx/resources/inventoryHost/inventoryHostConstructed.cy.ts b/cypress/e2e/awx/resources/inventoryHost/inventoryHostConstructed.cy.ts index 98d0689f11..ec56950f23 100644 --- a/cypress/e2e/awx/resources/inventoryHost/inventoryHostConstructed.cy.ts +++ b/cypress/e2e/awx/resources/inventoryHost/inventoryHostConstructed.cy.ts @@ -5,6 +5,7 @@ import { InventoryGroup } from '../../../../../frontend/awx/interfaces/Inventory import { Organization } from '../../../../../frontend/awx/interfaces/Organization'; import { runCommand } from './runCommandFunction'; import { checkHiddenButton, checkHiddenTab } from '../../../../support/hostsfunctions'; +import { launchHostJob } from '../../../../support/hostsfunctions'; describe('Inventory Host Tab Tests for contructed inventory', () => { let organization: Organization; @@ -104,10 +105,17 @@ describe('Inventory Host Tab Tests for contructed inventory', () => { }); }); - it.skip('can launch a job template that uses an inventory with a particular host and view the job on the host jobs tab inside the inventory', () => { + it('can launch a job template that uses an inventory with a particular host and view the job on the host jobs tab inside the inventory', () => { //1) Use inventory and host //2) create a job template that uses that inventory, launch the job template, wait for job to finish //3) Navigate back to inventory -> host tab -> jobs tab -> assert presence of job in that list + cy.createAwxProject({ organization: organization.id }).then((project) => { + cy.createInventoryHost(organization, 'constructed').then((result) => { + launchHostJob(result.inventory, result.host, organization.id, project.id, 'InventoryHost'); + cy.deleteAwxInventory(result.inventory, { failOnStatusCode: false }); + cy.deleteAwxProject(project, { failOnStatusCode: false }); + }); + }); }); //there is NO jobs tab in constructed inventory -> host diff --git a/cypress/e2e/awx/resources/inventoryHost/inventoryHostRegular.cy.ts b/cypress/e2e/awx/resources/inventoryHost/inventoryHostRegular.cy.ts index a6625979ec..580846ee71 100644 --- a/cypress/e2e/awx/resources/inventoryHost/inventoryHostRegular.cy.ts +++ b/cypress/e2e/awx/resources/inventoryHost/inventoryHostRegular.cy.ts @@ -4,6 +4,7 @@ import { Organization } from '../../../../../frontend/awx/interfaces/Organizatio import { AwxUser } from '../../../../../frontend/awx/interfaces/User'; import { runCommand } from './runCommandFunction'; import { randomString } from '../../../../../framework/utils/random-string'; +import { launchHostJob } from '../../../../support/hostsfunctions'; import { Project } from '../../../../../frontend/awx/interfaces/Project'; import { @@ -79,10 +80,17 @@ describe('Inventory Host Tab Tests for regular inventory', () => { checkFactsInHost(inventory, 'inventory_host'); }); - it.skip('can launch a job template that uses an inventory with a particular host and view the job on the host jobs tab inside the inventory', () => { + it('can launch a job template that uses an inventory with a particular host and view the job on the host jobs tab inside the inventory', () => { //1) Use inventory and host //2) create a job template that uses that inventory, launch the job template, wait for job to finish //3) Navigate back to inventory -> host tab -> jobs tab -> assert presence of job in that list + cy.createAwxProject({ organization: organization.id }).then((project) => { + cy.createInventoryHost(organization, '').then((result) => { + launchHostJob(result.inventory, result.host, organization.id, project.id, 'InventoryHost'); + cy.deleteAwxInventory(result.inventory, { failOnStatusCode: false }); + cy.deleteAwxProject(project, { failOnStatusCode: false }); + }); + }); }); it('can cancel a currently running job from the host jobs tab inside an inventory', () => { diff --git a/cypress/e2e/awx/resources/inventoryHost/inventoryHostSmart.cy.ts b/cypress/e2e/awx/resources/inventoryHost/inventoryHostSmart.cy.ts index 45e48cf9d2..3829c53b03 100644 --- a/cypress/e2e/awx/resources/inventoryHost/inventoryHostSmart.cy.ts +++ b/cypress/e2e/awx/resources/inventoryHost/inventoryHostSmart.cy.ts @@ -5,6 +5,7 @@ import { Organization } from '../../../../../frontend/awx/interfaces/Organizatio import { AwxUser } from '../../../../../frontend/awx/interfaces/User'; import { runCommand } from './runCommandFunction'; import { checkHiddenButton, checkHiddenTab } from '../../../../support/hostsfunctions'; +import { launchHostJob } from '../../../../support/hostsfunctions'; describe('Inventory Host Tab Tests for smart inventory', () => { let organization: Organization; @@ -68,10 +69,17 @@ describe('Inventory Host Tab Tests for smart inventory', () => { //5) Navigate back to the Inventory -> Jobs Tab to assert that the Run Command job shows up there }); - it.skip('can launch a job template that uses an inventory with a particular host and view the job on the host jobs tab inside the inventory', () => { + it('can launch a job template that uses an inventory with a particular host and view the job on the host jobs tab inside the inventory', () => { //1) Use inventory and host //2) create a job template that uses that inventory, launch the job template, wait for job to finish //3) Navigate back to inventory -> host tab -> jobs tab -> assert presence of job in that list + cy.createAwxProject({ organization: organization.id }).then((project) => { + cy.createInventoryHost(organization, 'smart').then((result) => { + launchHostJob(result.inventory, result.host, organization.id, project.id, 'InventoryHost'); + cy.deleteAwxInventory(result.inventory, { failOnStatusCode: false }); + cy.deleteAwxProject(project, { failOnStatusCode: false }); + }); + }); }); //there is NO jobs tab in smart inventory -> host diff --git a/cypress/e2e/awx/resources/inventoryHost/runCommandFunction.ts b/cypress/e2e/awx/resources/inventoryHost/runCommandFunction.ts index 426e7a1596..9018308970 100644 --- a/cypress/e2e/awx/resources/inventoryHost/runCommandFunction.ts +++ b/cypress/e2e/awx/resources/inventoryHost/runCommandFunction.ts @@ -92,6 +92,9 @@ export function runCommand(params: { cy.getByDataCy('forks').contains(params.forks.toString()); cy.getByDataCy('execution-environment').contains(executionEnvironment.name); + + cy.deleteAwxCredential(credential, { failOnStatusCode: false }); + cy.deleteAwxExecutionEnvironment(executionEnvironment, { failOnStatusCode: false }); }); } ); diff --git a/cypress/support/hostsfunctions.ts b/cypress/support/hostsfunctions.ts index 747ccadce9..282fc1098d 100644 --- a/cypress/support/hostsfunctions.ts +++ b/cypress/support/hostsfunctions.ts @@ -308,50 +308,51 @@ export function createHostAndCancelJob( }); } -export function createHostAndLaunchJob( +export function launchHostJob( inventory: Inventory, + host: AwxHost, organizationId: number, projectId: number, - hostInInventory?: boolean + type: 'Host' | 'InventoryHost' ) { cy.createAwxJobTemplate({ inventory: inventory.id, organization: organizationId, project: projectId, }).then(() => { - // go to inventory hosts - cy.navigateTo('awx', 'inventories'); - cy.filterTableByMultiSelect('name', [inventory.name]); - cy.get('[data-cy="name-column-cell"]').contains(inventory.name).click(); - cy.get('.pf-v5-c-tabs__item > a').contains('Hosts').click(); - // add a host - const hostName = createHost('inventory_host', inventory.id); - // go to inventory job templates cy.navigateTo('awx', 'inventories'); cy.filterTableByMultiSelect('name', [inventory.name]); cy.get('[data-cy="name-column-cell"]').contains(inventory.name).click(); - cy.get('.pf-v5-c-tabs__item > a').contains('Job templates').click(); - // run a template and wait for redirect to Job output - cy.get('[data-cy="launch-template"]').first().click(); - cy.location('pathname').should('match', /\/output$/); - if (hostInInventory) { + cy.contains(`[role='tab']`, 'Job templates').click(); + + // run a template and wait for request + cy.intercept('POST', awxAPI`/job_templates/*/launch`).as('launch'); + cy.get('[data-cy="launch-template"]').click(); + cy.wait('@launch').should('exist'); + + cy.contains('span', 'Failed', { timeout: 60000 }); + + if (type === 'InventoryHost') { // go to the Hosts under Inventory cy.navigateTo('awx', 'inventories'); cy.filterTableByMultiSelect('name', [inventory.name]); cy.get('[data-cy="name-column-cell"]').contains(inventory.name).click(); - cy.get('.pf-v5-c-tabs__item > a').contains('Hosts').click(); + cy.contains(`[role='tab']`, 'Jobs').click(); } else { // go to the Hosts cy.navigateTo('awx', 'hosts'); + cy.filterTableByMultiSelect('name', [host.name]); + cy.get('[data-cy="name-column-cell"]').contains(host.name).click(); + + // go to Jobs tab + cy.contains(`[role='tab']`, 'Jobs').click(); } - cy.filterTableByMultiSelect('name', [hostName]); - cy.get('[data-cy="name-column-cell"]').contains(hostName).click(); - // go to Jobs tab - cy.get('.pf-v5-c-tabs__item > a').contains('Jobs').click(); + cy.get('[data-cy="relaunch-using-host-parameters"]').should('exist'); cy.get('[data-cy="relaunch-using-host-parameters"]').click(); cy.get('[data-cy="relaunch-on-all-hosts"]').should('exist'); cy.get('[data-cy="relaunch-on-failed-hosts"]').should('exist'); + // relaunch job cy.intercept('POST', awxAPI`/jobs/*/relaunch`).as('relaunch'); cy.get('[data-cy="relaunch-on-all-hosts"]').click();