Add test for example plugins into system test

Add test cases for Example Plugin

Implements blueprint template-based-testcases
Change-Id: I4352dd895f7686445e1764cd3f026611265450e5
Co-Authored-By: Vladimir Khlyunev <vkhlyunev@mirantis.com>
This commit is contained in:
Dmitry Tyzhnenko 2015-11-09 19:06:09 +02:00 committed by Vladimir Khlyunev
parent 5d618561e5
commit d698b2c2a0
9 changed files with 360 additions and 15 deletions

View File

@ -54,6 +54,29 @@ Strength Base
.. automodule:: system_test.tests.strength.strength_base
:members:
Plugin tests
============
Plugins Base
------------
.. automodule:: system_test.tests.plugins_actions
:members:
Example plugin Base
-------------------
.. automodule:: system_test.tests.plugins.plugin_example
:members:
Example plugin
--------------
.. automodule:: system_test.tests.plugins.plugin_example.test_plugin_example
:members:
Example plugin v3
-----------------
.. automodule:: system_test.tests.plugins.plugin_example.test_plugin_example_v3
:members:
Helpers
=======
@ -65,4 +88,4 @@ Decorators
Utils
-----
.. automodule:: system_test.helpers.utils
:members:
:members:

View File

@ -136,6 +136,8 @@ def import_tests():
from system_test.tests.strength import destroy_controllers # noqa
from system_test.tests.strength import filling_root # noqa
from system_test.tests import test_fuel_migration # noqa
from system_test.tests.plugins.plugin_example import test_plugin_example # noqa
from system_test.tests.plugins.plugin_example import test_plugin_example_v3 # noqa
from gates_tests.tests import test_review_in_fuel_agent # noqa

View File

