コード例 #1
0
    def test_container_actions_get_by_container(self, mock_db_inst,
                                                mock_write, mock_read):
        mock_db_inst.return_value = etcdapi.get_backend()
        mock_read.side_effect = etcd.EtcdKeyNotFound
        uuid1 = uuidutils.generate_uuid()

        expected = []

        action_values = self._create_action_values(uuid1)
        action = dbapi.action_start(self.context, action_values)
        action['start_time'] = datetime.isoformat(action['start_time'])
        expected.append(action)

        action_values['action'] = 'test-action'
        action = dbapi.action_start(self.context, action_values)
        action['start_time'] = datetime.isoformat(action['start_time'])
        expected.append(action)

        # Create an other container action.
        uuid2 = uuidutils.generate_uuid()
        action_values = self._create_action_values(uuid2, 'test-action')
        dbapi.action_start(self.context, action_values)

        mock_read.side_effect = lambda *args: FakeEtcdMultipleResult(
            expected)
        actions = dbapi.actions_get(self.context, uuid1)
        self._assertEqualListsOfObjects(expected, actions)
コード例 #2
0
    def test_container_actions_get_by_container(self):
        """Ensure we can get actions by UUID."""
        uuid1 = uuidutils.generate_uuid()

        expected = []

        action_values = self._create_action_values(uuid1)
        action = dbapi.action_start(self.context, action_values)
        expected.append(action)

        action_values['action'] = 'test-action'
        action = dbapi.action_start(self.context, action_values)
        expected.append(action)

        # Create an other container action.
        uuid2 = uuidutils.generate_uuid()
        action_values = self._create_action_values(uuid2, 'test-action')
        dbapi.action_start(self.context, action_values)

        actions = dbapi.actions_get(self.context, uuid1)
        self._assertEqualListsOfObjects(expected, actions)
コード例 #3
0
 def get_by_container_uuid(cls, context, instance_uuid):
     db_actions = dbapi.actions_get(context, instance_uuid)
     return ContainerAction._from_db_object_list(context, cls, db_actions)
コード例 #4
0
 def _assertActionSaved(self, action, uuid):
     """Retrieve the action to ensure it was successfully added."""
     actions = dbapi.actions_get(self.context, uuid)
     self.assertEqual(1, len(actions))
     self._assertEqualObjects(action, actions[0])
コード例 #5
0
ファイル: container_action.py プロジェクト: openstack/higgins
 def get_by_container_uuid(cls, context, container_uuid):
     db_actions = dbapi.actions_get(context, container_uuid)
     return ContainerAction._from_db_object_list(context, cls, db_actions)