This is an automated email from the ASF dual-hosted git repository.

vjasani pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new e96595dfa1 AMBARI-26081 : Fix TestConfigs python test case failures in 
Ambari (#3785)
e96595dfa1 is described below

commit e96595dfa1fa02dc6b07c8908f6472a5680f2d23
Author: Himanshu Maurya <[email protected]>
AuthorDate: Thu Jun 13 07:23:36 2024 +0530

    AMBARI-26081 : Fix TestConfigs python test case failures in Ambari (#3785)
---
 ambari-server/src/main/resources/scripts/configs.py | 6 ++++--
 ambari-server/src/test/python/TestConfigs.py        | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/ambari-server/src/main/resources/scripts/configs.py 
b/ambari-server/src/main/resources/scripts/configs.py
index 7c07c4c72a..14c9faa140 100644
--- a/ambari-server/src/main/resources/scripts/configs.py
+++ b/ambari-server/src/main/resources/scripts/configs.py
@@ -95,7 +95,8 @@ def api_accessor(host, login, password, protocol, port, 
unsafe=None):
       else:
         response = urllib.request.urlopen(request)
 
-      response_body = response.read().decode('utf-8')
+      response_body = response.read()
+      response_body = response_body.decode('utf-8') if 
isinstance(response_body, bytes) else response_body
     except Exception as exc:
       raise Exception('Problem with accessing api. Reason: {0}'.format(exc))
     return response_body
@@ -124,7 +125,8 @@ def create_new_desired_config(cluster, config_type, 
properties, attributes, acce
   }
   if len(attributes.keys()) > 0:
     new_config[CLUSTERS][DESIRED_CONFIGS][ATTRIBUTES] = attributes
-  request_body = json.dumps(new_config).encode('utf-8')
+  request_body = json.dumps(new_config)
+  request_body = request_body.encode('utf-8') if isinstance(request_body, str) 
else request_body
   new_file = 'doSet_{0}.json'.format(new_tag)
   logger.info('### PUTting json into: {0}'.format(new_file))
   output_to_file(new_file)(new_config)
diff --git a/ambari-server/src/test/python/TestConfigs.py 
b/ambari-server/src/test/python/TestConfigs.py
index fd31890113..a5b51d01ac 100644
--- a/ambari-server/src/test/python/TestConfigs.py
+++ b/ambari-server/src/test/python/TestConfigs.py
@@ -54,7 +54,7 @@ class TestConfigs(TestCase):
           response.read.side_effect = [response_data]
         request_check = req_type.get('request_assertion', None)
         if request_check is not None:
-          request_body = json.loads(json.loads(request.data))
+          request_body = json.loads(request.data)
           request_check.get(request_url, lambda x: None)(request_body)
       return response
     return urlopen_side_effect


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to