From 0d437f99584510b61ebbdca7f226aad708b892c3 Mon Sep 17 00:00:00 2001 From: Philip Zeyliger Date: Mon, 13 Apr 2015 11:15:00 -0700 Subject: [PATCH] OPSAPS-26038. Conditionalize 'roles' argument. Tests running against older CM versions had the following error: test_support_bundle45 fails with error: Unrecognized property: 'roles' (error 400) As it turns out, we have the capability to set an API version when using the python client, and the client should take care of things like this, so I've done so. To test this, I ran: $ cp ~/src/cm_api/python/src/cm_api/endpoints/cms.py ./target/env/lib/python2.7/site-packages/cm_api/endpoints/cms.py $ systest.py --agents="cdh5+parcels@nightly53-{1..4}.ent.cloudera.com" run_tests -n "test_support_bundle:SupportBundleTests.test_support_bundle_45" --disable-pre-validations --version cm53 Before my change (that I manually cherrypicked in the first hand): ApiException: Unrecognized property: 'roles' (error 400) ---------------------------------------------------------------------- Ran 1 test in 0.499s FAILED (errors=1) False After: *********************************************************************** * End test_support_bundle_45 (test_support_bundle.SupportBundleTests) * *********************************************************************** ---------------------------------------------------------------------- Ran 1 test in 128.929s I also tested against nightly (5.5) to make sure this didn't regress. It passed. $./systest.py --agents="cdh5+parcels@nightly-{1..4}.ent.cloudera.com" run_tests -n "test_support_bundle:SupportBundleTests.test_support_bundle_45" --disable-pre-validations (cherry picked from commit e58b3ccf2a5b63bf42460fde1f9b1c2e596bf440) --- python/src/cm_api/endpoints/cms.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/src/cm_api/endpoints/cms.py b/python/src/cm_api/endpoints/cms.py index 6c14e742..55f0196c 100644 --- a/python/src/cm_api/endpoints/cms.py +++ b/python/src/cm_api/endpoints/cms.py @@ -201,9 +201,10 @@ def collect_diagnostic_data_45(self, end_datetime, bundle_size_bytes, cluster_na args = { 'endTime': end_datetime.isoformat(), 'bundleSizeBytes': bundle_size_bytes, - 'clusterName': cluster_name, - 'roles': roles + 'clusterName': cluster_name } + if self._get_resource_root().version >= 10: + args['roles'] = roles return self._cmd('collectDiagnosticData', data=args) def hosts_decommission(self, host_names):