How to use scan_content method in tempest

Best Python code snippet using tempest_python

multiscan_enhancement_2i.py

Source:multiscan_enhancement_2i.py Github

copy

Full Screen

...30 scan_contents.append([{"Seek": [30]}])31 scan_contents.append([{"Seek": ["Kala", 30]}])32 scan_contents.append([{"Seek": ["Zack"]}])33 scan_contents.append([{"Seek": [None]}])34 multiscan_content = self._update_multiscan_content(1)35 for bucket in self.buckets:36 id_map = self.create_index_using_rest(bucket, query_definition)37 for scan_content in scan_contents:38 multiscan_content["scans"] = json.dumps(scan_content)39 multiscan_result = \40 self.rest.multiscan_for_gsi_index_with_rest(41 id_map["id"], json.dumps(multiscan_content))42 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(43 id_map["id"], json.dumps(multiscan_content))44 check = self._verify_items_indexed_for_two_field_index(45 bucket, id_map["id"],46 ["name"], scan_content, multiscan_result, multiscan_count_result)47 if not check:48 failed_scans.append(scan_content)49 msg = "Failed Scans: {0}".format(failed_scans)50 self.assertEqual(len(failed_scans), 0, msg)51 def test_simple_index_multiple_seek(self):52 failed_scans = []53 query_definition = QueryDefinition(54 index_name="name_index", index_fields=["name"],55 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %56 "name > \"Adara\" AND "57 "name < \"Winta\" ORDER BY _id"),58 groups=["simple"], index_where_clause=" name IS NOT NULL ")59 scan_contents = []60 scan_contents.append([{"Seek": None}, {"Seek": None}])61 scan_contents.append([{"Seek": None}, {"Seek": ["Kala"]}])62 scan_contents.append([{"Seek": None}, {"Seek": ["Kala", 30]}])63 scan_contents.append([{"Seek": None}, {"Seek": ["Winta"]}])64 scan_contents.append([{"Seek": None}, {"Seek": ["Zack"]}])65 scan_contents.append([{"Seek": None}, {"Seek": [None]}])66 scan_contents.append([{"Seek": ["Kala"]},{"Seek": None}])67 scan_contents.append([{"Seek": ["Kala"]},{"Seek": ["Kala"]}])68 scan_contents.append([{"Seek": ["Kala"]},{"Seek": ["Kala", 30]}])69 scan_contents.append([{"Seek": ["Kala"]},{"Seek": ["Winta"]}])70 scan_contents.append([{"Seek": ["Kala"]},{"Seek": ["Zack"]}])71 scan_contents.append([{"Seek": ["Kala"]},{"Seek": [None]}])72 scan_contents.append([{"Seek": ["Kala", 30]}, {"Seek": None}])73 scan_contents.append([{"Seek": ["Kala", 30]}, {"Seek": ["Kala"]}])74 scan_contents.append([{"Seek": ["Kala", 30]}, {"Seek": ["Kala", 30]}])75 scan_contents.append([{"Seek": ["Kala", 30]}, {"Seek": ["Winta"]}])76 scan_contents.append([{"Seek": ["Kala", 30]}, {"Seek": ["Zack"]}])77 scan_contents.append([{"Seek": ["Kala", 30]}, {"Seek": [None]}])78 scan_contents.append([{"Seek": ["Winta"]}, {"Seek": ["Kala"]}])79 scan_contents.append([{"Seek": ["Winta"]}, {"Seek": ["Kala", 30]}])80 scan_contents.append([{"Seek": ["Winta"]}, {"Seek": ["Winta"]}])81 scan_contents.append([{"Seek": ["Winta"]}, {"Seek": ["Zack"]}])82 scan_contents.append([{"Seek": ["Winta"]}, {"Seek": [None]}])83 scan_contents.append([{"Seek": [None]}, {"Seek": None}])84 scan_contents.append([{"Seek": [None]}, {"Seek": ["Kala"]}])85 scan_contents.append([{"Seek": [None]}, {"Seek": ["Kala", 30]}])86 scan_contents.append([{"Seek": [None]}, {"Seek": ["Winta"]}])87 scan_contents.append([{"Seek": [None]}, {"Seek": ["Zack"]}])88 scan_contents.append([{"Seek": [None]}, {"Seek": [None]}])89 scan_contents.append([{"Seek": ["Adara"]}, {"Seek": ["Winta"]}])90 multiscan_content = self._update_multiscan_content(1)91 for bucket in self.buckets:92 id_map = self.create_index_using_rest(bucket, query_definition)93 for scan_content in scan_contents:94 multiscan_content["scans"] = json.dumps(scan_content)95 multiscan_result = \96 self.rest.multiscan_for_gsi_index_with_rest(97 id_map["id"], json.dumps(multiscan_content))98 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(99 id_map["id"], json.dumps(multiscan_content))100 check = self._verify_items_indexed_for_two_field_index(101 bucket, id_map["id"],102 ["name"], scan_content, multiscan_result, multiscan_count_result)103 if not check:104 failed_scans.append(copy.deepcopy(scan_content))105 msg = "Failed Scans: {0}".format(failed_scans)106 self.assertEqual(len(failed_scans), 0, msg)107 def test_simple_index_filter(self):108 failed_scans = []109 query_definition = QueryDefinition(110 index_name="name_index", index_fields=["name"],111 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %112 "name > \"Adara\" AND "113 "name < \"Winta\" ORDER BY _id"),114 groups=["simple"], index_where_clause=" name IS NOT NULL ")115 scan_contents = []116 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Winta"}]}])117 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Winta"}]}])118 scan_contents.append([{"Filter":[{"Low":"Callia", "High":"Kala"}]}])119 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Callia"}]}])120 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Kala"}]}])121 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Kala"}]}])122 scan_contents.append([{"Filter":[{"Low":"Kala", "High": NULL_STRING}]}])123 scan_contents.append([{"Filter":[{"Low":"Winta", "High": NULL_STRING}]}])124 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Adara"}]}])125 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High": NULL_STRING}]}])126 scan_contents.append([{"Filter":[{"Low":None, "High":"Callia"}]}])127 scan_contents.append([{"Filter":[{"Low":"Kala", "High": None}]}])128 scan_contents.append([{"Filter":[{"Low":"Kala", "High": 30}]}])129 scan_contents.append([{"Filter":[{"Low": 30, "High": "Kala"}]}])130 #TODO: Missing Scenarios131 #scan_contents.append([{"Low": MISSING, "High":"Kala"}])132 #scan_contents.append([{"Low": "Kala", "High": MISSING}])133 #scan_contents.append([{"Low": MISSING, "High": MISSING}])134 multiscan_content = self._update_multiscan_content(1)135 for bucket in self.buckets:136 id_map = self.create_index_using_rest(bucket, query_definition)137 for scan_content in scan_contents:138 for name_inclusion in range(4):139 scan_content[0]["Filter"][0]["Inclusion"] = name_inclusion140 multiscan_content["scans"] = json.dumps(scan_content)141 multiscan_result = \142 self.rest.multiscan_for_gsi_index_with_rest(143 id_map["id"], json.dumps(multiscan_content))144 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(145 id_map["id"], json.dumps(multiscan_content))146 check = self._verify_items_indexed_for_two_field_index(147 bucket, id_map["id"],148 ["name"], scan_content, multiscan_result, multiscan_count_result)149 if not check:150 failed_scans.append(copy.deepcopy(scan_content))151 msg = "Failed Scans: {0}".format(failed_scans)152 self.assertEqual(len(failed_scans), 0, msg)153 def test_simple_index_multiple_filter_spans(self):154 failed_scans = []155 query_definition = QueryDefinition(156 index_name="name_index", index_fields=["name"],157 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %158 "name > \"Adara\" AND "159 "name < \"Winta\" ORDER BY _id"),160 groups=["simple"], index_where_clause=" name IS NOT NULL ")161 scan_contents = []162 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Callia"}]},163 {"Filter":[{"Low": "Kala", "High": "Winta"}]}])164 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Callia"}]},165 {"Filter":[{"Low": "Callia", "High": "Winta"}]}])166 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Callia"}]},167 {"Filter":[{"Low": "Callia", "High": "Callia"}]}])168 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Kala"}]},169 {"Filter":[{"Low": "Callia", "High": "Winta"}]}])170 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Winta"}]},171 {"Filter":[{"Low": "Callia", "High": "Kala"}]}])172 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Callia"}]},173 {"Filter":[{"Low": "Kala", "High": "Winta"}]}])174 scan_contents.append([{"Filter":[{"Low":"Adara", "High": NULL_STRING}]},175 {"Filter":[{"Low": "Callia", "High": "Winta"}]}])176 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Callia"}]},177 {"Filter":[{"Low": NULL_STRING, "High": "Winta"}]}])178 scan_contents.append([{"Filter":[{"Low":"Adara", "High":"Callia"}]},179 {"Filter":[{"Low": "Callia", "High": NULL_STRING}]}])180 multiscan_content = self._update_multiscan_content(1)181 for bucket in self.buckets:182 id_map = self.create_index_using_rest(bucket, query_definition)183 for scan_content in scan_contents:184 for name_inclusion_first in range(4):185 for name_inclusion_second in range(4):186 scan_content[0]["Filter"][0]["Inclusion"] = name_inclusion_first187 scan_content[1]["Filter"][0]["Inclusion"] = name_inclusion_second188 multiscan_content["scans"] = json.dumps(scan_content)189 multiscan_result = \190 self.rest.multiscan_for_gsi_index_with_rest(191 id_map["id"], json.dumps(multiscan_content))192 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(193 id_map["id"], json.dumps(multiscan_content))194 check = self._verify_items_indexed_for_two_field_index(195 bucket, id_map["id"],196 ["name"], scan_content, multiscan_result, multiscan_count_result)197 if not check:198 failed_scans.append(copy.deepcopy(scan_content))199 msg = "Failed Scans: {0}".format(failed_scans)200 self.assertEqual(len(failed_scans), 0, msg)201 def test_two_field_composite_index_seek(self):202 failed_scans = []203 query_definition = QueryDefinition(204 index_name="name_index", index_fields=["name", "age"],205 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %206 "name < \"Winta\""207 "AND age > 0 AND age "208 "< 100 ORDER BY _id"),209 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")210 scan_contents = []211 scan_contents.append([{"Seek": ["Kacila", 58]}])212 scan_contents.append([{"Seek": None}])213 scan_contents.append([{"Seek": [None, 30]}])214 scan_contents.append([{"Seek": [None, None]}])215 scan_contents.append([{"Seek": ["Kacila"]}])216 scan_contents.append([{"Seek": ["Kacila", None]}])217 scan_contents.append([{"Seek": [58, "Kacila"]}])218 scan_contents.append([{"Seek": [NULL_STRING, 58]}])219 scan_contents.append([{"Seek": ["Kacila", NULL_STRING]}])220 scan_contents.append([{"Seek": [NULL_STRING, NULL_STRING]}])221 scan_contents.append([{"Seek": ["Kacila", 58, "Bangalore"]}])222 #TODO Missing Elements223 #scan_contents.append({"Seek": ["Kacila", MISSING]})224 #scan_contents.append({"Seek": [MISSING, 58]})225 #scan_contents.append({"Seek": [MISSING, MISSING]})226 multiscan_content = self._update_multiscan_content()227 for bucket in self.buckets:228 id_map = self.create_index_using_rest(bucket, query_definition)229 for scan_content in scan_contents:230 multiscan_content["scans"] = json.dumps(scan_content)231 multiscan_result = self.rest.multiscan_for_gsi_index_with_rest(232 id_map["id"], json.dumps(multiscan_content))233 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(234 id_map["id"], json.dumps(multiscan_content))235 check = self._verify_items_indexed_for_two_field_index(236 bucket, id_map["id"],237 ["name", "age"], scan_content, multiscan_result, multiscan_count_result)238 if not check:239 failed_scans.append(copy.deepcopy(scan_content))240 msg = "Failed Scans: {0}".format(failed_scans)241 self.assertEqual(len(failed_scans), 0, msg)242 def test_two_field_composite_index_basic_filter(self):243 failed_scans = []244 query_definition = QueryDefinition(245 index_name="two_field_composite_name_age", index_fields=["name", "age"],246 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %247 "name > \"Callia\" AND "248 "name < \"Kala\""249 "AND age > 0 AND age "250 "< 100 ORDER BY _id"),251 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")252 scan_contents = []253 scan_contents.append([{"Seek": None, "Filter":[{"Low":"Callia", "High":"Kala"},254 {"Low":40, "High":70}]}])255 scan_contents.append([{"Filter":[{"Low":"Callia", "High":"Kala"},256 {"Low":40, "High":70}]}])257 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Kala"},258 {"Low":40, "High":70}]}])259 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Callia"},260 {"Low":40, "High":70}]}])261 scan_contents.append([{"Filter":[{"Low":"Callia", "High":"Kala"},262 {"Low":40, "High":40}]}])263 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Kala"},264 {"Low":40, "High":40}]}])265 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Callia"},266 {"Low":40, "High":40}]}])267 scan_contents.append([{"Filter":[{"Low":"Callia", "High":"Kala"},268 {"Low":70, "High":40}]}])269 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Kala"},270 {"Low":70, "High":40}]}])271 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Callia"},272 {"Low":70, "High":40}]}])273 multiscan_content = self._update_multiscan_content()274 for bucket in self.buckets:275 id_map = self.create_index_using_rest(bucket, query_definition)276 for scan_content in scan_contents:277 for name_inclusion in range(4):278 for age_inclusion in range(4):279 scan_content[0]["Filter"][0]["Inclusion"] = \280 name_inclusion281 scan_content[0]["Filter"][1]["Inclusion"] = \282 age_inclusion283 multiscan_content["scans"] = json.dumps(scan_content)284 multiscan_result = \285 self.rest.multiscan_for_gsi_index_with_rest(286 id_map["id"], json.dumps(multiscan_content))287 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(288 id_map["id"], json.dumps(multiscan_content))289 check = self._verify_items_indexed_for_two_field_index(290 bucket, id_map["id"],291 ["name", "age"], scan_content, multiscan_result, multiscan_count_result)292 if not check:293 failed_scans.append(copy.deepcopy(scan_content))294 msg = "Failed Scans: {0}".format(failed_scans)295 self.assertEqual(len(failed_scans), 0, msg)296 def test_two_field_composite_index_unbounded_filter(self):297 failed_scans = []298 query_definition = QueryDefinition(299 index_name="two_field_composite_name_age",300 index_fields=["name", "age"],301 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %302 "name > \"Adara\" AND "303 "name < \"Winta\""304 "AND age > 0 AND age "305 "< 100 ORDER BY _id"),306 groups=["two_field_index"],307 index_where_clause=" name IS NOT NULL ")308 scan_contents = []309 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Winta"},310 {"Low":30, "High":50}]}])311 scan_contents.append([{"Filter":[{"Low":"Kala", "High": NULL_STRING},312 {"Low":30, "High":50}]}])313 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High": NULL_STRING},314 {"Low":30, "High":50}]}])315 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Winta"},316 {"Low": NULL_STRING, "High":50}]}])317 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Winta"},318 {"Low":30, "High": NULL_STRING}]}])319 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Winta"},320 {"Low": NULL_STRING, "High": NULL_STRING}]}])321 scan_contents.append([{"Filter":[{"Low":"Kala", "High": NULL_STRING},322 {"Low":30, "High": NULL_STRING}]}])323 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Winta"},324 {"Low": NULL_STRING, "High":50}]}])325 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Winta"},326 {"Low":30, "High": NULL_STRING}]}])327 scan_contents.append([{"Filter":[{"Low":"Kala", "High": NULL_STRING},328 {"Low": NULL_STRING, "High":50}]}])329 scan_contents.append([{"Filter":[{"Low":"Kala", "High": NULL_STRING},330 {"Low":NULL_STRING, "High": NULL_STRING}]}])331 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Winta"},332 {"Low": NULL_STRING, "High": NULL_STRING}]}])333 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High": NULL_STRING},334 {"Low": 30, "High": NULL_STRING}]}])335 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High": NULL_STRING},336 {"Low": NULL_STRING, "High": 50}]}])337 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High": NULL_STRING},338 {"Low": NULL_STRING, "High": NULL_STRING}]}])339 for bucket in self.buckets:340 id_map = self.create_index_using_rest(bucket, query_definition)341 multiscan_content = self._update_multiscan_content()342 for scan_content in scan_contents:343 for name_inclusion in range(4):344 for age_inclusion in range(4):345 scan_content[0]["Filter"][0]["Inclusion"] = \346 name_inclusion347 scan_content[0]["Filter"][1]["Inclusion"] = \348 age_inclusion349 multiscan_content["scans"] = json.dumps(scan_content)350 multiscan_result = \351 self.rest.multiscan_for_gsi_index_with_rest(352 id_map["id"], json.dumps(multiscan_content))353 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(354 id_map["id"], json.dumps(multiscan_content))355 check = self._verify_items_indexed_for_two_field_index(356 bucket, id_map["id"],357 ["name", "age"], scan_content, multiscan_result, multiscan_count_result)358 if not check:359 failed_scans.append(copy.deepcopy(scan_content))360 msg = "Failed Scans: {0}".format(failed_scans)361 self.assertEqual(len(failed_scans), 0, msg)362 def test_two_field_composite_index_null_filter(self):363 failed_scans = []364 query_definition = QueryDefinition(365 index_name="two_field_composite_name_age",366 index_fields=["name", "age"],367 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %368 "name > \"Adara\" AND "369 "name < \"Winta\""370 "AND age > 0 AND age "371 "< 100 ORDER BY _id"),372 groups=["two_field_index"],373 index_where_clause=" name IS NOT NULL ")374 scan_contents = []375 scan_contents.append([{"Filter":[{"Low": None, "High":"Winta"},376 {"Low":30, "High":50}]}])377 scan_contents.append([{"Filter":[{"Low":"Kala", "High": None},378 {"Low":30, "High":50}]}])379 scan_contents.append([{"Filter":[{"Low": None, "High": None},380 {"Low":30, "High":50}]}])381 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Winta"},382 {"Low": None, "High":50}]}])383 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Winta"},384 {"Low":30, "High": None}]}])385 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Winta"},386 {"Low": None, "High": None}]}])387 scan_contents.append([{"Filter":[{"Low":"Kala", "High": None},388 {"Low":30, "High": None}]}])389 scan_contents.append([{"Filter":[{"Low": None, "High":"Winta"},390 {"Low": None, "High":50}]}])391 scan_contents.append([{"Filter":[{"Low": None, "High":"Winta"},392 {"Low":30, "High": None}]}])393 scan_contents.append([{"Filter":[{"Low":"Kala", "High": None},394 {"Low": None, "High":50}]}])395 scan_contents.append([{"Filter":[{"Low":"Kala", "High": None},396 {"Low":None, "High": None}]}])397 scan_contents.append([{"Filter":[{"Low": None, "High":"Winta"},398 {"Low": None, "High": None}]}])399 scan_contents.append([{"Filter":[{"Low": None, "High": None},400 {"Low": 30, "High": None}]}])401 scan_contents.append([{"Filter":[{"Low": None, "High": None},402 {"Low": None, "High": 50}]}])403 scan_contents.append([{"Filter":[{"Low": None, "High": None},404 {"Low": None, "High": None}]}])405 for bucket in self.buckets:406 id_map = self.create_index_using_rest(bucket, query_definition)407 multiscan_content = self._update_multiscan_content()408 for scan_content in scan_contents:409 for name_inclusion in range(4):410 for age_inclusion in range(4):411 scan_content[0]["Filter"][0]["Inclusion"] = \412 name_inclusion413 scan_content[0]["Filter"][1]["Inclusion"] = \414 age_inclusion415 multiscan_content["scans"] = json.dumps(scan_content)416 multiscan_result = \417 self.rest.multiscan_for_gsi_index_with_rest(418 id_map["id"], json.dumps(multiscan_content))419 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(420 id_map["id"], json.dumps(multiscan_content))421 check = self._verify_items_indexed_for_two_field_index(422 bucket, id_map["id"],423 ["name", "age"], scan_content, multiscan_result, multiscan_count_result)424 if not check:425 failed_scans.append(copy.deepcopy(scan_content))426 msg = "Failed Scans: {0}".format(failed_scans)427 self.assertEqual(len(failed_scans), 0, msg)428 def test_two_field_composite_index_filter_empty_results(self):429 failed_scans = []430 query_definition = QueryDefinition(431 index_name="two_field_composite_name_age", index_fields=["name", "age"],432 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %433 "name > \"Callia\" AND "434 "name < \"Kala\""435 "AND age > 0 AND age "436 "< 100 ORDER BY _id"),437 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")438 scan_contents = []439 scan_contents.append([{"Seek": None, "Filter":[{"Low":"Callia", "High":"Kala"},440 {"Low":40, "High":70}]}])441 scan_contents.append([{"Filter":[{"Low":"Callia", "High":"Kala"},442 {"Low":40, "High":70}]}])443 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Kala"},444 {"Low":40, "High":70}]}])445 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Callia"},446 {"Low":40, "High":70}]}])447 scan_contents.append([{"Filter":[{"Low":"Callia", "High":"Kala"},448 {"Low":40, "High":40}]}])449 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Kala"},450 {"Low":40, "High":40}]}])451 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Callia"},452 {"Low":40, "High":40}]}])453 scan_contents.append([{"Filter":[{"Low":"Callia", "High":"Kala"},454 {"Low":70, "High":40}]}])455 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Kala"},456 {"Low":70, "High":40}]}])457 scan_contents.append([{"Filter":[{"Low":"Kala", "High":"Callia"},458 {"Low":70, "High":40}]}])459 multiscan_content = self._update_multiscan_content()460 for bucket in self.buckets:461 id_map = self.create_index_using_rest(bucket, query_definition)462 for scan_content in scan_contents:463 for name_inclusion in range(4):464 for age_inclusion in range(4):465 scan_content[0]["Filter"][0]["Inclusion"] = \466 name_inclusion467 scan_content[0]["Filter"][1]["Inclusion"] = \468 age_inclusion469 multiscan_content["scans"] = json.dumps(scan_content)470 multiscan_result = \471 self.rest.multiscan_for_gsi_index_with_rest(472 id_map["id"], json.dumps(multiscan_content))473 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(474 id_map["id"], json.dumps(multiscan_content))475 check = self._verify_items_indexed_for_two_field_index(476 bucket, id_map["id"],477 ["name", "age"], scan_content, multiscan_result, multiscan_count_result)478 if not check:479 failed_scans.append(copy.deepcopy(scan_content))480 msg = "Failed Scans: {0}".format(failed_scans)481 self.assertEqual(len(failed_scans), 0, msg)482 def test_name_age_composite_index_seek_filter(self):483 failed_scans = []484 query_definition = QueryDefinition(485 index_name="two_field_composite_name_age", index_fields=["name", "age"],486 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %487 "name > \"Adara\" AND "488 "name < \"Winta\""489 "AND age > 0 AND age "490 "< 100 ORDER BY _id"),491 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")492 scan_content = [{"Seek": ["Kimberly", 58],493 "Filter":[{"Low":"A", "High":"Z"},494 {"Low":50, "High":50}]}]495 multiscan_content = {}496 projection = {"EntryKeys":[1], "PrimaryKey":False}497 multiscan_content["projection"] = json.dumps(projection)498 multiscan_content["distinct"] = False499 multiscan_content["reverse"] = False500 multiscan_content["offset"] = 0501 multiscan_content["limit"] = 10000502 multiscan_content["stale"] = "false"503 for bucket in self.buckets:504 id_map = self.create_index_using_rest(bucket, query_definition)505 for name_inclusion in range(4):506 for age_inclusion in range(4):507 scan_content[0]["Filter"][0]["Inclusion"] = \508 name_inclusion509 scan_content[0]["Filter"][1]["Inclusion"] = \510 age_inclusion511 multiscan_content["scans"] = json.dumps(scan_content)512 multiscan_result = \513 self.rest.multiscan_for_gsi_index_with_rest(514 id_map["id"], json.dumps(multiscan_content))515 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(516 id_map["id"], json.dumps(multiscan_content))517 check = self._verify_items_indexed_for_two_field_index(518 bucket, id_map["id"],519 ["name"], scan_content, multiscan_result, multiscan_count_result)520 if not check:521 failed_scans.append(copy.deepcopy(scan_content))522 msg = "Failed Scans: {0}".format(failed_scans)523 self.assertEqual(len(failed_scans), 0, msg)524 def test_name_age_composite_index_empty_second_filter(self):525 failed_scans = []526 query_definition = QueryDefinition(527 index_name="two_field_composite_name_age",528 index_fields=["name", "age"],529 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %530 "name > \"Adara\" AND "531 "name < \"Winta\""532 "AND age > 0 AND age "533 "< 100 ORDER BY _id"),534 groups=["two_field_index"],535 index_where_clause=" name IS NOT NULL ")536 scan_content = [{"Filter":[{"Low": "M", "High": "Z"}, {}]}]537 for bucket in self.buckets:538 id_map = self.create_index_using_rest(bucket, query_definition)539 multiscan_content = self._update_multiscan_content()540 for name_inclusion in range(4):541 scan_content[0]["Filter"][0]["Inclusion"] = \542 name_inclusion543 multiscan_content["scans"] = json.dumps(scan_content)544 log.info(multiscan_content)545 multiscan_result = \546 self.rest.multiscan_for_gsi_index_with_rest(547 id_map["id"], json.dumps(multiscan_content))548 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(549 id_map["id"], json.dumps(multiscan_content))550 check = self._verify_items_indexed_for_two_field_index(551 bucket, id_map["id"], ["name"], scan_content, multiscan_result, multiscan_count_result)552 if not check:553 failed_scans.append(copy.deepcopy(scan_content))554 msg = "Failed Scans: {0}".format(failed_scans)555 self.assertEqual(len(failed_scans), 0, msg)556 def test_name_age_distinct_array_composite_index(self):557 failed_scans = []558 query_definition = QueryDefinition(559 index_name="two_field_composite_travel_history_age",560 index_fields=["DISTINCT ARRAY t FOR t in TO_ARRAY(`travel_history`) END", "age"],561 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")562 scan_contents = []563 #Basic Scan564 scan_contents.append([{"Seek": None,565 "Filter":[{"Low":"India", "High":"US"},566 {"Low":30, "High":60}]}])567 for bucket in self.buckets:568 id_map = self.create_index_using_rest(bucket, query_definition)569 for scan_content in scan_contents:570 multiscan_content = self._update_multiscan_content()571 for name_inclusion in range(4):572 for age_inclusion in range(4):573 scan_content[0]["Filter"][0]["Inclusion"] = \574 name_inclusion575 scan_content[0]["Filter"][1]["Inclusion"] = \576 age_inclusion577 multiscan_content["scans"] = json.dumps(scan_content)578 multiscan_result = \579 self.rest.multiscan_for_gsi_index_with_rest(580 id_map["id"], json.dumps(multiscan_content))581 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(582 id_map["id"], json.dumps(multiscan_content))583 check = self._verify_items_indexed_for_two_field_index(584 bucket, id_map["id"],585 ["name"], scan_content, multiscan_result, multiscan_count_result)586 if not check:587 failed_scans.append(copy.deepcopy(scan_content))588 msg = "Failed Scans: {0}".format(failed_scans)589 self.assertEqual(len(failed_scans), 0, msg)590 def test_name_age_all_array_composite_index(self):591 failed_scans = []592 query_definition = QueryDefinition(593 index_name="two_field_composite_travel_history_age",594 index_fields=["ALL ARRAY t FOR t in TO_ARRAY(`travel_history`) END", "age"],595 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")596 #Basic Scan597 scan_content = [{"Seek": None,598 "Filter":[{"Low":"India", "High":"US"},599 {"Low":30, "High":60}]}]600 for bucket in self.buckets:601 id_map = self.create_index_using_rest(bucket, query_definition)602 multiscan_content = self._update_multiscan_content()603 for name_inclusion in range(4):604 for age_inclusion in range(4):605 scan_content[0]["Filter"][0]["Inclusion"] = \606 name_inclusion607 scan_content[0]["Filter"][1]["Inclusion"] = \608 age_inclusion609 multiscan_content["scans"] = json.dumps(scan_content)610 multiscan_result = \611 self.rest.multiscan_for_gsi_index_with_rest(612 id_map["id"], json.dumps(multiscan_content))613 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(614 id_map["id"], json.dumps(multiscan_content))615 check = self._verify_items_indexed_for_two_field_index(616 bucket, id_map["id"],617 ["name"], scan_content, multiscan_result, multiscan_count_result)618 if not check:619 failed_scans.append(copy.deepcopy(scan_content))620 msg = "Failed Scans: {0}".format(failed_scans)621 self.assertEqual(len(failed_scans), 0, msg)622 def test_name_age_premium_customer_composite_index(self):623 failed_scans = []624 query_definition = QueryDefinition(625 index_name="three_field_composite_name_age",626 index_fields=["name", "age", "premium_customer"],627 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")628 #Basic Scan629 scan_content = [{"Seek": None,630 "Filter":[{"Low":"India", "High":"US"},631 {"Low":30, "High":60},632 {"Low": False, "High": True}]}]633 for bucket in self.buckets:634 id_map = self.create_index_using_rest(bucket, query_definition)635 multiscan_content = self._update_multiscan_content(index_fields=3)636 for name_inclusion in range(4):637 for age_inclusion in range(4):638 for cust_inclustion in range(4):639 scan_content[0]["Filter"][0]["Inclusion"] = \640 name_inclusion641 scan_content[0]["Filter"][1]["Inclusion"] = \642 age_inclusion643 scan_content[0]["Filter"][2]["Inclusion"] = \644 cust_inclustion645 multiscan_content["scans"] = json.dumps(scan_content)646 multiscan_result = \647 self.rest.multiscan_for_gsi_index_with_rest(648 id_map["id"], json.dumps(multiscan_content))649 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(650 id_map["id"], json.dumps(multiscan_content))651 check = self._verify_items_indexed_for_two_field_index(652 bucket, id_map["id"],653 ["name"], scan_content, multiscan_result, multiscan_count_result)654 if not check:655 failed_scans.append(copy.deepcopy(scan_content))656 msg = "Failed Scans: {0}".format(failed_scans)657 self.assertEqual(len(failed_scans), 0, msg)658 def test_two_field_composite_index_multiple_nonoverlapping_scans(self):659 failed_scans = []660 query_definition = QueryDefinition(661 index_name="two_field_composite_name_age", index_fields=["name", "age"],662 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %663 "name > \"Adara\" AND "664 "name < \"Winta\""665 "AND age > 0 AND age "666 "< 100 ORDER BY _id"),667 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")668 scan_contents = []669 scan_contents.append([{"Seek": None,670 "Filter":[{"Low": "Adara", "High":"Jerica"},671 {"Low":10, "High":100}]},672 {"Seek": None,673 "Filter":[{"Low":"Kacila", "High":"Winta"},674 {"Low":10, "High":100}]}])675 #non-overlapping second filters676 scan_contents.append([{"Seek": None,677 "Filter":[{"Low": "Adara", "High":"Winta"},678 {"Low":10, "High":50}]},679 {"Seek": None,680 "Filter":[{"Low":"Adara", "High":"Winta"},681 {"Low":51, "High":100}]}])682 #non-overlapping both Scans683 scan_contents.append([{"Seek": None,684 "Filter":[{"Low": "Adara", "High":"Jerica"},685 {"Low":10, "High":50}]},686 {"Seek": None,687 "Filter":[{"Low":"Kacila", "High":"Winta"},688 {"Low":51, "High":100}]}])689 # Boundary first Filters690 scan_contents.append([{"Filter":[{"Low": "Adara", "High":"Jerica"},691 {"Low":10, "High":100}]},692 {"Filter":[{"Low":"Jerica", "High":"Winta"},693 {"Low":10, "High":100}]}])694 # Boundary Second Filters695 scan_contents.append([{"Filter":[{"Low": "Adara", "High":"Winta"},696 {"Low":10, "High":50}]},697 {"Filter":[{"Low":"Adara", "High":"Winta"},698 {"Low":50, "High":100}]}])699 # Boundary Both Filters700 scan_contents.append([{"Filter":[{"Low": "Adara", "High":"Winta"},701 {"Low":10, "High":50}]},702 {"Filter":[{"Low":"Adara", "High":"Winta"},703 {"Low":50, "High":100}]}])704 # Unbounded First filter of first scan705 scan_contents.append([{"Filter":[{"Low": NULL_STRING, "High":"Jerica"},706 {"Low":10, "High":40}]},707 {"Filter":[{"Low":"Kala", "High":"Winta"},708 {"Low":50, "High":100}]}])709 # Unbounded Second filter of first scan710 scan_contents.append([{"Filter":[{"Low": "Adara", "High": NULL_STRING},711 {"Low":10, "High":40}]},712 {"Filter":[{"Low":"Kala", "High":"Winta"},713 {"Low":50, "High":100}]}])714 # Unbounded First filter of Second scan715 scan_contents.append([{"Filter":[{"Low": "Adara", "High": "Jerica"},716 {"Low":10, "High":40}]},717 {"Filter":[{"Low": NULL_STRING, "High":"Winta"},718 {"Low":50, "High":100}]}])719 # Unbounded Second filter of Second scan720 scan_contents.append([{"Filter":[{"Low": "Adara", "High": "Jerica"},721 {"Low":10, "High":40}]},722 {"Filter":[{"Low":"Kala", "High": NULL_STRING},723 {"Low":50, "High":100}]}])724 #non-overlapping both Scans Reversed725 scan_contents.append([{"Filter":[{"Low":"Kacila", "High":"Winta"},726 {"Low":51, "High":100}]},727 {"Filter":[{"Low": "Adara", "High":"Jerica"},728 {"Low":10, "High":50}]}])729 multiscan_content = self._update_multiscan_content()730 for bucket in self.buckets:731 id_map = self.create_index_using_rest(bucket, query_definition)732 for scan_content in scan_contents:733 for first_name_inclusion in range(4):734 for first_age_inclusion in range(4):735 for second_name_inclusion in range(4):736 for second_age_inclusion in range(4):737 if "Filter" in scan_content[0].keys():738 scan_content[0]["Filter"][0]["Inclusion"] = \739 first_name_inclusion740 scan_content[0]["Filter"][1]["Inclusion"] = \741 first_age_inclusion742 if "Filter" in scan_content[1].keys():743 scan_content[1]["Filter"][0]["Inclusion"] = \744 second_name_inclusion745 scan_content[1]["Filter"][1]["Inclusion"] = \746 second_age_inclusion747 multiscan_content["scans"] = json.dumps(scan_content)748 multiscan_result = \749 self.rest.multiscan_for_gsi_index_with_rest(750 id_map["id"], json.dumps(multiscan_content))751 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(752 id_map["id"], json.dumps(multiscan_content))753 check = self._verify_items_indexed_for_two_field_index(754 bucket, id_map["id"],755 ["name","age"], scan_content, multiscan_result, multiscan_count_result)756 if not check:757 failed_scans.append(copy.deepcopy(scan_content))758 msg = "Failed Scans: {0}".format(failed_scans)759 self.assertEqual(len(failed_scans), 0, msg)760 def test_two_field_composite_index_multiple_overlapping_scans(self):761 failed_scans = []762 query_definition = QueryDefinition(763 index_name="two_field_composite_name_age", index_fields=["name", "age"],764 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %765 "name > \"Adara\" AND "766 "name < \"Winta\""767 "AND age > 0 AND age "768 "< 100 ORDER BY _id"),769 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")770 scan_contents = []771 #Overlapping first Scans772 scan_contents.append([{"Seek": None,773 "Filter":[{"Low": "Adara", "High":"Jerica"},774 {"Low":10, "High":50}]},775 {"Seek": None,776 "Filter":[{"Low":"Jerica", "High":"Winta"},777 {"Low":50, "High":100}]}])778 #Second is subset of first - first filter779 scan_contents.append([{"Seek": None,780 "Filter":[{"Low": "Adara", "High":"Winta"},781 {"Low":10, "High":100}]},782 {"Seek": None,783 "Filter":[{"Low":"Jerica", "High":"Kacila"},784 {"Low":10, "High":100}]}])785 #overlapping second Scans786 scan_contents.append([{"Seek": None,787 "Filter":[{"Low": "Adara", "High":"Winta"},788 {"Low":10, "High":50}]},789 {"Seek": None,790 "Filter":[{"Low":"Adara", "High":"Winta"},791 {"Low":40, "High":100}]}])792 #Second is subset of first - second filter793 scan_contents.append([{"Seek": None,794 "Filter":[{"Low": "Adara", "High":"Winta"},795 {"Low":10, "High":100}]},796 {"Seek": None,797 "Filter":[{"Low":"Adara", "High":"Winta"},798 {"Low":40, "High":60}]}])799 #Overlapping both Scans800 scan_contents.append([{"Seek": None,801 "Filter":[{"Low": "Adara", "High":"Kacila"},802 {"Low":10, "High":50}]},803 {"Seek": None,804 "Filter":[{"Low":"Jerica", "High":"Winta"},805 {"Low":40, "High":100}]}])806 #Second is subset of first - both filter807 scan_contents.append([{"Seek": None,808 "Filter":[{"Low": "Adara", "High":"Winta"},809 {"Low":10, "High":70}]},810 {"Seek": None,811 "Filter":[{"Low":"Jerica", "High":"Kacila"},812 {"Low":40, "High":60}]}])813 #Seek First Scan814 scan_contents.append([{"Seek": ["Kacila", 40]},815 {"Seek": None,816 "Filter":[{"Low":"Jerica", "High":"Winta"},817 {"Low":40, "High":100}]}])818 #Seek Second Scan819 scan_contents.append([{"Seek": None,820 "Filter":[{"Low": "Adara", "High":"Kacila"},821 {"Low":10, "High":50}]},822 {"Seek": ["Jerica", 40]}])823 #Seek First And Second Scan824 scan_contents.append([{"Seek": ["Kacila", 40]},825 {"Seek": ["Jerica", 40]}])826 multiscan_content = self._update_multiscan_content()827 for bucket in self.buckets:828 id_map = self.create_index_using_rest(bucket, query_definition)829 for scan_content in scan_contents:830 for first_name_inclusion in range(4):831 for first_age_inclusion in range(4):832 for second_name_inclusion in range(4):833 for second_age_inclusion in range(4):834 if "Filter" in scan_content[0].keys():835 scan_content[0]["Filter"][0]["Inclusion"] = \836 first_name_inclusion837 scan_content[0]["Filter"][1]["Inclusion"] = \838 first_age_inclusion839 if "Filter" in scan_content[1].keys():840 scan_content[1]["Filter"][0]["Inclusion"] = \841 second_name_inclusion842 scan_content[1]["Filter"][1]["Inclusion"] = \843 second_age_inclusion844 multiscan_content["scans"] = json.dumps(scan_content)845 multiscan_result = \846 self.rest.multiscan_for_gsi_index_with_rest(847 id_map["id"], json.dumps(multiscan_content))848 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(849 id_map["id"], json.dumps(multiscan_content))850 check = self._verify_items_indexed_for_two_field_index(851 bucket, id_map["id"],852 ["name", "age"], scan_content, multiscan_result, multiscan_count_result)853 if not check:854 failed_scans.append(copy.deepcopy(scan_content))855 msg = "Failed Scans: {0}".format(failed_scans)856 self.assertEqual(len(failed_scans), 0, msg)857 def test_two_field_composite_index_three_scans(self):858 failed_scans = []859 query_definition = QueryDefinition(860 index_name="two_field_composite_name_age", index_fields=["name", "age"],861 query_template=RANGE_SCAN_TEMPLATE.format(emit_fields, " %s " %862 "name > \"Adara\" AND "863 "name < \"Winta\""864 "AND age > 0 AND age "865 "< 100 ORDER BY _id"),866 groups=["two_field_index"], index_where_clause=" name IS NOT NULL ")867 scan_contents = []868 # Three Non-Overlapping first Filters869 scan_contents.append([{"Filter": [{"Low": "Adara", "High":"Callia"},870 {"Low":10, "High":100}]},871 {"Filter": [{"Low":"Fantine", "High":"Kacila"},872 {"Low":10, "High":100}]},873 {"Filter": [{"Low": "Perdita", "High": "Winta"},874 {"Low":10, "High":100}]}])875 # Three Non-Overlapping second Filters876 scan_contents.append([{"Filter": [{"Low": "Adara", "High":"Winta"},877 {"Low":10, "High":30}]},878 {"Filter": [{"Low": "Adara", "High":"Winta"},879 {"Low":40, "High":50}]},880 {"Filter": [{"Low": "Adara", "High":"Winta"},881 {"Low":60, "High":80}]}])882 # Three Non-Overlapping second Filters883 scan_contents.append([{"Filter": [{"Low": "Adara", "High":"Callia"},884 {"Low":10, "High":30}]},885 {"Filter": [{"Low": "Fantine", "High":"Kacila"},886 {"Low":40, "High":50}]},887 {"Filter": [{"Low": "Perdita", "High":"Winta"},888 {"Low":60, "High":80}]}])889 multiscan_content = self._update_multiscan_content()890 for bucket in self.buckets:891 id_map = self.create_index_using_rest(bucket, query_definition)892 for scan_content in scan_contents:893 for first_name_inclusion in range(4):894 for first_age_inclusion in range(4):895 for second_name_inclusion in range(4):896 for second_age_inclusion in range(4):897 for third_name_inclusion in range(4):898 for third_age_inclusion in range(4):899 if "Filter" in scan_content[0].keys():900 scan_content[0]["Filter"][0]["Inclusion"] = \901 first_name_inclusion902 scan_content[0]["Filter"][1]["Inclusion"] = \903 first_age_inclusion904 if "Filter" in scan_content[1].keys():905 scan_content[1]["Filter"][0]["Inclusion"] = \906 second_name_inclusion907 scan_content[1]["Filter"][1]["Inclusion"] = \908 second_age_inclusion909 if "Filter" in scan_content[2].keys():910 scan_content[2]["Filter"][0]["Inclusion"] = \911 third_name_inclusion912 scan_content[2]["Filter"][1]["Inclusion"] = \913 third_age_inclusion914 multiscan_content["scans"] = json.dumps(scan_content)915 multiscan_result = \916 self.rest.multiscan_for_gsi_index_with_rest(917 id_map["id"], json.dumps(multiscan_content))918 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(919 id_map["id"], json.dumps(multiscan_content))920 check = self._verify_items_indexed_for_two_field_index(921 bucket, id_map["id"],922 ["name", "age"], scan_content, multiscan_result, multiscan_count_result)923 if not check:924 failed_scans.append(copy.deepcopy(scan_content))925 msg = "Failed Scans: {0}".format(failed_scans)926 self.assertEqual(len(failed_scans), 0, msg)927 def _update_multiscan_content(self, index_fields=2):928 multiscan_content = {}929 projection = {"EntryKeys": range(index_fields), "PrimaryKey": True}930 multiscan_content["projection"] = json.dumps(projection)931 multiscan_content["distinct"] = False932 multiscan_content["reverse"] = False933 multiscan_content["offset"] = 0934 multiscan_content["limit"] = 10000935 multiscan_content["stale"] = "false"936 return multiscan_content937 def _verify_items_indexed_for_two_field_index(self, bucket, index_id, index_fields,938 scan_content, multiscan_result, multiscan_count_result=None):939 err_message = "There are more ranges than number"940 if isinstance(multiscan_result, dict):941 if err_message in multiscan_result.values():...

