Skip to content

Commit c5718ec

Browse files
authored
Merge branch 'terraform' into merge-conflict-trace-validator
2 parents 085a0cf + 6e7afc9 commit c5718ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+909
-100
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ This is optional item, only do it if your goal is to add a component or fix a bu
3737

3838
4. find out the version number, click into the workflow page, click `e2etest-preparation` step, and click `Versioning for testing`, record the version number. Ex(v0.1.12-299946851).
3939

40-
5. provide your testing aws account id to Ying(wangmyin@), so that he will give permission to your aws account to fetch the testing image from a private ECR. [todo, once we migrate to dockerhub, you don't need this step]
41-
4240

4341
## 2. Run ECS Test
4442

@@ -48,7 +46,7 @@ This is optional item, only do it if your goal is to add a component or fix a bu
4846
cd terraform/ecs && terraform init && terraform apply -var-file="../testing-suites/statsd-ecs.tfvars"
4947
```
5048

51-
### 2.1 run with a specific aoc version
49+
### 2.2 run with a specific aoc version if you have done 1.4
5250

5351
```shell
5452
cd terraform/ecs && terraform init && terraform apply -var-file="../testing-suites/statsd-ecs.tfvars" -var="aoc_version={the version you got from workflow}"
@@ -61,35 +59,35 @@ cd terraform/ecs && terraform destory"
6159
```
6260
## 3. Run EC2
6361
64-
### 3.1 run with the testing suite [only amazonlinux2 is supported at this moment]
62+
### 3.1 run with the testing suite [support amazonlinux2, ubuntu16, windows2019]
6563
6664
```shell
67-
cd terraform/ec2 && terraform init && terraform apply -var="sshkey_s3_bucket={the bucket name you set in setup}" -var-file="../testing-suites/statsd-ec2.tfvars"
65+
cd terraform/ec2 && terraform init && terraform apply -var="testing_ami=amazonlinux2" -var="sshkey_s3_bucket={the bucket name you set in setup}" -var-file="../testing-suites/statsd-ec2.tfvars"
6866
```
6967
70-
### 3.2 run with a specfic aoc version
68+
### 3.2 run with a specfic aoc version if you have done 1.4
7169
7270
7371
```shell
7472
cd terraform/ec2 && terraform init && terraform apply -var="sshkey_s3_bucket={the bucket name you set in setup}" -var-file="../testing-suites/statsd-ec2.tfvars" -var="aoc_version={the version you got from workflow}"
7573
```
7674
77-
### 3.3 don't forget to clean the resources
75+
### 3.3 don't forget to clean the resources
7876
```shell
79-
cd terraform/ec2 && terraform destory"
77+
cd terraform/ec2 && terraform destory
8078
```
8179
8280
## 4. Run EKS
8381
84-
create a eks cluster in your account before run below command
82+
please note you are required to create a eks cluster in your account before running below command
8583
8684
### 4.1 run with the testing suite
8785
8886
```shell
8987
cd terraform/eks && terraform init && terraform apply -var="eks_cluster_name={the eks cluster name in your account}" -var-file="../testing-suites/statsd-eks.tfvars"
9088
```
9189
92-
### 4.2 run with a specfic aoc version
90+
### 4.2 run with a specfic aoc version if you have done 1.4
9391
9492
```shell
9593
cd terraform/eks && terraform init && terraform apply -var="eks_cluster_name={the eks cluster name in your account}" -var-file="../testing-suites/statsd-eks.tfvars" -var="aoc_version={the version you got from workflow}"

integ-test/src/main/java/com/amazon/aocagent/validators/MetricValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
@Log4j2
4343
public class MetricValidator implements IValidator {
4444
private static int MAX_RETRY_COUNT = 60;
45-
private static final String DEFAULT_DIMENSION_NAME = "OTLib";
45+
private static final String DEFAULT_DIMENSION_NAME = "OTelLib";
4646
private static final String DEFAULT_DIMENSION_VALUE = "cloudwatch-otel";
4747

4848
private MustacheHelper mustacheHelper = new MustacheHelper();

terraform/README.md

Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1-
## 1. Add a testing suite
1+
# How to add a testing suite to the framework
22

3-
please add a new tfvars file under `terraform/testing-suites` folder, each tfvar file represent a testing suite.
3+
## 1. Basic concepts
44

5-
### 1.1 add an ecs testing suite
5+
There're some concepts you might want to learn before starting to add your testing suite.
6+
7+
### 1.1 the workflow of the testing framework
8+
9+
the testing framework is built based on terraform, every time you run your testing suite, it will
10+
11+
1. **Create resources** Create the related resources in your aws account, such as, ec2 instance/ecs cluster.
12+
2. **Install softwares** Install AWS Otel Collector/sample apps onto it and start it base on the configurations you provide.
13+
3. **Validate data** Validate the data by fetching them from backend(CloudWatch, XRay) base on the validation config you provide.
14+
15+
16+
### 1.2 Testing Suite
17+
18+
each file with suffix ".tfvar" under folder `terraform/testing-suites` will be treated as a testing suite, each testing suite defines different otconfig, validation_config, and deployment config based on different platform.Ex(taskdef for ECS)
19+
20+
### 1.3 AOC Version
21+
22+
`aoc_version` is a parameter you can use while running the testing-suite, which tells the testing framework to fetch the AWS Otel Collector with this version, this parameter is useful especially when you create a PR to AWS Otel Collector, which will build a version to you with your unmerged code, so that you can test your "new code" with your new testing suite.
23+
24+
### 1.4 Testing Id
25+
26+
`testing_id` is a placeholder that you can use in your configuration, which is a unique id representing each run of the testing suite. You can use this testing id as part of your metric name, or dimension name, to ensure the metric emitted from each run of the testing suite is different, so that the validation will always validate on your new metric.
27+
28+
29+
## 2. Add a testing suite
30+
31+
please add a new tfvars file under `terraform/testing-suites` folder, each tfvar file represent a testing suite.
32+
33+
### 2.1 add an ecs testing suite
634

735
specify below config in the tfvars file
836
1. otconfig_path, please put a new otconfig file under `terraform/templates/otconfig` folder and specify the path in the tfvars file.
@@ -13,24 +41,47 @@ specify below config in the tfvars file
1341
6. [optional] aoc_image_repo, if you have an aoc image you just built with the new component, then set its repo name here
1442
7. [optional] aoc_version, if you have an aoc image you just built with the new component, then set it as its tag name.
1543

16-
### 1.2 add an ec2 testing suite
44+
an example here:
45+
46+
```shell
47+
sample_app_callable = false
48+
49+
otconfig_path="../template/otconfig/statsd_otconfig.tpl"
50+
ecs_taskdef_path="../template/ecstaskdef/statsd_taskdef.tpl"
51+
52+
# this file is defined in validator/src/main/resources/validations
53+
validation_config="statsd-metric-validation.yml"
54+
55+
data_emitter_image="alpine/socat:latest"
56+
```
57+
58+
### 2.2 add an ec2 testing suite
1759

1860
specify below config in the tfvars file
1961
1. otconfig_path, please put a new otconfig file under `terraform/templates/otconfig` folder and specify the path in the tfvars file.
2062
2. docker_compose_path, please put a new docker compose file under `terraform/templates/ec2-docker-compose-config` folder and specify the path in the tfvars file.
2163
3. validation_config, please put a new validation config file under `validator/src/main/resources/validations` folder and specify the filename in the tfvars file.
2264
4. [optional] sample_app_callable, by default it's true, only set it to false when you don't have a web application sample app image
2365
5. [optional] data_emitter_image, if you have a sample app then set its image name here
24-
6. [optional] package_s3_bucket, if you have an aoc rpm/deb/msi built with the new component, and uploaded it to s3, then set its s3 bucket name here.
2566
7. [optional] aoc_version, if you have an aoc rpm/dev/msi you just built with the new component, then set it as its tag name.
2667

27-
please note the rpm/dev/msi s3 object path should be
68+
an example here:
2869

2970
```shell
30-
/amazon_linux/amd64/${aoc_version}/aws-observability-collector.rpm/deb/msi
71+
sample_app_callable = false
72+
73+
otconfig_path="../template/otconfig/statsd_otconfig.tpl"
74+
75+
docker_compose_path="../template/ec2-docker-compose-config"
76+
77+
# this file is defined in validator/src/main/resources/validations
78+
validation_config="statsd-metric-validation.yml"
79+
80+
data_emitter_image="alpine/socat:latest"
3181
```
3282

33-
### 1.3 add an eks testing suite
83+
84+
### 2.3 add an eks testing suite
3485

3586
specify below config in the tfvars file
3687
1. otconfig_path, please put a new otconfig file under `terraform/templates/otconfig` folder and specify the path in the tfvars file.
@@ -41,9 +92,23 @@ specify below config in the tfvars file
4192
6. [optional] aoc_image_repo, if you have an aoc image you just built with the new component, then set its repo name here
4293
7. [optional] aoc_version, if you have an aoc image you just built with the new component, then set it as its tag name.
4394

44-
### 1.4 how to write the configurations?
95+
```shell
96+
sample_app_callable = false
97+
98+
otconfig_path="../template/otconfig/statsd_otconfig.tpl"
99+
eks_pod_config_path="../template/eks-pod-config/statsd-eks-config.tpl"
100+
101+
# this file is defined in validator/src/main/resources/validations
102+
validation_config="statsd-metric-validation.yml"
103+
104+
data_emitter_image="alpine/socat:latest"
105+
```
106+
107+
### 3 how to write the configurations?
108+
109+
You are able to use placeholders in your configuration files, the testing framework will replace the placeholders with its runtime value when you run the testing suite.
45110

46-
#### 1.4.1 otconfig
111+
#### 3.1 otconfig
47112

48113
Below are the placeholders you can use in the otconfig
49114

@@ -71,7 +136,7 @@ service:
71136
exporters: [logging, awsemf]
72137
```
73138
74-
#### 1.4.2 ecs task definition
139+
#### 3.2 ecs task definition
75140
76141
Below are the placeholders you can use in the ecs task def.
77142
@@ -185,7 +250,7 @@ an example:
185250
]
186251
```
187252

188-
#### 1.4.3 Docker compose file
253+
#### 3.3 Docker compose file
189254

190255
Below are the placeholders you can use in the docker compose file
191256

@@ -218,7 +283,7 @@ services:
218283
start_period: 10s
219284
```
220285
221-
#### 1.4.4 Eks Config
286+
#### 3.4 Eks Config
222287
223288
Below are the placeholders you can use in the EKS config.
224289
@@ -237,7 +302,7 @@ sample_app:
237302
args: []
238303
```
239304
240-
#### 1.4.5 Validation config.
305+
#### 3.5 Validation config.
241306
242307
An example for validation config.
243308
@@ -269,6 +334,10 @@ Below are the placeholders you can use in the expected data pattern.
269334

270335
* metricNamespace
271336
* testingId
337+
* ecsContext.ecsClusterName
338+
* ecsContext.ecsTaskArn
339+
* ecsContext.ecsTaskDefFamily
340+
* ecsContext.ecsTaskDefVersion
272341

273342
an example:
274343

@@ -278,7 +347,7 @@ an example:
278347
namespace: {{metricNamespace}}
279348
dimensions:
280349
-
281-
name: OTLib
350+
name: OTelLib
282351
value: cloudwatch-otel
283352
-
284353
name: apiName
@@ -291,7 +360,7 @@ an example:
291360
namespace: {{metricNamespace}}
292361
dimensions:
293362
-
294-
name: OTLib
363+
name: OTelLib
295364
value: cloudwatch-otel
296365
-
297366
name: apiName
@@ -304,7 +373,7 @@ an example:
304373
namespace: {{metricNamespace}}
305374
dimensions:
306375
-
307-
name: OTLib
376+
name: OTelLib
308377
value: cloudwatch-otel
309378
-
310379
name: apiName
@@ -317,7 +386,7 @@ an example:
317386
namespace: {{metricNamespace}}
318387
dimensions:
319388
-
320-
name: OTLib
389+
name: OTelLib
321390
value: cloudwatch-otel
322391
-
323392
name: apiName
@@ -328,7 +397,7 @@ an example:
328397
```
329398

330399

331-
## 2. Build Sample App
400+
## 4. Build Sample App
332401

333402
For any testing suite related with sdk, you are required to build a sample app.
334403

@@ -355,7 +424,7 @@ Environment Variable: There will be some env vars which will be set while runnin
355424

356425
* Keep “/” accessible with response code 200.: This “/” will be used for the load balancer health check.
357426

358-
## 3. configure the testing suite in github workflow
427+
## 5. configure the testing suite in github workflow
359428

360429
below is an example in the aoc repo workflow, you can also configure it in your sdk repos.
361430

terraform/basic_components/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# ------------------------------------------------------------------------
2+
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
# -------------------------------------------------------------------------
15+
116
module "common" {
217
source = "../common"
318
}

terraform/basic_components/outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# ------------------------------------------------------------------------
2+
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
# -------------------------------------------------------------------------
15+
116
output "aoc_vpc_id" {
217
value = data.aws_vpc.aoc_vpc.id
318
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# ------------------------------------------------------------------------
2+
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
# -------------------------------------------------------------------------
15+
116
variable "region" {
217
default = "us-west-2"
318
}

terraform/common/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# ------------------------------------------------------------------------
2+
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
# -------------------------------------------------------------------------
15+
116
# generate a testing_id whenever people want to use, for example, use it as a ecs cluster to prevent cluster name conflict
217
resource "random_id" "testing_id" {
318
byte_length = 8

terraform/common/outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# ------------------------------------------------------------------------
2+
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
# -------------------------------------------------------------------------
15+
116
output "testing_id" {
217
value = random_id.testing_id.hex
318
}

0 commit comments

Comments
 (0)