Skip to content

Commit

Permalink
[HWKMETRICS-474] Update the CQL query to use the correct String metri…
Browse files Browse the repository at this point in the history
…c type when querying with ASC order and limit.

(cherry picked from commit 4252af6)
Signed-off-by: Stefan Negrea <snegrea@redhat.com>
  • Loading branch information
Stefan Negrea committed Sep 7, 2016
1 parent c970612 commit ca482c8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public Observable<Row> findStringData(MetricId<String> id, long startTime, long
STRING.getCode(), id.getName(), DPART, getTimeUUID(startTime), getTimeUUID(endTime)));
} else {
return rxSession.executeAndFetch(findStringDataByDateRangeExclusiveWithLimitASC.bind(
id.getTenantId(), GAUGE.getCode(), id.getName(), DPART, getTimeUUID(startTime),
id.getTenantId(), STRING.getCode(), id.getName(), DPART, getTimeUUID(startTime),
getTimeUUID(endTime), limit));
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,58 @@ class StringITest extends RESTTest {
]))
}

@Test
void fetchRawStringWithQueryParamsLimitAndOrder() {
String tenantId = nextTenantId()
DateTime start = DateTime.now().minusHours(4)

def response = hawkularMetrics.post(
path: "strings/raw",
headers: [(tenantHeaderName): tenantId],
body: [
[
id: 'St1',
data: [
[timestamp: start.millis, value: 'running1'],
[timestamp: start.plusHours(1).millis, value: 'running2'],
[timestamp: start.plusHours(2).millis, value: 'maintenance1'],
[timestamp: start.plusHours(3).millis, value: 'maintenance2'],
[timestamp: start.plusHours(4).millis, value: 'down']
]
]
]
)
assertEquals(200, response.status)

response = hawkularMetrics.get(
path: "strings/St1/raw",
headers: [(tenantHeaderName): tenantId],
query: [
limit: 2,
order: 'asc'
]
)

assertEquals(200, response.status)
assertEquals(2, response.data.size)

assertEquals([timestamp: start.millis, value: 'running1'], response.data[0])
assertEquals([timestamp: start.plusHours(1).millis, value: 'running2'], response.data[1])

response = hawkularMetrics.get(
path: "strings/St1/raw",
headers: [(tenantHeaderName): tenantId],
query: [
limit: 2,
order: 'desc'
]
)

assertEquals(200, response.status)
assertEquals(2, response.data.size)

assertEquals([timestamp: start.plusHours(4).millis, value: 'down'], response.data[0])
assertEquals([timestamp: start.plusHours(3).millis, value: 'maintenance2'], response.data[1])
}

}

0 comments on commit ca482c8

Please sign in to comment.