Full Screen

Full Screen

asc_desc_collations.py

Source:asc_desc_collations.py Github

copy

Full Screen

...41 for bucket in self.buckets:42 for query_definition, scan_content in dict.iteritems():43 for desc_value in desc_values:44 id_map = self.create_index_using_rest(bucket, query_definition, desc=desc_value)45 multiscan_content = self._update_multiscan_content(index_fields=1)46 for inclusion in range(4):47 scan_content[0]["Filter"][0]["Inclusion"] = \48 inclusion49 multiscan_content["scans"] = json.dumps(scan_content)50 multiscan_result = \51 self.rest.multiscan_for_gsi_index_with_rest(52 id_map["id"], json.dumps(multiscan_content))53 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(54 id_map["id"], json.dumps(multiscan_content))55 print multiscan_result56 check = self._verify_items_indexed_for_two_field_index(57 bucket, id_map["id"],58 ["name"], scan_content, multiscan_result, desc_value, multiscan_count_result, )59 if not check:60 failed_scans.append(copy.deepcopy(scan_content))61 self.drop_index(bucket, query_definition)62 msg = "Failed Scans: {0}".format(failed_scans)63 self.assertEqual(len(failed_scans), 0, msg)64 def test_three_array_indexes_on_different_fields_with_asc_desc_combinations(self):65 failed_scans = []66 query_definition1 = QueryDefinition(67 index_name="index_array_field1",68 index_fields=["ALL ARRAY t FOR t in TO_ARRAY(`travel_history`) END"],69 groups=["array"], index_where_clause=" name IS NOT NULL ")70 scan_content1 = [{"Seek": None,71 "Filter": [{"Low": "India", "High": "US"}]}]72 query_definition2 = QueryDefinition(73 index_name="index_field2",74 index_fields=["age"],75 groups=["simple"], index_where_clause=" age IS NOT NULL ")76 scan_content2 = [{"Seek": None,77 "Filter": [{"Low": 20, "High": 60}]}]78 dict = {query_definition1: scan_content1, query_definition2: scan_content2}79 desc_values = [[True], [False]]80 for bucket in self.buckets:81 for query_definition, scan_content in dict.iteritems():82 for desc_value in desc_values:83 id_map = self.create_index_using_rest(bucket, query_definition, desc=desc_value)84 multiscan_content = self._update_multiscan_content(index_fields=1)85 for inclusion in range(4):86 scan_content[0]["Filter"][0]["Inclusion"] = \87 inclusion88 multiscan_content["scans"] = json.dumps(scan_content)89 multiscan_result = \90 self.rest.multiscan_for_gsi_index_with_rest(91 id_map["id"], json.dumps(multiscan_content))92 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(93 id_map["id"], json.dumps(multiscan_content))94 print multiscan_result95 check = self._verify_items_indexed_for_two_field_index(96 bucket, id_map["id"],97 ["name"], scan_content, multiscan_result, desc_value, multiscan_count_result, )98 if not check:99 failed_scans.append(copy.deepcopy(scan_content))100 self.drop_index(bucket, query_definition)101 msg = "Failed Scans: {0}".format(failed_scans)102 self.assertEqual(len(failed_scans), 0, msg)103 def test_composite_with_asc_desc_combinations(self):104 failed_scans = []105 query_definition = QueryDefinition(106 index_name="three_field_composite_name_age",107 index_fields=["name", "age", "premium_customer"],108 groups=["three_field_index"], index_where_clause=" name IS NOT NULL ")109 # Basic Scan110 scan_content = [{"Seek": None,111 "Filter": [{"Low": "Adara", "High": "Winta"},112 {"Low": 20, "High": 60},113 {"Low": False, "High": True}]}]114 desc_values = [[False, False, False], [False, False, True], [False, True, False], [True, False, False],115 [True, True, False], [True, False, True], [False, True, True], [True, True, True]]116 for bucket in self.buckets:117 for desc_value in desc_values:118 id_map = self.create_index_using_rest(bucket, query_definition, desc=desc_value)119 multiscan_content = self._update_multiscan_content(index_fields=3)120 for name_inclusion in range(4):121 for age_inclusion in range(4):122 for cust_inclustion in range(4):123 scan_content[0]["Filter"][0]["Inclusion"] = \124 name_inclusion125 scan_content[0]["Filter"][1]["Inclusion"] = \126 age_inclusion127 scan_content[0]["Filter"][2]["Inclusion"] = \128 cust_inclustion129 multiscan_content["scans"] = json.dumps(scan_content)130 multiscan_result = \131 self.rest.multiscan_for_gsi_index_with_rest(132 id_map["id"], json.dumps(multiscan_content))133 multiscan_count_result = self.rest.multiscan_count_for_gsi_index_with_rest(134 id_map["id"], json.dumps(multiscan_content))135 log.info("Collation order : {0}".format(desc_value))136 check = self._verify_items_indexed_for_two_field_index(137 bucket, id_map["id"],138 ["name"], scan_content, multiscan_result, desc_value, multiscan_count_result, )139 if not check:140 failed_scans.append(copy.deepcopy(scan_content))141 self.drop_index(bucket, query_definition)142 msg = "Failed Scans: {0}".format(failed_scans)143 self.assertEqual(len(failed_scans), 0, msg)144 def _verify_items_indexed_for_two_field_index(self, bucket, index_id, index_fields,145 scan_content, multiscan_result, desc, multiscan_count_result=None):146 err_message = "There are more ranges than number"147 if isinstance(multiscan_result, dict):148 if err_message in multiscan_result.values():149 multiscan_result = ''150 expected_results = []151 body = {"stale": "False"}152 for content in scan_content:153 doc_list = self.rest.full_table_scan_gsi_index_with_rest(index_id, body)154 seek = content.get("Seek", None)155 filters = content.get("Filter", None)156 if seek:157 temp_doc_list = copy.deepcopy(doc_list)158 for doc in temp_doc_list:159 if doc["key"] != seek:160 doc_list.remove(doc)161 elif filters:162 for i in range(len(filters)):163 temp_doc_list = copy.deepcopy(doc_list)164 f_low = filters[i].get("Low", None)165 f_high = filters[i].get("High", None)166 f_inclusion = filters[i].get("Inclusion", 3)167 for doc in temp_doc_list:168 doc_field = doc["key"][i]169 if f_low and f_low != NULL_STRING:170 if doc_field < f_low:171 doc_list.remove(doc)172 continue173 if f_high and f_high != NULL_STRING:174 if doc_field > f_high:175 doc_list.remove(doc)176 continue177 if f_inclusion == 0:178 if doc_field == f_low or doc_field == f_high:179 doc_list.remove(doc)180 continue181 if f_inclusion == 1:182 if doc_field == f_high:183 doc_list.remove(doc)184 continue185 if f_inclusion == 2:186 if doc_field == f_low:187 doc_list.remove(doc)188 continue189 if expected_results:190 for doc in doc_list:191 if not doc in expected_results:192 expected_results.append(doc)193 else:194 expected_results = doc_list195 if len(expected_results) != len(multiscan_result):196 print multiscan_count_result197 print len(expected_results)198 print expected_results199 print len(multiscan_result)200 log.info("No. of items mismatch :- expected = {0} and actual = {1}".format(201 len(expected_results), len(multiscan_result)))202 return False203 if multiscan_count_result is not None:204 if len(expected_results) != multiscan_count_result:205 log.info("No. of items mismatch from multiscan count:- expected = {0} and actual = {1}".format(206 len(expected_results), multiscan_count_result))207 return False208 if expected_results != multiscan_result:209 if len(expected_results) != 0 and multiscan_result:210 log.info("The number of rows match but the results mismatch, please check")211 return False212 temp_doc_list = []213 for tr in multiscan_result:214 temp_doc_val = str(tr["key"])215 " ".join(temp_doc_val)216 temp_doc_list.append(temp_doc_val)217 log.info("Collated list : {0}".format(temp_doc_list))218 # In case of composite index, the results are ordered by the leading key219 # and if the first key is same, then subsequent keys are considered for ordering.220 sorted_arr = sorted(temp_doc_list, reverse=desc[0])221 # check for idempotency222 if sorted_arr != temp_doc_list:223 self.fail(224 "results of mutiscan is not sorted based on the collation order specified: {0} \n {1}".format(225 sorted_arr, temp_doc_list))226 return True227 def _update_multiscan_content(self, index_fields=2):228 multiscan_content = {}229 projection = {"EntryKeys": range(index_fields), "PrimaryKey": True}230 multiscan_content["projection"] = json.dumps(projection)231 multiscan_content["distinct"] = False232 multiscan_content["reverse"] = False233 multiscan_content["offset"] = 0234 multiscan_content["limit"] = 10000235 multiscan_content["stale"] = "false"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful