Skip to content

Commit 22c675f

Browse files
committed
support ecs context parameter
1 parent 59e4e70 commit 22c675f

File tree

6 files changed

+40
-8
lines changed

6 files changed

+40
-8
lines changed

terraform/ecs/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ resource "aws_ecs_service" "aoc_without_sample_app" {
175175

176176
provisioner "local-exec" {
177177
working_dir = "../../"
178-
command = "${module.common.validator_path} --args='-c ${var.validation_config} -t ${module.common.testing_id} --region ${var.region} --metric-namespace ${module.common.otel_service_namespace}/${module.common.otel_service_name}'"
178+
command = "${module.common.validator_path} --args='-c ${var.validation_config} -t ${module.common.testing_id} --region ${var.region} --metric-namespace ${module.common.otel_service_namespace}/${module.common.otel_service_name} --ecs-context ecsClusterName=${module.ecs_cluster.cluster_name} --ecs-context ecsTaskArn=${aws_ecs_task_definition.aoc.arn} --ecs-context ecsTaskDefFamily=${aws_ecs_task_definition.aoc.family} --ecs-context ecsTaskDefVersion=${aws_ecs_task_definition.aoc.revision}'"
179179
}
180180
}
181181

terraform/testing-suites/xrayreceiver-ecs.tfvars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ validation_config="xrayreceiver-trace-validation.yml"
77
data_emitter_image="josephwy/integ-test-emitter:xrayreceiver"
88

99
# todo this is config needs to be removed once we have statsd built in the aoc image
10-
aoc_image_repo="johnwu20/aocimage"
10+
aoc_image_repo="josephwy/awscollector"
1111

1212
# todo this version needs to be removed, instead version should be received from workflow
13-
aoc_version="v0.1.0"
13+
aoc_version="xray"
1414

validator/src/main/java/com/amazon/aoc/App.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
import com.amazon.aoc.helpers.ConfigLoadHelper;
44
import com.amazon.aoc.models.Context;
5+
import com.amazon.aoc.models.ECSContext;
56
import com.amazon.aoc.models.ValidationConfig;
67
import com.amazon.aoc.validators.ValidatorFactory;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
79
import lombok.extern.log4j.Log4j2;
810
import picocli.CommandLine;
911

1012
import java.util.List;
13+
import java.util.Map;
1114
import java.util.concurrent.Callable;
1215

1316
@CommandLine.Command(name = "e2etest", mixinStandardHelpOptions = true, version = "1.0")
@@ -35,6 +38,12 @@ public class App implements Callable<Integer> {
3538
defaultValue = "us-west-2")
3639
private String region;
3740

41+
@CommandLine.Option(
42+
names = {"--ecs-context"},
43+
description = "eg, --ecs-context ecsCluster=xxx --ecs-context ecsTaskArn=xxxx"
44+
)
45+
private Map<String, String> ecsContexts;
46+
3847
public static void main(String[] args) throws Exception {
3948
int exitCode = new CommandLine(new App()).execute(args);
4049
System.exit(exitCode);
@@ -49,6 +58,8 @@ public Integer call() throws Exception {
4958
// build context
5059
Context context = new Context(this.testingId, this.metricNamespace, this.region);
5160
context.setEndpoint(this.endpoint);
61+
context.setEcsContext(buildECSContext(ecsContexts));
62+
5263
log.info(context);
5364

5465
// run validation
@@ -58,4 +69,11 @@ public Integer call() throws Exception {
5869
}
5970
return null;
6071
}
72+
73+
private ECSContext buildECSContext(Map<String, String> ecsContextMap){
74+
if(ecsContextMap == null) {
75+
return null;
76+
}
77+
return new ObjectMapper().convertValue(ecsContextMap, ECSContext.class);
78+
}
6179
}

validator/src/main/java/com/amazon/aoc/models/Context.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ public class Context {
2727
@NonNull private String region;
2828

2929
private String endpoint;
30+
31+
private ECSContext ecsContext;
3032
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.amazon.aoc.models;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public class ECSContext {
7+
// ecs related context
8+
private String ecsClusterName;
9+
private String ecsTaskArn;
10+
private String ecsTaskDefFamily;
11+
private String ecsTaskDefVersion;
12+
}

validator/src/main/resources/expected-data-template/ecsContainerExpectedMetric.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
value: Undefined
88
-
99
name: ecs.cluster
10-
value: "{{ecsClusterName}}"
10+
value: "{{ecsContext.ecsClusterName}}"
1111
-
1212
name: ecs.service
1313
value: "undefined"
1414
-
1515
name: ecs.task-arn
16-
value: "{{ecsTaskArn}}"
16+
value: "{{ecsContext.ecsTaskArn}}"
1717
-
1818
name: ecs.task-definition-family
19-
value: "{{ecsTaskDefFamily}}"
19+
value: "{{ecsContext.ecsTaskDefFamily}}"
2020
-
2121
name: ecs.task-definition-version
22-
value: "{{ecsTaskDefVersion}}"
22+
value: "{{ecsContext.ecsTaskDefVersion}}"
2323
-
2424
name: ecs.task-id
25-
value: "{{ecsTaskId}}"
25+
value: ""

0 commit comments

Comments
 (0)