Skip to content

Commit

Permalink
Add ITAR Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sethAmazon committed Feb 21, 2024
1 parent 41a2168 commit ea1f5ef
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion generator/resources/ec2_linux_test_matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
{
"os": "al2023",
"username": "ec2-user",
"instanceType":"m7g.medium",
"instanceType":"m6g.medium",
"installAgentCommand": "go run ./install/install_agent.go rpm",
"ami": "cloudwatch-agent-integration-test-aarch64-al2023*",
"caCertPath": "/etc/ssl/certs/ca-bundle.crt",
Expand Down
42 changes: 37 additions & 5 deletions generator/test_case_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ package main
import (
"encoding/json"
"fmt"
"github.com/mitchellh/mapstructure"
"golang.org/x/exp/slices"
"io"
"log"
"os"

"github.com/mitchellh/mapstructure"
)

type matrixRow struct {
Expand Down Expand Up @@ -208,6 +208,29 @@ var testTypeToTestConfig = map[string][]testConfig{
},
}

type partition struct {
configName string
tests []string
ami []string
}

var partitionTests = map[string]partition{
"commercial": {
configName: "",
tests: []string{},
ami: []string{},
},
"itar": {
configName: "_itar",
tests: []string{testTypeKeyEc2Linux},
ami: []string{"cloudwatch-agent-integration-test-aarch64-al2023*"},
},
"china": {configName: "_china",
tests: []string{testTypeKeyEc2Linux},
ami: []string{"cloudwatch-agent-integration-test-aarch64-al2023*"},
},
}

func copyAllEC2LinuxTestForOnpremTesting() {
/* Some tests need to be fixed in order to run in both environment, so for now for PoC, run one that works.
testTypeToTestConfig["ec2_linux_onprem"] = testTypeToTestConfig[testTypeKeyEc2Linux]
Expand All @@ -224,12 +247,17 @@ func main() {
copyAllEC2LinuxTestForOnpremTesting()

for testType, testConfigs := range testTypeToTestConfig {
testMatrix := genMatrix(testType, testConfigs)
writeTestMatrixFile(testType, testMatrix)
for _, partition := range partitionTests {
if len(partition.tests) != 0 && !slices.Contains(partition.tests, testType) {
continue
}
testMatrix := genMatrix(testType, testConfigs, partition.ami)
writeTestMatrixFile(testType+partition.configName, testMatrix)
}
}
}

func genMatrix(testType string, testConfigs []testConfig) []matrixRow {
func genMatrix(testType string, testConfigs []testConfig, ami []string) []matrixRow {
openTestMatrix, err := os.Open(fmt.Sprintf("generator/resources/%v_test_matrix.json", testType))

if err != nil {
Expand Down Expand Up @@ -260,6 +288,10 @@ func genMatrix(testType string, testConfigs []testConfig) []matrixRow {
log.Panicf("can't decode map test %v to metric line struct with error %v", testConfig, err)
}

if len(ami) != 0 && !slices.Contains(ami, row.Ami) {
continue
}

if testConfig.targets == nil || shouldAddTest(&row, testConfig.targets) {
testMatrixComplete = append(testMatrixComplete, row)
}
Expand Down

0 comments on commit ea1f5ef

Please sign in to comment.