aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050891904


##########
integration-test-groups/aws2/aws2-cw/src/test/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwTest.java:
##########
@@ -90,4 +97,148 @@ public void metric() {
 
     }
 
+    @Test
+    public void headers() {
+
+        final Instant startTime = 
Instant.ofEpochMilli(System.currentTimeMillis() - 10000);
+
+        final String namespace = "cq-metrics-" + 
java.util.UUID.randomUUID().toString().replace("-", "");
+        final String metricName = "metricName" + 
java.util.UUID.randomUUID().toString().replace("-", "");
+        final int value = (int) (Math.random() * 10000);
+
+        List<Map<String, Object>> data = new LinkedList<>();
+
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "even"));
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 2,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSIONS, CollectionHelper.mapOf("type", 
"even")));
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 4,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "even"));
+
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 1,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "odd"));
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace, 
Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 3,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "odd"));
+        //ignored because of timestamp
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace, 
Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 5,
+                Cw2Constants.METRIC_TIMESTAMP, System.currentTimeMillis() - 24 
* 60 * 60 * 10000,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "odd"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(data)
+                .post("/aws2-cw/send-metric-maps/" + namespace)
+                .then()
+                .statusCode(201);
+
+        Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120, 
TimeUnit.SECONDS).until(
+                () -> {
+
+                    List<Datapoint> oddDatapoints = client.getMetricStatistics(
+                            GetMetricStatisticsRequest.builder()
+                                    .namespace(namespace)
+                                    .metricName(metricName)
+                                    .statistics(Statistic.SAMPLE_COUNT, 
Statistic.MINIMUM, Statistic.MAXIMUM)
+                                    .startTime(startTime)
+                                    
.dimensions(Dimension.builder().name("type").value("odd").build())
+                                    
.endTime(Instant.ofEpochMilli(System.currentTimeMillis() + 10000))
+                                    .period(30)
+                                    .build())
+                            .datapoints();
+
+                    List<Datapoint> evenDatapoints = 
client.getMetricStatistics(
+                            GetMetricStatisticsRequest.builder()
+                                    .namespace(namespace)
+                                    .metricName(metricName)
+                                    .statistics(Statistic.SAMPLE_COUNT, 
Statistic.AVERAGE)
+                                    .startTime(startTime)
+                                    
.dimensions(Dimension.builder().name("type").value("even").build())
+                                    
.endTime(Instant.ofEpochMilli(System.currentTimeMillis() + 10000))
+                                    .period(30)
+                                    .build())
+                            .datapoints();
+                    LOG.debug("Expecting some datapoints for metric " + 
namespace + "/" + metricName + " (type='odd'), got "
+                            + oddDatapoints);
+                    if (oddDatapoints.isEmpty()) {
+                        return false;
+                    }
+                    LOG.debug("Expecting some datapoints for metric " + 
namespace + "/" + metricName + " (type='even'), got "
+                            + evenDatapoints);
+                    if (evenDatapoints.isEmpty()) {
+                        return false;
+                    }
+
+                    Datapoint oddDp = oddDatapoints.get(0);
+                    Datapoint evenDp = evenDatapoints.get(0);
+
+                    if (!(oddDp.sampleCount().intValue() == 2
+                            && oddDp.minimum().intValue() == 2 * value + 1
+                            && oddDp.maximum().intValue() == 2 * value + 3)) {
+                        throw new RuntimeException("Unexpected odd datapoint " 
+ oddDp

Review Comment:
   Ok, think I get that. It's actually a `pollInterval()` block.



##########
integration-test-groups/aws2/aws2-cw/src/test/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwTest.java:
##########
@@ -90,4 +97,148 @@ public void metric() {
 
     }
 
+    @Test
+    public void headers() {
+
+        final Instant startTime = 
Instant.ofEpochMilli(System.currentTimeMillis() - 10000);
+
+        final String namespace = "cq-metrics-" + 
java.util.UUID.randomUUID().toString().replace("-", "");
+        final String metricName = "metricName" + 
java.util.UUID.randomUUID().toString().replace("-", "");
+        final int value = (int) (Math.random() * 10000);
+
+        List<Map<String, Object>> data = new LinkedList<>();
+
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "even"));
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 2,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSIONS, CollectionHelper.mapOf("type", 
"even")));
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 4,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "even"));
+
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 1,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "odd"));
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace, 
Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 3,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "odd"));
+        //ignored because of timestamp
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace, 
Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value + 5,
+                Cw2Constants.METRIC_TIMESTAMP, System.currentTimeMillis() - 24 
* 60 * 60 * 10000,
+                Cw2Constants.METRIC_UNIT, "Count",
+                Cw2Constants.METRIC_DIMENSION_NAME, "type",
+                Cw2Constants.METRIC_DIMENSION_VALUE, "odd"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .body(data)
+                .post("/aws2-cw/send-metric-maps/" + namespace)
+                .then()
+                .statusCode(201);
+
+        Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120, 
TimeUnit.SECONDS).until(
+                () -> {
+
+                    List<Datapoint> oddDatapoints = client.getMetricStatistics(
+                            GetMetricStatisticsRequest.builder()
+                                    .namespace(namespace)
+                                    .metricName(metricName)
+                                    .statistics(Statistic.SAMPLE_COUNT, 
Statistic.MINIMUM, Statistic.MAXIMUM)
+                                    .startTime(startTime)
+                                    
.dimensions(Dimension.builder().name("type").value("odd").build())
+                                    
.endTime(Instant.ofEpochMilli(System.currentTimeMillis() + 10000))
+                                    .period(30)
+                                    .build())
+                            .datapoints();
+
+                    List<Datapoint> evenDatapoints = 
client.getMetricStatistics(
+                            GetMetricStatisticsRequest.builder()
+                                    .namespace(namespace)
+                                    .metricName(metricName)
+                                    .statistics(Statistic.SAMPLE_COUNT, 
Statistic.AVERAGE)
+                                    .startTime(startTime)
+                                    
.dimensions(Dimension.builder().name("type").value("even").build())
+                                    
.endTime(Instant.ofEpochMilli(System.currentTimeMillis() + 10000))
+                                    .period(30)
+                                    .build())
+                            .datapoints();
+                    LOG.debug("Expecting some datapoints for metric " + 
namespace + "/" + metricName + " (type='odd'), got "
+                            + oddDatapoints);
+                    if (oddDatapoints.isEmpty()) {
+                        return false;
+                    }
+                    LOG.debug("Expecting some datapoints for metric " + 
namespace + "/" + metricName + " (type='even'), got "
+                            + evenDatapoints);
+                    if (evenDatapoints.isEmpty()) {
+                        return false;
+                    }
+
+                    Datapoint oddDp = oddDatapoints.get(0);
+                    Datapoint evenDp = evenDatapoints.get(0);
+
+                    if (!(oddDp.sampleCount().intValue() == 2
+                            && oddDp.minimum().intValue() == 2 * value + 1
+                            && oddDp.maximum().intValue() == 2 * value + 3)) {
+                        throw new RuntimeException("Unexpected odd datapoint " 
+ oddDp
+                                + "; expected sampleCount == 2 && minimum ~ " 
+ (2 * value + 1)
+                                + " && maximum ~ " + (2 * value + 3));
+                    }
+
+                    if (!(evenDp.average() == 2 * value + 2
+                            && evenDp.sampleCount() == 3)) {
+                        throw new RuntimeException("Unexpected even datapoint 
" + evenDp
+                                + "; expected sampleCount == 3 && average == " 
+ (2 * value + 2));
+                    }
+
+                    return true;
+                });
+
+    }
+
+    @Test
+    public void customClient() {
+        final String namespace = "cq-metrics-" + 
java.util.UUID.randomUUID().toString().replace("-", "");
+        final String metricName = "metricName" + 
java.util.UUID.randomUUID().toString().replace("-", "");
+        final int value = (int) (Math.random() * 10000);
+
+        List<Map<String, Object>> data = new LinkedList<>();
+
+        data.add(CollectionHelper.mapOf(
+                Cw2Constants.METRIC_NAMESPACE, namespace,
+                Cw2Constants.METRIC_NAME, metricName,
+                Cw2Constants.METRIC_VALUE, 2 * value,
+                Cw2Constants.METRIC_UNIT, "Count"));
+
+        RestAssured.given()
+                .contentType(ContentType.JSON)
+                .queryParam("customClientName", "customClient")
+                .body(data)
+                .post("/aws2-cw/send-metric-maps/" + namespace)
+                .then()
+                .statusCode(200)
+                .body(is("MockedClient"));

Review Comment:
   ok, caught. Many thanks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to