Add helpers folder for Contrail plugin

Change-Id: I3dc345197feacdc1a0608f8607d7da21ce07050f
This commit is contained in:
Iryna Vovk
2015-12-11 19:02:09 +02:00
parent 7c5b31b3a6
commit ac21fe2f5d
6 changed files with 173 additions and 129 deletions

View File

@@ -0,0 +1,13 @@
# 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.

View File

@@ -0,0 +1,52 @@
# 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 time
from fuelweb_test import logger
from fuelweb_test.settings import DEPLOYMENT_MODE
from fuelweb_test.helpers.checkers import check_repo_managment
def assign_net_provider(obj, pub_all_nodes=False, ceph_value=False):
"""Assign neutron with tunneling segmentation"""
segment_type = 'tun'
obj.cluster_id = obj.fuel_web.create_cluster(
name=obj.__class__.__name__,
mode=DEPLOYMENT_MODE,
settings={
"net_provider": 'neutron',
"net_segment_type": segment_type,
"assign_to_all_nodes": pub_all_nodes,
"images_ceph": ceph_value
}
)
return obj.cluster_id
def deploy_cluster(obj):
"""
Deploy cluster with additional time for waiting on node's availability
"""
try:
obj.fuel_web.deploy_cluster_wait(
obj.cluster_id, check_services=False)
except:
nailgun_nodes = obj.env.fuel_web.client.list_cluster_nodes(
obj.env.fuel_web.get_last_created_cluster())
time.sleep(420)
for n in nailgun_nodes:
check_repo_managment(
obj.env.d_env.get_ssh_to_remote(n['ip']))
logger.info('ip is {0}'.format(n['ip'], n['name']))

View File

@@ -0,0 +1,83 @@
# 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 time
from fuelweb_test import logger
from fuelweb_test.helpers import checkers
from fuelweb_test.settings import CONTRAIL_PLUGIN_PATH
from proboscis.asserts import assert_true
import openstack
def upload_contrail_packages(obj):
node_ssh = obj.env.d_env.get_admin_remote()
if os.path.splitext(obj.pack_path)[1] == ".deb":
pkg_name = os.path.basename(obj.pack_path)
logger.debug("Uploading package {0} "
"to master node".format(pkg_name))
node_ssh.upload(obj.pack_path, obj.pack_copy_path)
else:
raise Exception('Failed to upload file to the master node')
def install_packages(obj, remote):
command = "cd " + obj.pack_copy_path + " && ./install.sh"
logger.info('The command is %s', command)
remote.execute_async(command)
time.sleep(50)
os.path.isfile(obj.add_package)
def prepare_contrail_plugin(
obj, slaves=None, pub_all_nodes=False, ceph_value=False):
"""Copy necessary packages to the master node and install them"""
obj.env.revert_snapshot("ready_with_%d_slaves" % slaves)
# copy plugin to the master node
checkers.upload_tarball(
obj.env.d_env.get_admin_remote(),
CONTRAIL_PLUGIN_PATH, '/var')
# install plugin
checkers.install_plugin_check_code(
obj.env.d_env.get_admin_remote(),
plugin=os.path.basename(CONTRAIL_PLUGIN_PATH))
if obj.CONTRAIL_DISTRIBUTION == 'juniper':
# copy additional packages to the master node
upload_contrail_packages(obj)
# install packages
install_packages(obj, obj.env.d_env.get_admin_remote())
# prepare fuel
openstack.assign_net_provider(obj, pub_all_nodes, ceph_value)
def activate_plugin(obj):
"""Enable plugin in contrail settings"""
plugin_name = 'contrail'
msg = "Plugin couldn't be enabled. Check plugin version. Test aborted"
assert_true(
obj.fuel_web.check_plugin_exists(obj.cluster_id, plugin_name),
msg)
logger.debug('we have contrail element')
if obj.CONTRAIL_DISTRIBUTION == 'juniper':
option = {'metadata/enabled': True,
'contrail_distribution/value': 'juniper', }
else:
option = {'metadata/enabled': True, }
obj.fuel_web.update_plugin_data(obj.cluster_id, plugin_name, option)

View File

@@ -41,7 +41,8 @@ class CloseSSHConnectionsPlugin(Plugin):
def import_tests():
from tests import test_fuel_plugin_contrail
from tests import test_smoke_bvt
from tests import integration_tests
def run_tests():

View File

@@ -0,0 +1,13 @@
# 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.

View File

