0fe7803400
Including skipped by default tasks may be usefull for maintenance or patching procedure. All tasks received by uri: /clusters/(?P<cluster_id>\d+)/deploy_tasks/ Will be included to execution, without exception for state. If user wants to use nailgun graph filtering logic and include some tasks into execution - additional input *include* with list of tasks must be provided to ClusterDeploymentTasksHandler. If include wont be provided - skipped=True will be preserved, and tasks wont be returned. *state=skipped* should be deprecated, and removed after notification in mailing list. Change-Id: I4d9621d77c09c8f0101e3eb0e8fa17372cf3f80e Closes-Bug: 1470822
87 lines
2.9 KiB
Python
87 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# 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 six
|
|
|
|
from nailgun.orchestrator import deployment_graph
|
|
from nailgun.orchestrator import graph_visualization
|
|
from nailgun.test import base
|
|
|
|
|
|
class TestDeploymentGraphViualization(base.BaseUnitTest):
|
|
|
|
def get_dotgraph_with_tasks(self, tasks):
|
|
graph = deployment_graph.DeploymentGraph()
|
|
graph.add_tasks(tasks)
|
|
visualization = graph_visualization.GraphVisualization(graph)
|
|
dotgraph = visualization.get_dotgraph()
|
|
return dotgraph.to_string()
|
|
|
|
def test_stage_type(self):
|
|
tasks = [
|
|
{'id': 'pre_deployment', 'type': 'stage'},
|
|
]
|
|
|
|
dotgraph = self.get_dotgraph_with_tasks(tasks)
|
|
|
|
six.assertRegex(self, dotgraph, 'pre_deployment .*color=red.*;')
|
|
six.assertRegex(self, dotgraph, 'pre_deployment .*shape=rect.*;')
|
|
six.assertRegex(self, dotgraph, 'pre_deployment .*style=filled.*;')
|
|
|
|
def test_group_type(self):
|
|
tasks = [
|
|
{'id': 'controller', 'type': 'group'},
|
|
]
|
|
|
|
dotgraph = self.get_dotgraph_with_tasks(tasks)
|
|
|
|
six.assertRegex(self, dotgraph, 'controller .*color=lightskyblue.*;')
|
|
six.assertRegex(self, dotgraph, 'controller .*shape=box.*;')
|
|
six.assertRegex(self, dotgraph,
|
|
'controller .*style="filled, rounded".*;')
|
|
|
|
def test_skipped_type(self):
|
|
tasks = [
|
|
{'id': 'hiera', 'type': 'skipped'},
|
|
]
|
|
dotgraph = self.get_dotgraph_with_tasks(tasks)
|
|
self.assertIn('hiera [color=gray95];', dotgraph)
|
|
|
|
def test_add_simple_connection(self):
|
|
tasks = [
|
|
{'id': 'task-A'},
|
|
{'id': 'task-B', 'requires': ['task-A']},
|
|
]
|
|
|
|
dotgraph = self.get_dotgraph_with_tasks(tasks)
|
|
|
|
self.assertIn('"task-A" -> "task-B"', dotgraph)
|
|
|
|
def test_node_default_attrs(self):
|
|
tasks = [
|
|
{'id': 'task-A'},
|
|
]
|
|
dotgraph = self.get_dotgraph_with_tasks(tasks)
|
|
six.assertRegex(self, dotgraph, '"task-A" .*color=yellowgreen.*;')
|
|
six.assertRegex(self, dotgraph, '"task-A" .*style=filled.*;')
|
|
|
|
def test_skipped_metaparam(self):
|
|
tasks = [
|
|
{'id': 'task_a', 'skipped': True},
|
|
]
|
|
dotgraph = self.get_dotgraph_with_tasks(tasks)
|
|
self.assertIn('task_a [color=gray95];', dotgraph)
|