@@ -43,18 +43,31 @@ public CollectionRateDetailTest() throws Exception {
43
43
44
44
@ Test
45
45
public void findZeroValuesTest () throws Exception {
46
- String project = "default " ;
47
- String container = "hawkular-metrics " ;
46
+ String project = "zproject9 " ;
47
+ String container = "stress " ;
48
48
String testID = "namespace: " + project + ", container: " + container ;
49
49
50
+ // for easy identification in the log
50
51
String metricID = super .getMetricID (project , container , METRIC_SUFFIX .CPU_USAGE );
51
52
53
+ // Get a lot of data in the last few days
52
54
long now = Instant .now ().toEpochMilli ();
53
55
long start = now - Duration .ofHours (36 ).toMillis ();
54
- long dur = start + Duration .ofHours (36 ).toMillis ();
56
+ long end = start + Duration .ofHours (36 ).toMillis ();
55
57
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 ) {
56
69
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 );
58
71
59
72
Assert .assertNotNull (rawData , testID );
60
73
Reporter .log ("raw datapoints: " + rawData .size (), true );
@@ -63,8 +76,6 @@ public void findZeroValuesTest() throws Exception {
63
76
64
77
Assert .assertTrue (zeroList == null || zeroList .size () == 0 , testID );
65
78
66
- Duration timeBucket = Duration .ofHours (1 );
67
-
68
79
Map <Long , Integer > hist = OpenshiftBaseTest .makeHistogram (rawData , timeBucket );
69
80
70
81
Double [] result = hist .entrySet ().stream ()
@@ -74,7 +85,8 @@ public void findZeroValuesTest() throws Exception {
74
85
double [] d = ArrayUtils .toPrimitive (result );
75
86
76
87
// 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 );
78
90
79
91
Reporter .log (hist .toString (), true );
80
92
Reporter .log ("size: " + stats .getN (), true );
0 commit comments