[Intern] Casper tests replaced with Intern

Intern-based test suites are quite complete and stable and
should be used instead of outdated CasperJS-based suites.

Related to blueprint ui-functional-tests-with-intern
Partial-Bug: #1495536

Change-Id: I7272eb81fa54d914915ef45a0be777afa4b9d793
This commit is contained in:
Nick Bogdanov 2015-09-11 13:29:13 +03:00 committed by Vitaly Kramskikh
parent 8cee51e582
commit 4087edc05a
12 changed files with 2 additions and 2620 deletions

View File

@ -160,13 +160,12 @@ Setup for Web UI Tests
sudo apt-get remove --yes nodejs nodejs-legacy
sudo apt-get install --yes software-properties-common
sudo apt-get install --yes libfontconfig # missing package required by phantomjs
sudo add-apt-repository --yes ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install --yes nodejs
sudo apt-get install --yes npm
npm install >/dev/null 2>&1 || true # To initialize $HOME/.npm
sudo npm install -g gulp phantomjs
sudo npm install -g gulp
cd nailgun
npm install

View File

@ -1,35 +0,0 @@
(function() {
var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
Fp.bind = function(context) {
var func = this;
var args = slice.call(arguments, 1);
function bound() {
var invokedAsConstructor = func.prototype && (this instanceof func);
return func.apply(
// Ignore the context parameter when invoking the bound function
// as a constructor. Note that this includes not only constructor
// invocations using the new keyword but also calls to base class
// constructors such as BaseClass.call(this, ...) or super(...).
!invokedAsConstructor && context || this,
args.concat(slice.call(arguments))
);
}
// The bound function must share the .prototype of the unbound
// function so that any object created by one constructor will count
// as an instance of both constructors.
bound.prototype = func.prototype;
return bound;
};
}
})();

View File

