Пример #1
0
    def test_action_list_with_search_with_all_opt_one_match(self):
        count = 0
        actionids = []
        while (count < 20):
            doc = copy.deepcopy(self.fake_action_3)
            action_id = common.get_fake_action_id()
            doc['action_id'] = action_id
            if count in [0, 4, 8, 12, 16]:
                doc['max_retries'] = 10
            result = self.dbapi.add_action(
                user_id=self.fake_action_3.get('user_id'), doc=doc)

            self.assertIsNotNone(result)
            self.assertEqual(result, action_id)
            actionids.append(action_id)
            count += 1

        search_opt = {'match': [{'_all': '[{"max_retries": 10}]'}]}
        result = self.dbapi.search_action(
            user_id=self.fake_action_3.get('user_id'),
            limit=20,
            offset=0,
            search=search_opt)

        self.assertIsNotNone(result)
        self.assertEqual(len(result), 5)
        for index in range(len(result)):
            actionmap = result[index]
            self.assertEqual(10, actionmap['max_retries'])
Пример #2
0
    def test_action_list_with_search_with_error_all_opt_return_alltuples(self):
        count = 0
        actionids = []
        while (count < 20):
            doc = copy.deepcopy(self.fake_action_3)
            action_id = common.get_fake_action_id()
            doc['action_id'] = action_id
            if count in [0, 4, 8, 12, 16]:
                doc['max_retries'] = 10
            result = self.dbapi.add_action(
                user_id=self.fake_action_3.get('user_id'), doc=doc)

            self.assertIsNotNone(result)
            self.assertEqual(result, action_id)
            actionids.append(action_id)
            count += 1

        search_opt = {'match': [{'_all': '{"max_retries": 10}'}]}
        result = self.dbapi.search_action(
            user_id=self.fake_action_3.get('user_id'),
            limit=20,
            offset=0,
            search=search_opt)

        self.assertIsNotNone(result)
        self.assertEqual(len(result), 20)
        search_opt = {'match': [{'_all': 'max_retries=10'}]}
        result = self.dbapi.search_action(
            user_id=self.fake_action_3.get('user_id'),
            limit=20,
            offset=0,
            search=search_opt)

        self.assertIsNotNone(result)
        self.assertEqual(len(result), 20)
Пример #3
0
    def test_action_list_with_search_match_not_list(self):
        count = 0
        actionids = []
        while (count < 20):
            doc = copy.deepcopy(self.fake_action_3)
            action_id = common.get_fake_action_id()
            doc['action_id'] = action_id
            if count in [0, 4, 8, 12, 16]:
                doc['max_retries'] = 10
                if count in [4, 12]:
                    doc['freezer_action']['mode'] = 'nova'
            result = self.dbapi.add_action(
                user_id=self.fake_action_3.get('user_id'), doc=doc)

            self.assertIsNotNone(result)
            self.assertEqual(result, action_id)
            actionids.append(action_id)
            count += 1

        search_opt = {'match_not': [{'mode': 'nova'}, {'max_retries': 5}]}
        result = self.dbapi.search_action(
            user_id=self.fake_action_3.get('user_id'),
            limit=20,
            offset=0,
            search=search_opt)

        self.assertIsNotNone(result)
        self.assertEqual(len(result), 3)
        for index in range(len(result)):
            actionmap = result[index]
            self.assertEqual(10, actionmap['max_retries'])
            self.assertEqual('fs', actionmap['freezer_action']['mode'])
Пример #4
0
    def test_add_and_search_action(self):
        count = 0
        actionids = []
        while (count < 20):
            doc = copy.deepcopy(self.fake_action_3)
            action_id = common.get_fake_action_id()
            doc['action_id'] = action_id
            result = self.dbapi.add_action(
                user_id=self.fake_action_3.get('user_id'),
                doc=doc,
                project_id=self.fake_project_id)
            self.assertIsNotNone(result)
            self.assertEqual(result, action_id)
            actionids.append(action_id)
            count += 1

        result = self.dbapi.search_action(
            project_id=self.fake_project_id,
            user_id=self.fake_action_3.get('user_id'),
            limit=10,
            offset=0)

        self.assertIsNotNone(result)

        self.assertEqual(len(result), 10)

        for index in range(len(result)):
            actionmap = result[index]
            self.assertEqual(actionids[index], actionmap['action_id'])
Пример #5
0
 def setUp(self):
     super(DbActionTestCase, self).setUp()
     self.fake_action_0 = common.get_fake_action_0()
     self.fake_action_2 = common.get_fake_action_2()
     self.fake_action_3 = common.get_fake_action_3()
     self.freezer_action_0 = self.fake_action_0.get('freezer_action')
     self.freezer_action_2 = self.fake_action_2.get('freezer_action')
     self.fake_user_id = self.fake_action_0.get('user_id')
     self.fake_action_id = common.get_fake_action_id()
     CONF.enable_v1_api = True
Пример #6
0
 def setUp(self):
     super(DbActionTestCase, self).setUp()
     self.fake_action_0 = common.get_fake_action_0()
     self.fake_action_2 = common.get_fake_action_2()
     self.fake_action_3 = common.get_fake_action_3()
     self.freezer_action_0 = self.fake_action_0.get('freezer_action')
     self.freezer_action_2 = self.fake_action_2.get('freezer_action')
     self.fake_project_id = self.fake_action_0.get('project_id')
     self.fake_user_id = self.fake_action_0.get('user_id')
     self.fake_action_id = common.get_fake_action_id()
Пример #7
0
    def test_action_list_with_search_with_all_opt_two_matchs(self):
        count = 0
        actionids = []
        while (count < 20):
            doc = copy.deepcopy(self.fake_action_3)
            action_id = common.get_fake_action_id()
            doc['action_id'] = action_id
            if count in [0, 4, 8, 12, 16]:
                doc['max_retries'] = 10
                if count in [4, 12]:
                    doc['freezer_action']['mode'] = 'nova'
            result = self.dbapi.add_action(
                user_id=self.fake_action_3.get('user_id'),
                doc=doc,
                project_id=self.fake_project_id)

            self.assertIsNotNone(result)
            self.assertEqual(result, action_id)
            actionids.append(action_id)
            count += 1

        search_opt = {
            'match': [{
                '_all': '[{"max_retries": 10}, '
                '{"mode": "nova"}]'
            }]
        }
        result = self.dbapi.search_action(
            project_id=self.fake_project_id,
            user_id=self.fake_action_3.get('user_id'),
            limit=20,
            offset=0,
            search=search_opt)

        self.assertIsNotNone(result)
        self.assertEqual(len(result), 2)
        for index in range(len(result)):
            actionmap = result[index]
            self.assertEqual(10, actionmap['max_retries'])
            self.assertEqual('nova', actionmap['freezer_action']['mode'])