mirror of
https://github.com/ansible/awx.git
synced 2026-02-14 01:34:45 -03:30
ci adjustments
lint
This commit is contained in:
@@ -242,27 +242,6 @@ const getNotificationTemplate = (namespace = session) => getOrganization(namespa
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/* Retrieves a project, and creates it if it does not exist.
|
|
||||||
* name prefix. If an organization does not exist with the same prefix, it is
|
|
||||||
* created as well.
|
|
||||||
*
|
|
||||||
* @param[namespace] - A unique name prefix for the host.
|
|
||||||
* @param[scmUrl] - The url of the repository.
|
|
||||||
* @param[scmType] - The type of scm (git, etc.)
|
|
||||||
*/
|
|
||||||
const getProject = (
|
|
||||||
namespace = session,
|
|
||||||
scmUrl = 'https://github.com/ansible/ansible-tower-samples',
|
|
||||||
scmType = 'git'
|
|
||||||
) => getOrganization(namespace)
|
|
||||||
.then(organization => getOrCreate(`/organizations/${organization.id}/projects/`, {
|
|
||||||
name: `${namespace}-project`,
|
|
||||||
description: namespace,
|
|
||||||
organization: organization.id,
|
|
||||||
scm_url: `${scmUrl}`,
|
|
||||||
scm_type: `${scmType}`
|
|
||||||
}));
|
|
||||||
|
|
||||||
const waitForJob = endpoint => {
|
const waitForJob = endpoint => {
|
||||||
const interval = 2000;
|
const interval = 2000;
|
||||||
const statuses = ['successful', 'failed', 'error', 'canceled'];
|
const statuses = ['successful', 'failed', 'error', 'canceled'];
|
||||||
@@ -288,17 +267,36 @@ const waitForJob = endpoint => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Retrieves a project, and creates it if it does not exist.
|
||||||
|
* name prefix. If an organization does not exist with the same prefix, it is
|
||||||
|
* created as well.
|
||||||
|
*
|
||||||
|
* @param[namespace] - A unique name prefix for the host.
|
||||||
|
* @param[scmUrl] - The url of the repository.
|
||||||
|
* @param[scmType] - The type of scm (git, etc.)
|
||||||
|
*/
|
||||||
|
const getProject = (
|
||||||
|
namespace = session,
|
||||||
|
scmUrl = 'https://github.com/ansible/ansible-tower-samples',
|
||||||
|
scmType = 'git'
|
||||||
|
) => getOrganization(namespace)
|
||||||
|
.then(organization => getOrCreate(`/organizations/${organization.id}/projects/`, {
|
||||||
|
name: `${namespace}-project`,
|
||||||
|
description: namespace,
|
||||||
|
organization: organization.id,
|
||||||
|
scm_url: `${scmUrl}`,
|
||||||
|
scm_type: `${scmType}`
|
||||||
|
}));
|
||||||
|
|
||||||
const getUpdatedProject = (namespace = session) => {
|
const getUpdatedProject = (namespace = session) => {
|
||||||
const promises = [
|
const promises = [
|
||||||
getProject(namespace),
|
getProject(namespace),
|
||||||
];
|
];
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
.then(([project]) => {
|
.then(([project]) =>
|
||||||
post(`/api/v2/projects/${project.id}/update/`, {})
|
post(`/api/v2/projects/${project.id}/update/`, {})
|
||||||
.then(update => waitForJob(update.data.url))
|
.then(update => waitForJob(update.data.url))
|
||||||
.then(() => { project = getProject(namespace); });
|
.then(() => getProject(namespace)));
|
||||||
return project;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Retrieves a job template, and creates it if it does not exist.
|
/* Retrieves a job template, and creates it if it does not exist.
|
||||||
@@ -336,17 +334,22 @@ const getJobTemplate = (
|
|||||||
* @param[namespace] - A unique name prefix for the job and its dependencies.
|
* @param[namespace] - A unique name prefix for the job and its dependencies.
|
||||||
* @param[playbook] - The playbook file to be run by the job template.
|
* @param[playbook] - The playbook file to be run by the job template.
|
||||||
* @param[name] - A unique name for the job template.
|
* @param[name] - A unique name for the job template.
|
||||||
|
* @param[wait] - Choose whether to return the result of the completed job.
|
||||||
*/
|
*/
|
||||||
const getJob = (
|
const getJob = (
|
||||||
namespace = session,
|
namespace = session,
|
||||||
playbook = 'hello_world.yml',
|
playbook = 'hello_world.yml',
|
||||||
name = `${namespace}-job-template`
|
name = `${namespace}-job-template`,
|
||||||
|
wait = true
|
||||||
) => getJobTemplate(namespace, playbook, name)
|
) => getJobTemplate(namespace, playbook, name)
|
||||||
.then(template => {
|
.then(template => {
|
||||||
const launchURL = template.related.launch;
|
const launchURL = template.related.launch;
|
||||||
return post(launchURL, {}).then(response => {
|
return post(launchURL, {}).then(response => {
|
||||||
const jobURL = response.data.url;
|
const jobURL = response.data.url;
|
||||||
return waitForJob(jobURL).then(() => response.data);
|
if (wait) {
|
||||||
|
return waitForJob(jobURL).then(() => response.data);
|
||||||
|
}
|
||||||
|
return response.data;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -423,10 +426,13 @@ const getAuditor = (namespace = session) => getOrganization(namespace)
|
|||||||
*/
|
*/
|
||||||
const getUser = (
|
const getUser = (
|
||||||
namespace = session,
|
namespace = session,
|
||||||
|
// unique substrings are needed to avoid the edge case
|
||||||
|
// where a user and org both exist, but the user is not in the organization.
|
||||||
|
// this ensures a new user is always created.
|
||||||
username = `user-${uuid().substr(0, 8)}`
|
username = `user-${uuid().substr(0, 8)}`
|
||||||
) => getOrganization(namespace)
|
) => getOrganization(namespace)
|
||||||
.then(organization => getOrCreate(`/organizations/${organization.id}/users/`, {
|
.then(organization => getOrCreate(`/organizations/${organization.id}/users/`, {
|
||||||
username: `${username}`,
|
username: `${username}-${uuid().substr(0, 8)}`,
|
||||||
organization: organization.id,
|
organization: organization.id,
|
||||||
first_name: 'firstname',
|
first_name: 'firstname',
|
||||||
last_name: 'lastname',
|
last_name: 'lastname',
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ const teamsText = `name.iexact:"${namespace}-team"`;
|
|||||||
const teamsSearchBadgeCount = '//span[contains(@class, "List-titleBadge") and contains(text(), "1")]';
|
const teamsSearchBadgeCount = '//span[contains(@class, "List-titleBadge") and contains(text(), "1")]';
|
||||||
const teamCheckbox = '//*[@item="team"]//input[@type="checkbox"]';
|
const teamCheckbox = '//*[@item="team"]//input[@type="checkbox"]';
|
||||||
const addUserToTeam = '//*[@aw-tool-tip="Add User"]';
|
const addUserToTeam = '//*[@aw-tool-tip="Add User"]';
|
||||||
const userText = `username.iexact:"${namespace}-user"`;
|
|
||||||
|
|
||||||
const trashButton = '//i[contains(@class, "fa-trash")]';
|
const trashButton = '//i[contains(@class, "fa-trash")]';
|
||||||
const deleteButton = '//*[text()="DELETE"]';
|
const deleteButton = '//*[text()="DELETE"]';
|
||||||
@@ -99,8 +98,9 @@ module.exports = {
|
|||||||
.useXpath()
|
.useXpath()
|
||||||
.findThenClick(usersTab)
|
.findThenClick(usersTab)
|
||||||
.findThenClick(addUserToTeam)
|
.findThenClick(addUserToTeam)
|
||||||
|
.waitForElementVisible(modalSearchBar)
|
||||||
.clearValue(modalSearchBar)
|
.clearValue(modalSearchBar)
|
||||||
.setValue(modalSearchBar, [userText, client.Keys.ENTER])
|
.setValue(modalSearchBar, [`username.iexact:${data.user.username}`, client.Keys.ENTER])
|
||||||
.waitForElementNotVisible(spinny)
|
.waitForElementNotVisible(spinny)
|
||||||
.findThenClick(checkbox)
|
.findThenClick(checkbox)
|
||||||
.findThenClick(userRoleSearchBar)
|
.findThenClick(userRoleSearchBar)
|
||||||
@@ -126,13 +126,13 @@ module.exports = {
|
|||||||
.waitForElementNotVisible(spinny)
|
.waitForElementNotVisible(spinny)
|
||||||
.findThenClick(saveButton)
|
.findThenClick(saveButton)
|
||||||
.clearValue(searchBar)
|
.clearValue(searchBar)
|
||||||
.setValue(searchBar, [userText, client.Keys.ENTER])
|
.setValue(searchBar, [`username.iexact:${data.user.username}`, client.Keys.ENTER])
|
||||||
.waitForElementVisible(verifyTeamPermissions);
|
.waitForElementVisible(verifyTeamPermissions);
|
||||||
},
|
},
|
||||||
after: client => {
|
after: client => {
|
||||||
client
|
client
|
||||||
.findThenClick(usersNavTab)
|
.findThenClick(usersNavTab)
|
||||||
.setValue(searchBar, [userText, client.Keys.ENTER])
|
.setValue(searchBar, [`username.iexact:${data.user.username}`, client.Keys.ENTER])
|
||||||
.waitForElementNotVisible(spinny)
|
.waitForElementNotVisible(spinny)
|
||||||
.findThenClick(trashButton)
|
.findThenClick(trashButton)
|
||||||
.findThenClick(deleteButton)
|
.findThenClick(deleteButton)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
AWX_E2E_URL,
|
AWX_E2E_URL,
|
||||||
|
AWX_E2E_TIMEOUT_ASYNC,
|
||||||
AWX_E2E_TIMEOUT_LONG,
|
AWX_E2E_TIMEOUT_LONG,
|
||||||
AWX_E2E_TIMEOUT_MEDIUM,
|
AWX_E2E_TIMEOUT_MEDIUM,
|
||||||
} from '../settings';
|
} from '../settings';
|
||||||
@@ -56,12 +57,12 @@ module.exports = {
|
|||||||
client
|
client
|
||||||
.useCss()
|
.useCss()
|
||||||
.navigateTo(`${AWX_E2E_URL}/#/home`);
|
.navigateTo(`${AWX_E2E_URL}/#/home`);
|
||||||
getJob('test-websockets', 'debug.yml', 'test-websockets-successful');
|
getJob('test-websockets', 'debug.yml', 'test-websockets-successful', false);
|
||||||
|
|
||||||
client.expect.element('.spinny')
|
client.expect.element('.spinny')
|
||||||
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
||||||
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
client.useXpath().expect.element(`${successfulJt}${sparklineIcon}[1]${success}`)
|
client.useXpath().expect.element(`${successfulJt}${sparklineIcon}[1]${success}`)
|
||||||
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
},
|
},
|
||||||
@@ -70,12 +71,12 @@ module.exports = {
|
|||||||
client
|
client
|
||||||
.useCss()
|
.useCss()
|
||||||
.navigateTo(`${AWX_E2E_URL}/#/home`);
|
.navigateTo(`${AWX_E2E_URL}/#/home`);
|
||||||
getJob('test-websockets', 'fail_unless.yml', 'test-websockets-failed');
|
getJob('test-websockets', 'fail_unless.yml', 'test-websockets-failed', false);
|
||||||
|
|
||||||
client.expect.element('.spinny')
|
client.expect.element('.spinny')
|
||||||
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
||||||
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
client.useXpath().expect.element(`${failedJt}${sparklineIcon}[1]${fail}`)
|
client.useXpath().expect.element(`${failedJt}${sparklineIcon}[1]${fail}`)
|
||||||
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
},
|
},
|
||||||
@@ -84,6 +85,7 @@ module.exports = {
|
|||||||
client
|
client
|
||||||
.useCss()
|
.useCss()
|
||||||
.findThenClick('[ui-sref=projects]', 'css')
|
.findThenClick('[ui-sref=projects]', 'css')
|
||||||
|
.waitForElementVisible('.SmartSearch-input')
|
||||||
.clearValue('.SmartSearch-input')
|
.clearValue('.SmartSearch-input')
|
||||||
.setValue(
|
.setValue(
|
||||||
'.SmartSearch-input',
|
'.SmartSearch-input',
|
||||||
@@ -92,7 +94,7 @@ module.exports = {
|
|||||||
getUpdatedProject('test-websockets');
|
getUpdatedProject('test-websockets');
|
||||||
|
|
||||||
client.expect.element('i.icon-job-running')
|
client.expect.element('i.icon-job-running')
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
client.expect.element('i.icon-job-success')
|
client.expect.element('i.icon-job-success')
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
},
|
},
|
||||||
@@ -101,17 +103,18 @@ module.exports = {
|
|||||||
client
|
client
|
||||||
.useCss()
|
.useCss()
|
||||||
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/job_templates`)
|
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/job_templates`)
|
||||||
|
.waitForElementVisible('[ui-view=templatesList] .SmartSearch-input')
|
||||||
.clearValue('[ui-view=templatesList] .SmartSearch-input')
|
.clearValue('[ui-view=templatesList] .SmartSearch-input')
|
||||||
.setValue(
|
.setValue(
|
||||||
'[ui-view=templatesList] .SmartSearch-input',
|
'[ui-view=templatesList] .SmartSearch-input',
|
||||||
['test-websockets-successful', client.Keys.ENTER]
|
['test-websockets-successful', client.Keys.ENTER]
|
||||||
);
|
);
|
||||||
getJob('test-websockets', 'debug.yml', 'test-websockets-successful');
|
getJob('test-websockets', 'debug.yml', 'test-websockets-successful', false);
|
||||||
|
|
||||||
client.expect.element('.spinny')
|
client.expect.element('.spinny')
|
||||||
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
||||||
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
client.useXpath().expect.element(`${sparklineIcon}[1]${success}`)
|
client.useXpath().expect.element(`${sparklineIcon}[1]${success}`)
|
||||||
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
},
|
},
|
||||||
@@ -119,17 +122,18 @@ module.exports = {
|
|||||||
client
|
client
|
||||||
.useCss()
|
.useCss()
|
||||||
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/job_templates`)
|
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/job_templates`)
|
||||||
|
.waitForElementVisible('[ui-view=templatesList] .SmartSearch-input')
|
||||||
.clearValue('[ui-view=templatesList] .SmartSearch-input')
|
.clearValue('[ui-view=templatesList] .SmartSearch-input')
|
||||||
.setValue(
|
.setValue(
|
||||||
'[ui-view=templatesList] .SmartSearch-input',
|
'[ui-view=templatesList] .SmartSearch-input',
|
||||||
['test-websockets-failed', client.Keys.ENTER]
|
['test-websockets-failed', client.Keys.ENTER]
|
||||||
);
|
);
|
||||||
getJob('test-websockets', 'debug.yml', 'test-websockets-failed');
|
getJob('test-websockets', 'debug.yml', 'test-websockets-failed', false);
|
||||||
|
|
||||||
client.expect.element('.spinny')
|
client.expect.element('.spinny')
|
||||||
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
||||||
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
client.useXpath().expect.element(`${sparklineIcon}[1]${running}`)
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
client.useXpath().expect.element(`${sparklineIcon}[1]${fail}`)
|
client.useXpath().expect.element(`${sparklineIcon}[1]${fail}`)
|
||||||
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
},
|
},
|
||||||
@@ -137,6 +141,7 @@ module.exports = {
|
|||||||
client
|
client
|
||||||
.useCss()
|
.useCss()
|
||||||
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/projects`)
|
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/projects`)
|
||||||
|
.waitForElementVisible('.projectsList .SmartSearch-input')
|
||||||
.clearValue('.projectsList .SmartSearch-input')
|
.clearValue('.projectsList .SmartSearch-input')
|
||||||
.setValue(
|
.setValue(
|
||||||
'.projectsList .SmartSearch-input',
|
'.projectsList .SmartSearch-input',
|
||||||
@@ -145,9 +150,9 @@ module.exports = {
|
|||||||
getUpdatedProject('test-websockets');
|
getUpdatedProject('test-websockets');
|
||||||
|
|
||||||
client.expect.element('i.icon-job-running')
|
client.expect.element('i.icon-job-running')
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
|
|
||||||
client.expect.element('i.icon-job-success')
|
|
||||||
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
|
||||||
|
client.expect.element('i.icon-job-success')
|
||||||
|
.to.be.visible.before(AWX_E2E_TIMEOUT_ASYNC);
|
||||||
},
|
},
|
||||||
|
|
||||||
after: client => {
|
after: client => {
|
||||||
|
|||||||
Reference in New Issue
Block a user