Adapt plugin-tests to run on real nailgun

Change-Id: I2e97be848f0acbeac919564d60a649d486dde0a4
This commit is contained in:
ekhomyakova 2016-12-23 14:30:41 +04:00
parent 46d7910b1d
commit e4e95c4595
9 changed files with 200 additions and 31 deletions

View File

@ -121,6 +121,10 @@ function runIntern(suites, browser) {
var config = {
environments: [{browserName: browser}],
excludeInstrumentation: true,
tunnelOptions: {
hostname: process.env.SELENIUM_SERVER_HOST || 'localhost',
port: process.env.SELENIUM_SERVER_PORT || 4444
},
reporters: [
'Runner',
'tests/functional/screenshot_on_fail',

View File

@ -25,7 +25,7 @@ export CONF_PATH="${TESTS_ROOT}/${TESTS_DIR_NAME}/plugin_conf"
export NO_NAILGUN_START=${NO_NAILGUN_START:-0}
export FUEL_WEB_ROOT=$(readlink -f ${FUEL_WEB_ROOT:-"$(dirname $0)/../fuel-web"})
export ARTIFACTS=${ARTIFACTS:-"$(pwd)/test_run/ui_component"}
export ARTIFACTS=${ARTIFACTS:-"$(pwd)/test_run/${TESTS_DIR_NAME}"}
export PLUGIN_RPM=${PLUGIN_RPM:-''}
if [ -z "${PLUGIN_RPM}" ]; then
@ -92,7 +92,7 @@ function install_prepare_plugin {
}
function remove_plugins {
for plug in $(echo $INSTALLED_PLUGINS | tr ";")
for plug in $(echo ${INSTALLED_PLUGINS} | tr ";" "\n")
do
fuel --os-username admin --os-password admin plugins \
--remove "${plug}" 2>/dev/null && \

View File

@ -0,0 +1,125 @@
#!/bin/bash
# Copyright 2016 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.
set -eu
# Variables for remote (master node)
export REMOTE_HOST=${REMOTE_HOST:-'10.109.0.2'}
export REMOTE_USER=${REMOTE_USER:-'root'}
export REMOTE_SSH_PORT=${REMOTE_SSH_PORT:-22}
export REMOTE_PASSWORD=${REMOTE_PASSWORD:-'r00tme'}
export REMOTE_DIR=${REMOTE_DIR:-'/root'}
export FUEL_UI_HOST=${FUEL_UI_HOST:-${REMOTE_HOST}}
export REMOTE_EXEC="sshpass -p ${REMOTE_PASSWORD}
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
-p ${REMOTE_SSH_PORT} ${REMOTE_USER}@${REMOTE_HOST}"
# Variables for tests
export TESTS_ROOT="$(pwd)/static/tests/functional/real_plugin"
export SCRIPT_PATH="${TESTS_ROOT}/update_plugin_on_real.sh"
export TEST_PREFIX=${TEST_PREFIX:-'test_*'}
export TESTS_DIR_NAME=${TESTS_DIR_NAME:-'feature_nics'}
export CONF_PATH="${TESTS_ROOT}/${TESTS_DIR_NAME}/plugin_conf"
export ARTIFACTS=${ARTIFACTS:-"$(pwd)/test_run/${TESTS_DIR_NAME}"}
plugins='https://product-ci.infra.mirantis.net/view/All/job/9.0.build-fuel-plugins'
path='lastSuccessfulBuild/artifact/built_plugins/fuel_plugin_example_v5-1.0-1.0.0-1.noarch.rpm'
plugin_url=${PLUGIN_URL:-"${plugins}/${path}"}
plugins='http://plugins.mirantis.com/repository/f/u/fuel-plugin-vmware-dvs'
path='fuel-plugin-vmware-dvs-3.1-3.1.0-1.noarch.rpm'
plugin2_url=${PLUGIN_URL_SECOND:-"${plugins}/${path}"}
export NAILGUN_STATIC=$ARTIFACTS/static
mkdir -p "$ARTIFACTS"
function install_prepare_plugin {
url=$1
file_name=$2
${REMOTE_EXEC} wget --no-check-certificate -O "${REMOTE_DIR}/${file_name}.rpm" "${url}"
export PLUGIN_PATH=$(
${REMOTE_EXEC} fuel plugins --install "${REMOTE_DIR}/${file_name}.rpm" | awk '/Installing:/ { getline; print $1 }'
)
export PLUGIN_PATH="/var/www/nailgun/plugins/${PLUGIN_PATH}"
meta="${PLUGIN_PATH}/metadata.yaml"
export plugin_name=$(${REMOTE_EXEC} egrep '^name: ' "${meta}" | cut -d ' ' -f 2)
export plugin_version=$(${REMOTE_EXEC} egrep '^version: ' "${meta}" | cut -d ' ' -f 2)
# Fix package version
${REMOTE_EXEC} sed -i '$!s/4.0.0/5.0.0/' ${PLUGIN_PATH}/metadata.yaml
${REMOTE_EXEC} fuel plugins --sync
# Fix components settings
${REMOTE_EXEC} sed -i '/requires/,/+$/s/^/#/' ${PLUGIN_PATH}/components.yaml
${REMOTE_EXEC} fuel plugins --sync
export INSTALLED_PLUGINS="${INSTALLED_PLUGINS};${plugin_name}==${plugin_version//\'/}"
}
function remove_plugin {
for plug in $(echo ${INSTALLED_PLUGINS} | tr ";" "\n")
do
${REMOTE_EXEC} fuel plugins --remove "${plug}" 2>/dev/null && \
echo "${plug} was removed" || echo "Can not remove plugin ${plug}"
done
}
function remote_scp {
local_file=$1
sshpass -p ${REMOTE_PASSWORD} \
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-P ${REMOTE_SSH_PORT} $local_file ${REMOTE_USER}@${REMOTE_HOST}:/${REMOTE_DIR}/
}
function run_component_tests {
local GULP='./node_modules/.bin/gulp'
local TESTS_DIR="static/tests/functional/real_plugin/${TESTS_DIR_NAME}"
local TESTS=${TESTS_DIR}/${TEST_PREFIX}.js
local result=0
export INSTALLED_PLUGINS=''
if [ ${TESTS_DIR_NAME} == 'feature_nics' ]; then
install_prepare_plugin ${plugin2_url} "plugin2"
for conf in 'nic' 'node' 'bond'; do
remote_scp ${CONF_PATH}/${conf}_plugin2.yaml
${REMOTE_EXEC} cp ${REMOTE_DIR}/${conf}_plugin2.yaml ${PLUGIN_PATH}/${conf}_config.yaml
done
fi
install_prepare_plugin ${plugin_url} "plugin"
for test_case in $TESTS; do
echo "INFO: Running test case ${test_case}"
ARTIFACTS=$ARTIFACTS \
${GULP} intern:functional --suites="${test_case}" || result=1
done
remove_plugin
return $result
}
run_component_tests

View File

@ -469,7 +469,7 @@ _.defaults(Command.prototype, {
}
});
var serverHost = '127.0.0.1';
var serverHost = process.env.NAILGUN_HOST || '127.0.0.1';
var serverPort = process.env.NAILGUN_PORT || 5544;
var serverUrl = 'http://' + serverHost + ':' + serverPort;
var username = 'admin';

View File

@ -47,13 +47,9 @@ registerSuite(() => {
return this.remote
.deleteCluster(modal);
},
'Set up attributes'() {
return this.remote
.updatePlugin('update_bonds bond_setup')
.newClusterWithPlugin(modal);
},
'Test attributes for BOND interfaces provided by plugin'() {
test_bonds() { // Test attributes for BOND interfaces provided by plugin
return this.remote
.updatePlugin('update_bonds bond_setup')
.newClusterWithPlugin(modal)
// Add one node, open interface configuration
@ -69,7 +65,7 @@ registerSuite(() => {
// Save changes
.applyItfChanges();
},
'Test Load defaults for BONDs'() {
bond_defaults() { // Test Load defaults for BONDs
return this.remote
.newClusterWithPlugin(modal)
@ -93,14 +89,13 @@ registerSuite(() => {
.assertElementNotExists('input[label="bond0"]', 'Interfaces were not unbonded')
.applyItfChanges();
},
'Test several plugins with different attributes for BOND'() {
bond_multiple_plugins() { // Test several plugins with different BOND configs
var bondCheckboxDVS = 'input[type="checkbox"][name="attribute_checkbox_b"]';
return this.remote
// Create cluster with plugins
.newClusterFillName(modal)
.pressKeys('\uE007') // go to Compute
.clickByCssSelector('input[name="hypervisor:vmware"]')
.pressKeys('\uE007') // Networking
.clickByCssSelector('input[name="network:neutron:ml2:dvs"]')
.pressKeys('\uE007') // Storage
@ -176,7 +171,7 @@ registerSuite(() => {
// Save with default values
.applyItfChanges();
},
'Test restrictions for Bonds'() {
bond_restrictions() { // Test restrictions for Bonds
return this.remote
.updatePlugin('update_bonds bond_restrict')
.newClusterWithPlugin(modal)

View File

@ -47,7 +47,7 @@ registerSuite(() => {
return this.remote
.deleteCluster(modal);
},
'Set up all attributes'() {
set_up() { // Set up all attributes
return this.remote
.updatePlugin('update_nics nic_setup')
.updatePlugin('update_nodes node_setup')
@ -55,7 +55,7 @@ registerSuite(() => {
.newClusterWithPlugin(modal);
},
'Test attributes for NIC interfaces'() {
test_nics() { // Test attributes for NIC interfaces
return this.remote
.newClusterWithPlugin(modal)
@ -79,7 +79,7 @@ registerSuite(() => {
// Save changes
.applyItfChanges();
},
'Test Load defaults attributes for NIC'() {
nic_defaults() { // Test Load defaults attributes for NIC
return this.remote
.newClusterWithPlugin(modal)
@ -112,7 +112,7 @@ registerSuite(() => {
// Save with default values
.applyItfChanges();
},
'Test cluster without plugin has only core attributes'() {
test_core() { // Test cluster without plugin has only core attributes
return this.remote
.then(() => common.createCluster('test')) // Create cluster without plugin
@ -148,7 +148,7 @@ registerSuite(() => {
.then(() => modal.close())
.then(() => modal.waitToClose());
},
'Test that NIC config may be changed for several nodes simultaneously'() {
test_mass_config() { // Test NICs may be changed for two nodes simultaneously
return this.remote
.newClusterWithPlugin(modal)
@ -183,7 +183,7 @@ registerSuite(() => {
.applyItfChanges();
},
'Test several plugins with different attributes for NIC'() {
nic_multiple_plugins() { // Test several plugins with different NIC configs
var nicCheckboxDVS = 'input[type="checkbox"][name="attribute_checkbox_b"]';
var nicTextItf1 = '.ifc-list > div:nth-child(1) ' + nicText;
@ -191,7 +191,6 @@ registerSuite(() => {
// Create cluster with plugins
.newClusterFillName(modal)
.pressKeys('\uE007') // go to Compute
.clickByCssSelector('input[name="hypervisor:vmware"]')
.pressKeys('\uE007') // Networking
.clickByCssSelector('input[name="network:neutron:ml2:dvs"]')
.pressKeys('\uE007') // Storage
@ -258,7 +257,7 @@ registerSuite(() => {
// Save with default values
.applyItfChanges();
},
'Test restrictions'() {
nic_restrictions() { // Test restrictions for NICs
var nicText = 'input[type="text"][name="attribute_text_r"]';
return this.remote

View File

@ -45,13 +45,9 @@ registerSuite(() => {
return this.remote
.deleteCluster(modal);
},
'Set up attributes'() {
test_nodes() { // Test attributes for Nodes
return this.remote
.updatePlugin('update_nodes node_setup')
.newClusterWithPlugin(modal);
},
'Test attributes for Nodes'() {
return this.remote
.newClusterWithPlugin(modal)
// Add node and open settings for it
@ -76,7 +72,7 @@ registerSuite(() => {
.then(() => modal.close())
.then(() => modal.waitToClose());
},
'Test Load defaults for Nodes'() {
node_defaults() { // Test Load defaults for Nodes
return this.remote
.newClusterWithPlugin(modal)
@ -107,14 +103,13 @@ registerSuite(() => {
.then(() => modal.close())
.then(() => modal.waitToClose());
},
'Test several plugins with different attributes for Nodes'() {
node_multiple_plugins() { // Test several plugins with different Nodes configs
var nodeCheckboxDVS = 'input[type=checkbox][name="attribute_checkbox_b"]';
return this.remote
// Create cluster with plugins
.newClusterFillName(modal)
.pressKeys('\uE007') // go to Compute
.clickByCssSelector('input[name="hypervisor:vmware"]')
.pressKeys('\uE007') // Networking
.clickByCssSelector('input[name="network:neutron:ml2:dvs"]')
.pressKeys('\uE007') // Storage
@ -182,7 +177,7 @@ registerSuite(() => {
.then(() => modal.close())
.then(() => modal.waitToClose());
},
'Test restrictions for Nodes'() {
node_restrictions() { // Test restrictions for Nodes
return this.remote
.updatePlugin('update_nodes node_restrict')
.newClusterWithPlugin(modal)

View File

@ -89,7 +89,9 @@ _.defaults(Command.prototype, {
.then(() => modal.waitToOpen())
.clickIfExists('button.remove-cluster-btn')
.then(() => modal.waitToClose());
.then(() => modal.waitToClose())
.waitForCssSelector('.create-cluster', 1000);
});
},
clickObjectByIndex(objectsCssSelector, index) {

View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
function remote_scp {
local_file=$1
sshpass -p ${REMOTE_PASSWORD} \
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-P ${REMOTE_SSH_PORT} $local_file ${REMOTE_USER}@${REMOTE_HOST}:/${REMOTE_DIR}/
}
function update_components {
default=${CONF_PATH}/$1.yaml
components_file=${CONF_PATH}/$2.yaml
remote_scp ${components_file}
remote_scp ${default}
${REMOTE_EXEC} sh -c "cat ${REMOTE_DIR}/$1.yaml ${REMOTE_DIR}/$1.yaml > ${PLUGIN_PATH}/components.yaml"
}
function update_nics {
nic_file=${CONF_PATH}/$1.yaml
remote_scp ${nic_file}
${REMOTE_EXEC} cp ${REMOTE_DIR}/$1.yaml ${PLUGIN_PATH}/nic_config.yaml
}
function update_nodes {
node_file=${CONF_PATH}/$1.yaml
remote_scp ${node_file}
${REMOTE_EXEC} cp ${REMOTE_DIR}/$1.yaml ${PLUGIN_PATH}/node_config.yaml
}
function update_bonds {
bond_file=${CONF_PATH}/$1.yaml
remote_scp ${bond_file}
${REMOTE_EXEC} cp ${REMOTE_DIR}/$1.yaml ${PLUGIN_PATH}/bond_config.yaml
}
case $1 in
update_components|update_nics|update_nodes|update_bonds) func=$1; params="${@:2}";;
*) func=update_components; params="$@";;
esac
$func $params
${REMOTE_EXEC} fuel plugins --sync