@ -1,230 +0,0 @@
/*
* Copyright 2013 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
var system = require('system');
var port = system.env.SERVER_PORT || 5544;
var baseUrl = 'http://127.0.0.1:' + port + '/';
var authToken;
var addTokenHeader = function(headers) {
var ret = {},
property;
headers = headers || {};
if (authToken) {
ret['X-Auth-Token'] = authToken;
}
for (property in headers) {
if (headers.hasOwnProperty(property)) {
ret[property] = headers[property];
}
}
return ret;
};
casper.on('page.error', function(msg) {
casper.echo(msg, 'ERROR');
});
casper.on('page.initialized', function(msg) {
this.loadJsFile('bind-polyfill');
});
casper.loadPage = function(page) {
//FIXME: hack to prevent ajax requests interruption (phantomjs issue)
this.wait(1000);
return this.thenOpen(baseUrl + page).waitWhileSelector('#main-container > .loading');
}
casper.loadJsFile = function(file) {
return this.page.injectJs('ui_tests/' + file + '.js');
}
casper.test.assertSelectorAppears = function(selector, message, timeout) {
return this.casper.waitForSelector(selector, function () {
this.test.pass(message);
}, function() {
this.test.fail(message);
}, timeout);
}
casper.test.assertSelectorDisappears = function(selector, message, timeout) {
return this.casper.waitWhileSelector(selector, function () {
this.test.pass(message);
}, function() {
this.test.fail(message);
}, timeout);
}
casper.authenticate = function(options) {
options = options || {};
var username = options.username || 'admin',
password = options.password || 'admin';
this.thenOpen(baseUrl + 'keystone/v2.0/tokens', {
method: 'post',
headers: addTokenHeader({'Content-Type': 'application/json'}),
data: JSON.stringify({
auth: {
passwordCredentials: {
username: username,
password: password
}
}
})
});
this.then(function() {
authToken = this.evaluate(function() {
var data,
authToken = '',
username;
try {
data = JSON.parse(document.body.innerText);
authToken = data.access.token.id;
username = data.access.user.username;
} catch (ignore) {}
localStorage.setItem('token', authToken);
localStorage.setItem('username', username);
return authToken;
});
});
return this;
}
casper.skipWelcomeScreen = function() {
return this.then(function() {
this.thenOpen(baseUrl + 'api/settings', {
method: 'get',
headers: addTokenHeader({'Content-Type': 'application/json'})
});
this.then(function() {
var fuelSettings = this.evaluate(function() {
return JSON.parse(document.body.innerText);
});
fuelSettings.settings.statistics.user_choice_saved.value = true;
this.thenOpen(baseUrl + 'api/settings', {
method: 'put',
headers: addTokenHeader({'Content-Type': 'application/json'}),
data: JSON.stringify(fuelSettings)
});
});
});
}
casper.createCluster = function(options) {
options.release = 2; // ubuntu
this.then(function() {
return this.open(baseUrl + 'api/clusters', {
method: 'post',
headers: addTokenHeader({'Content-Type': 'application/json'}),
data: JSON.stringify(options)
});
});
}
casper.createNode = function(options) {
var mac = '52:54:00:96:81:6E';
if('mac' in options) {
mac = options['mac'];
}
options.meta = {
"disks": [
{
"model": "TOSHIBA MK3259GS",
"disk": "sda",
"name": "sda",
"size": 100010485760
},
{
"model": "TOSHIBA",
"disk": "vda",
"name": "vda",
"size": 80010485760
}
],
"interfaces": [
{
"mac": mac,
"name": "eth0",
"max_speed": 1000,
"current_speed": 100
},
{
"ip": "10.20.0.3",
"mac": "C8:0A:A9:A6:FF:28",
"name": "eth1",
"max_speed": 1000,
"current_speed": 1000,
"pxe": true
},
{
"mac": "D4:56:C3:88:99:DF",
"name": "eth0:1",
"max_speed": 2000,
"current_speed": null
}
],
"cpu": {
"real": 0,
"0": {
"family": "6",
"vendor_id": "GenuineIntel",
"mhz": "3192.766",
"stepping": "3",
"cache_size": "4096 KB",
"flags": [
"fpu",
"lahf_lm"
],
"model": "2",
"model_name": "QEMU Virtual CPU version 0.14.1"
},
"total": 1
},
"memory": {
"slots": 6,
"total": 4294967296,
"maximum_capacity": 8589934592,
"devices": [
{
"size": 1073741824
},
{
"size": 1073741824
},
{
"size": 1073741824
},
{
"size": 1073741824
}
]
}
};
return this.thenOpen(baseUrl + 'api/nodes', {
method: 'post',
headers: addTokenHeader({'Content-Type': 'application/json'}),
data: JSON.stringify(options)
});
}

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +0,0 @@
/*
* Copyright 2013 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().authenticate().skipWelcomeScreen();
casper.createCluster({name: 'Test Cluster'});
casper.createNode({status: 'discover', mac: '84:AA:B8:E6:30:F0', cluster_id: 1});
casper.loadPage('#cluster/1/logs').waitForSelector('.logs-tab > *');
casper.then(function() {
if (this.loadJsFile('sinon-server')) {
this.evaluate(function() {
var server = sinon.fakeServer.create();
server.autoRespond = true;
server.respondWith(/\/api\/logs.*/, [
200, {"Content-Type": "application/json"},
JSON.stringify({
from: 1,
entries: [['Date', 'INFO', 'Test Log Entry']]
})
]);
});
} else {
this.test.error('Unable to load sinon');
this.test.done();
}
});
casper.then(function() {
this.test.comment('Testing logs tab');
this.test.assertSelectorAppears('.sticker select[name=source] option', 'Log source selection box appears and is not empty');
this.test.assertSelectorAppears('.sticker button:disabled', '"Show logs" button is locked');
this.then(function() {
this.fill('.sticker', {'level': 'DEBUG'});
});
this.test.assertSelectorAppears('.sticker button:not([disabled])', '"Show logs" button is enabled after "Levels" change');
this.then(function() {
this.click('.sticker button');
});
this.waitForSelector('.log-entries > *').then(function() {
this.test.assertSelectorHasText('.log-entries tr:first-child td:last-child', 'Test Log Entry', 'Log entry appears after clicking "Show logs" button');
});
});
casper.run(function() {
this.test.done();
});

View File

@ -1,115 +0,0 @@
/*
* Copyright 2015 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().authenticate().skipWelcomeScreen();
casper.createCluster({name: 'Test Cluster', net_provider: 'nova_network'});
casper.loadPage('#cluster/1/network').waitForSelector('.network-tab > *');
casper.then(function() {
this.test.comment('Testing cluster networks: layout rendered');
this.test.assertEvalEquals(function() {return $('.checkbox-group input[name=net_provider]').length}, 2, 'Network manager options are presented');
this.test.assertExists('input[value=FlatDHCPManager]:checked', 'Flat DHCP manager is chosen');
this.test.assertEvalEquals(function() {return $('.network-tab h3').length}, 4, 'All networks are presented');
this.test.assertDoesntExist('.verify-networks-btn:disabled', 'Verify networks button is enabled');
this.test.assertExists('.apply-btn:disabled', 'Save networks button is disabled');
});
casper.then(function() {
this.test.comment('Testing cluster networks: Save button interactions');
this.click('input[name=net_provider]:not(:checked)');
this.test.assertDoesntExist('.apply-btn:disabled', 'Save networks button is enabled if there are changes');
this.click('input[name=net_provider]:not(:checked)');
this.test.assertExists('.apply-btn:disabled', 'Save networks button is disabled again if there are no changes');
});
casper.then(function() {
this.test.comment('Testing cluster networks: change network manager');
this.click('input[name=net_provider]:not(:checked)');
this.test.assertExists('input[name=fixed_networks_amount]', 'Amount field for a fixed network is presented in VLAN mode');
this.test.assertExists('select[name=fixed_network_size]', 'Size field for a fixed network is presented in VLAN mode');
this.test.assertExists('.apply-btn:not(:disabled)', 'Save networks button is enabled after manager was changed');
this.click('input[name=net_provider]:not(:checked)');
this.test.assertDoesntExist('input[name=fixed_networks_amount]', 'Amount field was hidden after revert to FlatDHCP');
this.test.assertDoesntExist('select[name=fixed_network_size]', 'Size field was hidden after revert to FlatDHCP');
this.test.assertExists('.apply-btn:disabled', 'Save networks button is disabled again after revert to FlatDHCP');
});
casper.then(function() {
this.test.comment('Testing cluster networks: VLAN range fields');
this.click('input[name=net_provider]:not(:checked)');
this.test.assertExists('.network-section-wrapper input[name=range-end_fixed_networks_vlan_start]', 'VLAN range is displayed');
this.click('input[name=net_provider]:not(:checked)');
});
casper.then(function() {
this.test.comment('Testing cluster networks: save changes');
this.click('input[name=net_provider]:not(:checked)');
this.click('.apply-btn:not(:disabled)');
this.test.assertSelectorAppears('input:not(:disabled)', 'Input is not disabled');
this.then(function() {
this.test.assertDoesntExist('.alert-error', 'Correct settings were saved successfully');
});
this.click('input[name=net_provider]:not(:checked)');
});
casper.then(function() {
this.test.comment('Testing cluster networks: verification');
this.click('.verify-networks-btn:not(:disabled)');
this.test.assertSelectorAppears('.connect-3.error',
' At least two nodes are required to be in the environment for network verification.', 10000);
});
casper.then(function() {
this.test.comment('Testing cluster networks: verification task deletion');
this.click('input[name=net_provider]:not(:checked)');
this.test.assertDoesntExist('.page-control-box .alert', 'Verification task was removed after settings has been changed');
this.click('input[name=net_provider]:not(:checked)');
});
casper.then(function() {
this.test.comment('Check VlanID field validation');
this.click('.management input[type=checkbox]');
this.then(function() {
this.click('.management input[type=checkbox]');
});
this.then(function() {
this.test.assertExists('.management .has-error input[name=vlan_start]', 'Field validation has worked properly in case of empty value');
});
});
casper.then(function() {
this.test.comment('Testing cluster networks: data validation');
this.click('.network-section-wrapper input[name=fixed_networks_vlan_start]');
this.click('input[name=net_provider]:not(:checked)');
this.test.assertExists('.network-section-wrapper .has-error input[name=range-start_fixed_networks_vlan_start]', 'Field validation has worked');
this.test.assertExists('.apply-btn:disabled', 'Save networks button is disabled if there is validation error');
this.click('input[name=net_provider]:not(:checked)');
this.click('.network-section-wrapper input[name=fixed_networks_vlan_start]');
this.test.assertDoesntExist('.network-section-wrapper .has-error input[name=range-start_fixed_networks_vlan_start]', 'Field validation works properly');
});
/*
* casper tests with text input fields validation do not work
* because the version of casper we use cannot send native
* keyboard events to the text inputs
* (morale)
* @TODO: port these tests
*/
casper.run(function() {
this.test.done();
});

View File

@ -1,79 +0,0 @@
/*
* Copyright 2013 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().authenticate().skipWelcomeScreen();
casper.createCluster({name: 'Test Cluster'});
casper.loadPage('#cluster/1/settings').waitForSelector('.settings-tab > *');
casper.then(function() {
this.test.comment('Testing cluster OpenStack settings');
this.test.assertExists('.btn-load-defaults:not(:disabled)', 'Load defaults button is enabled');
this.test.assertExists('.btn-revert-changes:disabled', 'Cancel changes button is disabled');
this.test.assertExists('.btn-apply-changes:disabled', 'Save settings button is disabled');
});
casper.then(function() {
this.test.comment('Switch to common subtab');
this.click('a.subtab-link-common');
this.test.assertSelectorAppears('span.subtab-group-common', 'Common subtab is selected');
});
casper.then(function() {
this.test.comment('Testing cluster OpenStack settings: Save button interractions');
this.click('input[type=checkbox]');
this.test.assertExists('.btn-apply-changes:not(:disabled)', 'Save settings button is enabled if there are changes');
this.click('input[type=checkbox]');
this.test.assertSelectorAppears('.btn-apply-changes:disabled', 'Save settings button is disabled again if there are no changes');
});
casper.then(function() {
this.test.comment('Testing cluster OpenStack settings: cancel changes operation');
this.click('input[type=checkbox]');
this.click('.cluster-tab.active + .cluster-tab');
this.test.assertSelectorAppears('.dismiss-settings-dialog', 'Dismiss changes dialog appears if there are changes and user is going to leave the tab');
this.then(function() {
this.click('.modal-footer .btn-default');
});
this.test.assertSelectorDisappears('.dismiss-settings-dialog', 'Dismiss changes dialog was closed');
this.then(function() {
this.click('.btn-revert-changes');
this.test.assertExists('.btn-apply-changes:disabled', 'Save settings button is disabled again after changes were cancelled');
});
});
casper.then(function() {
this.test.comment('Testing OpenStack settings: save changes');
this.click('input[type=checkbox]');
this.test.assertExists('.btn-apply-changes:not(:disabled)', 'Save settings button is enabled');
this.click('.btn-apply-changes:not(:disabled)');
this.waitWhileSelector('.btn-load-defaults:disabled');
this.then(function() {
this.test.assertExists('.btn-revert-changes:disabled', 'Cancel changes button is disabled after changes were saved successfully');
});
});
casper.then(function() {
this.test.comment('Testing OpenStack settings: load defaults');
this.click('.btn-load-defaults');
this.waitWhileSelector('.btn-load-defaults:disabled');
this.then(function() {
this.test.assertExists('.btn-revert-changes:not(:disabled)', 'Cancel changes button is enabled after defaults were loaded');
this.test.assertExists('.btn-apply-changes:not(:disabled)', 'Save settings button is enabled after defaults were loaded');
});
});
casper.run(function() {
this.test.done();
});

View File

@ -1,202 +0,0 @@
/*
* Copyright 2013 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().authenticate().skipWelcomeScreen();
casper.createCluster({name: 'Test Cluster'});
var nodes = [
{status: 'discover', manufacturer: 'Dell', mac: 'C0:8D:DF:52:76:F1'}
];
nodes.forEach(function(node) {
casper.createNode(node);
});
casper.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
casper.then(function() {
this.test.comment('Testing cluster page');
this.test.assertDoesntExist('.deploy-btn:disabled', 'Deploy changes button is hidden');
});
casper.loadPage('#cluster/1/nodes').waitForSelector('.nodes-tab > *');
casper.then(function() {
this.test.assertExists('.btn-configure-disks:disabled', 'Button Configure Disks is disabled');
this.test.assertExists('.btn-configure-interfaces:disabled', 'Button Configure Interfaces is disabled');
this.test.assertExists('.btn-add-nodes:not(:disabled)', 'Add Nodes button is enabled');
this.test.assertEvalEquals(function() {return $('.node').length}, 0, 'Number of environment nodes is correct');
});
casper.then(function() {
this.test.comment('Testing adding node with controller role');
this.click('.btn-add-nodes');
this.test.assertSelectorAppears('.node', 'Add Nodes screen appeared and unallocated nodes loaded');
this.then(function() {
this.test.assertEvalEquals(function() {return $('.node').length}, 9, 'Number of unallocated nodes is correct');
this.click('input[name=controller]');
this.click('.node input[type=checkbox]');
this.test.assertSelectorAppears('.node .role-list > ul', 'Controller role is applied to the node');
});
this.then(function() {
this.click('.btn-apply');
this.test.assertSelectorDisappears('.role-panel', 'Return to nodes tab');
});
this.then(function() {
this.test.assertEvalEquals(function() {return $('.node').length}, 1, 'Number of available roles is correct');
});
});
casper.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
casper.then(function() {
this.test.assertExists('.deploy-btn:not(:disabled)', 'Deploy changes button is enabled now');
this.test.comment('Testing Reset button is hidden');
this.test.assertDoesntExist('.reset-environment-btn', 'Reset button does not exist');
});
casper.then(function() {
this.test.comment('Testing stop deployment');
this.test.assertExists('.deploy-btn:not(:disabled)', 'Deploy changes button is enabled');
this.click('.deploy-btn'); // "Deploy changes" button click
this.test.assertSelectorAppears('.modal', 'Deployment dialog opens');
this.then(function() {
this.click('.modal .start-deployment-btn'); // "Start Deployment" button click
});
this.test.assertSelectorDisappears('.modal', 'Deployment dialog closes after clicking Start Deployment');
this.test.assertSelectorDisappears('.deploy-btn', 'Deploy changes button disappears');
this.then(function() {
this.test.assertSelectorAppears('.deploy-process .progress-bar', 'Deployment progress bar appears');
this.test.assertSelectorAppears('.stop-deployment-btn', 'Stop deployment button appears');
});
this.then(function() {
this.click('.stop-deployment-btn'); // "Stop Deployment" button click
});
this.test.assertSelectorAppears('.modal', 'Stop Deployment dialog opens');
this.then(function() {
this.click('.modal .stop-deployment-btn'); // "Stop Deployment" on modal screen button click
});
this.then(function() {
this.test.assertSelectorDisappears('.modal', 'Stop deployment dialog closes after clicking Stop button');
this.test.assertSelectorAppears('.deploy-process .progress-bar', 'Deployment progress bar appears');
this.test.assertSelectorDisappears('.deploy-process .progress-bar', 'Deployment progress bar disappears', 60000);
});
this.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
this.then(function() {
this.test.assertSelectorAppears('.deploy-btn:not(:disabled)', 'Deploy changes button is enabled again');
this.test.assertSelectorAppears('.alert-warning', 'Success stopping deployment alert message appears');
});
this.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
this.then(function() {
this.test.assertExists('.reset-environment-btn:not(:disabled)', 'Reset button exist and enabled after stopped deployment');
});
});
casper.loadPage('#cluster/1/nodes').waitForSelector('.nodes-tab > *');
casper.then(function() {
this.test.comment('Testing Tabs locking after deployment stop and there are no Ready Nodes');
this.test.assertEvalEquals(function() {return $('.node.ready').length}, 0, 'Number of ready nodes is correct');
this.loadPage('#cluster/1/network').waitForSelector('.network-tab > *');
this.then(function() {
this.test.assertDoesntExist('.network-tab .changes-locked', 'Network Tab is unlocked');
});
this.loadPage('#cluster/1/settings').waitForSelector('.settings-tab > *');
this.then(function() {
this.test.assertExists('input[name=tenant]:not(:disabled)', 'Settings Tab is unlocked');
});
// TODO: add "Health Check" Tab checking - it should be locked in this scenario
});
casper.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
casper.then(function() {
this.test.comment('Testing deployment process');
this.test.assertExists('.deploy-btn:not(:disabled)', 'Deploy changes button is enabled');
this.click('.deploy-btn'); // "Deploy changes" button click
this.test.assertSelectorAppears('.modal', 'Deployment dialog opens');
this.then(function() {
this.click('.modal .start-deployment-btn'); // "Start Deployment" button click
});
this.test.assertSelectorDisappears('.modal', 'Deployment dialog closes after clicking Start Deployment');
this.test.assertSelectorDisappears('.deploy-btn', 'Deploy changes button disappears');
this.test.assertSelectorAppears('.deploy-process .progress-bar', 'Deployment progress bar appears');
this.test.assertSelectorAppears('.stop-deployment-btn', 'Stop deployment button appears');
this.waitForSelector('.node.ready', function() { // We are waiting till node become ready
this.test.assertEvalEquals(function() {return $('.node.ready').length}, 1, 'Number of ready nodes is correct');
}, function() { this.test.comment('Timeout reached'); }, 60000);
this.test.assertSelectorDisappears('.deploy-process .progress-bar', 'Deployment progress bar disappears', 60000);
this.then(function() {
this.test.assertExists('.alert-success', 'Success deployment process finish message appears');
this.test.assertSelectorDisappears('.deploy-btn', 'Deploy changes button is not shown');
var countIsReadyNodes = this.evaluate(function() { // get count of Nodes with Ready status
return $('.node.ready').length;
});
this.test.assertEvalEquals(function() {return $('.node').length}, countIsReadyNodes, 'All nodes in list are ready');
});
});
casper.then(function() {
this.test.comment('Testing Tabs locking after deployment finished completely');
this.loadPage('#cluster/1/network').waitForSelector('.network-tab > *');
this.then(function() {
this.test.assertExists('.network-tab .changes-locked', 'Network Tab is Locked');
});
this.loadPage('#cluster/1/settings').waitForSelector('.settings-tab > *');
this.then(function() {
this.test.assertExists('input[name=tenant]:disabled', 'Settings Tab is Locked');
});
// TODO: add "Health Check" Tab checking - it should be Unlocked in this scenario
});
casper.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
casper.then(function() {
this.test.comment('Testing Reset button');
this.test.assertExists('.reset-environment-btn:not(:disabled)', 'Reset button exist and enabled after successful finished deployment');
this.click('.reset-environment-btn'); // "Reset" button click
this.test.assertSelectorAppears('.modal', 'Reset dialog opens');
this.then(function() {
this.click('.modal .reset-environment-btn'); // "Reset environment" button click
});
this.test.assertSelectorAppears('.modal .confirm-reset-form', 'Confirmation of reset action requested');
this.then(function() {
this.fill('.modal .confirm-reset-form', {name: 'Test Cluster'});
this.click('.modal .reset-environment-btn:not(:disabled)');
});
this.test.assertSelectorDisappears('.modal', 'Reset dialog closes after clicking Reset button');
this.test.assertSelectorDisappears('.deploy-btn', 'Deploy changes button disappears');
this.test.assertSelectorAppears('.deploy-process .progress-bar', 'Reset progress bar appears');
this.test.assertSelectorDisappears('.deploy-process .progress-bar', 'Reset progress bar disappears', 60000);
casper.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
this.then(function() {
this.test.assertExists('.deploy-btn:not(:disabled)', 'Deploy changes button is enabled again');
this.test.assertExists('.alert-warning', 'Success reset message appears');
});
casper.loadPage('#cluster/1/nodes').waitForSelector('.nodes-tab > *');
this.then(function() {
this.test.assertEvalEquals(function() {return $('.node').length}, 1, 'Number of count nodes is correct');
this.test.assertEvalEquals(function() {return $('.node.ready').length}, 0, 'Number of ready nodes is correct');
});
this.loadPage('#cluster/1/dashboard').waitForSelector('.dashboard-tab > *');
this.then(function() {
this.test.assertSelectorDisappears('.reset-environment-btn', 'Reset button is not shown after successful reset');
});
});
casper.run(function() {
this.test.done();
});

View File

@ -1,47 +0,0 @@
/*
* Copyright 2013 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().authenticate().skipWelcomeScreen().loadPage('#clusters').waitForSelector('.clusters-page');
casper.then(function() {
this.test.comment('Testing cluster list page');
this.test.assertExists('.clusters-page > .row', 'Cluster container exists');
this.test.assertExists('.create-cluster', 'Cluster creation control exists');
});
casper.then(function() {
this.test.comment('Testing cluster creation');
var name = 'Test Cluster';
this.click('.create-cluster');
this.test.assertSelectorAppears('.modal', 'Cluster creation dialog opens');
this.test.assertSelectorAppears('.modal form select[name=release] option', 'Release select box updates with releases');
this.then(function() {
this.fill('form.create-cluster-form', {name: name});
for (var i = 0; i < 6; i++) {
this.click('.next-pane-btn');
}
this.click('.finish-btn');
});
this.test.assertSelectorDisappears('.modal', 'Cluster creation dialog closes after from submission');
this.then(function() {
// redirect should be made to the cluster page
this.test.assertUrlMatch(/#cluster\/\d+\/dashboard/, 'Redirect to cluster page');
});
});
casper.run(function() {
this.test.done();
});

View File

@ -1,116 +0,0 @@
/*
* Copyright 2014 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().loadPage('#');
casper.then(function() {
this.evaluate(function() {
window.app.logout();
})
});
casper.then(function() {
var authenticated = this.evaluate(function() {
return window.app.user.get('authenticated');
}),
token = this.evaluate(function() {
return window.app.keystoneClient.token;
});
this.test.assertNot(authenticated, 'User is not authenticated');
this.test.assertNot(token, 'Token is not set');
this.test.assertUrlMatch(/#login/, 'Redirect to login page after logout');
});
casper.then(casper.authenticate).then(casper.skipWelcomeScreen).loadPage('#clusters').waitForSelector('.clusters-page');
casper.then(function() {
var authenticated = this.evaluate(function() {
return window.app.user.get('authenticated');
}),
token = this.evaluate(function() {
return window.app.keystoneClient.token;
});
this.test.assertExists('.navbar-icons .user-icon', 'User icon exists');
this.click('.navbar-icons .user-icon');
this.test.assertExists('.user-popover .btn-logout', 'Logout button exists');
this.test.assertExists('.user-popover .name', 'Username exists');
// TODO: test for span.username content to be equal to localStorage.getItem('username')
// The problem for now is that CasperJS doesn't preserve localStorage for some reason
this.test.assert(authenticated, 'User is authenticated');
this.test.assert(!!token, 'Token is set');
});
casper.loadPage('#logout');
casper.then(function() {
var authenticated = this.evaluate(function() {
return window.app.user.get('authenticated');
}),
token = this.evaluate(function() {
return window.app.keystoneClient.token;
});
this.test.assertNot(authenticated, 'User is not authenticated');
this.test.assertNot(token, 'Token is not set');
this.test.assertUrlMatch(/#login/, 'Redirect to login page after logout');
});
// Test failing token DELETE response
casper.then(casper.authenticate).loadPage('#clusters');
casper.then(function() {
if (this.loadJsFile('sinon-server')) {
this.evaluate(function() {
var server = sinon.fakeServer.create();
server.autoRespond = true;
server.respondWith('DELETE', /\/keystone\/v2\.0\/tokens\/.*/, [
502, null, ''
]);
});
} else {
this.test.error('Unable to load sinon');
this.test.done();
}
});
casper.then(function() {
casper.loadPage('#logout');
});
casper.then(function() {
this.test.assertUrlMatch(/#login/, 'Redirect to login page after logout with failed server request');
});
// make sure we're on #login page again, not clusters
casper.then(function() {
casper.loadPage('#clusters');
});
casper.then(function() {
this.test.assertUrlMatch(/#login/, 'Redirect to login page after requesting #clusters, when logged out with failed server request');
});
casper.loadPage('#clusters');
casper.then(function() {
this.test.assertUrlMatch(/#login/, 'Redirect to login page after requesting #clusters, when logged out with failed server request');
});
casper.run(function() {
this.test.done();
});

View File

@ -1,107 +0,0 @@
/*
* Copyright 2013 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().authenticate().skipWelcomeScreen();
casper.createCluster({name: 'Test Cluster'});
var nodes = [
{status: 'discover', manufacturer: 'Dell', mac: 'C0:8D:DF:52:76:F1', cluster_id: 1, roles: ['compute'], pending_addition: true}
];
nodes.forEach(function(node) {
casper.createNode(node);
});
var vmSDA;
var osSDA;
casper.loadPage('#cluster/1/nodes').waitForSelector('.nodes-tab > *');
casper.then(function() {
this.test.comment('Testing nodes disks');
var sdaDisk = '.disk-box[data-disk=sda]';
var sdaDiskVM = sdaDisk + ' .disk-utility-box [data-volume=vm]';
var sdaDiskOS = sdaDisk + ' .disk-utility-box [data-volume=os]';
var vdaDisk = '.disk-box[data-disk=vda]';
var vdaDiskVM = vdaDisk + ' .disk-utility-box [data-volume=vm]';
var vdaDiskOS = vdaDisk + ' .disk-utility-box [data-volume=os]';
this.then(function() {
this.then(function() {
this.click('.node-settings');
});
this.test.assertSelectorAppears('.modal', 'Node details popup was opened');
this.then(function() {
this.click('.btn-edit-disks');
});
this.test.assertSelectorAppears('.disk-box', 'Node disks configuration screen appears');
});
this.then(function() {
this.test.comment('Testing nodes disks layout');
this.test.assertEvalEquals(function() {return $('.disk-box').length}, 2, 'Number of disks is correct');
this.test.assertExists('.btn-defaults:not(:disabled)', 'Load Defaults button is enabled');
this.test.assertExists('.btn-revert-changes:disabled', 'Cancel button is disabled');
this.test.assertExists('.btn-apply:disabled', 'Apply button is disabled');
});
this.then(function() {
this.test.comment('Testing nodes disk block');
this.click(sdaDisk + ' .disk-visual [data-volume=os] .toggle');
vmSDA = this.getElementAttribute(sdaDiskVM + ' input[type=number]', 'value');
osSDA = this.getElementAttribute(sdaDiskOS + ' input[type=number]', 'value');
this.test.assertExists(sdaDiskOS, 'Base system group form is presented');
this.test.assertExists(sdaDiskVM, 'Virtual Storage group form is presented');
this.test.assertDoesntExist(sdaDisk + ' .disk-visual [data-volume=os] .close-btn', 'Button Close for Base system group is not presented');
this.test.assertExists(sdaDisk + ' .disk-visual [data-volume=vm] .close-btn', 'Button Close for Virtual Storage group is presented');
});
this.then(function() {
this.test.comment('Testing button Apply: interractions');
this.fill(sdaDiskVM, {'vm': '80'});
this.evaluate(function(sdaDiskVM) {$(sdaDiskVM + ' input').keyup();}, {sdaDiskVM: sdaDiskVM});
this.test.assertExists('.btn-defaults:not(:disabled)', 'Load Defaults button is enabled');
this.test.assertExists('.btn-revert-changes:not(:disabled)', 'Cancel button is enabled');
this.test.assertExists('.btn-apply:not(:disabled)', 'Apply button is enabled');
});
this.then(function() {
this.test.comment('Testing button Load Defaults');
this.test.assertExists('.btn-defaults:not(:disabled)', 'Load Defaults button is enabled');
this.click('.btn-defaults');
this.test.assertSelectorAppears('.btn-defaults:not(:disabled)', 'Defaults were loaded');
this.then(function() {
this.test.assertEvalEquals(function(sdaDiskVM) {return $(sdaDiskVM + ' input[type=number]').attr('value')}, vmSDA, 'Volume group input control VM contains default value', {sdaDiskVM:sdaDiskVM});
this.test.assertEvalEquals(function(sdaDiskOS) {return $(sdaDiskOS + ' input[type=number]').attr('value')}, osSDA, 'Volume group input control OS contains default value', {sdaDiskOS:sdaDiskOS});
});
});
this.then(function() {
this.test.comment('Testing volume group deletion and Cancel button');
this.click(sdaDisk + ' .disk-visual [data-volume=vm] .close-btn');
this.test.assertEquals(this.getElementBounds(sdaDisk + ' .disk-visual [data-volume=vm]').width, 0, 'VM group was removed successfully');
this.click('.btn-revert-changes');
this.then(function() {
this.test.assertEvalEquals(function(sdaDiskVM) {return $(sdaDiskVM + ' input[type=number]').attr('value')}, vmSDA, 'Volume group input control VM contains default value', {sdaDiskVM:sdaDiskVM});
this.click(sdaDisk + ' .disk-visual [data-volume=vm] .close-btn');
this.test.assertEval(function(sdaDisk) {return $(sdaDisk + ' .disk-visual [data-volume=unallocated]').width() > 0}, 'There is unallocated space after Virtual Storage VG removal',{sdaDisk:sdaDisk});
this.test.assertEvalEquals(function(sdaDiskVM) {return $(sdaDiskVM + ' input[type=number]').val()}, '0', 'Volume group input control contains correct value',{sdaDiskVM:sdaDiskVM});
});
});
});
casper.run(function() {
this.test.done();
});

View File

@ -41,7 +41,6 @@ function usage {
echo " --no-ui-unit Don't run UI unit tests"
echo " --ui-func Run UI functional tests"
echo " --no-ui-func Don't run UI functional tests"
echo " --ui-selenium Run UI functional selenium tests"
echo " --no-ui-compression Skip UI compression"
echo ""
echo "Note: with no options specified, the script will try to run all available"
@ -73,7 +72,6 @@ function process_options {
--no-ui-unit) no_ui_unit_tests=1;;
--ui-func) ui_func_tests=1;;
--no-ui-func) no_ui_func_tests=1;;
--ui-selenium) ui_func_selenium_tests=1;;
--no-ui-compression) no_ui_compression=1;;
-t|--tests) certain_tests=1;;
-*) testropts="$testropts $arg";;
@ -131,7 +129,6 @@ no_ui_func_tests=0
extensions_tests=0
no_extensions_tests=0
certain_tests=0
ui_func_selenium_tests=0
no_ui_compression=0
function run_tests {
@ -161,7 +158,6 @@ function run_tests {
$ui_lint_checks -eq 0 && \
$ui_unit_tests -eq 0 && \
$ui_func_tests -eq 0 && \
$ui_func_selenium_tests -eq 0 && \
$upgrade_system -eq 0 && \
$shotgun_tests -eq 0 && \
$extensions_tests -eq 0 && \
@ -204,11 +200,6 @@ function run_tests {
run_ui_func_tests || errors+=" ui_func_tests"
fi
if [ $ui_func_selenium_tests -eq 1 ]; then
echo "Starting UI functional selenium tests..."
run_ui_func_selenium_tests || errors+=" ui_func_selenium_tests"
fi
if [ $upgrade_system -eq 1 ]; then
echo "Starting upgrade system tests..."
run_upgrade_system_tests || errors+=" upgrade_system_tests"
@ -291,74 +282,6 @@ function run_ui_unit_tests {
#
# $@ -- tests to be run; with no arguments all tests will be run
function run_ui_func_tests {
local SERVER_PORT=$UI_SERVER_PORT
local TESTS_DIR=$ROOT/nailgun/ui_tests
local TESTS=$TESTS_DIR/test_*.js
local artifacts=$ARTIFACTS/ui_func
local config=$artifacts/test.yaml
prepare_artifacts $artifacts $config
local COMPRESSED_STATIC_DIR=$artifacts/static_compressed
if [ $# -ne 0 ]; then
TESTS=$@
fi
pushd $ROOT/nailgun >> /dev/null
if [ $no_ui_compression -ne 1 ]; then
echo -n "Compressing UI... "
local output
output=$(${GULP} build --static-dir=$COMPRESSED_STATIC_DIR 2>&1)
if [ $? -ne 0 ]; then
echo "$output"
popd >> /dev/null
return 1
fi
echo "done"
else
echo "Using compressed UI from $COMPRESSED_STATIC_DIR"
if [ ! -f "$COMPRESSED_STATIC_DIR/index.html" ]; then
echo "Cannot find compressed UI. Don't use --no-ui-compression key"
return 1
fi
fi
# run js testcases
local server_log=`mktemp /tmp/test_nailgun_ui_server.XXXX`
local result=0
local pid
for testcase in $TESTS; do
dropdb $config
syncdb $config true
run_server $SERVER_PORT $server_log $config || \
{ echo 'Failed to start Nailgun'; return 1; }
SERVER_PORT=$SERVER_PORT \
${CASPERJS} test --includes="$TESTS_DIR/helpers.js" --fail-fast "$testcase"
if [ $? -ne 0 ]; then
result=1
break
fi
kill_server $SERVER_PORT
done
rm $server_log
popd >> /dev/null
return $result
}
# Run UI functional tests.
#
# Arguments:
#
# $@ -- tests to be run; with no arguments all tests will be run
function run_ui_func_selenium_tests {
local SERVER_PORT=$UI_SERVER_PORT
local TESTS_DIR=$ROOT/nailgun/static/tests/functional
local TESTS=$TESTS_DIR/test_*.js
@ -684,10 +607,8 @@ EOL
#
# $1 -- path to the test file
function guess_test_run {
if [[ $1 == *ui_tests* && $1 == *.js ]]; then
if [[ $1 == *functional* && $1 == *.js ]]; then
run_ui_func_tests $1 || echo "ERROR: $1"
elif [[ $1 == *functional* && $1 == *.js ]]; then
run_ui_func_selenium_tests $1 || echo "ERROR: $1"
elif [[ $1 == *fuel_upgrade_system* ]]; then
run_upgrade_system_tests $1 || echo "ERROR: $1"
elif [[ $1 == *shotgun* ]]; then