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 af68503199
commit 5586bfaad4
9 changed files with 201 additions and 33 deletions

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
@ -91,7 +91,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,124 @@
#!/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

@ -19,10 +19,15 @@ define(function() {
return {
proxyPort: 9057,
tunnelOptions: {
hostname: process.env.SELENIUM_SERVER_HOST || 'localhost',
port: process.env.SELENIUM_SERVER_PORT || 4444
},
proxyUrl: 'http://localhost:9057/',
maxConcurrency: 1,
grep: /^/,
excludeInstrumentation: /^/,
reporters: ['Runner', 'tests/functional/screenshot_on_fail']
reporters: ['Runner', 'tests/functional/screenshot_on_fail',
{id: 'JUnit', filename: process.env.ARTIFACTS + '/junit.xml'}]
};
});

View File

@ -503,7 +503,7 @@ define([
}
});
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

@ -52,14 +52,9 @@ define([
return this.remote
.deleteCluster(modal);
},
'Set up attributes': function() {
return this.remote
.updatePlugin('update_bonds bond_setup')
.newClusterWithPlugin(modal);
},
'Test attributes for BOND interfaces provided by plugin': function() {
test_bonds: function() { // Test attributes for BOND interfaces provided by plugin
return this.remote
.updatePlugin('update_bonds bond_setup')
.newClusterWithPlugin(modal)
// Add one node, open interface configuration
@ -77,7 +72,7 @@ define([
// Save changes
.applyItfChanges();
},
'Test Load defaults for BONDs': function() {
bond_defaults: function() { // Test Load defaults for BONDs
return this.remote
.newClusterWithPlugin(modal)
@ -103,14 +98,13 @@ define([
.assertElementNotExists('input[label="bond0"]', 'Interfaces were not unbonded')
.applyItfChanges();
},
'Test several plugins with different attributes for BOND': function() {
bond_multiple_plugins: function() { // 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
@ -190,7 +184,7 @@ define([
// Save with default values
.applyItfChanges();
},
'Test restrictions for Bonds': function() {
bond_restrictions: function() { // Test restrictions for Bonds
return this.remote
.updatePlugin('update_bonds bond_restrict')
.newClusterWithPlugin(modal)

View File

@ -52,7 +52,7 @@ define([
return this.remote
.deleteCluster(modal);
},
'Set up all attributes': function() {
set_up: function() { // Set up all attributes
return this.remote
.updatePlugin('update_nics nic_setup')
.updatePlugin('update_nodes node_setup')
@ -60,7 +60,7 @@ define([
.newClusterWithPlugin(modal);
},
'Test attributes for NIC interfaces': function() {
test_nics: function() { // Test attributes for NIC interfaces
return this.remote
.newClusterWithPlugin(modal)
@ -86,7 +86,7 @@ define([
// Save changes
.applyItfChanges();
},
'Test Load defaults attributes for NIC': function() {
nic_defaults: function() { // Test Load defaults attributes for NIC
return this.remote
.newClusterWithPlugin(modal)
@ -121,7 +121,7 @@ define([
// Save with default values
.applyItfChanges();
},
'Test cluster without plugin has only core attributes': function() {
test_core: function() { // Test cluster without plugin has only core attributes
return this.remote
// Create cluster without plugin
.clickByCssSelector('.create-cluster')
@ -183,7 +183,7 @@ define([
return modal.waitToClose();
});
},
'Test that NIC config may be changed for several nodes simultaneously': function() {
test_mass_config: function() { // Test NICs may be changed for two nodes simultaneously
return this.remote
.newClusterWithPlugin(modal)
@ -224,7 +224,7 @@ define([
.applyItfChanges();
},
'Test several plugins with different attributes for NIC': function() {
nic_multiple_plugins: function() { // 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;
@ -232,7 +232,6 @@ define([
// 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
@ -303,7 +302,7 @@ define([
// Save with default values
.applyItfChanges();
},
'Test restrictions': function() {
nic_restrictions: function() { // Test restrictions for NICs
var nicText = 'input[type="text"][name="attribute_text_r"]';
return this.remote

View File

@ -50,13 +50,9 @@ define([
return this.remote
.deleteCluster(modal);
},
'Set up attributes': function() {
test_nodes: function() { // Test attributes for Nodes
return this.remote
.updatePlugin('update_nodes node_setup')
.newClusterWithPlugin(modal);
},
'Test attributes for Nodes': function() {
return this.remote
.newClusterWithPlugin(modal)
// Add node and open settings for it
@ -90,7 +86,7 @@ define([
return modal.waitToClose();
});
},
'Test Load defaults for Nodes': function() {
node_defaults: function() { // Test Load defaults for Nodes
return this.remote
.newClusterWithPlugin(modal)
@ -129,14 +125,13 @@ define([
return modal.waitToClose();
});
},
'Test several plugins with different attributes for Nodes': function() {
node_multiple_plugins: function() { // 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
@ -214,7 +209,7 @@ define([
return modal.waitToClose();
});
},
'Test restrictions for Nodes': function() {
node_restrictions: function() { // Test restrictions for Nodes
return this.remote
.updatePlugin('update_nodes node_restrict')
.newClusterWithPlugin(modal)

View File

@ -104,7 +104,9 @@ define([
.clickIfExists('button.remove-cluster-btn')
.then(function() {
modal.waitToClose();
});
})
.waitForCssSelector('.create-cluster', 1000);
});
},
clickObjectByIndex: function(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