Пример #1
0
 def test_container_stats(self, mock_srv_list, mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_stats(self.context, container)
     mock_call.assert_called_once_with(container.host,
                                       "container_stats",
                                       container=container)
Пример #2
0
 def test_container_delete_with_host_no_tup(self, mock_rpc_call,
                                            mock_list, mock_service_is_up):
     test_container = utils.get_test_container()
     test_container_obj = objects.Container(self.context, **test_container)
     test_service = utils.get_test_zun_service(host="fake_host")
     test_service_obj = objects.ZunService(self.context, **test_service)
     mock_list.return_value = [test_service_obj]
     mock_service_is_up.return_value = False
     self.assertRaises(exception.ContainerHostNotUp,
                       self.compute_rpcapi.container_delete,
                       self.context, test_container_obj, False)
Пример #3
0
 def test_container_delete_with_host_no_tup(self, mock_rpc_call,
                                            mock_list, mock_service_is_up):
     test_container = utils.get_test_container()
     test_container_obj = objects.Container(self.context, **test_container)
     test_service = utils.get_test_zun_service(host="fake_host")
     test_service_obj = objects.ZunService(self.context, **test_service)
     mock_list.return_value = [test_service_obj]
     mock_service_is_up.return_value = False
     self.assertRaises(exception.ContainerHostNotUp,
                       self.compute_rpcapi.container_delete,
                       self.context, test_container_obj, False)
Пример #4
0
 def test_container_stats(self, mock_srv_list,
                          mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_stats(self.context, container)
     mock_call.assert_called_once_with(
         container.host, "container_stats",
         container=container)
Пример #5
0
 def test_container_exec_resize(self, mock_srv_list,
                                mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_exec_resize(
         self.context, container, '123', 10, 5)
     mock_call.assert_called_once_with(
         container.host, "container_exec_resize",
         exec_id='123', height=10, width=5)
Пример #6
0
 def test_container_put_archive(self, mock_srv_list,
                                mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_put_archive(
         self.context, container, "/root", {}, True)
     mock_call.assert_called_once_with(
         container.host, "container_put_archive",
         container=container, path="/root", data={}, decode_data=True)
Пример #7
0
 def test_container_attach(self, mock_srv_list, mock_srv_up, mock_call):
     mock_call.return_value = 'fake-token'
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     url = self.compute_api.container_attach(self.context, container)
     mock_call.assert_called_once_with(container.host,
                                       "container_attach",
                                       container=container)
     expected_url = '%s?token=%s&uuid=%s' % (CONF.websocket_proxy.base_url,
                                             'fake-token', container.uuid)
     self.assertEqual(expected_url, url)
Пример #8
0
 def test_container_exec(self, mock_srv_list, mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_exec(self.context, container, "/bin/bash",
                                     True, True)
     mock_call.assert_called_once_with(container.host,
                                       "container_exec",
                                       container=container,
                                       command="/bin/bash",
                                       run=True,
                                       interactive=True)
Пример #9
0
 def test_container_logs(self, mock_srv_list,
                         mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_logs(
         self.context, container, 1, 1, 1, 1, 1)
     mock_call.assert_called_once_with(
         container.host, "container_logs",
         container=container, stdout=1, stderr=1,
         timestamps=1, tail=1, since=1)
Пример #10
0
 def test_container_get_archive(self, mock_srv_list, mock_srv_up,
                                mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_get_archive(self.context, container,
                                            "/root", True)
     mock_call.assert_called_once_with(container.host,
                                       "container_get_archive",
                                       container=container,
                                       path="/root",
                                       encode_data=True)
Пример #11
0
 def test_container_exec(self, mock_srv_list,
                         mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_exec(
         self.context, container, "/bin/bash", True, True)
     mock_call.assert_called_once_with(
         container.host, "container_exec",
         container=container, command="/bin/bash",
         run=True, interactive=True)
Пример #12
0
 def test_container_exec_resize(self, mock_srv_list, mock_srv_up,
                                mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_exec_resize(self.context, container, '123',
                                            10, 5)
     mock_call.assert_called_once_with(container.host,
                                       "container_exec_resize",
                                       exec_id='123',
                                       height=10,
                                       width=5)
Пример #13
0
 def test_container_logs(self, mock_srv_list, mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_logs(self.context, container, 1, 1, 1, 1, 1)
     mock_call.assert_called_once_with(container.host,
                                       "container_logs",
                                       container=container,
                                       stdout=1,
                                       stderr=1,
                                       timestamps=1,
                                       tail=1,
                                       since=1)
Пример #14
0
 def test_container_delete(self, mock_start, mock_srv_list, mock_srv_up,
                           mock_cast):
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_delete(self.context, container, False)
     mock_start.assert_called_once_with(self.context,
                                        container.uuid,
                                        container_actions.DELETE,
                                        want_result=False)
     mock_cast.assert_called_once_with(container.host,
                                       "container_delete",
                                       container=container,
                                       force=False)
Пример #15
0
    def test_get_all_availability_zones(self, mock_availability_zone_list,
                                        mock_policy):
        mock_policy.return_value = True
        test_a_zone = utils.get_test_zun_service()
        availability_zones = [objects.ZunService(self.context, **test_a_zone)]
        mock_availability_zone_list.return_value = availability_zones

        response = self.get('/v1/availability_zones')

        mock_availability_zone_list.assert_called_once_with(
            mock.ANY, 1000, None, 'availability_zone', 'asc')
        self.assertEqual(200, response.status_int)
        actual_a_zones = response.json['availability_zones']
        self.assertEqual(1, len(actual_a_zones))
        self.assertEqual(test_a_zone['availability_zone'],
                         actual_a_zones[0].get('availability_zone'))
Пример #16
0
 def test_container_commit(self, mock_start, mock_srv_list,
                           mock_srv_up, mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_commit(
         self.context, container, "ubuntu", "latest")
     mock_start.assert_called_once_with(
         self.context, container.uuid,
         container_actions.COMMIT, want_result=False)
     mock_call.assert_called_once_with(
         container.host, "container_commit",
         container=container, repository="ubuntu", tag="latest")
Пример #17
0
 def test_container_attach(self, mock_srv_list,
                           mock_srv_up, mock_call):
     mock_call.return_value = 'fake-token'
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     url = self.compute_api.container_attach(self.context, container)
     mock_call.assert_called_once_with(
         container.host, "container_attach",
         container=container)
     expected_url = '%s?token=%s&uuid=%s' % (
         CONF.websocket_proxy.base_url, 'fake-token', container.uuid)
     self.assertEqual(expected_url, url)
Пример #18
0
 def test_container_delete(self, mock_start, mock_srv_list,
                           mock_srv_up, mock_cast):
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_delete(
         self.context, container, False)
     mock_start.assert_called_once_with(
         self.context, container.uuid,
         container_actions.DELETE, want_result=False)
     mock_cast.assert_called_once_with(
         container.host, "container_delete",
         container=container, force=False)
Пример #19
0
    def test_get_all_availability_zones(self,
                                        mock_availability_zone_list,
                                        mock_policy):
        mock_policy.return_value = True
        test_a_zone = utils.get_test_zun_service()
        availability_zones = [objects.ZunService(self.context, **test_a_zone)]
        mock_availability_zone_list.return_value = availability_zones

        response = self.get('/v1/availability_zones')

        mock_availability_zone_list.assert_called_once_with(
            mock.ANY, 1000, None, 'availability_zone', 'asc')
        self.assertEqual(200, response.status_int)
        actual_a_zones = response.json['availability_zones']
        self.assertEqual(1, len(actual_a_zones))
        self.assertEqual(test_a_zone['availability_zone'],
                         actual_a_zones[0].get('availability_zone'))
Пример #20
0
 def test_container_commit(self, mock_start, mock_srv_list, mock_srv_up,
                           mock_call):
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     self.compute_api.container_commit(self.context, container, "ubuntu",
                                       "latest")
     mock_start.assert_called_once_with(self.context,
                                        container.uuid,
                                        container_actions.COMMIT,
                                        want_result=False)
     mock_call.assert_called_once_with(container.host,
                                       "container_commit",
                                       container=container,
                                       repository="ubuntu",
                                       tag="latest")
Пример #21
0
 def test_container_exec_interactive(
         self, mock_srv_list, mock_srv_up, mock_call):
     mock_call.return_value = {'token': 'fake-token',
                               'exec_id': 'fake-exec-id'}
     container = self.container
     srv = objects.ZunService(
         self.context,
         **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     result = self.compute_api.container_exec(
         self.context, container, "/bin/bash", True, True)
     self.assertIn('fake-token', result['proxy_url'])
     self.assertIn('fake-exec-id', result['proxy_url'])
     mock_call.assert_called_once_with(
         container.host, "container_exec",
         container=container, command="/bin/bash",
         run=True, interactive=True)
Пример #22
0
 def test_container_exec_interactive(self, mock_srv_list, mock_srv_up,
                                     mock_call):
     mock_call.return_value = {
         'token': 'fake-token',
         'exec_id': 'fake-exec-id'
     }
     container = self.container
     srv = objects.ZunService(
         self.context, **utils.get_test_zun_service(host=container.host))
     mock_srv_list.return_value = [srv]
     mock_srv_up.return_value = True
     result = self.compute_api.container_exec(self.context, container,
                                              "/bin/bash", True, True)
     self.assertIn('fake-token', result['proxy_url'])
     self.assertIn('fake-exec-id', result['proxy_url'])
     mock_call.assert_called_once_with(container.host,
                                       "container_exec",
                                       container=container,
                                       command="/bin/bash",
                                       run=True,
                                       interactive=True)
Пример #23
0
 def setUp(self):
     super(TestZunServiceObject, self).setUp()
     self.fake_zun_service = utils.get_test_zun_service()
Пример #24
0
 def setUp(self):
     super(TestZunServiceObject, self).setUp()
     self.fake_zun_service = utils.get_test_zun_service()