Skip to content

Commit 4e9a641

Browse files
author
Viet Nguyen
committed
Also get 1 hr data
1 parent 7eae74a commit 4e9a641

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/test/java/org/hawkular/client/test/metrics/openshift/CollectionRateDetailTest.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,31 @@ public CollectionRateDetailTest() throws Exception {
4343

4444
@Test
4545
public void findZeroValuesTest() throws Exception {
46-
String project = "default";
47-
String container = "hawkular-metrics";
46+
String project = "zproject9";
47+
String container = "stress";
4848
String testID = "namespace: " + project + ", container: " + container;
4949

50+
// for easy identification in the log
5051
String metricID = super.getMetricID(project, container, METRIC_SUFFIX.CPU_USAGE);
5152

53+
// Get a lot of data in the last few days
5254
long now = Instant.now().toEpochMilli();
5355
long start = now - Duration.ofHours(36).toMillis();
54-
long dur = start + Duration.ofHours(36).toMillis();
56+
long end = start + Duration.ofHours(36).toMillis();
5557

58+
Duration timeBucket = Duration.ofHours(1);
59+
getData(metricID, testID, start, end, timeBucket);
60+
61+
// get data in the last hour
62+
start = now - Duration.ofHours(1).toMillis();
63+
end = now;
64+
timeBucket = Duration.ofMinutes(1);
65+
getData(metricID, testID, start, end, timeBucket);
66+
}
67+
68+
private void getData(String metricID, String testID, long start, long end, Duration timeBucket) {
5669
Reporter.log("Fetching large data set... may take a couple minutes", true);
57-
List<GaugeDataPoint> rawData = client().metrics().getGaugeData(TENANT_ID, metricID, start, dur);
70+
List<GaugeDataPoint> rawData = client().metrics().getGaugeData(TENANT_ID, metricID, start, end);
5871

5972
Assert.assertNotNull(rawData, testID);
6073
Reporter.log("raw datapoints: " + rawData.size(), true);
@@ -63,8 +76,6 @@ public void findZeroValuesTest() throws Exception {
6376

6477
Assert.assertTrue(zeroList == null || zeroList.size() == 0, testID);
6578

66-
Duration timeBucket = Duration.ofHours(1);
67-
6879
Map<Long, Integer> hist = OpenshiftBaseTest.makeHistogram(rawData, timeBucket);
6980

7081
Double[] result = hist.entrySet().stream()
@@ -74,7 +85,8 @@ public void findZeroValuesTest() throws Exception {
7485
double[] d = ArrayUtils.toPrimitive(result);
7586

7687
// drop the first and last as they are usually outliers
77-
DescriptiveStatistics stats = new DescriptiveStatistics(Arrays.copyOfRange(d,1, d.length-1));
88+
double samples[] = Arrays.copyOfRange(d,1, d.length-1);
89+
DescriptiveStatistics stats = new DescriptiveStatistics(samples);
7890

7991
Reporter.log(hist.toString(), true);
8092
Reporter.log("size: " + stats.getN(), true);

0 commit comments

Comments
 (0)