Add tests and handlers for graph_concept_extension.
Test scenario 1: 1. Revert snapshot "ready_with_3_slaves" 2. Create env with 3 controller nodes and 1 compute+cinder node 3. Provision nodes 4. Upload two simple graphs 5. Make snapshots for next tests and resume snapshot 6. Execute graphs 7. Check that graph tasks was executed and finished without any errors 8. Check the created by graph tasks file Test scenario 2: 1. Revert snapshot "extension_graph_prepare_env" 2. Execute graphs via API 3. Check that graph tasks was executed and finished without any errors 4. Check the created by graph tasks file Change-Id: I45849d680c1224771ac8db61827ac56950c903f4 Closes bug: 1619638 Blueprint: graph-concept-extension
This commit is contained in:
parent
084ff864f2
commit
894f6883be
|
@ -756,3 +756,8 @@ Test SR-IOV
|
|||
-----------
|
||||
.. automodule:: fuelweb_test.tests.test_sriov
|
||||
:members:
|
||||
|
||||
Test graph extension
|
||||
------------------------------------------------------
|
||||
.. automodule:: fuelweb_test.tests.test_graph_extension
|
||||
:members:
|
|
@ -2120,24 +2120,27 @@ class FuelWebClient29(object):
|
|||
cluster_id,
|
||||
graph_type,
|
||||
node_ids=None,
|
||||
tasks=None,
|
||||
progress=None):
|
||||
"""Deploy custom graph of a given type.
|
||||
|
||||
:param cluster_id: Id of a cluster to deploy
|
||||
:param graph_type: Custom graph type to deploy
|
||||
:param node_ids: Ids of nodes to deploy. None means all
|
||||
:param tasks: list of tasks. None means all
|
||||
:param progress: Progress at which count deployment as a success.
|
||||
"""
|
||||
logger.info('Start cluster #{cid} custom type "{type}" '
|
||||
'graph deployment on nodes: {nodes}. '
|
||||
'graph deployment on nodes: {nodes}. With tasks "{tasks}" '
|
||||
'None means on all nodes.'.format(
|
||||
cid=cluster_id,
|
||||
type=graph_type,
|
||||
tasks=tasks,
|
||||
nodes=node_ids
|
||||
))
|
||||
task = self.client.deploy_custom_graph(cluster_id,
|
||||
graph_type,
|
||||
node_ids)
|
||||
node_ids, tasks)
|
||||
self.assert_task_success(task, progress=progress)
|
||||
|
||||
@logwrap
|
||||
|
|
|
@ -145,22 +145,26 @@ class NailgunClient(object):
|
|||
return self._put(url="/clusters/{}/changes/".format(cluster_id)).json()
|
||||
|
||||
@logwrap
|
||||
def deploy_custom_graph(self, cluster_id, graph_type, node_ids=None):
|
||||
def deploy_custom_graph(self, cluster_id, graph_type, node_ids=None,
|
||||
tasks=None):
|
||||
"""Method to deploy custom graph on cluster.
|
||||
|
||||
:param cluster_id: Cluster to be custom deployed
|
||||
:param graph_type: Type of a graph to deploy
|
||||
:param node_ids: nodes to deploy. None or empty list means all.
|
||||
:return:
|
||||
:param tasks: list of string with task names in graph
|
||||
:return: ``task_uuid`` -- unique ID of accepted transaction
|
||||
"""
|
||||
if not node_ids:
|
||||
nailgun_nodes = self.list_cluster_nodes(cluster_id)
|
||||
node_ids = [str(_node['id']) for _node in nailgun_nodes]
|
||||
return self._put(
|
||||
'/clusters/{0}/deploy/?graph_type={1}&nodes={2}'.format(
|
||||
cluster_id,
|
||||
graph_type,
|
||||
','.join(node_ids))).json()
|
||||
scenario = {"cluster": int(cluster_id),
|
||||
"graphs": [
|
||||
{"type": graph_type,
|
||||
"tasks": tasks,
|
||||
"nodes": node_ids
|
||||
}],
|
||||
"dry_run": False,
|
||||
"force": False}
|
||||
endpoint = '/graphs/execute/'
|
||||
return self._post(endpoint, json=scenario).json()
|
||||
|
||||
@logwrap
|
||||
def get_release_tasks(self, release_id):
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
# 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.
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from proboscis import test
|
||||
from proboscis.asserts import assert_equal
|
||||
|
||||
from fuelweb_test.helpers.decorators import log_snapshot_after_test
|
||||
from fuelweb_test.tests.base_test_case import SetupEnvironment
|
||||
from fuelweb_test.tests.base_test_case import TestBasic
|
||||
|
||||
TEST_GRAPH = '''- id: test_1
|
||||
type: shell
|
||||
version: 2.1.0
|
||||
role: ['/.*/']
|
||||
parameters:
|
||||
cmd: echo "test_1" >> /etc/test_file
|
||||
timeout: 5
|
||||
- id: test_2
|
||||
type: shell
|
||||
version: 2.1.0
|
||||
role: ['/.*/']
|
||||
requires: [test_1]
|
||||
parameters:
|
||||
cmd: echo "test_2" >> /etc/test_file
|
||||
timeout: 5'''
|
||||
|
||||
|
||||
@test(groups=["graph_extension"])
|
||||
class GraphExtension(TestBasic):
|
||||
|
||||
def __init__(self):
|
||||
super(GraphExtension, self).__init__()
|
||||
self._cluster_id = None
|
||||
self._admin_ip = self.env.get_admin_node_ip()
|
||||
|
||||
@property
|
||||
def cluster_id(self):
|
||||
if self._cluster_id:
|
||||
return self._cluster_id
|
||||
|
||||
@cluster_id.setter
|
||||
def cluster_id(self, cluster_id):
|
||||
self._cluster_id = cluster_id
|
||||
|
||||
@property
|
||||
def admin_ip(self):
|
||||
return self._admin_ip
|
||||
|
||||
def deploy_custom_graph_wait_cli(self, graph_type):
|
||||
command = 'fuel2 graph execute --env {} -t {} --format=json'.format(
|
||||
self.cluster_id, graph_type)
|
||||
task = self.ssh_manager.check_call(self.admin_ip, command).stdout_json
|
||||
self.fuel_web.assert_task_success(task)
|
||||
|
||||
def check_created_by_tasks_file(self):
|
||||
test_file = '/etc/test_file'
|
||||
cmd = 'egrep "test_1|test_2" {} |wc -l'.format(test_file)
|
||||
for node in self.fuel_web.client.list_cluster_nodes(self.cluster_id):
|
||||
res = self.ssh_manager.check_call(node['ip'], cmd).stdout_str
|
||||
msg = "The file {0} consists of the wrong count of grepped lines" \
|
||||
": `egrep 'test_1|test_2' {0} |wc -l` should be 2, but it " \
|
||||
"is {1} on the node {2}".format(test_file, res, node['name'])
|
||||
assert_equal(int(res), 2, msg)
|
||||
|
||||
@test(depends_on=[SetupEnvironment.prepare_slaves_3],
|
||||
groups=["graph_extension_cli"])
|
||||
@log_snapshot_after_test
|
||||
def graph_extension_cli(self):
|
||||
"""Upload and execute graph for env with 4 slaves (CLI)
|
||||
Scenario:
|
||||
1. Revert snapshot "ready_with_3_slaves"
|
||||
2. Create env with 1 controller nodes and 1 compute+cinder node
|
||||
3. Provision nodes
|
||||
4. Upload two simple graphs
|
||||
5. Make snapshots for next tests and resume snapshot
|
||||
6. Execute graphs
|
||||
7. Check that graph tasks was executed and
|
||||
finished without any errors
|
||||
8. Check the created by graph tasks file
|
||||
|
||||
Duration 10m
|
||||
"""
|
||||
self.show_step(1)
|
||||
self.env.revert_snapshot("ready_with_3_slaves")
|
||||
self.cluster_id = self.fuel_web.create_cluster(
|
||||
name=self.__class__.__name__)
|
||||
self.show_step(2)
|
||||
self.fuel_web.update_nodes(
|
||||
self.cluster_id,
|
||||
{
|
||||
'slave-01': ['controller'],
|
||||
'slave-02': ['compute', 'cinder']
|
||||
})
|
||||
self.show_step(3)
|
||||
self.fuel_web.provisioning_cluster_wait(self.cluster_id)
|
||||
self.show_step(4)
|
||||
with self.ssh_manager.open_on_remote(
|
||||
self.admin_ip, '/root/graph.yaml', "w") as f:
|
||||
f.write(TEST_GRAPH)
|
||||
cmd = \
|
||||
'fuel2 graph upload -e {} -t my_graph -f /root/graph.yaml'.format(
|
||||
self.cluster_id)
|
||||
self.ssh_manager.check_call(self.admin_ip, cmd)
|
||||
self.show_step(5)
|
||||
self.env.make_snapshot("extension_graph_prepare_env", is_make=True)
|
||||
self.env.resume_environment()
|
||||
self.env.sync_time()
|
||||
self.show_step(6)
|
||||
self.deploy_custom_graph_wait_cli('my_graph')
|
||||
self.show_step(7)
|
||||
self.fuel_web.assert_all_tasks_completed(self.cluster_id)
|
||||
self.show_step(8)
|
||||
self.cluster_id = self.fuel_web.get_last_created_cluster()
|
||||
self.check_created_by_tasks_file()
|
||||
|
||||
@test(depends_on=[graph_extension_cli],
|
||||
groups=["graph_extension_api"])
|
||||
@log_snapshot_after_test
|
||||
def graph_extension_api(self):
|
||||
"""Upload and execute graph for env with 4 slaves (CLI)
|
||||
Scenario:
|
||||
1. Revert snapshot "extension_graph_prepare_env"
|
||||
2. Execute graphs via API
|
||||
3. Check that graph tasks was executed and
|
||||
finished without any errors
|
||||
4. Check the created by graph tasks file
|
||||
|
||||
Duration 10m
|
||||
"""
|
||||
self.show_step(1)
|
||||
self.env.revert_snapshot("extension_graph_prepare_env")
|
||||
self.show_step(2)
|
||||
self.cluster_id = self.env.fuel_web.get_last_created_cluster()
|
||||
self.fuel_web.deploy_custom_graph_wait(self.cluster_id, 'my_graph')
|
||||
self.show_step(3)
|
||||
self.fuel_web.assert_all_tasks_completed(self.cluster_id)
|
||||
self.show_step(4)
|
||||
self.check_created_by_tasks_file()
|
Loading…
Reference in New Issue