Skip to content

Commit 5a2992c

Browse files
committed
MB-65480 Use new isColumnar field from /pools endpoint
Since MB-65393 has been completed, we should use the new isColumnar field from the /pools endpoint to decide whether the cluster is a Columnar one instead of inferring from the implementationVersion. Change-Id: I50b3b345aa2232703dbfe5656d3988ddf924bce2 Reviewed-on: https://review.couchbase.org/c/couchbase-cli/+/225258 Tested-by: Build Bot <[email protected]> Reviewed-by: Lubo Marinski <[email protected]>
1 parent 145767c commit 5a2992c

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

cluster_manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,15 @@ def is_cluster_initialized(self):
263263
return False, errors
264264

265265
def is_enterprise_columnar(self):
266+
"""
267+
Returns a tuple of (isEnterprise, isColumnar, errors)
268+
"""
266269
data, errors = self.pools()
267270
if errors:
268271
return None, None, errors
269-
# use data["isColumnar"] once MB-65393 is completed
270-
return data["isEnterprise"], data["implementationVersion"].endswith("-columnar"), None
272+
273+
# If isColumnar isn't present, then it must be a <8.0 non-Columnar cluster (MB-65393)
274+
return data["isEnterprise"], data.get("isColumnar", False), None
271275

272276
def get_hostnames_for_service(self, service_name):
273277
""" Gets all hostnames that run a service

test/mock_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def get_pools(rest_params=None, server_args=None, path="", endpoint_match=None):
290290
'lhttpc': '1.3.0', 'sasl': '2.3.4'}, 'implementationVersion': version,
291291
'isAdminCreds': is_admin, 'isROAdminCreds': False}
292292

293-
response_no_init = {'uuid': [], 'settings': [], 'pools': [], 'isEnterprise': enterprise,
293+
response_no_init = {'uuid': [], 'settings': [], 'pools': [], 'isEnterprise': enterprise, 'isColumnar': columnar,
294294
'componentsVersion': {'kernel': '5.4.3.2', 'ale': version, 'ssl': '8.2.6.2', 'os_mon': '2.4.4',
295295
'stdlib': '3.4.5', 'inets': '6.5.2.4', 'public_key': '1.5.2',
296296
'ns_server': version, 'crypto': '4.2.2.2', 'asn1': '5.0.5.1',

test/test_cluster_manager.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,54 @@ def test_is_cluster_initialized(self):
249249
server.shutdown()
250250

251251
self.assertEqual(res, test["expected_res"])
252+
253+
def test_is_enterprise_columnar(self):
254+
tests = {
255+
"Enterprise_Columnar": {
256+
"pools_response": (200, {
257+
"isEnterprise": True,
258+
"isColumnar": True
259+
}),
260+
"expected": (True, True, None)
261+
},
262+
"Enterprise_NonColumnar": {
263+
"pools_response": (200, {
264+
"isEnterprise": True,
265+
"isColumnar": False
266+
}),
267+
"expected": (True, False, None)
268+
},
269+
"Enterprise_MissingColumnarField": {
270+
"pools_response": (200, {
271+
"isEnterprise": True
272+
# isColumnar field is missing, should default to False
273+
}),
274+
"expected": (True, False, None)
275+
},
276+
"NonEnterprise_MissingColumnarField": {
277+
"pools_response": (200, {
278+
"isEnterprise": False
279+
# isColumnar field is missing, should default to False
280+
}),
281+
"expected": (False, False, None)
282+
},
283+
"Error": {
284+
"pools_response": (400, {"_": "error"}),
285+
"expected": (None, None, [{"_": "error"}])
286+
}
287+
}
288+
289+
for name, test in tests.items():
290+
with self.subTest(name=name):
291+
server = MockRESTServer('127.0.0.1', 6789)
292+
server.args["override-pools"] = test["pools_response"]
293+
server.run()
294+
295+
cluster_manager = ClusterManager("http://127.0.0.1:6789", "Administrator", "asdasd")
296+
is_enterprise, is_columnar, errors = cluster_manager.is_enterprise_columnar()
297+
298+
server.shutdown()
299+
300+
self.assertEqual(is_enterprise, test["expected"][0], "is_enterprise value does not match expected")
301+
self.assertEqual(is_columnar, test["expected"][1], "is_columnar value does not match expected")
302+
self.assertEqual(errors, test["expected"][2], "errors value does not match expected")

0 commit comments

Comments
 (0)