You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/12/16 11:43:48 UTC
[GitHub] [camel-quarkus] JiriOndrusek opened a new pull request, #4345: Expand AWS CW test coverage #4196
JiriOndrusek opened a new pull request, #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345
fixes https://github.com/apache/camel-quarkus/issues/4196
Different ways of configuring credentials are not covered.
<!-- Uncomment and fill this section if your PR is not trivial
[ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
[ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
[ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
[ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
[ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
[ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
-->
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1063434325
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/ClientBuilder.java:
##########
@@ -0,0 +1,875 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.aws2.cw.it;
+
+import java.util.function.Consumer;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.model.CloudWatchException;
+import software.amazon.awssdk.services.cloudwatch.model.ConcurrentModificationException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardInvalidInputErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardNotFoundErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageResponse;
+import software.amazon.awssdk.services.cloudwatch.model.InternalServiceException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidFormatException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidNextTokenException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterCombinationException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterValueException;
+import software.amazon.awssdk.services.cloudwatch.model.LimitExceededException;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.MissingRequiredParameterException;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ResourceNotFoundException;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateRequest;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmHistoryIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAnomalyDetectorsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.GetMetricDataIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListDashboardsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListManagedInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricStreamsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricsIterable;
+import software.amazon.awssdk.services.cloudwatch.waiters.CloudWatchWaiter;
+
+public class ClientBuilder {
+
+ @Inject
+ CamelContext camelContext;
+
+ @Produces
+ @Named("customClient")
+ CloudWatchClient produceClient() {
+
+ return new MockedClient();
+ }
+
+ @Produces
+ @Named("customClient2")
+ CloudWatchClient produceClient2() {
+ //second client is required to avoid autowiring of the first client if there is only one client
+ return new MockedClient();
+ }
+
+ class MockedClient implements CloudWatchClient {
Review Comment:
Do we need to re-implement the default methods ?
In Camel, it looks possible not do to so:
https://github.com/apache/camel/blob/main/components/camel-aws/camel-aws2-cw/src/test/java/org/apache/camel/component/aws2/cw/CloudWatchClientMock.java
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1067842457
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/CloudWatchClientMock.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.cw;
+
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse;
+
+public class CloudWatchClientMock implements CloudWatchClient {
+
+ public CloudWatchClientMock() {
+ System.out.println(1);
Review Comment:
removed
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
jamesnetherton commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1062476120
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/ClientBuilder.java:
##########
@@ -0,0 +1,875 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.aws2.cw.it;
+
+import java.util.function.Consumer;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.model.CloudWatchException;
+import software.amazon.awssdk.services.cloudwatch.model.ConcurrentModificationException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardInvalidInputErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardNotFoundErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageResponse;
+import software.amazon.awssdk.services.cloudwatch.model.InternalServiceException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidFormatException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidNextTokenException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterCombinationException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterValueException;
+import software.amazon.awssdk.services.cloudwatch.model.LimitExceededException;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.MissingRequiredParameterException;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ResourceNotFoundException;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateRequest;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmHistoryIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAnomalyDetectorsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.GetMetricDataIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListDashboardsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListManagedInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricStreamsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricsIterable;
+import software.amazon.awssdk.services.cloudwatch.waiters.CloudWatchWaiter;
+
+public class ClientBuilder {
+
+ @Inject
+ CamelContext camelContext;
+
+ @Produces
+ @Named("customClient")
+ CloudWatchClient produceClient() {
+
+ return new MockedClient();
+ }
+
+ @Produces
+ @Named("customClient2")
+ CloudWatchClient produceClient2() {
+ //second client is required to avoid autowiring of the first client if there is only one client
Review Comment:
Bit of a nitpick - but can we not just set `camel.component.aws2-cw.autowired-enabled=false` in `application.properties`?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#issuecomment-1369506073
The proposal based on plain resteasy seems to me more readable and easier to maintain. I wonder what other think.
I wonder what key words we could search to find an existing library that would do this. Maybe a non reflective java serialization library.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1066894817
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/ClientBuilder.java:
##########
@@ -0,0 +1,875 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.aws2.cw.it;
+
+import java.util.function.Consumer;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.model.CloudWatchException;
+import software.amazon.awssdk.services.cloudwatch.model.ConcurrentModificationException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardInvalidInputErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardNotFoundErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageResponse;
+import software.amazon.awssdk.services.cloudwatch.model.InternalServiceException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidFormatException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidNextTokenException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterCombinationException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterValueException;
+import software.amazon.awssdk.services.cloudwatch.model.LimitExceededException;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.MissingRequiredParameterException;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ResourceNotFoundException;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateRequest;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmHistoryIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAnomalyDetectorsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.GetMetricDataIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListDashboardsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListManagedInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricStreamsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricsIterable;
+import software.amazon.awssdk.services.cloudwatch.waiters.CloudWatchWaiter;
+
+public class ClientBuilder {
+
+ @Inject
+ CamelContext camelContext;
+
+ @Produces
+ @Named("customClient")
+ CloudWatchClient produceClient() {
+
+ return new MockedClient();
+ }
+
+ @Produces
+ @Named("customClient2")
+ CloudWatchClient produceClient2() {
+ //second client is required to avoid autowiring of the first client if there is only one client
Review Comment:
Problem in camel prevents that -> fix was already proposed - https://issues.apache.org/jira/browse/CAMEL-18878
I reported an issue to remove this workaround once change in camel is consumed by cq. - https://github.com/apache/camel-quarkus/issues/4400
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1063425092
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwResource.java:
##########
@@ -61,4 +68,48 @@ public Response post(
.created(new URI("https://camel.apache.org/"))
.build();
}
+
+ @Path("/send-metric-map/{namespace}")
+ @POST
+ @Consumes("application/x-www-form-urlencoded")
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response postMap(
+ @PathParam("namespace") String namespace,
+ @HeaderParam("customClientName") String customClientName,
+ MultivaluedMap<String, String> formParams) throws Exception {
+
+ String uri = "aws2-cw://" + namespace;
+ uri = customClientName != null && !customClientName.isEmpty()
+ ? uri + "?autowiredEnabled=false&amazonCwClient=#" + customClientName : uri;
+
+ //use Instant as timestamp header
Review Comment:
Does this comment apply to the whole set of instructions below ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#issuecomment-1370828810
I agree with the simple solution with plain RESTeasy. Solution is straightforward and easily understandable.
I'll amend the change from https://github.com/ppalaga/camel-quarkus/commits/pr4345 into this PR. Do you agree, @aldettinger @ppalaga .
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1066892401
##########
integration-test-groups/aws2/aws2-cw/pom.xml:
##########
@@ -39,6 +39,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
Review Comment:
fixed
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1067839702
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/CloudWatchClientMock.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.cw;
+
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse;
+
+public class CloudWatchClientMock implements CloudWatchClient {
+
+ public CloudWatchClientMock() {
+ System.out.println(1);
Review Comment:
oh, I missed that, will be removed, thanls!
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1067814693
##########
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, String>> 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, "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,
Review Comment:
Looks it make sense. The real service is in need of real data.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050886513
##########
integration-test-groups/aws2/aws2-cw/pom.xml:
##########
@@ -39,6 +39,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
Review Comment:
Yes, we should come with an idea that improve the situation, if feasible. On top of my mind, I don't have much. Would passing a Map<String, String> works in plain text ? Maybe we could then add long/int as extra parameters... Not sure it would make it.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#issuecomment-1359415890
I created a jira ticket https://github.com/apache/camel-quarkus/issues/4353 for implementation of this idea separately.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1067822866
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/CloudWatchClientMock.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.cw;
+
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse;
+
+public class CloudWatchClientMock implements CloudWatchClient {
+
+ public CloudWatchClientMock() {
+ System.out.println(1);
Review Comment:
Maybe this println could be removed ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1063419833
##########
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, String>> 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, "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,
Review Comment:
`currentTimeMillis` unit is ms ? So, should we do 24h * 60 * 60s * 1000 instead of _10000_ ?
One step further, couldn't we simply put a fixed value ? That way we avoid variation in test execution ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050832303
##########
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:
@aldettinger Here is assertion for the result of the mocked client exception from previous comment.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#issuecomment-1359342758
Here is a commit with the serialization feature and its use in aws2-cw - 6c42c54aec56d7bbf9abc8488a02baa9aab5b0ca
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga commented on pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
ppalaga commented on PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#issuecomment-1368103637
I'd vote for keeping this as simple as possible. The serialization task gets a bit easier when we pass a single map per HTTP request instead of sending a list of maps at once. We can do that because we loop over the list-of-maps entries in the REST handler anyway. A map can be smuggled to plain RESTeasy in many ways: via QueryParams, Headers or URL-encoded body, which I tried to implement here: https://github.com/ppalaga/camel-quarkus/commits/pr4345 What do others think?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1063419833
##########
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, String>> 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, "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,
Review Comment:
`currentTimeMillis` unit is ms ? So, should we do 24h * 60 * 60s * 1000 instead of _10000_ ?
One step further, couldn't we simply put a fixed value instead of `currentTimeMillis()` ? That way we avoid variation in test execution ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050831620
##########
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:
I'm asserting the returned message in the test class. It doesn't feel good to call assert from runtime (not test) scope.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050834747
##########
integration-test-groups/aws2/aws2-cw/pom.xml:
##########
@@ -39,6 +39,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
Review Comment:
I agree that we should avoid using `quarkus-resteasy-jackson`. I'll refactor the code and then we can decide whether it is the right way to go.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050724047
##########
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:
Is there any specific reason to throw RuntimeException instead of using assert* methods ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1066932493
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwResource.java:
##########
@@ -61,4 +68,48 @@ public Response post(
.created(new URI("https://camel.apache.org/"))
.build();
}
+
+ @Path("/send-metric-map/{namespace}")
+ @POST
+ @Consumes("application/x-www-form-urlencoded")
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response postMap(
+ @PathParam("namespace") String namespace,
+ @HeaderParam("customClientName") String customClientName,
+ MultivaluedMap<String, String> formParams) throws Exception {
+
+ String uri = "aws2-cw://" + namespace;
+ uri = customClientName != null && !customClientName.isEmpty()
+ ? uri + "?autowiredEnabled=false&amazonCwClient=#" + customClientName : uri;
+
+ //use Instant as timestamp header
Review Comment:
removed
##########
integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/ClientBuilder.java:
##########
@@ -0,0 +1,875 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.aws2.cw.it;
+
+import java.util.function.Consumer;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.camel.CamelContext;
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
+import software.amazon.awssdk.services.cloudwatch.model.CloudWatchException;
+import software.amazon.awssdk.services.cloudwatch.model.ConcurrentModificationException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardInvalidInputErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DashboardNotFoundErrorException;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DeleteMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmHistoryResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsForMetricResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAlarmsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeAnomalyDetectorsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DescribeInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.DisableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableAlarmActionsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.EnableInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetInsightRuleReportResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageRequest;
+import software.amazon.awssdk.services.cloudwatch.model.GetMetricWidgetImageResponse;
+import software.amazon.awssdk.services.cloudwatch.model.InternalServiceException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidFormatException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidNextTokenException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterCombinationException;
+import software.amazon.awssdk.services.cloudwatch.model.InvalidParameterValueException;
+import software.amazon.awssdk.services.cloudwatch.model.LimitExceededException;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListDashboardsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListMetricsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.ListTagsForResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.MissingRequiredParameterException;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutAnomalyDetectorResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutCompositeAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutDashboardResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutInsightRuleResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutManagedInsightRulesResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricAlarmResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamRequest;
+import software.amazon.awssdk.services.cloudwatch.model.PutMetricStreamResponse;
+import software.amazon.awssdk.services.cloudwatch.model.ResourceNotFoundException;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateRequest;
+import software.amazon.awssdk.services.cloudwatch.model.SetAlarmStateResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StartMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsRequest;
+import software.amazon.awssdk.services.cloudwatch.model.StopMetricStreamsResponse;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.TagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceRequest;
+import software.amazon.awssdk.services.cloudwatch.model.UntagResourceResponse;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmHistoryIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAlarmsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeAnomalyDetectorsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.DescribeInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.GetMetricDataIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListDashboardsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListManagedInsightRulesIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricStreamsIterable;
+import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricsIterable;
+import software.amazon.awssdk.services.cloudwatch.waiters.CloudWatchWaiter;
+
+public class ClientBuilder {
+
+ @Inject
+ CamelContext camelContext;
+
+ @Produces
+ @Named("customClient")
+ CloudWatchClient produceClient() {
+
+ return new MockedClient();
+ }
+
+ @Produces
+ @Named("customClient2")
+ CloudWatchClient produceClient2() {
+ //second client is required to avoid autowiring of the first client if there is only one client
+ return new MockedClient();
+ }
+
+ class MockedClient implements CloudWatchClient {
Review Comment:
Good catch! fixed
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton merged pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
jamesnetherton merged PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1066932343
##########
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, String>> 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, "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,
Review Comment:
I fixed the test to use 24h * 60 * 60s * 1000.
I'm not sure whether using fixed value is the right approach here. What if real service somehow limits the timestamp-metric? (for example performance wise - to not save old data) I tried simple run with fixed time of 1970-01-06T19:04:15.080Z (long - 24 * 60 * 60 * 1000 * 1000) and execution with real service failed (local execution was successful). Therefore I think that using metrics as is supposed to be - using current time +/- 1 day is a correct way. What do you think, @aldettinger ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
aldettinger commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050729041
##########
integration-test-groups/aws2/aws2-cw/pom.xml:
##########
@@ -39,6 +39,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
Review Comment:
@ppalaga If I remember well, we try our best not to use `quarkus-resteasy-jackson` in tests because it registers some native reflections that could potentially hide bug in our extensions ? If yes, what could we advise in the test at hand ?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on a diff in pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on code in PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#discussion_r1050830595
##########
integration-test-groups/aws2/aws2-cw/pom.xml:
##########
@@ -39,6 +39,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
Review Comment:
@aldettinger I can refactor the test to use a "custom" serialization. I tried that in this case, but it seems like a potential cause of errors. Maybe we could add some kind of "util", "helper" class to serialize and deserialize maps into some test extension, what do you think?
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#issuecomment-1359341656
@aldettinger I created a helper class `SerializationUtil`, which is able to serialize/deserialize maps, list and some primitive types (String, integer, long).
I didn't find a right location for such code, so I created a simple module for it (without dependencies - to not affect native build). Helper method can be used by different modules.
@ppalaga , @jamesnetherton , @aldettinger Once we agreed that this kind of solution is acceptable, I'll add support to more primitive types and extend the test coverage. I'd like personally to create a separated issue for such feature and a separated PR for it. This is only a "working preview" to discuss whether we want to use this. I'm changing this PR to draft for above reasons.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] JiriOndrusek commented on pull request #4345: Expand AWS CW test coverage #4196
Posted by GitBox <gi...@apache.org>.
JiriOndrusek commented on PR #4345:
URL: https://github.com/apache/camel-quarkus/pull/4345#issuecomment-1370909500
Change is amended, thanks @ppalaga for the simple solution.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org