コード例 #1
0
    def setUp(self):
        super(TestTaskCommand, self).setUp()

        self.m_client.get_all.return_value = [utils.get_fake_task()
                                              for _ in range(10)]
        self.m_client.get_by_id.return_value = utils.get_fake_task()
        self.current_path = os.path.join(os.path.abspath(os.curdir))
コード例 #2
0
    def test_task_list_w_parameters(self):
        env_id = 36
        statuses = ['ready', 'error']
        names = ['dump', 'provision']
        fake_tasks = [
            utils.get_fake_task(task_id=45,
                                cluster=env_id,
                                status=statuses[0],
                                name=names[0]),
            utils.get_fake_task(task_id=46,
                                cluster=env_id,
                                status=statuses[0],
                                name=names[1]),
            utils.get_fake_task(task_id=49,
                                cluster=env_id,
                                status=[1],
                                name=names[1]),
        ]
        params = ('?cluster_id={env_id}'
                  '&statuses={statuses}'
                  '&transaction_types={names}')
        expected_url = self.res_uri + params.format(
            env_id=env_id, statuses=','.join(statuses), names=','.join(names))

        matcher = self.m_request.get(expected_url, json=fake_tasks)

        tasks = self.client.get_all(cluster_id=env_id,
                                    statuses=statuses,
                                    transaction_types=names)

        self.assertTrue(matcher.called)
        self.assertEqual(3, len(tasks))
コード例 #3
0
    def setUp(self):
        super(TestTaskCommand, self).setUp()

        self.m_client.get_all.return_value = [utils.get_fake_task()
                                              for i in range(10)]
        self.m_client.get_by_id.return_value = utils.get_fake_task()
        self.current_path = os.path.join(os.path.abspath(os.curdir))
コード例 #4
0
    def setUp(self):
        super(TestTaskFacade, self).setUp()

        self.version = 'v1'
        self.res_uri = '/api/{version}/tasks/'.format(version=self.version)

        self.fake_task = utils.get_fake_task()
        self.fake_tasks = [utils.get_fake_task() for _ in range(10)]

        self.client = fuelclient.get_client('task', self.version)
コード例 #5
0
    def setUp(self):
        super(TestTaskFacade, self).setUp()

        self.version = 'v1'
        self.res_uri = '/api/{version}/tasks/'.format(version=self.version)

        self.fake_task = utils.get_fake_task()
        self.fake_tasks = [utils.get_fake_task() for _ in range(10)]

        self.client = fuelclient.get_client('task', self.version)
コード例 #6
0
    def setUp(self):
        super(TestSnapshotFacade, self).setUp()

        self.version = 'v1'
        self.res_uri = '/api/{version}/logs/package'.format(
            version=self.version)
        self.client = fuelclient.get_client('snapshot', self.version)
        self.fake_task = utils.get_fake_task()
コード例 #7
0
    def test_env_stop(self):
        env_id = 42
        expected_uri = self.get_object_uri(self.res_uri, env_id,
                                           '/stop_deployment/')

        matcher = self.m_request.put(expected_uri, json=utils.get_fake_task())

        self.client.stop(env_id)

        self.assertTrue(matcher.called)
コード例 #8
0
    def test_env_reset_force(self):
        env_id = 42
        force = True
        expected_uri = self.get_object_uri(self.res_uri, env_id, '/reset/')

        matcher = self.m_request.put(expected_uri, json=utils.get_fake_task())

        self.client.reset(env_id, force=force)

        self.assertTrue(matcher.called)
        self.assertEqual(matcher.last_request.qs['force'][0], str(int(force)))
コード例 #9
0
    def test_env_provision_nodes(self):
        env_id = 42
        node_ids = [43, 44]

        expected_url = self.get_object_uri(self.res_uri, env_id, '/provision/')
        matcher = self.m_request.put(expected_url, json=utils.get_fake_task())

        self.client.provision_nodes(env_id, node_ids)

        self.assertTrue(matcher.called)
        self.assertEqual([','.join(str(i) for i in node_ids)],
                         matcher.last_request.qs['nodes'])
コード例 #10
0
    def test_env_deploy_nodes_force(self):
        env_id = 42
        node_ids = [43, 44]
        force = True

        expected_url = self.get_object_uri(self.res_uri, env_id, '/deploy/')
        matcher = self.m_request.put(expected_url, json=utils.get_fake_task())

        self.client.deploy_nodes(env_id, node_ids, force=force)

        self.assertTrue(matcher.called)
        self.assertEqual([','.join(str(i) for i in node_ids)],
                         matcher.last_request.qs['nodes'])
        self.assertEqual(matcher.last_request.qs['force'][0], str(int(force)))
コード例 #11
0
    def test_config_force_execute(self):
        task_id = 42
        test_task = utils.get_fake_task(task_id=task_id)

        self.m_client.execute.return_value = test_task

        cmd = ('openstack-config execute --env {0}'
               ' --node {1} --force ').format(self.CLUSTER_ID, self.NODE_ID)

        self.exec_command(cmd)

        self.m_get_client.assert_called_once_with('openstack-config', mock.ANY)
        self.m_client.execute.assert_called_once_with(
            cluster_id=self.CLUSTER_ID, node_ids=[self.NODE_ID],
            node_role=None, force=True)
コード例 #12
0
    def test_env_network_verify(self):
        env_id = 42
        fake_env = utils.get_fake_env(env_id=env_id)
        test_conf = utils.get_fake_env_network_conf()

        env_uri = self.get_object_uri(self.res_uri, env_id)
        download_uri = self.get_object_uri(self.res_uri,
                                           env_id,
                                           self.net_conf_uri)
        verify_uri = self.get_object_uri(self.res_uri,
                                         env_id,
                                         self.net_verify_uri)

        m_get = self.m_request.get(env_uri, json=fake_env)
        m_download = self.m_request.get(download_uri, json=test_conf)
        m_verify = self.m_request.put(verify_uri, json=utils.get_fake_task())

        self.client.verify_network(env_id)

        self.assertTrue(m_get.called)
        self.assertTrue(m_download.called)
        self.assertTrue(m_verify.called)
        self.assertEqual(test_conf, m_verify.last_request.json())
コード例 #13
0
 def test_new_graph_dry_run_subgraph(self):
     matcher_post = self.m_request.post(
         '/api/v1/graphs/execute/', json=utils.get_fake_task(cluster=370))
     # this is required to form running task info
     self.m_request.get('/api/v1/nodes/?cluster_id=370', json={})
     self.client.execute(env_id=1,
                         nodes=[1, 2, 3],
                         graph_types=["custom_graph"],
                         dry_run=True,
                         subgraphs=[
                             'primary-database/1,3:keystone-db/1-2,5',
                             'openstack-controller'
                         ])
     self.assertTrue(matcher_post.called)
     expected_body = {
         'cluster':
         1,
         'dry_run':
         True,
         'graphs': [{
             'nodes': [1, 2, 3],
             'type': 'custom_graph',
             'tasks': ['rsync_core_puppet']
         }, {
             'nodes': [1, 2, 3],
             'type': 'another_custom_graph',
             'tasks': ['rsync_core_puppet']
         }],
         'subgraphs': [{
             'start': ['primary-database/1,3'],
             'end': ['keystone-db/1-2,5']
         }, {
             'start': ['openstack-controller'],
             'end': [None]
         }]
     }
     self.assertItemsEqual(matcher_post.last_request.json(), expected_body)