Skip to content

Commit

Permalink
Merge pull request #807 from hawkular/HWKMETRICS-621_4
Browse files Browse the repository at this point in the history
[HWKMETRICS-621] Make /m a short alternative path to /metrics.
  • Loading branch information
John Sanda committed Apr 11, 2017
2 parents 7e24a27 + d059a2b commit cb503c2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -94,7 +94,7 @@
*
* @author Heiko W. Rupp
*/
@Path("/metrics")
@Path("/{dual_path:metrics|m}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Api(tags = "Metric")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Red Hat, Inc. and/or its affiliates
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,6 +25,46 @@ import static org.junit.Assert.assertEquals
*/
class MetricsITest extends RESTTest {

@Test
void dualPathTest() {
String tenantId = nextTenantId()
DateTime start = DateTime.now().minusMinutes(10)

def response = hawkularMetrics.post(
path: "metrics/raw",
headers: [(tenantHeaderName): tenantId],
body: [
gauges: [
[
id: 'CG1',
data: [
[timestamp: start.millis, value: 10.032],
[timestamp: start.plusMinutes(1).millis, value: 9.589]
],
]
],
availabilities: [
[
id: 'CA1',
data: [
[timestamp: start.millis, value: "down"],
[timestamp: start.plusMinutes(1).millis, value: "up"]
]
]
]
]
)
assertEquals(200, response.status)

response = hawkularMetrics.get(path: 'metrics', headers: [(tenantHeaderName): tenantId])
assertEquals(200, response.status)
assertEquals(2, response.data.size)

response = hawkularMetrics.get(path: 'm', headers: [(tenantHeaderName): tenantId])
assertEquals(200, response.status)
assertEquals(2, response.data.size)
}

@Test
void addMixedData() {
String tenantId = nextTenantId()
Expand Down

0 comments on commit cb503c2

Please sign in to comment.