Skip to content

Commit

Permalink
Fix and move tc for advisor, stats and cbqshell
Browse files Browse the repository at this point in the history
Change-Id: Iab6266375cfa0690c3c144f14c8f473a5a22dd99
Reviewed-on: https://review.couchbase.org/c/testrunner/+/170286
Tested-by: Couchbase QE
Reviewed-by: Ajay Bhullar <ajay.bhullar@couchbase.com>
  • Loading branch information
pierrecouch committed Feb 9, 2022
1 parent 580eb38 commit 9ba5563
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 28 deletions.
6 changes: 3 additions & 3 deletions conf/tuq/py-tuq-advisor.conf
Expand Up @@ -47,8 +47,8 @@ tuqquery.tuq_advisor.QueryAdvisorTests:
test_session_delete_completed_req
test_session_drop_collection
test_session_drop_scope
test_session_kill_index
test_session_kill_query
test_session_multi_node
test_session_skip_statement
test_session_skip_count
test_session_skip_count
test_session_kill_index
test_session_kill_query
6 changes: 3 additions & 3 deletions conf/tuq/py-tuq-statistics.conf
Expand Up @@ -23,9 +23,6 @@ tuqquery.tuq_update_statistics.QueryUpdateStatsTests:
test_update_stats_array
test_update_stats_gsi
test_update_stats_fts
test_drop_sys_collection
test_drop_sys_scope
test_drop_sys_bucket
test_negative_txn
test_negative_authorization
test_sys_bucket_100mb
Expand Down Expand Up @@ -53,3 +50,6 @@ tuqquery.tuq_update_statistics.QueryUpdateStatsTests:
test_update_histogram
test_stats_insert
test_more_than_ten_column
test_drop_sys_collection
test_drop_sys_scope
test_drop_sys_bucket
2 changes: 1 addition & 1 deletion pytests/tuqquery/tuq_advancedcbqshell.py
Expand Up @@ -306,7 +306,7 @@ def test_connect_disconnect(self):
self.assertTrue("Too many input arguments to command" in o)
queries = ['\connect http://localhost:8091;', 'create primary index on bucketname;']
o = self.execute_commands_inside(self.cbqpath, '', queries, '', '', bucket.name, '' )
self.assertTrue("GSI CreatePrimaryIndex() - cause: Index #primary already exists." in o)
self.assertTrue("The index #primary already exists." in o)

def test_history(self):
for server in self.servers:
Expand Down
27 changes: 13 additions & 14 deletions pytests/tuqquery/tuq_advisor.py
Expand Up @@ -916,8 +916,8 @@ def test_session_collection(self):
self.fail()

def test_session_collection_context(self):
advise_index1 = "CREATE INDEX adv_lower_city_country ON `default`:`travel-sample`.`inventory`.`airport`(lower(`city`),`country`)"
advise_index2 = "CREATE INDEX adv_country_lower_city ON `default`:`travel-sample`.`inventory`.`airport`(`country`,lower(`city`))"
advise_index1 = "CREATE INDEX adv_lower_city_country ON `airport`(lower(`city`),`country`)"
advise_index2 = "CREATE INDEX adv_country_lower_city ON `airport`(`country`,lower(`city`))"
query1='SELECT airportname FROM airport WHERE lower(city) = "lyon" AND country = "France"'
query_contexts = ["", f"default:`{self.bucket_name}`.inventory", f"default:`{self.bucket_name}`._default"]
self.wait_for_index_online(bucket='travel-sample', scope='inventory', collection='airport', index='def_inventory_airport_primary')
Expand Down Expand Up @@ -1141,24 +1141,23 @@ def test_session_kill_query(self):
node1 = self.servers[0]
node2 = self.servers[1]
try:
# Start session on node1
start = self.run_cbq_query(query="SELECT ADVISOR({'action':'start', 'duration':'40m'})", server=node1)
# Start session on node2
start = self.run_cbq_query(query="SELECT ADVISOR({'action':'start', 'duration':'40m'})", server=node2)
session = start['results'][0]['$1']['session']
# Run query on node1
results = self.run_cbq_query(query=query1, server=node1)
# Kill n1ql service on node1
remote_client = RemoteMachineShellConnection(node1)
# Run query on node2
results = self.run_cbq_query(query=query1, server=node2)
# Kill n1ql service on node2
remote_client = RemoteMachineShellConnection(node2)
remote_client.terminate_process(process_name="cbq-engine")
self.sleep(3)
# Stop session on node2
stop = self.run_cbq_query(query=f"SELECT ADVISOR({{'action':'stop', 'session':'{session}'}}) as Stop", server=node2)
# List session on node1 and node2
# Stop session on node1
stop = self.run_cbq_query(query=f"SELECT ADVISOR({{'action':'stop', 'session':'{session}'}}) as Stop", server=node1)
# List session
self.sleep(1)
list_node1 = self.run_cbq_query(query=f"SELECT ADVISOR({{'action':'list'}}) as List", server=node1)
list_node2 = self.run_cbq_query(query=f"SELECT ADVISOR({{'action':'list'}}) as List", server=node2)
statement1 = list_node1['results'][0]['List'][0]['tasks_cache']['results'][0]['recommended_indexes'][0]['statements'][0]['statement']
# Check advise
self.assertEqual(list_node1['results'][0]['List'], [])
self.assertEqual(list_node2['results'][0]['List'], [])
self.assertEqual(statement1, query1)
except Exception as e:
self.log.error(f"Advisor session failed: {e}")
self.fail()
Expand Down
21 changes: 14 additions & 7 deletions pytests/tuqquery/tuq_update_statistics.py
Expand Up @@ -332,11 +332,18 @@ def test_drop_sys_scope(self):
self.run_cbq_query(query="DROP SCOPE `N1QL_SYSTEM_BUCKET`.`N1QL_SYSTEM_SCOPE`")
self.sleep(1)
# update stats after drop system scope
try:
self.run_cbq_query(query=update_stats, query_params={'timeout':'600s'})
except CBQError as ex:
self.log.info("Let's try update stas again at least once more as you might get exception first time")
self.run_cbq_query(query=update_stats, query_params={'timeout':'600s'})
try_count = 0
while True:
try:
try_count += 1
self.run_cbq_query(query=update_stats, query_params={'timeout':'600s'})
break
except CBQError as ex:
if try_count == 5:
self.log.error(f"Update statistics failed: {ex}")
self.fail()
else:
self.log.info(f"Attempt# {try_count} of 5 failed. Let's try again")
# check stats
histogram = self.run_cbq_query(query=histogram_query)
self.assertEqual(histogram['results'],histogram_expected)
Expand Down Expand Up @@ -469,7 +476,7 @@ def test_update_stats_sample(self):
if self.scope == '_default' and self.collection == '_default':
min_size, max_size = 11507, 31591
else:
min_size, max_size = 1968, 1968
min_size, max_size = 1332, 1332
try:
# run stats
self.run_cbq_query(query=update_stats)
Expand Down Expand Up @@ -556,7 +563,7 @@ def test_missing_field(self):
def test_missing_keyspace(self):
error_code = 12003
fake_keyspaces = {
"`fake-bucket`": "Keyspace not found in CB datastore: default:fake-bucket - cause: No bucket named 'fake-bucket'",
"`fake-bucket`": "Keyspace not found in CB datastore: default:fake-bucket - cause: No bucket named fake-bucket",
"`travel-sample`.inventory.`fake-collection`": "Keyspace not found in CB datastore: default:travel-sample.inventory.fake-collection"
}
for keyspace in fake_keyspaces:
Expand Down

0 comments on commit 9ba5563

Please sign in to comment.