mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
refactor e2e settings and config modules
This should make the settings and configuration logic less implicit and a little easier to follow. Some familiarity with the configuration behavior of nightwatch is still necessary in places - specifically, one should know that all test_settings defined for non-default environments are treated as overrides to the values defined for the default environment.
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
"test": "karma start test/spec/karma.spec.js",
|
"test": "karma start test/spec/karma.spec.js",
|
||||||
"jshint": "grunt jshint:source --no-color",
|
"jshint": "grunt jshint:source --no-color",
|
||||||
"test:ci": "npm run test -- --single-run --reporter junit,dots --browsers=PhantomJS",
|
"test:ci": "npm run test -- --single-run --reporter junit,dots --browsers=PhantomJS",
|
||||||
"e2e": "./test/e2e/runner.js --config ./test/e2e/nightwatch.conf.js",
|
"e2e": "./test/e2e/runner.js --config ./test/e2e/nightwatch.conf.js --suiteRetries=2",
|
||||||
"unit": "karma start test/unit/karma.unit.js",
|
"unit": "karma start test/unit/karma.unit.js",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"dev": "webpack --config build/webpack.development.js --progress",
|
"dev": "webpack --config build/webpack.development.js --progress",
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ import https from 'https';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
awxURL,
|
AWX_E2E_URL,
|
||||||
awxUsername,
|
AWX_E2E_USERNAME,
|
||||||
awxPassword
|
AWX_E2E_PASSWORD
|
||||||
} from './settings';
|
} from './settings';
|
||||||
|
|
||||||
let authenticated;
|
let authenticated;
|
||||||
|
|
||||||
const session = axios.create({
|
const session = axios.create({
|
||||||
baseURL: awxURL,
|
baseURL: AWX_E2E_URL,
|
||||||
xsrfHeaderName: 'X-CSRFToken',
|
xsrfHeaderName: 'X-CSRFToken',
|
||||||
xsrfCookieName: 'csrftoken',
|
xsrfCookieName: 'csrftoken',
|
||||||
httpsAgent: new https.Agent({
|
httpsAgent: new https.Agent({
|
||||||
@@ -24,7 +24,7 @@ const getEndpoint = location => {
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${awxURL}/api/v2${location}`;
|
return `${AWX_E2E_URL}/api/v2${location}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const authenticate = () => {
|
const authenticate = () => {
|
||||||
@@ -35,8 +35,8 @@ const authenticate = () => {
|
|||||||
const uri = getEndpoint('/authtoken/');
|
const uri = getEndpoint('/authtoken/');
|
||||||
|
|
||||||
const credentials = {
|
const credentials = {
|
||||||
username: awxUsername,
|
username: AWX_E2E_USERNAME,
|
||||||
password: awxPassword
|
password: AWX_E2E_PASSWORD
|
||||||
};
|
};
|
||||||
|
|
||||||
return session.post(uri, credentials).then(res => {
|
return session.post(uri, credentials).then(res => {
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { inherits } from 'util';
|
import { inherits } from 'util';
|
||||||
|
|
||||||
|
import {
|
||||||
|
AWX_E2E_USERNAME,
|
||||||
|
AWX_E2E_PASSWORD,
|
||||||
|
AWX_E2E_TIMEOUT_LONG
|
||||||
|
} from '../settings';
|
||||||
|
|
||||||
function Login () {
|
function Login () {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
}
|
}
|
||||||
@@ -8,14 +14,14 @@ function Login () {
|
|||||||
inherits(Login, EventEmitter);
|
inherits(Login, EventEmitter);
|
||||||
|
|
||||||
Login.prototype.command = function command (username, password) {
|
Login.prototype.command = function command (username, password) {
|
||||||
username = username || this.api.globals.awxUsername;
|
username = username || AWX_E2E_USERNAME;
|
||||||
password = password || this.api.globals.awxPassword;
|
password = password || AWX_E2E_PASSWORD;
|
||||||
|
|
||||||
const loginPage = this.api.page.login();
|
const loginPage = this.api.page.login();
|
||||||
|
|
||||||
loginPage
|
loginPage
|
||||||
.navigate()
|
.navigate()
|
||||||
.waitForElementVisible('@submit', this.api.globals.longWait)
|
.waitForElementVisible('@submit', AWX_E2E_TIMEOUT_LONG)
|
||||||
.waitForElementNotVisible('div.spinny')
|
.waitForElementNotVisible('div.spinny')
|
||||||
.setValue('@username', username)
|
.setValue('@username', username)
|
||||||
.setValue('@password', password)
|
.setValue('@password', password)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import { AWX_E2E_TIMEOUT_ASYNC } from '../settings';
|
||||||
|
|
||||||
exports.command = function waitForAngular (callback) {
|
exports.command = function waitForAngular (callback) {
|
||||||
this.timeoutsAsyncScript(this.globals.asyncHookTimeout, () => {
|
this.timeoutsAsyncScript(AWX_E2E_TIMEOUT_ASYNC, () => {
|
||||||
this.executeAsync(done => {
|
this.executeAsync(done => {
|
||||||
if (angular && angular.getTestability) {
|
if (angular && angular.getTestability) {
|
||||||
angular.getTestability(document.body).whenStable(done);
|
angular.getTestability(document.body).whenStable(done);
|
||||||
|
|||||||
@@ -2,46 +2,55 @@ import path from 'path';
|
|||||||
|
|
||||||
import chromedriver from 'chromedriver';
|
import chromedriver from 'chromedriver';
|
||||||
|
|
||||||
import { test_workers } from './settings.js';
|
import {
|
||||||
|
AWX_E2E_CLUSTER_HOST,
|
||||||
|
AWX_E2E_CLUSTER_PORT,
|
||||||
|
AWX_E2E_CLUSTER_WORKERS,
|
||||||
|
AWX_E2E_LAUNCH_URL,
|
||||||
|
AWX_E2E_TIMEOUT_ASYNC,
|
||||||
|
AWX_E2E_TIMEOUT_MEDIUM
|
||||||
|
} from './settings';
|
||||||
|
|
||||||
const resolve = location => path.resolve(__dirname, location);
|
const resolve = location => path.resolve(__dirname, location);
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
src_folders: [resolve('tests')],
|
src_folders: [resolve('tests')],
|
||||||
output_folder: resolve('reports'),
|
output_folder: resolve('reports'),
|
||||||
custom_commands_path: resolve('commands'),
|
custom_commands_path: resolve('commands'),
|
||||||
page_objects_path: resolve('objects'),
|
page_objects_path: resolve('objects'),
|
||||||
globals_path: resolve('settings.js'),
|
|
||||||
test_settings: {
|
test_settings: {
|
||||||
default: {
|
default: {
|
||||||
test_workers,
|
|
||||||
skip_testcases_on_fail: false,
|
|
||||||
desiredCapabilities: {
|
|
||||||
browserName: 'chrome'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
smoke: {
|
|
||||||
disable_colors: true,
|
|
||||||
skip_testcases_on_fail: true,
|
|
||||||
filter: 'smoke.js'
|
|
||||||
},
|
|
||||||
debug: {
|
|
||||||
selenium_port: 9515,
|
|
||||||
selenium_host: 'localhost',
|
selenium_host: 'localhost',
|
||||||
|
selenium_port: 9515,
|
||||||
default_path_prefix: '',
|
default_path_prefix: '',
|
||||||
|
desiredCapabilities: { browserName: 'chrome' },
|
||||||
test_workers: { enabled: false },
|
test_workers: { enabled: false },
|
||||||
globals: {
|
globals: {
|
||||||
before(done) {
|
launch_url: AWX_E2E_LAUNCH_URL,
|
||||||
chromedriver.start();
|
retryAssertionTimeout: AWX_E2E_TIMEOUT_MEDIUM,
|
||||||
|
waitForConditionTimeout: AWX_E2E_TIMEOUT_MEDIUM,
|
||||||
|
asyncHookTimeout: AWX_E2E_TIMEOUT_ASYNC,
|
||||||
|
before (done) {
|
||||||
|
chromedriver.start(['--port=9515']);
|
||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
after(done) {
|
after (done) {
|
||||||
chromedriver.stop();
|
chromedriver.stop();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// Note: These are environment-specific overrides to the default
|
||||||
|
// test settings defined above.
|
||||||
|
cluster: {
|
||||||
|
selenium_host: AWX_E2E_CLUSTER_HOST,
|
||||||
|
selenium_port: AWX_E2E_CLUSTER_PORT,
|
||||||
|
default_path_prefix: '/wd/hub',
|
||||||
|
test_workers: {
|
||||||
|
enabled: (AWX_E2E_CLUSTER_WORKERS > 0),
|
||||||
|
workers: AWX_E2E_CLUSTER_WORKERS
|
||||||
|
},
|
||||||
|
globals: { before: {}, after: {} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,30 +1,25 @@
|
|||||||
|
const AWX_E2E_CLUSTER_HOST = process.env.AWX_E2E_CLUSTER_HOST || 'localhost';
|
||||||
|
const AWX_E2E_CLUSTER_PORT = process.env.AWX_E2E_CLUSTER_PORT || 4444;
|
||||||
|
const AWX_E2E_CLUSTER_WORKERS = process.env.AWX_E2E_CLUSTER_WORKERS || 0;
|
||||||
|
const AWX_E2E_PASSWORD = process.env.AWX_E2E_PASSWORD || 'password';
|
||||||
const AWX_E2E_URL = process.env.AWX_E2E_URL || 'https://localhost:8043';
|
const AWX_E2E_URL = process.env.AWX_E2E_URL || 'https://localhost:8043';
|
||||||
const AWX_E2E_USERNAME = process.env.AWX_E2E_USERNAME || 'awx-e2e';
|
const AWX_E2E_USERNAME = process.env.AWX_E2E_USERNAME || 'awx-e2e';
|
||||||
const AWX_E2E_PASSWORD = process.env.AWX_E2E_PASSWORD || 'password';
|
|
||||||
const AWX_E2E_SELENIUM_HOST = process.env.AWX_E2E_SELENIUM_HOST || 'localhost';
|
|
||||||
const AWX_E2E_SELENIUM_PORT = process.env.AWX_E2E_SELENIUM_PORT || 4444;
|
|
||||||
const AWX_E2E_LAUNCH_URL = process.env.AWX_E2E_LAUNCH_URL || AWX_E2E_URL;
|
|
||||||
const AWX_E2E_TIMEOUT_SHORT = process.env.AWX_E2E_TIMEOUT_SHORT || 1000;
|
|
||||||
const AWX_E2E_TIMEOUT_MEDIUM = process.env.AWX_E2E_TIMEOUT_MEDIUM || 5000;
|
|
||||||
const AWX_E2E_TIMEOUT_LONG = process.env.AWX_E2E_TIMEOUT_LONG || 10000;
|
|
||||||
const AWX_E2E_TIMEOUT_ASYNC = process.env.AWX_E2E_TIMEOUT_ASYNC || 30000;
|
const AWX_E2E_TIMEOUT_ASYNC = process.env.AWX_E2E_TIMEOUT_ASYNC || 30000;
|
||||||
const AWX_E2E_WORKERS = process.env.AWX_E2E_WORKERS || 0;
|
const AWX_E2E_TIMEOUT_LONG = process.env.AWX_E2E_TIMEOUT_LONG || 10000;
|
||||||
|
const AWX_E2E_TIMEOUT_MEDIUM = process.env.AWX_E2E_TIMEOUT_MEDIUM || 5000;
|
||||||
|
const AWX_E2E_TIMEOUT_SHORT = process.env.AWX_E2E_TIMEOUT_SHORT || 1000;
|
||||||
|
const AWX_E2E_LAUNCH_URL = process.env.AWX_E2E_LAUNCH_URL || AWX_E2E_URL;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
awxURL: AWX_E2E_URL,
|
AWX_E2E_CLUSTER_HOST,
|
||||||
awxUsername: AWX_E2E_USERNAME,
|
AWX_E2E_CLUSTER_PORT,
|
||||||
awxPassword: AWX_E2E_PASSWORD,
|
AWX_E2E_CLUSTER_WORKERS,
|
||||||
asyncHookTimeout: AWX_E2E_TIMEOUT_ASYNC,
|
AWX_E2E_LAUNCH_URL,
|
||||||
longTmeout: AWX_E2E_TIMEOUT_LONG,
|
AWX_E2E_PASSWORD,
|
||||||
mediumTimeout: AWX_E2E_TIMEOUT_MEDIUM,
|
AWX_E2E_URL,
|
||||||
retryAssertionTimeout: AWX_E2E_TIMEOUT_MEDIUM,
|
AWX_E2E_USERNAME,
|
||||||
selenium_host: AWX_E2E_SELENIUM_HOST,
|
AWX_E2E_TIMEOUT_ASYNC,
|
||||||
selenium_port: AWX_E2E_SELENIUM_PORT,
|
AWX_E2E_TIMEOUT_LONG,
|
||||||
launch_url: AWX_E2E_LAUNCH_URL,
|
AWX_E2E_TIMEOUT_MEDIUM,
|
||||||
shortTimeout: AWX_E2E_TIMEOUT_SHORT,
|
AWX_E2E_TIMEOUT_SHORT
|
||||||
waitForConditionTimeout: AWX_E2E_TIMEOUT_MEDIUM,
|
|
||||||
test_workers: {
|
|
||||||
enabled: (AWX_E2E_WORKERS > 0),
|
|
||||||
workers: AWX_E2E_WORKERS
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
|
|
||||||
|
import { AWX_E2E_TIMEOUT_LONG } from '../settings';
|
||||||
|
|
||||||
const testID = uuid().substr(0, 8);
|
const testID = uuid().substr(0, 8);
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
@@ -161,7 +163,7 @@ module.exports = {
|
|||||||
const row = '#credentials_table tbody tr';
|
const row = '#credentials_table tbody tr';
|
||||||
|
|
||||||
credentials.section.list.section.search
|
credentials.section.list.section.search
|
||||||
.waitForElementVisible('@input', client.globals.longWait)
|
.waitForElementVisible('@input', AWX_E2E_TIMEOUT_LONG)
|
||||||
.setValue('@input', `name:${store.credential.name}`)
|
.setValue('@input', `name:${store.credential.name}`)
|
||||||
.click('@searchButton');
|
.click('@searchButton');
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
|
|
||||||
|
import { AWX_E2E_TIMEOUT_LONG } from '../settings';
|
||||||
|
|
||||||
const testID = uuid().substr(0, 8);
|
const testID = uuid().substr(0, 8);
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
@@ -123,7 +125,7 @@ module.exports = {
|
|||||||
const row = '#credentials_table tbody tr';
|
const row = '#credentials_table tbody tr';
|
||||||
|
|
||||||
credentials.section.list.section.search
|
credentials.section.list.section.search
|
||||||
.waitForElementVisible('@input', client.globals.longWait)
|
.waitForElementVisible('@input', AWX_E2E_TIMEOUT_LONG)
|
||||||
.setValue('@input', `name:${store.credential.name}`)
|
.setValue('@input', `name:${store.credential.name}`)
|
||||||
.click('@searchButton');
|
.click('@searchButton');
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
|
|
||||||
|
import { AWX_E2E_TIMEOUT_LONG } from '../settings';
|
||||||
|
|
||||||
const testID = uuid().substr(0, 8);
|
const testID = uuid().substr(0, 8);
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
@@ -169,7 +171,7 @@ module.exports = {
|
|||||||
const row = '#credentials_table tbody tr';
|
const row = '#credentials_table tbody tr';
|
||||||
|
|
||||||
credentials.section.list.section.search
|
credentials.section.list.section.search
|
||||||
.waitForElementVisible('@input', client.globals.longWait)
|
.waitForElementVisible('@input', AWX_E2E_TIMEOUT_LONG)
|
||||||
.setValue('@input', `name:${store.credential.name}`)
|
.setValue('@input', `name:${store.credential.name}`)
|
||||||
.click('@searchButton');
|
.click('@searchButton');
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
|
|
||||||
|
import { AWX_E2E_TIMEOUT_LONG } from '../settings';
|
||||||
|
|
||||||
const testID = uuid().substr(0, 8);
|
const testID = uuid().substr(0, 8);
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
@@ -194,7 +196,7 @@ module.exports = {
|
|||||||
const row = '#credentials_table tbody tr';
|
const row = '#credentials_table tbody tr';
|
||||||
|
|
||||||
credentials.section.list.section.search
|
credentials.section.list.section.search
|
||||||
.waitForElementVisible('@input', client.globals.longWait)
|
.waitForElementVisible('@input', AWX_E2E_TIMEOUT_LONG)
|
||||||
.setValue('@input', `name:${store.credential.name}`)
|
.setValue('@input', `name:${store.credential.name}`)
|
||||||
.click('@searchButton');
|
.click('@searchButton');
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
|
|
||||||
|
import { AWX_E2E_TIMEOUT_LONG } from '../settings';
|
||||||
|
|
||||||
const testID = uuid().substr(0, 8);
|
const testID = uuid().substr(0, 8);
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
@@ -163,7 +165,7 @@ module.exports = {
|
|||||||
const row = '#credentials_table tbody tr';
|
const row = '#credentials_table tbody tr';
|
||||||
|
|
||||||
credentials.section.list.section.search
|
credentials.section.list.section.search
|
||||||
.waitForElementVisible('@input', client.globals.longWait)
|
.waitForElementVisible('@input', AWX_E2E_TIMEOUT_LONG)
|
||||||
.setValue('@input', `name:${store.credential.name}`)
|
.setValue('@input', `name:${store.credential.name}`)
|
||||||
.click('@searchButton');
|
.click('@searchButton');
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import uuid from 'uuid';
|
import uuid from 'uuid';
|
||||||
|
|
||||||
|
import { AWX_E2E_TIMEOUT_LONG } from '../settings';
|
||||||
|
|
||||||
const testID = uuid().substr(0, 8);
|
const testID = uuid().substr(0, 8);
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
organization: {
|
organization: {
|
||||||
name: `org-${testID}`
|
name: `org-${testID}`
|
||||||
@@ -123,7 +126,7 @@ module.exports = {
|
|||||||
const row = '#credentials_table tbody tr';
|
const row = '#credentials_table tbody tr';
|
||||||
|
|
||||||
credentials.section.list.section.search
|
credentials.section.list.section.search
|
||||||
.waitForElementVisible('@input', client.globals.longWait)
|
.waitForElementVisible('@input', AWX_E2E_TIMEOUT_LONG)
|
||||||
.setValue('@input', `name:${store.credential.name}`)
|
.setValue('@input', `name:${store.credential.name}`)
|
||||||
.click('@searchButton');
|
.click('@searchButton');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user