From 868581c226ff0a35862b729155ee2337afb5a58c Mon Sep 17 00:00:00 2001 From: pierrecouch Date: Thu, 29 Sep 2022 08:00:14 -0700 Subject: [PATCH] New throttling tc Change-Id: Idea6b9e3852818b9a1f683a7f1e6c07e3eaba629 Reviewed-on: https://review.couchbase.org/c/testrunner/+/180607 Reviewed-by: Girish Benakappa Tested-by: Pierre Regazzoni --- conf/tuq/py-gsi-throttling.conf | 3 ++- pytests/tuqquery/tuq_throttling.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/conf/tuq/py-gsi-throttling.conf b/conf/tuq/py-gsi-throttling.conf index 9aec90b9c0..bd1880fa34 100644 --- a/conf/tuq/py-gsi-throttling.conf +++ b/conf/tuq/py-gsi-throttling.conf @@ -1,3 +1,4 @@ tuqquery.tuq_throttling.QueryThrottlingTests: test_gsi_create - test_gsi_below_throttle \ No newline at end of file + test_gsi_below_throttle + test_gsi_limit \ No newline at end of file diff --git a/pytests/tuqquery/tuq_throttling.py b/pytests/tuqquery/tuq_throttling.py index 7d12b00b2b..ada6733df3 100644 --- a/pytests/tuqquery/tuq_throttling.py +++ b/pytests/tuqquery/tuq_throttling.py @@ -10,6 +10,7 @@ def setUp(self): self.kv_wu, self.kv_ru = 1024, 4096 self.index_wu, self.index_ru = 1024, 256 self.scope_limit, self.collection_limit = 100, 100 + self.gsi_limit = 200 self.kvThrottleLimit = self.get_throttle_limits(service='kvThrottleLimit') self.log.info(f'kvThrottleLimit is {self.kvThrottleLimit}') @@ -143,4 +144,20 @@ def test_collection_limit(self): self.assertTrue(f'_:Maximum number of collections ({self.collection_limit}) for this bucket has been reached' in error['msg']) finally: for i in range(self.collection_limit): - self.run_cbq_query(f'DROP COLLECTION {self.bucket}.`_default`.collection{i} IF EXISTS') + self.run_cbq_query(f'DROP COLLECTION {self.bucket}.`_default`.collection{i} IF EXISTS') + + def test_gsi_limit(self): + indexes = self.run_cbq_query('SELECT raw count(*) FROM system:indexes WHERE `using` = "gsi"') + count = indexes['results'][0] + for i in range(self.gsi_limit - count): + self.run_cbq_query(f'CREATE INDEX idx{i} IF NOT EXISTS ON {self.bucket}(a)') + try: + self.run_cbq_query(f'CREATE INDEX idx{self.gsi_limit+1} IF NOT EXISTS ON {self.bucket}(a)') + self.fail(f'We should not be able to create index beyond limit of {self.gsi_limit}') + except CBQError as ex: + error = self.process_CBQE(ex) + self.assertEqual(error['code'], 4350) + self.assertEqual(error['msg'], f'GSI CreateIndex() - cause: Limit for number of indexes that can be created per bucket has been reached. Limit : {self.gsi_limit}') + finally: + for i in range(self.gsi_limit): + self.run_cbq_query(f'DROP INDEX idx{i} IF EXISTS ON {self.bucket}') \ No newline at end of file