def populateCluster(): serviceUrl = baseUrl + 'v0/config/cluster/clusterconf-sample' payload = ''' <request> <clusterConfig> <name>clusterconf-sample</name> <test>true</test> <prod>true</prod> <adHoc>true</adHoc> <bonus>true</bonus> <sla>true</sla> <s3MapredSiteXml>s3://PATH/TO/MAPRED-SITE.XML</s3MapredSiteXml> <s3CoreSiteXml>s3://PATH/TO/CORE-SITE.XML</s3CoreSiteXml> <s3HdfsSiteXml>s3://PATH/TO/HDFS-SITE.XML</s3HdfsSiteXml> <user>testuser</user> <testHiveConfigId>hiveconf-testhive-sample</testHiveConfigId> <prodHiveConfigId>hiveconf-prodhive-sample</prodHiveConfigId> <testPigConfigId>pigconf-testpig-sample</testPigConfigId> <prodPigConfigId>pigconf-prodpig-sample</prodPigConfigId> <hadoopVersion>1.0.3</hadoopVersion> <status>UP</status> <hasStats>false</hasStats> <jobFlowId>j-18EQGLSSWPOMG</jobFlowId> <gatewayJobFlowIds>j-31E6N85M87U3U</gatewayJobFlowIds> </clusterConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateCluster(): serviceUrl = baseUrl + 'v0/config/cluster/clusterconf-sample' payload = ''' <request> <clusterConfig> <name>clusterconf-sample</name> <test>true</test> <prod>true</prod> <adHoc>true</adHoc> <bonus>true</bonus> <sla>true</sla> <s3MapredSiteXml>file:///PATH/TO/MAPRED-SITE.XML</s3MapredSiteXml> <s3CoreSiteXml>file:///PATH/TO/CORE-SITE.XML</s3CoreSiteXml> <s3HdfsSiteXml>file:///PATH/TO/HDFS-SITE.XML</s3HdfsSiteXml> <s3YarnSiteXml>file:///PATH/TO/YARN-SITE.XML</s3YarnSiteXml> <user>testuser</user> <testHiveConfigId>hiveconf-testhive-sample</testHiveConfigId> <prodHiveConfigId>hiveconf-prodhive-sample</prodHiveConfigId> <testPigConfigId>pigconf-testpig-sample</testPigConfigId> <prodPigConfigId>pigconf-prodpig-sample</prodPigConfigId> <hadoopVersion>1.0.3</hadoopVersion> <status>UP</status> <hasStats>false</hasStats> <jobFlowId>j-18EQGLSSWPOMG</jobFlowId> <gatewayJobFlowIds>j-31E6N85M87U3U</gatewayJobFlowIds> </clusterConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateTestHive(): serviceUrl = baseUrl + 'v0/config/hive/hiveconf-testhive-sample' payload = ''' <request> <hiveConfig> <name>testhive</name> <type>TEST</type> <s3HiveSiteXml>file:///PATH/TO/TEST-HIVE-SITE.XML</s3HiveSiteXml> <user>testuser</user> <status>ACTIVE</status> <hiveVersion>0.11</hiveVersion> </hiveConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateProdHive(): serviceUrl = baseUrl + 'v0/config/hive/hiveconf-prodhive-sample' payload = ''' <request> <hiveConfig> <name>prodhive</name> <type>PROD</type> <s3HiveSiteXml>s3://BUCKET/PATH/TO/PROD-HIVE-SITE.XML</s3HiveSiteXml> <user>testuser</user> <status>ACTIVE</status> <hiveVersion>0.8.1</hiveVersion> </hiveConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateProdHive(): serviceUrl = baseUrl + 'v0/config/hive/hiveconf-prodhive-emr' payload = ''' <request> <hiveConfig> <name>prodhive</name> <type>PROD</type> <s3HiveSiteXml>file:///home/hadoop/.versions/hive-0.11.0/conf/hive-site.xml</s3HiveSiteXml> <user>produser</user> <status>ACTIVE</status> <hiveVersion>0.11</hiveVersion> </hiveConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateProdPig(): serviceUrl = baseUrl + 'v0/config/pig/pigconf-prodpig-sample' payload = ''' <request> <pigConfig> <name>prodpig</name> <type>PROD</type> <s3PigProperties>file:///PATH/TO/PROD-PIG.PROPERTIES</s3PigProperties> <user>testuser</user> <status>ACTIVE</status> <pigVersion>0.9.2</pigVersion> </pigConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateProdHive(): serviceUrl = baseUrl + 'v0/config/hive/hiveconf-prodhive-sample' payload = ''' <request> <hiveConfig> <name>prodhive</name> <type>PROD</type> <s3HiveSiteXml>file:///PATH/TO/PROD-HIVE-SITE.XML</s3HiveSiteXml> <user>testuser</user> <status>ACTIVE</status> <hiveVersion>0.8.1</hiveVersion> </hiveConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateProdPig(): serviceUrl = baseUrl + 'v0/config/pig/pigconf-prodpig-sample' payload = ''' <request> <pigConfig> <name>prodpig</name> <type>PROD</type> <s3PigProperties>s3://BUCKET/PATH/TO/PROD-PIG.PROPERTIES</s3PigProperties> <user>testuser</user> <status>ACTIVE</status> <pigVersion>0.9.2</pigVersion> </pigConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateTestPig(): serviceUrl = baseUrl + 'v0/config/pig/pigconf-testpig-sample' payload = ''' <request> <pigConfig> <name>testpig</name> <type>TEST</type> <s3PigProperties>file:///PATH/TO/TEST-PIG.PROPERTIES</s3PigProperties> <user>testuser</user> <status>ACTIVE</status> <pigVersion>0.11</pigVersion> </pigConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateProdPig(): serviceUrl = baseUrl + 'v0/config/pig/pigconf-prodpig-emr' payload = ''' <request> <pigConfig> <name>prodpig</name> <type>PROD</type> <s3PigProperties>file:///home/hadoop/.versions/pig-0.11.1/conf/pig.properties</s3PigProperties> <user>produser</user> <status>ACTIVE</status> <pigVersion>0.11</pigVersion> </pigConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def populateCluster(): serviceUrl = baseUrl + 'v0/config/cluster/clusterconf-emr' payload = ''' <request> <clusterConfig> <name>clusterconf-emr</name> <prod>true</prod> <adHoc>true</adHoc> <s3MapredSiteXml>file:///home/hadoop/.versions/1.0.3/conf/mapred-site.xml</s3MapredSiteXml> <s3CoreSiteXml>file:///home/hadoop/.versions/1.0.3/conf/core-site.xml</s3CoreSiteXml> <s3HdfsSiteXml>file:///home/hadoop/.versions/1.0.3/conf/hdfs-site.xml</s3HdfsSiteXml> <user>produser</user> <prodHiveConfigId>hiveconf-prodhive-emr</prodHiveConfigId> <prodPigConfigId>pigconf-prodpig-emr</prodPigConfigId> <hadoopVersion>1.0.3</hadoopVersion> <status>UP</status> </clusterConfig> </request> ''' restclient.put(serviceUrl=serviceUrl, payload=payload, contentType='application/xml')
def testPutBadStatus(self): print "HTTP PUT: bad status" payload = ''' { "hiveConfig": { "status": "BAD_STATUS", "user": "******" } } ''' params = '/' + id try: response = restclient.put(serviceUrl=serviceUrl, params=params, payload=payload) print response.read() assert False, "received unexpected successful response" except urllib2.HTTPError, e: print e.read() assert e.code == 400, "received unexpected unsuccessful response"
def testPut(self): print "HTTP PUT: changing fields" payload = ''' { "hiveConfig": { "name": "NEW_NAME", "s3HiveSiteXml": "s3://NEW/PATH", "user": "******" } } ''' params = '/' + id response = restclient.put(serviceUrl=serviceUrl, params=params, payload=payload) print response.code assert response.code == 200, "unable to put config for id" + id obj= json.loads(response.read()) assert obj['hiveConfigs']['hiveConfig']['updateTime'] > obj['hiveConfigs']['hiveConfig']['createTime'], \ "Update time not greater than create time"
def testPutErr(self): print "HTTP PUT: missing all params for new entry" payload = ''' { "hiveConfig": { "name": "prod", "type": "TEST", "user": "******" } } ''' params = '/new-' + id try: response = restclient.put(serviceUrl=serviceUrl, params=params, payload=payload) print response.read() assert False, "received unexpected successful response" except urllib2.HTTPError, e: print e.read() assert e.code == 400, "received unexpected unsuccessful response"
def testPutMissingParamsErr(self): print "HTTP PUT: missing required parameters for new entry" payload = ''' { "clusterConfig": { "prod": true, "user": "******", "prodHiveConfigId": "unittest_hiveconfig_id" } } ''' params = '/new-' + id try: response = restclient.put(serviceUrl=serviceUrl, params=params, payload=payload) print response.read() assert False, "received unexpected successful response" except urllib2.HTTPError, e: print e.read() assert e.code == 400, "received unexpected unsuccessful response"
def testPut(self): print "HTTP PUT: updating entry" payload = ''' { "clusterConfig": { "prod": true, "s3MapredSiteXml": "s3://PATH/TO/NEW/MAPRED", "s3CoreSiteXml": "s3://PATH/TO/NEW/CORE", "s3HdfsSiteXml": "s3://PATH/TO/NEW/HDFS", "user": "******", "prodHiveConfigId": "unittest_hiveconfig_id" } } ''' params = '/' + id response = restclient.put(serviceUrl=serviceUrl, params=params, payload=payload) print response.code assert response.code == 200, "unable to put config for id" + id obj= json.loads(response.read()) assert obj['clusterConfigs']['clusterConfig']['updateTime'] > obj['clusterConfigs']['clusterConfig']['createTime'], \ "Update time not greater than create time"
def testPutNoSuchConfigErr(self): print "HTTP PUT: updating entry" payload = ''' { "clusterConfig": { "prod": true, "s3MapredSiteXml": "s3://PATH/TO/NEW/MAPRED", "s3CoreSiteXml": "s3://PATH/TO/NEW/CORE", "s3HdfsSiteXml": "s3://PATH/TO/NEW/HDFS", "user": "******", "prodHiveConfigId": "does_not_exist" } } ''' params = '/' + id try: response = restclient.put(serviceUrl=serviceUrl, params=params, payload=payload) print response.read() assert False, "received unexpected successful response" except urllib2.HTTPError, e: print e.read() assert e.code == 400, "received unexpected unsuccessful response"
def testPut(self): print "HTTP PUT: updating entry" payload = ''' { "clusterConfig": { "prod": true, "s3MapredSiteXml": "s3://PATH/TO/NEW/MAPRED", "s3CoreSiteXml": "s3://PATH/TO/NEW/CORE", "s3HdfsSiteXml": "s3://PATH/TO/NEW/HDFS", "user": "******", "prodHiveConfigId": "unittest_hiveconfig_id" } } ''' params = '/' + id response = restclient.put(serviceUrl=serviceUrl, params=params, payload=payload) print response.code assert response.code == 200, "unable to put config for id" + id obj = json.loads(response.read()) assert obj['clusterConfigs']['clusterConfig']['updateTime'] > obj['clusterConfigs']['clusterConfig']['createTime'], \ "Update time not greater than create time"
def putcase(case,sso_cookie): body = get_body(case) headers = case.headers resp = restclient.put(case.url, sso_cookie, body=body, args=case.args, headers=headers) return resp