@@ -14,42 +14,14 @@
import os
import os.path
import time
from copy import deepcopy
from proboscis import test
from proboscis.asserts import assert_true
from fuelweb_test.helpers.decorators import log_snapshot_after_test
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.tests.base_test_case import SetupEnvironment
from fuelweb_test.tests.base_test_case import TestBasic
from fuelweb_test.helpers.checkers import check_repo_managment
BOND_CONFIG = [{
'mac': None,
'mode': 'active-backup',
'name': 'lnx-bond0',
'slaves': [
{'name': 'eth4'},
{'name': 'eth2'}
],
'state': None,
'type': 'bond',
'assigned_networks': []}]
INTERFACES = {
'eth0': ['fuelweb_admin'],
'eth1': ['public'],
'eth3': ['private'],
'lnx-bond0': ['management',
'storage',
]
}
from helpers import plugin
from helpers import openstack
@test(groups=["plugins"])
@@ -66,99 +38,8 @@ class ContrailPlugin(TestBasic):
pack_path = CONTRAIL_PLUGIN_PACK_UB_PATH
NEUTRON_BOND_CONFIG = deepcopy(BOND_CONFIG)
NEUTRON_INTERFACES = deepcopy(INTERFACES)
CONTRAIL_DISTRIBUTION = os.environ.get('CONTRAIL_DISTRIBUTION')
def upload_contrail_packages(self):
node_ssh = self.env.d_env.get_admin_remote()
if os.path.splitext(self.pack_path)[1] == ".deb":
pkg_name = os.path.basename(self.pack_path)
logger.debug("Uploading package {0} "
"to master node".format(pkg_name))
node_ssh.upload(self.pack_path, self.pack_copy_path)
else:
raise Exception('Failed to upload file to the master node')
def install_packages(self, remote):
command = "cd " + self.pack_copy_path + " && ./install.sh"
logger.info('The command is %s', command)
remote.execute_async(command)
time.sleep(50)
os.path.isfile(self.add_package)
def assign_net_provider(self, pub_all_nodes=False, ceph_value=False):
"""Assign neutron with tunneling segmentation"""
segment_type = 'tun'
self.cluster_id = self.fuel_web.create_cluster(
name=self.__class__.__name__,
mode=DEPLOYMENT_MODE,
settings={
"net_provider": 'neutron',
"net_segment_type": segment_type,
"assign_to_all_nodes": pub_all_nodes,
"images_ceph": ceph_value
}
)
return self.cluster_id
def prepare_contrail_plugin(
self, slaves=None, pub_all_nodes=False, ceph_value=False):
"""Copy necessary packages to the master node and install them"""
self.env.revert_snapshot("ready_with_%d_slaves" % 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))
if self.CONTRAIL_DISTRIBUTION == 'juniper':
# copy additional packages to the master node
self.upload_contrail_packages()
# install packages
self.install_packages(self.env.d_env.get_admin_remote())
# prepare fuel
self.assign_net_provider(pub_all_nodes, ceph_value)
def activate_plugin(self):
"""Enable plugin in contrail settings"""
plugin_name = 'contrail'
msg = "Plugin couldn't be enabled. Check plugin version. Test aborted"
assert_true(
self.fuel_web.check_plugin_exists(self.cluster_id, plugin_name),
msg)
logger.debug('we have contrail element')
if self.CONTRAIL_DISTRIBUTION == 'juniper':
option = {'metadata/enabled': True,
'contrail_distribution/value': 'juniper', }
else:
option = {'metadata/enabled': True, }
self.fuel_web.update_plugin_data(self.cluster_id, plugin_name, option)
def deploy_cluster(self):
"""
Deploy cluster with additional time for waiting on node's availability
"""
try:
self.fuel_web.deploy_cluster_wait(
self.cluster_id, check_services=False)
except:
nailgun_nodes = self.env.fuel_web.client.list_cluster_nodes(
self.env.fuel_web.get_last_created_cluster())
time.sleep(420)
for n in nailgun_nodes:
check_repo_managment(
self.env.d_env.get_ssh_to_remote(n['ip']))
logger.info('ip is {0}'.format(n['ip'], n['name']))
@test(depends_on=[SetupEnvironment.prepare_slaves_3],
groups=["install_contrail"])
@log_snapshot_after_test
@@ -175,7 +56,8 @@ class ContrailPlugin(TestBasic):
Duration 20 min
"""
self.prepare_contrail_plugin(slaves=3)
plugin.prepare_contrail_plugin(self, slaves=3)
@test(depends_on=[SetupEnvironment.prepare_slaves_3],
groups=["contrail_smoke"])
@@ -196,10 +78,10 @@ class ContrailPlugin(TestBasic):
Duration 90 min
"""
self.prepare_contrail_plugin(slaves=3)
plugin.prepare_contrail_plugin(self, slaves=3)
# enable plugin in contrail settings
self.activate_plugin()
plugin.activate_plugin(self)
self.fuel_web.update_nodes(
self.cluster_id,
@@ -212,7 +94,7 @@ class ContrailPlugin(TestBasic):
})
# deploy cluster
self.deploy_cluster()
openstack.deploy_cluster(self)
@test(depends_on=[SetupEnvironment.prepare_slaves_9],
groups=["contrail_bvt"])
@@ -237,10 +119,10 @@ class ContrailPlugin(TestBasic):
Duration 110 min
"""
self.prepare_contrail_plugin(slaves=9)
plugin.prepare_contrail_plugin(self, slaves=9)
# enable plugin in contrail settings
self.activate_plugin()
plugin.activate_plugin(self)
self.fuel_web.update_nodes(
self.cluster_id,
@@ -255,7 +137,7 @@ class ContrailPlugin(TestBasic):
})
# deploy cluster
self.deploy_cluster()
openstack.deploy_cluster(self)
# TODO
# Tests using north-south connectivity are expected to fail because