You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/06/04 07:14:02 UTC

svn commit: r1489292 - in /incubator/ambari/trunk/ambari-client/src: main/python/ambari_client/ main/python/ambari_client/model/ test/python/ test/python/json/

Author: mahadev
Date: Tue Jun  4 05:14:01 2013
New Revision: 1489292

URL: http://svn.apache.org/r1489292
Log:
AMBARI-1843. Python client testcases for AMBARI-1769. (subin m via mahadev)

Added:
    incubator/ambari/trunk/ambari-client/src/test/python/TestAmbariClient.py
    incubator/ambari/trunk/ambari-client/src/test/python/json/
    incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_clusters.json
    incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_services.json
    incubator/ambari/trunk/ambari-client/src/test/python/json/get_cluster.json
    incubator/ambari/trunk/ambari-client/src/test/python/json/get_service.json
Modified:
    incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/ambari_api.py
    incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_client.py
    incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_utils.py
    incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/base_model.py
    incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/utils.py
    incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/rest_resource.py

Modified: incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/ambari_api.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/ambari_api.py?rev=1489292&r1=1489291&r2=1489292&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/ambari_api.py (original)
+++ incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/ambari_api.py Tue Jun  4 05:14:01 2013
@@ -40,7 +40,7 @@ class AmbariClient(RestResource):
   """
 
   def __init__(self, host_name, port=None,user_name="admin", password="admin",
-               version=API_VERSION):
+               version=API_VERSION , client = None):
     """
     Creates a RestResource object.
 
@@ -57,7 +57,8 @@ class AmbariClient(RestResource):
     if port is None: 
       port = 8080
     host_url = "%s://%s:%s/api/v%s" %(protocol, host_name, port, version)
-    client = HttpClient(host_url, user_name , password )
+    if client is None:
+        client = HttpClient(host_url, user_name , password )
     RestResource.__init__(self, client)
 
 

Modified: incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_client.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_client.py?rev=1489292&r1=1489291&r2=1489292&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_client.py (original)
+++ incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_client.py Tue Jun  4 05:14:01 2013
@@ -112,7 +112,7 @@ class HttpClient(object):
         self.c.setopt(pycurl.UPLOAD, 1)
     else:
         self.c.setopt(pycurl.CUSTOMREQUEST, http_method)
-        iri_to_uri
+        
     if http_method in ('POST','PUT'):
       LOG.debug( "data..........."+str(payload))
       data = json.dumps(payload)

Modified: incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_utils.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_utils.py?rev=1489292&r1=1489291&r2=1489292&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_utils.py (original)
+++ incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/http_utils.py Tue Jun  4 05:14:01 2013
@@ -33,6 +33,8 @@ def uri_encoding(url):
         return url
     return urllib.quote(get_utf8_str(url), safe="/#%[]=:;$&()+,!?*@'~")
 