@ -24,6 +24,7 @@ from fuelweb_test import settings as test_settings
from system_test import logger
from system_test.tests import base_actions_factory
from system_test.tests.ostf_base_actions import HealthCheckActions
from system_test.tests.plugins_actions import PluginsActions
from system_test.helpers.decorators import make_snapshot_if_step_fail
from system_test.helpers.decorators import deferred_decorator
from system_test.helpers.decorators import action
@ -153,7 +154,7 @@ class PrepareBase(base_actions_factory.BaseActionsFactory):
]
class ActionsBase(PrepareBase, HealthCheckActions):
class ActionsBase(PrepareBase, HealthCheckActions, PluginsActions):
"""Basic actions for acceptance cases
For choosing action order use actions_order variable, set list of actions
@ -177,6 +178,27 @@ class ActionsBase(PrepareBase, HealthCheckActions):
super(ActionsBase, self).__init__()
self.config_file = config_file
self.cluster_id = None
self.assigned_slaves = set()
self.scale_step = 0
def _add_node(self, nodes_list):
"""Add nodes to Environment"""
logger.info("Add nodes to env {}".format(self.cluster_id))
names = "slave-{:02}"
slaves = int(self.full_config['template']['slaves'])
num = iter(xrange(1, slaves + 1))
nodes = {}
for new in nodes_list:
for one in xrange(new['count']):
name = names.format(next(num))
while name in self.assigned_slaves:
name = names.format(next(num))
self.assigned_slaves.add(name)
nodes[name] = new['roles']
logger.info("Set roles {} to node {}".format(new['roles'],
name))
self.fuel_web.update_nodes(self.cluster_id, nodes)
@deferred_decorator([make_snapshot_if_step_fail])
@action
@ -239,18 +261,7 @@ class ActionsBase(PrepareBase, HealthCheckActions):
if self.cluster_id is None:
raise SkipTest()
slaves = int(self.full_config['template']['slaves'])
logger.info("Add nodes to env {}".format(self.cluster_id))
names = "slave-{:02}"
num = iter(xrange(1, slaves + 1))
nodes = {}
for new in self.env_config['nodes']:
for one in xrange(new['count']):
name = names.format(next(num))
nodes[name] = new['roles']
logger.info("Set roles {} to node {}".format(new['roles'],
name))
self.fuel_web.update_nodes(self.cluster_id, nodes)
self._add_node(self.env_config['nodes'])
@deferred_decorator([make_snapshot_if_step_fail])
@action
@ -311,6 +322,14 @@ class ActionsBase(PrepareBase, HealthCheckActions):
"HAProxy backends are DOWN. {0}".format(
haproxy_status))
@deferred_decorator([make_snapshot_if_step_fail])
@action
def scale_node(self):
"""Scale node in cluster"""
step_config = self.env_config['scale_nodes'][self.scale_step]
self._add_node(step_config)
self.scale_step += 1
@deferred_decorator([make_snapshot_if_step_fail])
@action
def reset_cluster(self):

View File

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.
from proboscis import factory
from fuelweb_test.settings import EXAMPLE_PLUGIN_PATH
from system_test.helpers.utils import case_factory
from system_test.tests.actions_base import ActionsBase
class DeployWithPluginExample(ActionsBase):
"""Deploy cluster with one controller and example plugin
Scenario:
1. Upload plugin to the master node
2. Install plugin
3. Create cluster
4. Add 1 node with controller role
5. Add 2 nodes with compute role
6. Deploy the cluster
7. Run network verification
8. Check plugin health
9. Run OSTF
Duration 35m
Snapshot deploy_ha_one_controller_neutron_example
"""
base_group = ['system_test',
'system_test.plugins',
'system_test.plugins.example_plugin',
'system_test.plugins.example_plugin.simple']
plugin_name = "fuel_plugin_example"
plugin_path = EXAMPLE_PLUGIN_PATH
actions_order = [
'prepare_env_with_plugin',
'create_env',
'enable_plugin',
'add_nodes',
'network_check',
'deploy_cluster',
'network_check',
'check_example_plugin',
'health_check',
]
class DeployScaleWithPluginExample(ActionsBase):
"""Deploy and scale cluster in ha mode with example plugin
Scenario:
1. Upload plugin to the master node
2. Install plugin
3. Create cluster
4. Add 1 node with controller role
5. Add 1 nodes with compute role
6. Add 1 nodes with cinder role
7. Deploy the cluster
8. Run network verification
9. Check plugin health
10. Run OSTF
11. Add 2 nodes with controller role
12. Deploy cluster
13. Check plugin health
14. Run OSTF
Duration 150m
Snapshot deploy_neutron_example_ha_add_node
"""
base_group = ['system_test',
'system_test.plugins',
'system_test.plugins.example_plugin',
'system_test.plugins.example_plugin.simple_scale']
plugin_name = "fuel_plugin_example"
plugin_path = EXAMPLE_PLUGIN_PATH
actions_order = [
'prepare_env_with_plugin',
'create_env',
'enable_plugin',
'add_nodes',
'network_check',
'deploy_cluster',
'network_check',
'check_example_plugin',
'health_check',
'scale_node',
'network_check',
'deploy_cluster',
'network_check',
'check_example_plugin',
'health_check',
]
@factory
def cases():
return (case_factory(DeployWithPluginExample) +
case_factory(DeployScaleWithPluginExample))

View File

@ -0,0 +1,76 @@
# 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.
from proboscis import factory
from fuelweb_test.settings import EXAMPLE_PLUGIN_V3_PATH
from system_test.helpers.utils import case_factory
from system_test.helpers.decorators import make_snapshot_if_step_fail
from system_test.helpers.decorators import deferred_decorator
from system_test.helpers.decorators import action
from system_test.tests.actions_base import ActionsBase
class DeployWithPluginExampleV3(ActionsBase):
"""Deploy cluster with one controller and example plugin v3
Scenario:
1. Upload plugin to the master node
2. Install plugin
3. Create cluster
4. Add 1 node with controller role
5. Add 1 node with compute role
6. Add 1 node with custom plugin role
7. Deploy the cluster
8. Run network verification
9. Check plugin health
10. Run OSTF
Duration 35m
Snapshot deploy_ha_one_controller_neutron_example_v3
"""
base_group = ['system_test',
'system_test.plugins',
'system_test.plugins.example_plugin_v3',
'system_test.plugins.example_plugin_v3.simple']
plugin_name = 'fuel_plugin_example_v3'
plugin_path = EXAMPLE_PLUGIN_V3_PATH
actions_order = [
'prepare_env_with_plugin',
'create_env',
'enable_plugin',
'add_nodes',
'add_custom_role_node',
'network_check',
'deploy_cluster',
'network_check',
'check_example_plugin',
'health_check',
]
@deferred_decorator([make_snapshot_if_step_fail])
@action
def add_custom_role_node(self):
"""Add node with custom role from the plugin"""
self._add_node([{
'roles': ['fuel_plugin_example_v3'],
'count': 1
}])
@factory
def cases():
return (case_factory(DeployWithPluginExampleV3))

View File

@ -0,0 +1,111 @@
# 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
from proboscis.asserts import assert_true, assert_equal
from fuelweb_test.helpers import checkers
from system_test import logger
from system_test.helpers.decorators import action
from system_test.helpers.decorators import deferred_decorator
from system_test.helpers.decorators import make_snapshot_if_step_fail
from system_test.helpers.decorators import nested_action
from system_test.tests import base_actions_factory
class PluginsActions(base_actions_factory.BaseActionsFactory):
plugin_name = None
plugin_path = None
@nested_action
def prepare_env_with_plugin():
return [
'setup_master',
'config_release',
'make_slaves',
'revert_slaves',
'upload_plugin',
'install_plugin'
]
@deferred_decorator([make_snapshot_if_step_fail])
@action
def upload_plugin(self):
"""Upload plugin to master node"""
# copy plugin to the master node
assert_true(self.plugin_path, "plugin_path is not specified")
with self.env.d_env.get_admin_remote() as remote:
checkers.upload_tarball(
remote,
self.plugin_path, '/var')
@deferred_decorator([make_snapshot_if_step_fail])
@action
def install_plugin(self):
"""Install plugin to Fuel"""
assert_true(self.plugin_path, "plugin_path is not specified")
with self.env.d_env.get_admin_remote() as remote:
checkers.install_plugin_check_code(
remote,
plugin=os.path.basename(self.plugin_path))
@deferred_decorator([make_snapshot_if_step_fail])
@action
def enable_plugin(self):
"""Enable plugin for Fuel"""
assert_true(self.plugin_name, "plugin_name is not specified")
msg = "Plugin couldn't be enabled. Check plugin version. Test aborted"
assert_true(
self.fuel_web.check_plugin_exists(
self.cluster_id,
self.plugin_name),
msg)
options = {'metadata/enabled': True}
self.fuel_web.update_plugin_data(
self.cluster_id,
self.plugin_name, options)
@deferred_decorator([make_snapshot_if_step_fail])
@action
def check_example_plugin(self):
"""Check if service ran on controller"""
cmd_curl = 'curl localhost:8234'
cmd = 'pgrep -f fuel-simple-service'
n_ctrls = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
cluster_id=self.cluster_id,
roles=['controller'])
d_ctrls = self.fuel_web.get_devops_nodes_by_nailgun_nodes(n_ctrls)
for node in d_ctrls:
logger.info("Check plugin service on node {0}".format(node.name))
with self.fuel_web.get_ssh_for_node(node.name) as remote:
res_pgrep = remote.execute(cmd)
assert_equal(0, res_pgrep['exit_code'],
'Failed with error {0} '
'on node {1}'.format(res_pgrep['stderr'], node))
assert_equal(1, len(res_pgrep['stdout']),
'Failed with error {0} on the '
'node {1}'.format(res_pgrep['stderr'], node))
# curl to service
res_curl = remote.execute(cmd_curl)
assert_equal(0, res_pgrep['exit_code'],
'Failed with error {0} '
'on node {1}'.format(res_curl['stderr'], node))

View File

@ -12,6 +12,6 @@ template:
nodes:
!include cluster_configs/nodes/single/1ctrl_1comp_1cndr.yaml
scale_nodes:
- - role:
- - roles:
- controller
count: 2