Add "Install plugin" test case.

Verify possibility to copy plugin to the master node and install plugin on it.

Update "update_node_networks" method.
Add boolean flag to "update_node_networks" method that specifies whether to use standard method for updating data or specific for Contrail tests.

Add import in run_tests.py for running Contrail test cases.

Update settings.py file for Contrail test cases by new variable for Contrail plugin

Clean plugin_contrail/__init__.py file

Bug: 1435438

Change-Id: Id05a77d368d32a4ca8645a759111d7a00d0fba9b
This commit is contained in:
Iryna Vovk 2015-03-13 16:53:29 +02:00
parent f1aa8ad9f9
commit 900ee550fd
6 changed files with 129 additions and 3 deletions

View File

@ -292,7 +292,7 @@ def upload_tarball(node_ssh, tar_path, tar_target):
@logwrap
def check_archive_type(tar_path):
if os.path.splitext(tar_path)[1] not in [".tar", ".lrz", ".fp"]:
if os.path.splitext(tar_path)[1] not in [".tar", ".lrz", ".fp", ".rpm"]:
raise Exception("Wrong archive type!")

View File

@ -726,7 +726,8 @@ class FuelWebClient(object):
@logwrap
def update_nodes(self, cluster_id, nodes_dict,
pending_addition=True, pending_deletion=False,
update_nodegroups=False):
update_nodegroups=False, contrail=False):
# update nodes in cluster
nodes_data = []
nodes_groups = {}
@ -747,13 +748,19 @@ class FuelWebClient(object):
assert_true(node['online'],
'Node {} is online'.format(node['mac']))
if contrail and nodes_dict[node_name][0] == 'base-os':
name = 'contrail-' + node_name.split('-')[1].strip('0')
else:
name = '{}_{}'.format(node_name, "_".join(node_roles))
node_data = {
'cluster_id': cluster_id,
'id': node['id'],
'pending_addition': pending_addition,
'pending_deletion': pending_deletion,
'pending_roles': node_roles,
'name': '{}_{}'.format(node_name, "_".join(node_roles))
'name': name
}
nodes_data.append(node_data)
if node_group not in nodes_groups.keys():

View File

@ -38,6 +38,7 @@ def import_tests():
from tests import test_zabbix # noqa
from tests import test_upgrade # noqa
from tests.plugins.plugin_example import test_fuel_plugin_example # noqa
from tests.plugins.plugin_contrail import test_fuel_plugin_contrail # noqa
from tests.plugins.plugin_glusterfs import test_plugin_glusterfs # noqa
from tests.plugins.plugin_lbaas import test_plugin_lbaas # noqa
from tests.plugins.plugin_reboot import test_plugin_reboot_task # noqa

View File

@ -245,6 +245,7 @@ VCENTER_IP = os.environ.get('VCENTER_IP')
VCENTER_USERNAME = os.environ.get('VCENTER_USERNAME')
VCENTER_PASSWORD = os.environ.get('VCENTER_PASSWORD')
# Services tests
SERVTEST_LOCAL_PATH = os.environ.get('SERVTEST_LOCAL_PATH', '/tmp')
SERVTEST_USERNAME = os.environ.get('SERVTEST_USERNAME', 'admin')
@ -345,6 +346,9 @@ SSH_CREDENTIALS = {
# Plugin path for plugins tests
CONTRAIL_PLUGIN_PATH = os.environ.get('CONTRAIL_PLUGIN_PATH')
CONTRAIL_PLUGIN_PACK_UB_PATH = os.environ.get('CONTRAIL_PLUGIN_PACK_UB_PATH')
CONTRAIL_PLUGIN_PACK_CEN_PATH = os.environ.get('CONTRAIL_PLUGIN_PACK_CEN_PATH')
GLUSTER_PLUGIN_PATH = os.environ.get('GLUSTER_PLUGIN_PATH')
GLUSTER_CLUSTER_ENDPOINT = os.environ.get('GLUSTER_CLUSTER_ENDPOINT')
EXAMPLE_PLUGIN_PATH = os.environ.get('EXAMPLE_PLUGIN_PATH')

View File

@ -0,0 +1,114 @@
# 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.
import os
import os.path
import time
from proboscis import test
from fuelweb_test.helpers.decorators import log_snapshot_on_error
from fuelweb_test.helpers import checkers
from fuelweb_test import logger
from fuelweb_test.settings import DEPLOYMENT_MODE
from fuelweb_test.settings import CONTRAIL_PLUGIN_PATH
from fuelweb_test.settings import CONTRAIL_PLUGIN_PACK_UB_PATH
from fuelweb_test.settings import CONTRAIL_PLUGIN_PACK_CEN_PATH
from fuelweb_test.tests.base_test_case import SetupEnvironment
from fuelweb_test.tests.base_test_case import TestBasic
@test(groups=["plugins"])
class ContrailPlugin(TestBasic):
master_path = '/var/www/nailgun/plugins/contrail-1.0'
add_ub_packag = \
'/var/www/nailgun/plugins/contrail-1.0/' \
'repositories/ubuntu/contrail-setup*'
add_cen_packeg = \
'/var/www/nailgun/plugins/contrail-1.0/' \
'repositories/centos/Packages/contrail-setup*'
def upload_packages(self, node_ssh, pack_path, master_path):
if os.path.splitext(pack_path)[1] in ".deb":
logger.debug("Start to upload deb packet to the master node")
node_ssh.upload(pack_path, master_path)
else:
logger.error('Failed to upload file')
def install_packages(self, remote, master_path):
command = "cd " + master_path + " && ./install.sh"
logger.info('The command is %s', command)
remote.execute_async(command)
time.sleep(50)
os.path.isfile(self.add_ub_packag or self.add_cen_packeg)
@test(depends_on=[SetupEnvironment.prepare_slaves_5],
groups=["test_install_contrail"])
@log_snapshot_on_error
def install_contrail(self):
"""Verify possibility to copy plugin to the master node and install
plugin on it. Verify that all steps were performed without any errors.
Scenario:
1. Revert snapshot "ready_with_5_slaves"
2. Upload contrail plugin to the master node
3. Install plugin and additional packages
4. Enable Neutron with VLAN segmentation
5. Create cluster
Duration 20 min
Snapshot contrail_installed
"""
self.env.revert_snapshot("ready_with_5_slaves")
# copy plugin to the master node
checkers.upload_tarball(
self.env.d_env.get_admin_remote(),
CONTRAIL_PLUGIN_PATH, '/var')
# install plugin
checkers.install_plugin_check_code(
self.env.d_env.get_admin_remote(),
plugin=os.path.basename(CONTRAIL_PLUGIN_PATH))
# copy additional packages to the master node
self.upload_packages(
self.env.d_env.get_admin_remote(),
CONTRAIL_PLUGIN_PACK_UB_PATH,
self.master_path
)
self.upload_packages(
self.env.d_env.get_admin_remote(),
CONTRAIL_PLUGIN_PACK_CEN_PATH,
self.master_path
)
# install packages
self.install_packages(self.env.d_env.get_admin_remote(),
self.master_path)
# create cluster
segment_type = 'vlan'
self.fuel_web.create_cluster(
name=self.__class__.__name__,
mode=DEPLOYMENT_MODE,
settings={
"net_provider": 'neutron',
"net_segment_type": segment_type,
}
)
self.env.make_snapshot("contrail_installed")