+
+
 def get_utf8_str(strr, encoding='utf-8'):
     """
     Returns a utf8 ecoded 'str'.
@@ -45,9 +47,10 @@ def get_utf8_str(strr, encoding='utf-8')
             if isinstance(strr, Exception):
                 return ' '.join([get_utf8_str(arg, encoding) for arg in strr])
             return unicode(strr).encode(encoding, errors)
-    elif strr and encoding != 'utf-8':
-        return strr.decode('utf-8', errors).encode(encoding, errors)
     elif isinstance(strr, unicode):
         return strr.encode(encoding, errors)
+    elif strr and encoding != 'utf-8':
+        return strr.decode('utf-8', errors).encode(encoding, errors)
     else:
-        return strr
\ No newline at end of file
+        return strr
+

Modified: incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/base_model.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/base_model.py?rev=1489292&r1=1489291&r2=1489292&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/base_model.py (original)
+++ incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/base_model.py Tue Jun  4 05:14:01 2013
@@ -45,8 +45,6 @@ class BaseModel(object):
 
   
   def __init__(self, resource_root, **rw_attrs):
-    #print" ================== base_model\n"
-    #print locals()
     self._resource_root = resource_root
     for k, v in rw_attrs.items():
       if k not in self.RW_ATTR:

Modified: incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/utils.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/utils.py?rev=1489292&r1=1489291&r2=1489292&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/utils.py (original)
+++ incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/model/utils.py Tue Jun  4 05:14:01 2013
@@ -120,7 +120,6 @@ def get_unicode( v):
   return v
   
 def retain_self_helper(self=None, **kwargs):
-    #print" ================== retain_self_helper\n"
     #print locals()
     from ambari_client.model.base_model import  BaseModel 
     BaseModel.__init__(self, **kwargs)

Modified: incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/rest_resource.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/rest_resource.py?rev=1489292&r1=1489291&r2=1489292&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/rest_resource.py (original)
+++ incubator/ambari/trunk/ambari-client/src/main/python/ambari_client/rest_resource.py Tue Jun  4 05:14:01 2013
@@ -42,8 +42,8 @@ class RestResource(object):
     self._path = path.strip('/')
 
   @property
-  def base_url(self):
-    return self._client.base_url
+  def host_url(self):
+    return self._client.host_url
 
   def _join_uri(self, relpath):
     if relpath is None:
@@ -55,13 +55,16 @@ class RestResource(object):
       return { 'Content-Type': content_type }
     return None
 
+
+  def make_invoke(self, http_method, payload, headers, path):
+      return self._client.invoke(http_method, path, payload=payload, headers=headers)
+
   def invoke(self, http_method, url_path=None, payload=None, headers=None):
     """
     Invoke an API http_method.
     """
     path = self._join_uri(url_path)
-    resp ,code , content  = self._client.invoke(http_method, path,payload=payload,
-                                headers=headers)
+    resp ,code , content  = self.make_invoke(http_method, payload, headers, path)
 
     LOG.debug ("RESPONSE from the REST request >>>>>>> \n"+str(resp) )
     LOG.debug ("\n===========================================================")

Added: incubator/ambari/trunk/ambari-client/src/test/python/TestAmbariClient.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/test/python/TestAmbariClient.py?rev=1489292&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/test/python/TestAmbariClient.py (added)
+++ incubator/ambari/trunk/ambari-client/src/test/python/TestAmbariClient.py Tue Jun  4 05:14:01 2013
@@ -0,0 +1,162 @@
+#!/usr/bin/env python2.6
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+
+
+from mock import MagicMock, patch
+from ambari_client.ambari_api import  AmbariClient 
+from ambari_client.person import Person
+import unittest
+
+class TestAmbariClient(unittest.TestCase):
+
+  def test_init(self):
+    """
+    AmbariClient is the top-level root resources.
+    This testcase checks if when the  init method was called &
+    the httpclient was initialized
+    """
+    client = AmbariClient("localhost", 8080, "admin","admin",version=1)
+    self.assertEqual(client.version, 1, "version should be 1")
+    self.assertEqual(client.host_url, "http://localhost:8080/api/v1", 
+                       "host_url should be http://localhost:8080/api/v1")
+      
+    client = AmbariClient(host_name="localhost",user_name="admin",password="admin")
+    self.assertEqual(client.version, 1, "version should be 1")
+    self.assertEqual(client.host_url, "http://localhost:8080/api/v1", 
+                       "host_url should be http://localhost:8080/api/v1")
+      
+    client = AmbariClient(host_name="localhost")
+    self.assertEqual(client.version, 1, "version should be 1")
+    self.assertEqual(client.host_url, "http://localhost:8080/api/v1", 
+                       "host_url should be http://localhost:8080/api/v1")
+    
+  
+    
+  @patch("ambari_client.http_client.HttpClient")  
+  def test_get_all_clusters_valid(self ,http_client):
+    """
+    Get all clusters.
+    This testcase checks if get_all_clusters returns a list of ModelList.
+    """
+    http_client_mock = MagicMock()
+    http_client.return_value = http_client_mock
+    
+    mocked_code = "200" 
+    mocked_content = "text/plain"
+    expected_output ={'items': [{'cluster_name': u'test1', 'version': u'HDP-1.2.1'}]}
+    
+    linestring = open('json/get_all_clusters.json', 'r').read()
+    mocked_response = linestring
+    http_client_mock.invoke.return_value = mocked_response , mocked_code , mocked_content
+   
+      
+    client = AmbariClient("localhost", 8080, "admin","admin",version=1 ,client= http_client_mock)
+    all_clusters = client.get_all_clusters()
+      
+    self.assertEqual(len(all_clusters), 1, "There should be a cluster from the response")
+    self.assertEqual(all_clusters.to_json_dict(), expected_output, "to_json_dict should convert ModelList")
+    
+   
+  @patch("ambari_client.http_client.HttpClient")  
+  def test_get_cluster_valid(self ,http_client):
+    """
+    Get all clusters.
+    This testcase checks if get_all_clusters returns a list of ModelList.
+    """
+    http_client_mock = MagicMock()
+    http_client.returned_obj = http_client_mock
+    mocked_code = "200" 
+    mocked_content = "text/plain"
+    
+    linestring = open('json/get_cluster.json', 'r').read()
+    mocked_response =  linestring
+    expected_dict_output = {'cluster_name': u'test1', 'version': u'HDP-1.2.1'}
+    
+    http_client_mock.invoke.return_value = mocked_response , mocked_code , mocked_content
+    client = AmbariClient("localhost", 8080, "admin","admin",version=1,client= http_client_mock)
+    cluster = client.get_cluster('test1')
+    
+    self.assertEqual(cluster.cluster_name, "test1", "cluster_name should be test1 ")
+    self.assertEqual(cluster.to_json_dict(), expected_dict_output, "to_json_dict should convert ClusterModel")
+
+
+
+  @patch("ambari_client.http_client.HttpClient")  
+  def test_get_all_services_valid(self ,http_client):
+    """
+    Get all services.
+    This testcase checks if get_all_services returns a list of ModelList.
+    """
+    http_client_mock = MagicMock()
+    http_client.returned_obj = http_client_mock
+    mocked_code = "200" 
+    mocked_content = "text/plain"
+    
+    expected_dict_output = {'cluster_name': u'test1', 'version': u'HDP-1.2.1'}
+    
+    http_client_mock.invoke.side_effect = http_client_invoke_side_effects
+    client = AmbariClient("localhost", 8080, "admin","admin",version=1,client= http_client_mock)
+    cluster = client.get_cluster('test1')
+    serviceList = cluster.get_all_services()
+    
+    self.assertEqual(cluster.cluster_name, "test1", "cluster_name should be test1 ")
+    self.assertEqual(cluster.to_json_dict(), expected_dict_output, "to_json_dict should convert ClusterModel")
+    self.assertEqual(len(serviceList), 3, "There should be a 3 services from the response")
+ 
+  @patch("ambari_client.http_client.HttpClient")  
+  def test_get_service_valid(self ,http_client):
+    """
+    Get the service.
+    This testcase checks if get_service returns a list of ServiceModel.
+    """
+    http_client_mock = MagicMock()
+    http_client.returned_obj = http_client_mock
+    mocked_code = "200" 
+    mocked_content = "text/plain"
+    
+    expected_dict_output = {'cluster_name': u'test1', 'version': u'HDP-1.2.1'}
+    
+    http_client_mock.invoke.side_effect = http_client_invoke_side_effects
+    client = AmbariClient("localhost", 8080, "admin","admin",version=1,client= http_client_mock)
+    cluster = client.get_cluster('test1')
+    serviceList = cluster.get_all_services()
+    ganglia = cluster.get_service("GANGLIA")  
+
+    self.assertEqual(cluster.cluster_name, "test1", "cluster_name should be test1 ")
+    self.assertEqual(cluster.to_json_dict(), expected_dict_output, "to_json_dict should convert ClusterModel")
+    self.assertEqual(len(serviceList), 3, "There should be a 3 services from the response")
+    #self.assertEqual(str(ganglia.state), "STARTED", "The ganglia service state should be fetched as STARTED")
+    self.assertEqual(ganglia.clusterRef.cluster_name, cluster.cluster_name, "The clusterRef value for  service  should be fetched ")
+    
+
+
+def http_client_invoke_side_effects(*args, **kwargs):
+    print locals()
+    mocked_code = "200" 
+    mocked_content = "text/plain"
+    if args[1] == "//clusters/test1":
+        mocked_response = open('json/get_cluster.json', 'r').read()
+        return mocked_response, mocked_code , mocked_content
+    elif args[1] == "//clusters/test1/services?fields=*":
+        mocked_response = open('json/get_all_services.json', 'r').read()
+        return mocked_response, mocked_code , mocked_content
+    elif args[1] == "//clusters/test1/services/GANGLIA":
+        mocked_response = open('json/get_service.json', 'r').read()
+        return mocked_response, mocked_code , mocked_content
\ No newline at end of file

Added: incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_clusters.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_clusters.json?rev=1489292&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_clusters.json (added)
+++ incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_clusters.json Tue Jun  4 05:14:01 2013
@@ -0,0 +1,12 @@
+{
+  "href" : "http://localhost:8080/api/v1/clusters",
+  "items" : [
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1",
+      "Clusters" : {
+        "cluster_name" : "test1",
+        "version" : "HDP-1.2.1"
+      }
+    }
+  ]
+}
\ No newline at end of file

Added: incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_services.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_services.json?rev=1489292&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_services.json (added)
+++ incubator/ambari/trunk/ambari-client/src/test/python/json/get_all_services.json Tue Jun  4 05:14:01 2013
@@ -0,0 +1,120 @@
+{
+  "href" : "http://localhost:8080/api/v1/clusters/test1/services?fields=*",
+  "items" : [
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/GANGLIA",
+      "ServiceInfo" : {
+        "cluster_name" : "test1",
+        "state" : "STARTED",
+        "service_name" : "GANGLIA",
+        "desired_configs" : {
+          "global" : "version1"
+        }
+      },
+      "components" : [
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/GANGLIA/components/GANGLIA_MONITOR",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "GANGLIA_MONITOR",
+            "service_name" : "GANGLIA"
+          }
+        },
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/GANGLIA/components/GANGLIA_SERVER",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "GANGLIA_SERVER",
+            "service_name" : "GANGLIA"
+          }
+        }
+      ]
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/MAPREDUCE",
+      "ServiceInfo" : {
+        "cluster_name" : "test1",
+        "state" : "STARTED",
+        "service_name" : "MAPREDUCE",
+        "desired_configs" : {
+          "mapred-site" : "version1",
+          "global" : "version1",
+          "core-site" : "version1"
+        }
+      },
+      "components" : [
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/MAPREDUCE/components/TASKTRACKER",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "TASKTRACKER",
+            "service_name" : "MAPREDUCE"
+          }
+        },
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/MAPREDUCE/components/MAPREDUCE_CLIENT",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "MAPREDUCE_CLIENT",
+            "service_name" : "MAPREDUCE"
+          }
+        },
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/MAPREDUCE/components/JOBTRACKER",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "JOBTRACKER",
+            "service_name" : "MAPREDUCE"
+          }
+        }
+      ]
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/HDFS",
+      "ServiceInfo" : {
+        "cluster_name" : "test1",
+        "state" : "STARTED",
+        "service_name" : "HDFS",
+        "desired_configs" : {
+          "global" : "version1",
+          "hdfs-site" : "version1",
+          "core-site" : "version1"
+        }
+      },
+      "components" : [
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/HDFS/components/SECONDARY_NAMENODE",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "SECONDARY_NAMENODE",
+            "service_name" : "HDFS"
+          }
+        },
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/HDFS/components/HDFS_CLIENT",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "HDFS_CLIENT",
+            "service_name" : "HDFS"
+          }
+        },
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/HDFS/components/NAMENODE",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "NAMENODE",
+            "service_name" : "HDFS"
+          }
+        },
+        {
+          "href" : "http://localhost:8080/api/v1/clusters/test1/services/HDFS/components/DATANODE",
+          "ServiceComponentInfo" : {
+            "cluster_name" : "test1",
+            "component_name" : "DATANODE",
+            "service_name" : "HDFS"
+          }
+        }
+      ]
+    }
+  ]
+}
\ No newline at end of file

Added: incubator/ambari/trunk/ambari-client/src/test/python/json/get_cluster.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/test/python/json/get_cluster.json?rev=1489292&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/test/python/json/get_cluster.json (added)
+++ incubator/ambari/trunk/ambari-client/src/test/python/json/get_cluster.json Tue Jun  4 05:14:01 2013
@@ -0,0 +1,103 @@
+{
+  "href" : "http://localhost:8080/api/v1/clusters/test1",
+  "Clusters" : {
+    "cluster_name" : "test1",
+    "cluster_id" : 1,
+    "version" : "HDP-1.2.1"
+  },
+  "requests" : [ ],
+  "services" : [
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/GANGLIA",
+      "ServiceInfo" : {
+        "cluster_name" : "test1",
+        "service_name" : "GANGLIA"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/MAPREDUCE",
+      "ServiceInfo" : {
+        "cluster_name" : "test1",
+        "service_name" : "MAPREDUCE"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/HDFS",
+      "ServiceInfo" : {
+        "cluster_name" : "test1",
+        "service_name" : "HDFS"
+      }
+    }
+  ],
+  "hosts" : [
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/hosts/r01mgt",
+      "Hosts" : {
+        "cluster_name" : "test1",
+        "host_name" : "r01mgt"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/hosts/r01hn01",
+      "Hosts" : {
+        "cluster_name" : "test1",
+        "host_name" : "r01hn01"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/hosts/r01wn03",
+      "Hosts" : {
+        "cluster_name" : "test1",
+        "host_name" : "r01wn03"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/hosts/r01wn02",
+      "Hosts" : {
+        "cluster_name" : "test1",
+        "host_name" : "r01wn02"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/hosts/r01wn01",
+      "Hosts" : {
+        "cluster_name" : "test1",
+        "host_name" : "r01wn01"
+      }
+    }
+  ],
+  "configurations" : [
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/configurations?type=mapred-site&tag=version1",
+      "tag" : "version1",
+      "type" : "mapred-site",
+      "Config" : {
+        "cluster_name" : "test1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/configurations?type=global&tag=version1",
+      "tag" : "version1",
+      "type" : "global",
+      "Config" : {
+        "cluster_name" : "test1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/configurations?type=hdfs-site&tag=version1",
+      "tag" : "version1",
+      "type" : "hdfs-site",
+      "Config" : {
+        "cluster_name" : "test1"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/configurations?type=core-site&tag=version1",
+      "tag" : "version1",
+      "type" : "core-site",
+      "Config" : {
+        "cluster_name" : "test1"
+      }
+    }
+  ]
+}
\ No newline at end of file

Added: incubator/ambari/trunk/ambari-client/src/test/python/json/get_service.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-client/src/test/python/json/get_service.json?rev=1489292&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-client/src/test/python/json/get_service.json (added)
+++ incubator/ambari/trunk/ambari-client/src/test/python/json/get_service.json Tue Jun  4 05:14:01 2013
@@ -0,0 +1,29 @@
+{
+  "href" : "http://localhost:8080/api/v1/clusters/test1/services/GANGLIA",
+  "ServiceInfo" : {
+    "cluster_name" : "test1",
+    "state" : "STARTED",
+    "service_name" : "GANGLIA",
+    "desired_configs" : {
+      "global" : "version1"
+    }
+  },
+  "components" : [
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/GANGLIA/components/GANGLIA_MONITOR",
+      "ServiceComponentInfo" : {
+        "cluster_name" : "test1",
+        "component_name" : "GANGLIA_MONITOR",
+        "service_name" : "GANGLIA"
+      }
+    },
+    {
+      "href" : "http://localhost:8080/api/v1/clusters/test1/services/GANGLIA/components/GANGLIA_SERVER",
+      "ServiceComponentInfo" : {
+        "cluster_name" : "test1",
+        "component_name" : "GANGLIA_SERVER",
+        "service_name" : "GANGLIA"
+      }
+    }
+  ]
+}
\ No newline at end of file