Exemple #1
0
    def test_deployment_serialization_ignore_customized(self, _):
        cluster = self._create_cluster_with_extensions()

        data = [{"uid": n.uid} for n in cluster.nodes]
        mserializer = mock.MagicMock()
        mserializer.return_value = mock.MagicMock()
        mserializer.return_value.serialize.return_value = data

        with mock.patch(
                'nailgun.orchestrator.deployment_serializers.'
                'get_serializer_for_cluster',
                return_value=mserializer):
            with mock.patch('nailgun.orchestrator.deployment_serializers.'
                            'fire_callback_on_deployment_data_serialization'
                            ) as mfire_callback:

                replaced_data = ["it's", "something"]
                with mock.patch.object(
                        cluster.nodes[0], 'replaced_deployment_info',
                        new_callable=mock.Mock(return_value=replaced_data)):

                    graph = orchestrator_graph.AstuteGraph(cluster)
                    deployment_serializers.serialize(
                        graph, cluster, cluster.nodes, ignore_customized=True)

        mfire_callback.assert_called_once_with(data, cluster, cluster.nodes)
Exemple #2
0
 def setUp(self):
     super(TestTasksRemoval, self).setUp()
     with mock.patch('nailgun.objects.Cluster') as cluster_m:
         cluster_m.get_deployment_tasks.return_value = yaml.load(TASKS +
                                                                 SUBTASKS)
         self.cluster = mock.Mock()
         self.astute = orchestrator_graph.AstuteGraph(self.cluster)
 def test_tasks_serialized_correctly(self):
     self.graph = orchestrator_graph.AstuteGraph(self.cluster)
     self.cluster.release.operating_system = consts.RELEASE_OS.ubuntu
     tasks = self.graph.pre_tasks_serialize(self.nodes)
     self.assertEqual(len(tasks), 20)
     tasks_tests = [('shell', ['master']), ('shell', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('upload_file', sorted(self.all_uids)),
                    ('copy_files', sorted(self.all_uids)),
                    ('sync', sorted(self.all_uids)),
                    ('shell', sorted(self.all_uids))]
     tasks_output = []
     for task in tasks:
         tasks_output.append((task['type'], sorted(task['uids'])))
     self.assertItemsEqual(tasks_tests, tasks_output)
Exemple #4
0
 def setUp(self):
     super(TestLegacyGraphSerialized, self).setUp()
     with mock.patch('nailgun.objects.Cluster') as cluster_m:
         cluster_m.get_deployment_tasks.return_value = yaml.load(
             graph_configuration.DEPLOYMENT_51_60)
         self.cluster = mock.Mock()
         self.graph = orchestrator_graph.AstuteGraph(self.cluster)
Exemple #5
0
 def setUp(self):
     super(GroupsTraversalTest, self).setUp()
     with mock.patch('nailgun.objects.Cluster') as cluster_m:
         cluster_m.get_deployment_tasks.return_value = yaml.load(
             self.GROUPS)
         self.cluster = mock.Mock()
         self.astute = orchestrator_graph.AstuteGraph(self.cluster)
         self.nodes = []
Exemple #6
0
 def _serialize(self, cluster, nodes):
     if objects.Release.is_lcm_supported(cluster.release):
         return deployment_serializers.serialize_for_lcm(
             cluster, nodes, ignore_customized=True)
     graph = orchestrator_graph.AstuteGraph(cluster)
     return deployment_serializers.serialize(graph,
                                             cluster,
                                             nodes,
                                             ignore_customized=True)
    def _serialize(self, cluster, nodes):
        if objects.Release.is_lcm_supported(cluster.release):
            serialized = deployment_serializers.serialize_for_lcm(
                cluster, nodes, ignore_customized=True)
        else:
            graph = orchestrator_graph.AstuteGraph(cluster)
            serialized = deployment_serializers.serialize(
                graph, cluster, nodes, ignore_customized=True)

        return _deployment_info_in_compatible_format(
            serialized, utils.parse_bool(web.input(split='0').split))
Exemple #8
0
    def test_deployment_serialization_ignore_customized_false(self, _):
        cluster = self._create_cluster_with_extensions(nodes_kwargs=[
            {
                'roles': ['controller'],
                'pending_addition': True
            },
            {
                'roles': ['controller'],
                'pending_addition': True
            },
            {
                'roles': ['controller'],
                'pending_addition': True
            },
            {
                'roles': ['controller'],
                'pending_addition': True
            },
        ])

        data = [{"uid": n.uid} for n in cluster.nodes]
        expected_data = copy.deepcopy(data[1:])

        mserializer = mock.MagicMock()
        mserializer.return_value = mock.MagicMock()
        mserializer.return_value.serialize.return_value = data

        with mock.patch(
                'nailgun.orchestrator.deployment_serializers.'
                'get_serializer_for_cluster',
                return_value=mserializer):
            with mock.patch(
                    'nailgun.orchestrator.deployment_serializers.'
                    'fire_callback_on_deployment_data_serialization',
            ) as mfire_callback:

                replaced_data = ["it's", "something"]
                with mock.patch.object(
                        cluster.nodes[0],
                        'replaced_deployment_info',
                        new_callable=mock.Mock(return_value=replaced_data)):

                    graph = orchestrator_graph.AstuteGraph(cluster)
                    deployment_serializers.serialize(graph,
                                                     cluster,
                                                     cluster.nodes,
                                                     ignore_customized=False)

        self.assertEqual(mfire_callback.call_args[0][0], expected_data)
        self.assertIs(mfire_callback.call_args[0][1], cluster)
        self.assertItemsEqual(mfire_callback.call_args[0][2],
                              cluster.nodes[1:])
Exemple #9
0
 def test_validation_failed_with_cycling_dependencies(self):
     yaml_tasks = """
     - id: test-controller-1
       type: role
       requires: [test-controller-2]
     - id: test-controller-2
       type: role
       requires: [test-controller-1]
     """
     tasks = yaml.load(yaml_tasks)
     graph = orchestrator_graph.AstuteGraph(self.cluster, tasks)
     with self.assertRaisesRegexp(
             errors.InvalidData,
             "Graph cannot be processed because it contains cycles in it"):
         graph.check()
Exemple #10
0
 def test_validation_pass_with_existing_dependencies(self):
     yaml_tasks = """
     - id: deploy_end
       type: stage
     - id: pre_deployment_start
       type: stage
     - id: test-controller
       type: group
       role: [test-controller]
       requires: [pre_deployment_start]
       required_for: [deploy_end]
       parameters:
         strategy:
           type: parallel
           amount: 2
       """
     tasks = yaml.load(yaml_tasks)
     graph = orchestrator_graph.AstuteGraph(self.cluster, tasks)
     self.assertNotRaises(errors.InvalidData, graph.check)
Exemple #11
0
    def test_validation_failed_with_not_existing_dependencies(self):
        dependencies_types = ['requires', 'required_for', 'groups', 'tasks']

        for dependency_type in dependencies_types:
            yaml_tasks = """
            - id: test-controller
              type: group
              role: [test-controlle]
              {dependency_type}: [non_existing_stage]
              parameters:
                strategy:
                  type: one_by_one
              """.format(dependency_type=dependency_type)

            tasks = yaml.load(yaml_tasks)
            graph = orchestrator_graph.AstuteGraph(self.cluster, tasks)

            with self.assertRaisesRegexp(
                    errors.InvalidData,
                    "Tasks 'non_existing_stage' can't be in requires|"
                    "required_for|groups|tasks for \['test-controller'\] "
                    "because they don't exist in the graph"):
                graph.check()
Exemple #12
0
 def _serialize(self, cluster, nodes):
     if objects.Release.is_lcm_supported(cluster.release):
         raise self.http(405,
                         msg="The plugin hooks are not supported anymore.")
     graph = orchestrator_graph.AstuteGraph(cluster)
     return post_deployment_serialize(graph, cluster, nodes)
 def setUp(self):
     super(TestConditionalTasksSerializers, self).setUp()
     self.graph = orchestrator_graph.AstuteGraph(self.cluster)
 def setUp(self):
     super(TestPostTaskSerialization, self).setUp()
     self.control_uids = [
         n.uid for n in self.nodes if 'controller' in n.roles
     ]
     self.graph = orchestrator_graph.AstuteGraph(self.cluster)