Skip to content

Commit

Permalink
Merge pull request #49 from /issues/46
Browse files Browse the repository at this point in the history
Issue #46: can now use patterns for cluster name/id
  • Loading branch information
amitsharmaak committed Nov 15, 2013
2 parents b7fcf82 + cc9c1f7 commit dd487ea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ public Response getClusterConfig(@PathParam("id") String id) {
}

/**
* Get cluster config based on user params If empty strings are passed for
* Get cluster config based on user params. If empty strings are passed for
* prod, test, unitTest, adHoc, sla, bonus and hasStats, they are treated as
* nulls (not false).
*
* @param id
* unique id for cluster
* unique id for cluster (can be a pattern)
* @param name
* cluster name
* cluster name (can be a pattern)
* @param prod
* if cluster supports prod jobs
* @param test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public interface ClusterConfigService {
* Get the cluster config by various params.
*
* @param id
* unique id for cluster
* unique id for cluster (can be a pattern)
* @param name
* name of cluster
* name of cluster (can be a pattern)
* @param config
* configuration supported
* @param schedule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ public ClusterConfigResponse getClusterConfig(String id, String name,
// construct query
ClauseBuilder criteria = new ClauseBuilder(ClauseBuilder.AND);
if ((id != null) && (!id.isEmpty())) {
criteria.append("id = '" + id + "'");
criteria.append("id like '" + id + "'");
}
if ((name != null) && (!name.isEmpty())) {
criteria.append("name = '" + name + "'");
criteria.append("name like '" + name + "'");
}
if ((jobType != null) && (Types.JobType.parse(jobType) == null)) {
ccr = new ClusterConfigResponse(new CloudServiceException(
Expand Down
16 changes: 16 additions & 0 deletions genie-web/src/test/python/config/clusterConfigTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

# use a global id for all tests
id='unittest_clusterconfig_id'
id_pattern='%clusterconfig%'
name='unittest_clusterconfig_name'
name_prefix='unittest%'

hive_id='unittest_hiveconfig_id'
hive_name='unittest_hiveconfig_name'
Expand Down Expand Up @@ -115,6 +117,13 @@ def testGetById(self):
response = restclient.get(serviceUrl=serviceUrl, params=params)
print response.code
assert response.code == 200, "can't get element by id: " + id

def testGetByIdPattern(self):
print "HTTP GET: getting elements by id"
params = '?id=' + id_pattern
response = restclient.get(serviceUrl=serviceUrl, params=params)
print response.code
assert response.code == 200, "can't get element by id: " + id

def testGetByName(self):
print "HTTP GET: getting elements by name"
Expand All @@ -123,6 +132,13 @@ def testGetByName(self):
print response.code
assert response.code == 200, "can't get element by name: " + name

def testGetByClusterPrefix(self):
print "HTTP GET: getting elements by name"
params = '?name=' + name_prefix
response = restclient.get(serviceUrl=serviceUrl, params=params)
print response.code
assert response.code == 200, "can't get element by name: " + name

def testGetByUpdateTime(self):
print "HTTP GET: getting elements by update time"
minUpdateTime = 0
Expand Down

0 comments on commit dd487ea

Please sign in to comment.