1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

ci adjustments

lint
This commit is contained in:
Daniel Sami 2019-03-27 15:59:48 -04:00
parent 90ea9a8cc4
commit ef3c0cfb38
3 changed files with 54 additions and 43 deletions

View File

@ -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 interval = 2000;
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 promises = [
getProject(namespace),
];
return Promise.all(promises)
.then(([project]) => {
.then(([project]) =>
post(`/api/v2/projects/${project.id}/update/`, {})
.then(update => waitForJob(update.data.url))
.then(() => { project = getProject(namespace); });
return project;
});
.then(() => getProject(namespace)));
};
/* 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[playbook] - The playbook file to be run by 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 = (
namespace = session,
playbook = 'hello_world.yml',
name = `${namespace}-job-template`
name = `${namespace}-job-template`,
wait = true
) => getJobTemplate(namespace, playbook, name)
.then(template => {
const launchURL = template.related.launch;
return post(launchURL, {}).then(response => {
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 = (
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)}`
) => getOrganization(namespace)
.then(organization => getOrCreate(`/organizations/${organization.id}/users/`, {
username: `${username}`,
username: `${username}-${uuid().substr(0, 8)}`,
organization: organization.id,
first_name: 'firstname',
last_name: 'lastname',

View File

@ -39,7 +39,6 @@ const teamsText = `name.iexact:"${namespace}-team"`;
const teamsSearchBadgeCount = '//span[contains(@class, "List-titleBadge") and contains(text(), "1")]';
const teamCheckbox = '//*[@item="team"]//input[@type="checkbox"]';
const addUserToTeam = '//*[@aw-tool-tip="Add User"]';
const userText = `username.iexact:"${namespace}-user"`;
const trashButton = '//i[contains(@class, "fa-trash")]';
const deleteButton = '//*[text()="DELETE"]';
@ -99,8 +98,9 @@ module.exports = {
.useXpath()
.findThenClick(usersTab)
.findThenClick(addUserToTeam)
.waitForElementVisible(modalSearchBar)
.clearValue(modalSearchBar)
.setValue(modalSearchBar, [userText, client.Keys.ENTER])
.setValue(modalSearchBar, [`username.iexact:${data.user.username}`, client.Keys.ENTER])
.waitForElementNotVisible(spinny)
.findThenClick(checkbox)
.findThenClick(userRoleSearchBar)
@ -126,13 +126,13 @@ module.exports = {
.waitForElementNotVisible(spinny)
.findThenClick(saveButton)
.clearValue(searchBar)
.setValue(searchBar, [userText, client.Keys.ENTER])
.setValue(searchBar, [`username.iexact:${data.user.username}`, client.Keys.ENTER])
.waitForElementVisible(verifyTeamPermissions);
},
after: client => {
client
.findThenClick(usersNavTab)
.setValue(searchBar, [userText, client.Keys.ENTER])
.setValue(searchBar, [`username.iexact:${data.user.username}`, client.Keys.ENTER])
.waitForElementNotVisible(spinny)
.findThenClick(trashButton)
.findThenClick(deleteButton)

View File

@ -12,6 +12,7 @@ import {
import {
AWX_E2E_URL,
AWX_E2E_TIMEOUT_ASYNC,
AWX_E2E_TIMEOUT_LONG,
AWX_E2E_TIMEOUT_MEDIUM,
} from '../settings';
@ -56,12 +57,12 @@ module.exports = {
client
.useCss()
.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')
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
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}`)
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
},
@ -70,12 +71,12 @@ module.exports = {
client
.useCss()
.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')
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
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}`)
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
},
@ -84,6 +85,7 @@ module.exports = {
client
.useCss()
.findThenClick('[ui-sref=projects]', 'css')
.waitForElementVisible('.SmartSearch-input')
.clearValue('.SmartSearch-input')
.setValue(
'.SmartSearch-input',
@ -92,7 +94,7 @@ module.exports = {
getUpdatedProject('test-websockets');
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')
.to.be.visible.before(AWX_E2E_TIMEOUT_LONG);
},
@ -101,17 +103,18 @@ module.exports = {
client
.useCss()
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/job_templates`)
.waitForElementVisible('[ui-view=templatesList] .SmartSearch-input')
.clearValue('[ui-view=templatesList] .SmartSearch-input')
.setValue(
'[ui-view=templatesList] .SmartSearch-input',
['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')
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
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}`)
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
},
@ -119,17 +122,18 @@ module.exports = {
client
.useCss()
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/job_templates`)
.waitForElementVisible('[ui-view=templatesList] .SmartSearch-input')
.clearValue('[ui-view=templatesList] .SmartSearch-input')
.setValue(
'[ui-view=templatesList] .SmartSearch-input',
['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')
.to.not.be.visible.before(AWX_E2E_TIMEOUT_MEDIUM);
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}`)
.to.be.present.before(AWX_E2E_TIMEOUT_LONG);
},
@ -137,6 +141,7 @@ module.exports = {
client
.useCss()
.navigateTo(`${AWX_E2E_URL}/#/organizations/${data.org.id}/projects`)
.waitForElementVisible('.projectsList .SmartSearch-input')
.clearValue('.projectsList .SmartSearch-input')
.setValue(
'.projectsList .SmartSearch-input',
@ -145,9 +150,9 @@ module.exports = {
getUpdatedProject('test-websockets');
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);
client.expect.element('i.icon-job-success')
.to.be.visible.before(AWX_E2E_TIMEOUT_ASYNC);
},
after: client => {