コード例 #1
0
ファイル: test_capsule.py プロジェクト: ppatel826/zun
 def test_get_capsule_by_uuid(self, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     capsule = utils.create_test_capsule(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(capsule.as_dict())
     res = dbapi.get_capsule_by_uuid(self.context, capsule.uuid)
     self.assertEqual(capsule.id, res.id)
     self.assertEqual(capsule.uuid, res.uuid)
コード例 #2
0
 def test_get_image_by_uuid(self, mock_get, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     image = utils.create_test_image(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(image.as_dict())
     res = self.dbapi.get_image_by_uuid(self.context, image.uuid)
     self.assertEqual(image.uuid, res.uuid)
コード例 #3
0
ファイル: test_container.py プロジェクト: ppatel826/zun
 def test_destroy_container(self, mock_delete, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     container = utils.create_test_container(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(container.as_dict(
     ))
     dbapi.destroy_container(self.context, container.uuid)
     mock_delete.assert_called_once_with('/containers/%s' % container.uuid)
コード例 #4
0
 def test_destroy_resource_class(self, mock_delete, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     resource_class = utils.create_test_resource_class(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(resource_class.
                                                          as_dict())
     dbapi.destroy_resource_class(self.context, resource_class.uuid)
     mock_delete.assert_called_once_with('/resource_classes/%s' %
                                         resource_class.uuid)
コード例 #5
0
 def test_get_resource_class_by_uuid(self, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     resource_class = utils.create_test_resource_class(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(resource_class.
                                                          as_dict())
     res = dbapi.get_resource_class(self.context, resource_class.uuid)
     self.assertEqual(resource_class.uuid, res.uuid)
     self.assertEqual(resource_class.name, res.name)
コード例 #6
0
ファイル: test_capsule.py プロジェクト: zukobronja/zun
 def test_destroy_capsule_by_uuid(self, mock_db_inst, mock_delete,
                                  mock_write, mock_read):
     mock_db_inst.return_value = etcdapi.get_backend()
     mock_read.side_effect = etcd.EtcdKeyNotFound
     capsule = utils.create_test_capsule(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(capsule.as_dict())
     dbapi.destroy_capsule(self.context, capsule.uuid)
     mock_delete.assert_called_once_with('/capsules/%s' % capsule.uuid)
コード例 #7
0
 def test_get_container_by_uuid(self, mock_inst, mock_write, mock_read):
     mock_inst.return_value = etcdapi.get_backend()
     mock_read.side_effect = etcd.EtcdKeyNotFound
     container = utils.create_test_container(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(container.as_dict(
     ))
     res = dbapi.get_container_by_uuid(self.context, container.uuid)
     self.assertEqual(container.id, res.id)
     self.assertEqual(container.uuid, res.uuid)
コード例 #8
0
ファイル: test_volume_mapping.py プロジェクト: ppatel826/zun
 def test_get_volume_mapping_by_uuid(self, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     volume_mapping = utils.create_test_volume_mapping(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(volume_mapping.
                                                          as_dict())
     res = dbapi.get_volume_mapping_by_uuid(self.context,
                                            volume_mapping.uuid)
     self.assertEqual(volume_mapping.id, res.id)
     self.assertEqual(volume_mapping.uuid, res.uuid)
コード例 #9
0
 def test_update_image(self, mock_get, mock_update, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     image = utils.create_test_image(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(image.as_dict())
     self.dbapi.update_image(image.uuid, {'tag': 'newtag'})
     self.assertEqual(
         'newtag',
         json.loads(mock_update.call_args_list[0][0][0].value)['tag'])
コード例 #10
0
ファイル: test_zun_service.py プロジェクト: ppatel826/zun
 def test_destroy_zun_service(self, mock_delete, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     zun_service = utils.create_test_zun_service()
     mock_read.side_effect = lambda *args: FakeEtcdResult(zun_service.
                                                          as_dict())
     dbapi.destroy_zun_service(zun_service.host, zun_service.binary)
     mock_delete.assert_called_once_with('/zun_services/%s' %
                                         zun_service.host + '_' +
                                         zun_service.binary)
コード例 #11
0
ファイル: test_zun_service.py プロジェクト: ppatel826/zun
 def test_get_zun_service(self, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     zun_service = utils.create_test_zun_service()
     mock_read.side_effect = lambda *args: FakeEtcdResult(zun_service.
                                                          as_dict())
     res = dbapi.get_zun_service(self.context, zun_service.host,
                                 zun_service.binary)
     self.assertEqual(zun_service.host, res.host)
     self.assertEqual(zun_service.binary, res.binary)
コード例 #12
0
ファイル: test_volume_mapping.py プロジェクト: ppatel826/zun
 def test_destroy_volume_mapping_by_uuid(self, mock_delete, mock_write,
                                         mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     volume_mapping = utils.create_test_volume_mapping(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(volume_mapping.
                                                          as_dict())
     dbapi.destroy_volume_mapping(self.context, volume_mapping.uuid)
     mock_delete.assert_called_once_with('/volume_mappings/%s' %
                                         volume_mapping.uuid)
コード例 #13
0
ファイル: test_compute_host.py プロジェクト: zukobronja/zun
 def test_get_compute_node_by_name(self, mock_db_inst,
                                   mock_write, mock_read):
     mock_db_inst.return_value = etcdapi.get_backend()
     mock_read.side_effect = etcd.EtcdKeyNotFound
     node = utils.create_test_compute_node(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(
         node.as_dict())
     res = dbapi.get_compute_node(self.context, node.hostname)
     self.assertEqual(node.uuid, res.uuid)
コード例 #14
0
ファイル: test_zun_service.py プロジェクト: ppatel826/zun
    def test_update_zun_service(self, mock_update, mock_write, mock_read):
        mock_read.side_effect = etcd.EtcdKeyNotFound
        service = utils.create_test_zun_service()
        new_host = 'new-host'

        mock_read.side_effect = lambda *args: FakeEtcdResult(service.as_dict())
        dbapi.update_zun_service(service.host, service.binary,
                                 {'host': new_host})
        self.assertEqual(
            new_host,
            json.loads(mock_update.call_args_list[0][0][0].value)['host'])
コード例 #15
0
ファイル: test_capsule.py プロジェクト: ppatel826/zun
    def test_update_capsule(self, mock_update, mock_write, mock_read):
        mock_read.side_effect = etcd.EtcdKeyNotFound
        capsule = utils.create_test_capsule(context=self.context)
        new_meta_name = 'new_meta_name'

        mock_read.side_effect = lambda *args: FakeEtcdResult(capsule.as_dict())
        dbapi.update_capsule(self.context, capsule.uuid,
                             {'meta_name': new_meta_name})
        self.assertEqual(
            new_meta_name,
            json.loads(mock_update.call_args_list[0][0][0].value.decode(
                'utf-8'))['meta_name'])
コード例 #16
0
ファイル: test_container.py プロジェクト: ppatel826/zun
    def test_update_container(self, mock_update, mock_write, mock_read):
        mock_read.side_effect = etcd.EtcdKeyNotFound
        container = utils.create_test_container(context=self.context)
        new_image = 'new-image'

        mock_read.side_effect = lambda *args: FakeEtcdResult(container.as_dict(
        ))
        dbapi.update_container(self.context, container.uuid,
                               {'image': new_image})
        self.assertEqual(
            new_image,
            json.loads(mock_update.call_args_list[0][0][0].value)['image'])
コード例 #17
0
 def test_update_resource_class(self, mock_update, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     resource_class = utils.create_test_resource_class(context=self.context)
     old_name = resource_class.name
     new_name = 'new-name'
     self.assertNotEqual(old_name, new_name)
     mock_read.side_effect = lambda *args: FakeEtcdResult(resource_class.
                                                          as_dict())
     dbapi.update_resource_class(self.context, resource_class.uuid,
                                 {'name': new_name})
     self.assertEqual(
         new_name,
         json.loads(mock_update.call_args_list[0][0][0].value)['name'])
コード例 #18
0
ファイル: test_volume_mapping.py プロジェクト: ppatel826/zun
    def test_update_volume_mapping(self, mock_update, mock_write, mock_read):
        mock_read.side_effect = etcd.EtcdKeyNotFound
        volume_mapping = utils.create_test_volume_mapping(context=self.context)
        new_conn_info = 'new-conn-info'

        mock_read.side_effect = lambda *args: FakeEtcdResult(volume_mapping.
                                                             as_dict())
        dbapi.update_volume_mapping(self.context, volume_mapping.uuid,
                                    {'container_info': new_conn_info})
        self.assertEqual(
            new_conn_info,
            json.loads(mock_update.call_args_list[0][0][0].value.decode(
                'utf-8'))['container_info'])
コード例 #19
0
ファイル: test_compute_host.py プロジェクト: ppatel826/zun
 def test_update_compute_node(self, mock_update, mock_write, mock_read):
     mock_read.side_effect = etcd.EtcdKeyNotFound
     compute_node = utils.create_test_compute_node(context=self.context)
     old_name = compute_node.hostname
     new_name = 'new-name'
     self.assertNotEqual(old_name, new_name)
     mock_read.side_effect = lambda *args: FakeEtcdResult(compute_node.
                                                          as_dict())
     dbapi.update_compute_node(self.context, compute_node.uuid,
                               {'hostname': new_name})
     self.assertEqual(
         new_name,
         json.loads(mock_update.call_args_list[0][0][0].value)['hostname'])
コード例 #20
0
    def test_container_action_event_finish_success(
            self, mock_db_inst, mock_get_event_by_name,
            mock__action_get_by_request_id,
            mock_update, mock_write, mock_read):
        """Finish a container action event."""
        mock_db_inst.return_value = etcdapi.get_backend()
        mock_read.side_effect = etcd.EtcdKeyNotFound
        uuid = uuidutils.generate_uuid()

        action = dbapi.action_start(self.context,
                                    self._create_action_values(uuid))

        event_values = self._create_event_values(uuid)
        event_values['action_uuid'] = action['uuid']

        mock__action_get_by_request_id.return_value = action
        mock_read.side_effect = etcd.EtcdKeyNotFound
        event = dbapi.action_event_start(self.context, event_values)

        event_values = {
            'finish_time': timeutils.utcnow() + timedelta(seconds=5),
            'result': 'Success'
        }

        event_values = self._create_event_values(uuid, extra=event_values)

        mock__action_get_by_request_id.return_value = action
        mock_get_event_by_name.return_value = event
        mock_read.side_effect = lambda *args: FakeEtcdResult(event)
        event = dbapi.action_event_finish(self.context, event_values)

        event['start_time'] = datetime.isoformat(event['start_time'])
        mock_read.side_effect = lambda *args: FakeEtcdMultipleResult([event])
        self._assertActionEventSaved(event, action['uuid'])

        mock_read.side_effect = lambda *args: FakeEtcdMultipleResult([action])
        action = dbapi.action_get_by_request_id(self.context, uuid,
                                                self.context.request_id)
        self.assertNotEqual('Error', action['message'])