d698b2c2a0
Add test cases for Example Plugin Implements blueprint template-based-testcases Change-Id: I4352dd895f7686445e1764cd3f026611265450e5 Co-Authored-By: Vladimir Khlyunev <vkhlyunev@mirantis.com>
112 lines
4.0 KiB
Python
112 lines
4.0 KiB
Python
# 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))
|