From dd40473661392c9103c83e7b1175897cb67eefcb Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 17 Jun 2022 20:58:57 +0000 Subject: [PATCH 001/122] Basic functionality for backend transmitter --- .../transmitter/transmitter.go | 237 ++++++++++++++++++ .../transmitter/transmitterTest.go | 67 +++++ 2 files changed, 304 insertions(+) create mode 100644 integration/test/performance_tracker/transmitter/transmitter.go create mode 100644 integration/test/performance_tracker/transmitter/transmitterTest.go diff --git a/integration/test/performance_tracker/transmitter/transmitter.go b/integration/test/performance_tracker/transmitter/transmitter.go new file mode 100644 index 0000000000..30fd30101e --- /dev/null +++ b/integration/test/performance_tracker/transmitter/transmitter.go @@ -0,0 +1,237 @@ +package transmitter + +import ( + "encoding/json" + "fmt" + "math" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/dynamodb" + "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" + "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" +) +const( + TIME_CONSTANT = 300.0 // this const is in seconds , 5 mins +) +type TransmitterAPI struct{ + DynamoDbClient dynamodbiface.DynamoDBAPI + DataBaseName string // this is the name of the table when test is run +} +// this is the packet that will be sent converted to DynamoItem +type Metric struct{ + Average float64 + StandardDev float64 + Period int //in seconds + Data []float64 +} + +type collectorData []struct{ // this is the struct data collector passes in + Id string `json:"Id"` + Label string `json:Label` + Messages string `json:Messages` + StatusCode string `json:StatusCode` + Timestamps []string `json:Timestamps` + Values []float64 `json:Values` +} + + +/* +InitializeTransmitterAPI +Desc: Initializes the transmitter class +Side effects: Can create a dynamodb table +*/ +func InitializeTransmitterAPI(DataBaseName string) * TransmitterAPI{ + transmitter := new(TransmitterAPI) + //setup aws session + session := session.Must(session.NewSessionWithOptions(session.Options{ + SharedConfigState: session.SharedConfigEnable, + })) + transmitter.DynamoDbClient = dynamodb.New(session) + transmitter.DataBaseName = DataBaseName //fmt.Sprintf("%d",int(time.Now().UnixNano())) + // check if the dynamo table exist if not create it + tableExist, err:= transmitter.TableExist() + if err !=nil{ + return nil + } + if !tableExist{ + fmt.Println("Table doesn't exist") + err := transmitter.CreateTable() + if err != nil{ + fmt.Println("Couldn't create table") + return nil + } + } + fmt.Println("API ready") + return transmitter + +} +/* +CreateTable() +Desc: Will create a DynamoDB Table with given param. and config +Params: +Side Effects: Creates a dynamoDB table +*/ +func (transmitter * TransmitterAPI) CreateTable() error{ + input := &dynamodb.CreateTableInput{ + AttributeDefinitions: []*dynamodb.AttributeDefinition{ + { + AttributeName: aws.String("Hash"), + AttributeType: aws.String("S"), + }, + }, + KeySchema: []*dynamodb.KeySchemaElement{ + { + AttributeName: aws.String("Hash"), + KeyType: aws.String("HASH"), + }, + }, + ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ + ReadCapacityUnits: aws.Int64(10), + WriteCapacityUnits: aws.Int64(10), + }, + TableName: aws.String(transmitter.DataBaseName), + } // this is the config for the new table + + _, err := transmitter.DynamoDbClient.CreateTable(input) + if err != nil { + fmt.Printf("Got error calling CreateTable: %s", err) + return err + } + + fmt.Println("Created the table", transmitter.DataBaseName) + return nil +} +/* +AddItem() +Desc: Takes in a packet and +will convert to dynamodb format and upload to dynamodb table. +Param: + packet * map[string]interface{}: is a map with data collection data +Side effects: + Adds an item to dynamodb table +*/ +func (transmitter * TransmitterAPI) AddItem(packet map[string]interface{})(string,error){ + // fmt.Printf("Packet: %+v \n",packet) + // metrics, _ := dynamodbattribute.MarshalMap(packet.Metrics) + // fmt.Printf("Metric: %+v \n OG:%+v \n",metrics, packet.Metrics) + item, err := dynamodbattribute.MarshalMap(packet) + if err != nil { + panic(err) + } + DBitem := &dynamodb.PutItemInput{ + Item: item, + TableName: aws.String(transmitter.DataBaseName), + } + // fmt.Println(DBitem) + // return err + _, err = transmitter.DynamoDbClient.PutItem(DBitem) + if err != nil { + fmt.Printf("Couldn't add item to table. Here's why: %v\n", err) + } + return fmt.Sprintf("%v",item),err +} +/* +TableExist() +Desc: Checks if the the table exist and returns the value +//https://github.com/awsdocs/aws-doc-sdk-examples/blob/05a89da8c2f2e40781429a7c34cf2f2b9ae35f89/gov2/dynamodb/actions/table_basics.go +*/ +func (transmitter * TransmitterAPI) TableExist() (bool,error){ + l,err := transmitter.ListTables() + for i:=0; i< len(l); i++{ + if transmitter.DataBaseName == l[i]{ + return true,nil + } + } + return false,err + +} +/* +RemoveTable() +Desc: Removes the table that was craeted with initialization. +Side effects: Removes a Dynamodb table +*/ +func (transmitter * TransmitterAPI) RemoveTable() error{ + input := dynamodb.DeleteTableInput{TableName: aws.String(transmitter.DataBaseName)} + + _,err:=transmitter.DynamoDbClient.DeleteTable(&input) + if err !=nil{ + fmt.Println(err) + } + return err +} +// ListTables lists the DynamoDB table names for the current account. +func (transmitter * TransmitterAPI) ListTables() ([]string, error) { + var tableNames []string + input := &dynamodb.ListTablesInput{} + tables, err := transmitter.DynamoDbClient.ListTables( + input) + if err != nil { + fmt.Printf("Couldn't list tables. Here's why: %v\n", err) + } else { + for i:=0; i< len(tables.TableNames); i++{ + tableNames = append(tableNames,*tables.TableNames[i]) + } + + } + return tableNames, err +} + +func (transmitter * TransmitterAPI) SendItem(data []byte) (string,error) { + // return nil + packet, err := transmitter.Parser(data) + if err != nil{ + return "",err + } + sentItem,err := transmitter.AddItem(packet) + return sentItem,err +} + +func (transmitter * TransmitterAPI) Parser(data []byte) (map[string]interface{},error){ + dataHolder := collectorData{} + err := json.Unmarshal(data,&dataHolder) + if err !=nil{ + return nil,err + } + packet := make(map[string]interface{}) + //temp solution + packet["Hash"] = fmt.Sprintf("%d",time.Now().UnixNano()) + /// will remove + for _,rawMetricData:= range dataHolder{ + numDataPoints := float64(len(rawMetricData.Timestamps)) + sum :=0.0 + for _,val := range rawMetricData.Values { + sum += val + } + avg := sum /numDataPoints + // calculate diff between mean and values + diffSum := 0.0 + for _,val := range rawMetricData.Values{ + diffSum = diffSum + (avg - val) + } + + metric := Metric{ + Average: avg, + StandardDev: math.Sqrt(math.Pow(diffSum,2)/float64(numDataPoints)), + Period: int(TIME_CONSTANT/(numDataPoints)), + Data: rawMetricData.Values} + // fmt.Printf("%+v\n",metric) + // packet.Metrics[rawMetricData.Label] = metric + packet[rawMetricData.Label] = metric + + + } + return packet,nil +} + +func testFiller(testname string) * TransmitterAPI{ + transmitter := new(TransmitterAPI) + //setup aws session + session := session.Must(session.NewSessionWithOptions(session.Options{ + SharedConfigState: session.SharedConfigEnable, + })) + transmitter.DynamoDbClient = dynamodb.New(session) + transmitter.DataBaseName = testname + return transmitter +} \ No newline at end of file diff --git a/integration/test/performance_tracker/transmitter/transmitterTest.go b/integration/test/performance_tracker/transmitter/transmitterTest.go new file mode 100644 index 0000000000..ec356820ed --- /dev/null +++ b/integration/test/performance_tracker/transmitter/transmitterTest.go @@ -0,0 +1,67 @@ +package transmitter +import ( + "testing" + "time" + "fmt" + "os" + "os/exec" +) +/* +TestTableGeneration +Desc: This test checks if a dynamodb table can be created succesfully +Check: After creating the table it checks by checking if it is listed in all tables. +Fail: It can fail if table cannot be create or removed +*/ +func TestTableGeneration(t * testing.T){ + testname := "TestTableGeneration" + transmitter := testFiller(testname) + transmitter.DataBaseName = testname + + err := transmitter.CreateTable() + if err != nil{ + t.Errorf("Couldn't create table") + } + + time.Sleep(7 * time.Second) // gives time for table generation to compelete + l,_ := transmitter.ListTables() + t.Log(l) + //add cleanup + err = transmitter.RemoveTable() + if err !=nil{ + t.Errorf("Couldnt remove the table") + } + time.Sleep(2 * time.Second) + +} +/* +TestTransmitterInit +Desc: This test checks if a transmitter class can be initialized succesfully +Check: After initialization it checks if the object is nil or not +Fail: If the object is nil it fails +*/ +func TestTransmitterInit(t * testing.T){ + transmitter := InitializeTransmitterAPI("TestTransmitterInit") + if transmitter == nil{ + t.Errorf("Couldnt generate transmitter") + }else if transmitter.DynamoDbClient == nil{ + t.Errorf("Couldnt generate transmitter") + } + time.Sleep(10 * time.Second) + transmitter.RemoveTable() +} +/* +TestParser +Desc: This test checks if a transmitter parser can succesfully parse and create a struct. +Check: Checks if map was created. +Fail: If the object is nil it fails +*/ +func TestParser(t * testing.T){ + filedata ,_ := os.ReadFile("../data_collector/data.json") + // t.Errorf(string(filedata)) + transmitter :=testFiller("TestParser") + parsedText,err:= transmitter.Parser(filedata) + if err !=nil{ + t.Errorf("Couldnt parse") + } + fmt.Printf("%+v\n",parsedText) +} From 978926581f0044451507642b4adf619cb81ac37a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 14:29:49 +0000 Subject: [PATCH 002/122] removed unit tests --- .../transmitter/transmitterTest.go | 67 ------------------- 1 file changed, 67 deletions(-) delete mode 100644 integration/test/performance_tracker/transmitter/transmitterTest.go diff --git a/integration/test/performance_tracker/transmitter/transmitterTest.go b/integration/test/performance_tracker/transmitter/transmitterTest.go deleted file mode 100644 index ec356820ed..0000000000 --- a/integration/test/performance_tracker/transmitter/transmitterTest.go +++ /dev/null @@ -1,67 +0,0 @@ -package transmitter -import ( - "testing" - "time" - "fmt" - "os" - "os/exec" -) -/* -TestTableGeneration -Desc: This test checks if a dynamodb table can be created succesfully -Check: After creating the table it checks by checking if it is listed in all tables. -Fail: It can fail if table cannot be create or removed -*/ -func TestTableGeneration(t * testing.T){ - testname := "TestTableGeneration" - transmitter := testFiller(testname) - transmitter.DataBaseName = testname - - err := transmitter.CreateTable() - if err != nil{ - t.Errorf("Couldn't create table") - } - - time.Sleep(7 * time.Second) // gives time for table generation to compelete - l,_ := transmitter.ListTables() - t.Log(l) - //add cleanup - err = transmitter.RemoveTable() - if err !=nil{ - t.Errorf("Couldnt remove the table") - } - time.Sleep(2 * time.Second) - -} -/* -TestTransmitterInit -Desc: This test checks if a transmitter class can be initialized succesfully -Check: After initialization it checks if the object is nil or not -Fail: If the object is nil it fails -*/ -func TestTransmitterInit(t * testing.T){ - transmitter := InitializeTransmitterAPI("TestTransmitterInit") - if transmitter == nil{ - t.Errorf("Couldnt generate transmitter") - }else if transmitter.DynamoDbClient == nil{ - t.Errorf("Couldnt generate transmitter") - } - time.Sleep(10 * time.Second) - transmitter.RemoveTable() -} -/* -TestParser -Desc: This test checks if a transmitter parser can succesfully parse and create a struct. -Check: Checks if map was created. -Fail: If the object is nil it fails -*/ -func TestParser(t * testing.T){ - filedata ,_ := os.ReadFile("../data_collector/data.json") - // t.Errorf(string(filedata)) - transmitter :=testFiller("TestParser") - parsedText,err:= transmitter.Parser(filedata) - if err !=nil{ - t.Errorf("Couldnt parse") - } - fmt.Printf("%+v\n",parsedText) -} From 9aa220e235dcd0d02d060e96c6313c40b60ee6c4 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 18:13:48 +0000 Subject: [PATCH 003/122] playing around with github --- .github/workflows/integrationTest.yml | 23 ++++++++++++++++++- .../test/performance_tracker/mainTest.go | 6 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 integration/test/performance_tracker/mainTest.go diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 3c65c63fd9..51df0fa2bc 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -615,4 +615,25 @@ jobs: max_attempts: 3 timeout_minutes: 8 retry_wait_seconds: 5 - command: cd integration/terraform/ecs/linux && terraform destroy --auto-approve \ No newline at end of file + command: cd integration/terraform/ecs/linux && terraform destroy --auto-approve + + PerformanceTrackingTest: + name: "PerformanceTrackingTest" + runs-on: ubuntu-latest + defaults: + run: + working-directory: integration/test/performance_tracker + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: RunTest + run: > + go run mainTest.go + diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go new file mode 100644 index 0000000000..a02c44ecb0 --- /dev/null +++ b/integration/test/performance_tracker/mainTest.go @@ -0,0 +1,6 @@ +package performancetracker +import "fmt" + +func main(){ + fmt.Println("Hello World") +} \ No newline at end of file From ca0a2e6745dab555ba16b3819edd3e4880cc0c4b Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 18:16:27 +0000 Subject: [PATCH 004/122] changed package name --- integration/test/performance_tracker/mainTest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index a02c44ecb0..a36368e169 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -1,4 +1,4 @@ -package performancetracker +package main import "fmt" func main(){ From 28dd6a8ef03cff6cd7e909c7068953439ba36ec2 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 18:18:55 +0000 Subject: [PATCH 005/122] seperated the test case --- .github/workflows/performance-test.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/performance-test.yml diff --git a/.github/workflows/performance-test.yml b/.github/workflows/performance-test.yml new file mode 100644 index 0000000000..433be58924 --- /dev/null +++ b/.github/workflows/performance-test.yml @@ -0,0 +1,19 @@ + PerformanceTrackingTest: + name: "PerformanceTrackingTest" + runs-on: ubuntu-latest + defaults: + run: + working-directory: integration/test/performance_tracker + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: RunTest + run: > + go run mainTest.go \ No newline at end of file From 9d12491b38144ce7a98f14d815461d80edd204ca Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 18:21:07 +0000 Subject: [PATCH 006/122] reformatted --- .github/workflows/performance-test.yml | 55 ++++++++++++++++++-------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/.github/workflows/performance-test.yml b/.github/workflows/performance-test.yml index 433be58924..d6e3d96aff 100644 --- a/.github/workflows/performance-test.yml +++ b/.github/workflows/performance-test.yml @@ -1,19 +1,40 @@ - PerformanceTrackingTest: - name: "PerformanceTrackingTest" - runs-on: ubuntu-latest - defaults: - run: - working-directory: integration/test/performance_tracker - steps: - - uses: actions/checkout@v2 +name: "PerformanceTrackingTest" +env: + PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }} + TERRAFORM_AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + TERRAFORM_AWS_SECRET_ACCESS_KEY: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + S3_INTEGRATION_BUCKET: ${{ secrets.S3_INTEGRATION_BUCKET }} + KEY_NAME: ${{ secrets.KEY_NAME }} + VPC_SECURITY_GROUPS_IDS: ${{ secrets.VPC_SECURITY_GROUPS_IDS }} + IAM_ROLE: ${{ secrets.IAM_ROLE }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} + GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} + GPG_TTY: $(tty) + ECR_INTEGRATION_TEST_REPO: "cwagent-integration-test" - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 +on: + push: + branches: + - master - - name: RunTest - run: > - go run mainTest.go \ No newline at end of file +runs-on: ubuntu-latest +defaults: + run: + working-directory: integration/test/performance_tracker +steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: RunTest + run: > + go run mainTest.go + + + \ No newline at end of file From bdaba05b5be9f4aac5a29778be1a30feee13d165 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 18:23:48 +0000 Subject: [PATCH 007/122] removed seperate test --- .github/workflows/performance-test.yml | 40 -------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .github/workflows/performance-test.yml diff --git a/.github/workflows/performance-test.yml b/.github/workflows/performance-test.yml deleted file mode 100644 index d6e3d96aff..0000000000 --- a/.github/workflows/performance-test.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: "PerformanceTrackingTest" -env: - PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }} - TERRAFORM_AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} - TERRAFORM_AWS_SECRET_ACCESS_KEY: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} - S3_INTEGRATION_BUCKET: ${{ secrets.S3_INTEGRATION_BUCKET }} - KEY_NAME: ${{ secrets.KEY_NAME }} - VPC_SECURITY_GROUPS_IDS: ${{ secrets.VPC_SECURITY_GROUPS_IDS }} - IAM_ROLE: ${{ secrets.IAM_ROLE }} - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - PASSPHRASE: ${{ secrets.PASSPHRASE }} - GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} - GPG_TTY: $(tty) - ECR_INTEGRATION_TEST_REPO: "cwagent-integration-test" - -on: - push: - branches: - - master - -runs-on: ubuntu-latest -defaults: - run: - working-directory: integration/test/performance_tracker -steps: - - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - - name: RunTest - run: > - go run mainTest.go - - - \ No newline at end of file From ebf886392fbbaacdacca7506071ea1656f3e91a6 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 18:35:44 +0000 Subject: [PATCH 008/122] changed package --- .github/workflows/integrationTest.yml | 2 +- integration/test/performance_tracker/mainTest.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 51df0fa2bc..80b9089be3 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -635,5 +635,5 @@ jobs: - name: RunTest run: > - go run mainTest.go + go test performance_tracker diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index a36368e169..34eefc959c 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -1,6 +1,6 @@ -package main +package performance_tracker import "fmt" -func main(){ +func TestPerformanceTracker(){ fmt.Println("Hello World") } \ No newline at end of file From c15113665cb6eaedfd4e386d41a0569622f370a1 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 19:12:39 +0000 Subject: [PATCH 009/122] new IntegrationTest Setup --- .github/workflows/integrationTest.yml | 61 +++++++++++++++++-- .../test/performance_tracker/mainTest.go | 10 ++- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 80b9089be3..29e3c2c3b4 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -619,10 +619,8 @@ jobs: PerformanceTrackingTest: name: "PerformanceTrackingTest" + needs: [MakeBinary, StartLocalStack, GenerateTestMatrix] runs-on: ubuntu-latest - defaults: - run: - working-directory: integration/test/performance_tracker steps: - uses: actions/checkout@v2 @@ -633,7 +631,58 @@ jobs: aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} aws-region: us-west-2 - - name: RunTest - run: > - go test performance_tracker + - name: Cache if success + id: performance-tracking + uses: actions/cache@v2 + with: + path: go.mod + key: performance-tracking-test-${{ github.sha }} + + - name: Echo Test Info + run: echo run performance-tracking + + - name: Verify Terraform version + run: terraform --version + + # nick-invision/retry@v2 starts at base dir + - name: Terraform apply + if: steps.performance-tracking.outputs.cache-hit != 'true' + uses: nick-invision/retry@v2 + with: + max_attempts: 3 + timeout_minutes: 30 + retry_wait_seconds: 5 + command: | + cd integration/terraform/ec2/linux + terraform init + if terraform apply --auto-approve \ + -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ + -var="github_sha=${GITHUB_SHA}" -var="install_agent=${{ }}" \ + -var="user=ec2-user" \ + -var="ami=cloudwatch-agent-integration-test-al2*" \ + -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ + -var="arc=amd64" \ + -var="binary_name=amazon-cloudwatch-agent.rpm" \ + -var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \ + -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ + -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ + -var="key_name=${KEY_NAME}" \ + -var="test_name=cw-integ-test-al2" \ + -var="iam_instance_profile=${IAM_ROLE}" \ + -var="test_dir=integration/test/performance_tracker" ; then terraform destroy -auto-approve + else + terraform destroy -auto-approve && exit 1 + fi + + #This is here just in case workflow cancel + - name: Terraform destroy + if: ${{ cancelled() && steps.performance-tracking.outputs.cache-hit != 'true' }} + uses: nick-invision/retry@v2 + with: + max_attempts: 3 + timeout_minutes: 8 + retry_wait_seconds: 5 + command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve + + diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index 34eefc959c..ed14349042 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -1,6 +1,10 @@ +//go:build linux && integration +// +build linux,integration package performance_tracker -import "fmt" +import ( + "testing" +) -func TestPerformanceTracker(){ - fmt.Println("Hello World") +func TestPerformanceTracker(t * testing.T){ + t.Log("Hello World") } \ No newline at end of file From 07c0ced00521ffbf811da9b3eb1b25b8bea60cab Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 20 Jun 2022 19:15:34 +0000 Subject: [PATCH 010/122] fixed integrationTest.yml --- .github/workflows/integrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 29e3c2c3b4..18425e8584 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -657,7 +657,7 @@ jobs: terraform init if terraform apply --auto-approve \ -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ - -var="github_sha=${GITHUB_SHA}" -var="install_agent=${{ }}" \ + -var="github_sha=${GITHUB_SHA}" -var="install_agent=rpm -U ./amazon-cloudwatch-agent.rpm" \ -var="user=ec2-user" \ -var="ami=cloudwatch-agent-integration-test-al2*" \ -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ From ca829a457830315305b42ad01191abd04806f672 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 16:37:54 +0000 Subject: [PATCH 011/122] applied pr feedback: -added new stored data called "CommitDate" -reorganized code -updated code to go v2 -changed metrics struct --- .../transmitter/transmitter.go | 111 +++++++++--------- 1 file changed, 55 insertions(+), 56 deletions(-) diff --git a/integration/test/performance_tracker/transmitter/transmitter.go b/integration/test/performance_tracker/transmitter/transmitter.go index 30fd30101e..c2b35f2c58 100644 --- a/integration/test/performance_tracker/transmitter/transmitter.go +++ b/integration/test/performance_tracker/transmitter/transmitter.go @@ -5,18 +5,20 @@ import ( "fmt" "math" "time" + "context" + "errors" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/dynamodb" - "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" - "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" -) -const( - TIME_CONSTANT = 300.0 // this const is in seconds , 5 mins + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/session" + "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbattribute" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbiface" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) +const METRIC_PERIOD= 300.0 // this const is in seconds , 5 mins + type TransmitterAPI struct{ - DynamoDbClient dynamodbiface.DynamoDBAPI + dynamoDbClient dynamodbiface.DynamoDBAPI DataBaseName string // this is the name of the table when test is run } // this is the packet that will be sent converted to DynamoItem @@ -36,20 +38,20 @@ type collectorData []struct{ // this is the struct data collector passes in Values []float64 `json:Values` } - /* InitializeTransmitterAPI Desc: Initializes the transmitter class -Side effects: Can create a dynamodb table +Side effects: Creates a dynamodb table if it doesn't already exist */ func InitializeTransmitterAPI(DataBaseName string) * TransmitterAPI{ - transmitter := new(TransmitterAPI) //setup aws session session := session.Must(session.NewSessionWithOptions(session.Options{ SharedConfigState: session.SharedConfigEnable, })) - transmitter.DynamoDbClient = dynamodb.New(session) - transmitter.DataBaseName = DataBaseName //fmt.Sprintf("%d",int(time.Now().UnixNano())) + transmitter := TransmitterAPI{ + dynamoDbClient: dynamodb.new(session), + DataBaseName: DataBaseName, + } // check if the dynamo table exist if not create it tableExist, err:= transmitter.TableExist() if err !=nil{ @@ -59,19 +61,16 @@ func InitializeTransmitterAPI(DataBaseName string) * TransmitterAPI{ fmt.Println("Table doesn't exist") err := transmitter.CreateTable() if err != nil{ - fmt.Println("Couldn't create table") return nil } } fmt.Println("API ready") - return transmitter + return &transmitter } /* CreateTable() Desc: Will create a DynamoDB Table with given param. and config -Params: -Side Effects: Creates a dynamoDB table */ func (transmitter * TransmitterAPI) CreateTable() error{ input := &dynamodb.CreateTableInput{ @@ -94,9 +93,9 @@ func (transmitter * TransmitterAPI) CreateTable() error{ TableName: aws.String(transmitter.DataBaseName), } // this is the config for the new table - _, err := transmitter.DynamoDbClient.CreateTable(input) + _, err := transmitter.dynamoDbClient.CreateTable(input) if err != nil { - fmt.Printf("Got error calling CreateTable: %s", err) + fmt.Printf("Error calling CreateTable: %s", err) return err } @@ -113,22 +112,17 @@ Side effects: Adds an item to dynamodb table */ func (transmitter * TransmitterAPI) AddItem(packet map[string]interface{})(string,error){ - // fmt.Printf("Packet: %+v \n",packet) - // metrics, _ := dynamodbattribute.MarshalMap(packet.Metrics) - // fmt.Printf("Metric: %+v \n OG:%+v \n",metrics, packet.Metrics) item, err := dynamodbattribute.MarshalMap(packet) if err != nil { panic(err) } - DBitem := &dynamodb.PutItemInput{ + dbItem := &dynamodb.PutItemInput{ Item: item, TableName: aws.String(transmitter.DataBaseName), } - // fmt.Println(DBitem) - // return err - _, err = transmitter.DynamoDbClient.PutItem(DBitem) + _, err = transmitter.dynamoDbClient.PutItem(dbItem) if err != nil { - fmt.Printf("Couldn't add item to table. Here's why: %v\n", err) + fmt.Printf("Error adding item to table. %v\n", err) } return fmt.Sprintf("%v",item),err } @@ -138,24 +132,37 @@ Desc: Checks if the the table exist and returns the value //https://github.com/awsdocs/aws-doc-sdk-examples/blob/05a89da8c2f2e40781429a7c34cf2f2b9ae35f89/gov2/dynamodb/actions/table_basics.go */ func (transmitter * TransmitterAPI) TableExist() (bool,error){ - l,err := transmitter.ListTables() - for i:=0; i< len(l); i++{ - if transmitter.DataBaseName == l[i]{ - return true,nil + // l,err := transmitter.ListTables() + // for i:=0; i< len(l); i++{ + // if transmitter.DataBaseName == l[i]{ + // return true,nil + // } + // } + // return false,err + exists := true + _, err := transmitter.dynamoDbClient.DescribeTable( + context.TODO(), &dynamodb.DescribeTableInput{TableName: aws.String(transmitter.DataBaseName)}, + ) + if err != nil { + var notFoundEx *types.ResourceNotFoundException + if errors.As(err, ¬FoundEx) { + fmt.Printf("Table %v does not exist.\n", transmitter.DataBaseName) + err = nil + } else { + fmt.Printf("Couldn't determine existence of table %v. Here's why: %v\n",transmitter.DataBaseName, err) } + exists = false } - return false,err - + return exists, err } /* RemoveTable() Desc: Removes the table that was craeted with initialization. -Side effects: Removes a Dynamodb table */ func (transmitter * TransmitterAPI) RemoveTable() error{ input := dynamodb.DeleteTableInput{TableName: aws.String(transmitter.DataBaseName)} - _,err:=transmitter.DynamoDbClient.DeleteTable(&input) + _,err:=transmitter.dynamoDbClient.DeleteTable(&input) if err !=nil{ fmt.Println(err) } @@ -165,10 +172,10 @@ func (transmitter * TransmitterAPI) RemoveTable() error{ func (transmitter * TransmitterAPI) ListTables() ([]string, error) { var tableNames []string input := &dynamodb.ListTablesInput{} - tables, err := transmitter.DynamoDbClient.ListTables( + tables, err := transmitter.dynamoDbClient.ListTables( input) if err != nil { - fmt.Printf("Couldn't list tables. Here's why: %v\n", err) + fmt.Printf("Error listing tables: %v\n", err) } else { for i:=0; i< len(tables.TableNames); i++{ tableNames = append(tableNames,*tables.TableNames[i]) @@ -177,7 +184,11 @@ func (transmitter * TransmitterAPI) ListTables() ([]string, error) { } return tableNames, err } - +/* +SendItem() +Desc: Parses the input data and adds it to the dynamo table +Param: data []byte is the data collected by data collector +*/ func (transmitter * TransmitterAPI) SendItem(data []byte) (string,error) { // return nil packet, err := transmitter.Parser(data) @@ -195,11 +206,13 @@ func (transmitter * TransmitterAPI) Parser(data []byte) (map[string]interface{}, return nil,err } packet := make(map[string]interface{}) - //temp solution + //@TODO: add git integration temp solution packet["Hash"] = fmt.Sprintf("%d",time.Now().UnixNano()) + packet["CommitDate"] = fmt.Sprintf("%d",time.Now().UnixNano()) /// will remove for _,rawMetricData:= range dataHolder{ numDataPoints := float64(len(rawMetricData.Timestamps)) + // @TODO: Export this part to GetMetricStatistics after merging with data collection code sum :=0.0 for _,val := range rawMetricData.Values { sum += val @@ -210,28 +223,14 @@ func (transmitter * TransmitterAPI) Parser(data []byte) (map[string]interface{}, for _,val := range rawMetricData.Values{ diffSum = diffSum + (avg - val) } - + //---------------- metric := Metric{ Average: avg, StandardDev: math.Sqrt(math.Pow(diffSum,2)/float64(numDataPoints)), - Period: int(TIME_CONSTANT/(numDataPoints)), + Period: int(METRIC_PERIOD/(numDataPoints)), Data: rawMetricData.Values} - // fmt.Printf("%+v\n",metric) - // packet.Metrics[rawMetricData.Label] = metric packet[rawMetricData.Label] = metric - - } return packet,nil } -func testFiller(testname string) * TransmitterAPI{ - transmitter := new(TransmitterAPI) - //setup aws session - session := session.Must(session.NewSessionWithOptions(session.Options{ - SharedConfigState: session.SharedConfigEnable, - })) - transmitter.DynamoDbClient = dynamodb.New(session) - transmitter.DataBaseName = testname - return transmitter -} \ No newline at end of file From 71fb0d7a03446c99f310d02d98462de2c441ac28 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 19:06:00 +0000 Subject: [PATCH 012/122] testing github hash fetch --- .github/workflows/integrationTest.yml | 1 + integration/test/performance_tracker/mainTest.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 18425e8584..9cdbaf9990 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -654,6 +654,7 @@ jobs: retry_wait_seconds: 5 command: | cd integration/terraform/ec2/linux + export $SHA = ${var.github_sha} terraform init if terraform apply --auto-approve \ -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index ed14349042..6b90f1be4a 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -1,10 +1,13 @@ //go:build linux && integration // +build linux,integration package performance_tracker + import ( + "os" "testing" ) func TestPerformanceTracker(t * testing.T){ t.Log("Hello World") + t.log("Hash", os.Getenv("SHA")) } \ No newline at end of file From ed2f492bf6074b1e2bead0d60d5cd0a03dfe0bb3 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 19:24:36 +0000 Subject: [PATCH 013/122] without terraform --- .github/workflows/integrationTest.yml | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 9cdbaf9990..2852a74ced 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -655,25 +655,25 @@ jobs: command: | cd integration/terraform/ec2/linux export $SHA = ${var.github_sha} - terraform init - if terraform apply --auto-approve \ - -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ - -var="github_sha=${GITHUB_SHA}" -var="install_agent=rpm -U ./amazon-cloudwatch-agent.rpm" \ - -var="user=ec2-user" \ - -var="ami=cloudwatch-agent-integration-test-al2*" \ - -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ - -var="arc=amd64" \ - -var="binary_name=amazon-cloudwatch-agent.rpm" \ - -var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \ - -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ - -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ - -var="key_name=${KEY_NAME}" \ - -var="test_name=cw-integ-test-al2" \ - -var="iam_instance_profile=${IAM_ROLE}" \ - -var="test_dir=integration/test/performance_tracker" ; then terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi + # terraform init + # if terraform apply --auto-approve \ + # -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ + # -var="github_sha=${GITHUB_SHA}" -var="install_agent=rpm -U ./amazon-cloudwatch-agent.rpm" \ + # -var="user=ec2-user" \ + # -var="ami=cloudwatch-agent-integration-test-al2*" \ + # -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ + # -var="arc=amd64" \ + # -var="binary_name=amazon-cloudwatch-agent.rpm" \ + # -var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \ + # -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ + # -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ + # -var="key_name=${KEY_NAME}" \ + # -var="test_name=cw-integ-test-al2" \ + # -var="iam_instance_profile=${IAM_ROLE}" \ + # -var="test_dir=integration/test/performance_tracker" ; then terraform destroy -auto-approve + # else + # terraform destroy -auto-approve && exit 1 + # fi #This is here just in case workflow cancel - name: Terraform destroy From 5a25b88c7b9f394efb17e8a1e81ae27bd03999cf Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 19:25:09 +0000 Subject: [PATCH 014/122] without terraform --- .github/workflows/integrationTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 2852a74ced..26f6230228 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -655,6 +655,7 @@ jobs: command: | cd integration/terraform/ec2/linux export $SHA = ${var.github_sha} + go test -run TestPerformanceTracker # terraform init # if terraform apply --auto-approve \ # -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ From 4047b0c1e2fcf7cab7d9c2a8f6033e112f820df1 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 19:30:42 +0000 Subject: [PATCH 015/122] new fast test --- .github/workflows/integrationTest.yml | 64 ++++++++++++++++++--------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 26f6230228..1bc58c2ce8 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -655,26 +655,25 @@ jobs: command: | cd integration/terraform/ec2/linux export $SHA = ${var.github_sha} - go test -run TestPerformanceTracker - # terraform init - # if terraform apply --auto-approve \ - # -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ - # -var="github_sha=${GITHUB_SHA}" -var="install_agent=rpm -U ./amazon-cloudwatch-agent.rpm" \ - # -var="user=ec2-user" \ - # -var="ami=cloudwatch-agent-integration-test-al2*" \ - # -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ - # -var="arc=amd64" \ - # -var="binary_name=amazon-cloudwatch-agent.rpm" \ - # -var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \ - # -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ - # -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ - # -var="key_name=${KEY_NAME}" \ - # -var="test_name=cw-integ-test-al2" \ - # -var="iam_instance_profile=${IAM_ROLE}" \ - # -var="test_dir=integration/test/performance_tracker" ; then terraform destroy -auto-approve - # else - # terraform destroy -auto-approve && exit 1 - # fi + terraform init + if terraform apply --auto-approve \ + -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ + -var="github_sha=${GITHUB_SHA}" -var="install_agent=rpm -U ./amazon-cloudwatch-agent.rpm" \ + -var="user=ec2-user" \ + -var="ami=cloudwatch-agent-integration-test-al2*" \ + -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ + -var="arc=amd64" \ + -var="binary_name=amazon-cloudwatch-agent.rpm" \ + -var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \ + -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ + -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ + -var="key_name=${KEY_NAME}" \ + -var="test_name=cw-integ-test-al2" \ + -var="iam_instance_profile=${IAM_ROLE}" \ + -var="test_dir=integration/test/performance_tracker" ; then terraform destroy -auto-approve + else + terraform destroy -auto-approve && exit 1 + fi #This is here just in case workflow cancel - name: Terraform destroy @@ -686,5 +685,26 @@ jobs: retry_wait_seconds: 5 command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve - - + DummySHATest: + name: 'DummySHATest' + runs-on: ubuntu-latest + defaults: + run: + working-directory: integration/terraform/ec2/localstack + outputs: + local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: the test + id: localstack + run: > + export $SHA = ${var.github_sha} + go test -run TestPerformanceTracker \ No newline at end of file From d833fd29b4526497b4ea76fbbab4e1bedd8042ec Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 19:36:35 +0000 Subject: [PATCH 016/122] sha change --- .github/workflows/integrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 1bc58c2ce8..5df885dcc5 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -706,5 +706,5 @@ jobs: - name: the test id: localstack run: > - export $SHA = ${var.github_sha} + export $SHA = ${{ steps.vars.outputs.sha_short }} go test -run TestPerformanceTracker \ No newline at end of file From f7e21234eb23e5e261b10c66ef54e2e090e5b171 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 19:55:47 +0000 Subject: [PATCH 017/122] typo fix --- .github/workflows/integrationTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 5df885dcc5..93911d8e13 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -706,5 +706,5 @@ jobs: - name: the test id: localstack run: > - export $SHA = ${{ steps.vars.outputs.sha_short }} - go test -run TestPerformanceTracker \ No newline at end of file + export SHA = ${{ steps.vars.outputs.sha_short }} + go test --run TestPerformanceTracker \ No newline at end of file From a3cef3078e2c2df69b6f92a184dbac19e3036f59 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 19:59:10 +0000 Subject: [PATCH 018/122] typo --- .github/workflows/integrationTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 93911d8e13..08f57ebbb0 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -706,5 +706,5 @@ jobs: - name: the test id: localstack run: > - export SHA = ${{ steps.vars.outputs.sha_short }} - go test --run TestPerformanceTracker \ No newline at end of file + export SHA=${{ steps.vars.outputs.sha_short }} + go test -run TestPerformanceTracker \ No newline at end of file From 6e3941872aa90a73b535c88e726b75aae155755a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 20:01:30 +0000 Subject: [PATCH 019/122] small change --- .github/workflows/integrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 08f57ebbb0..6c7c156079 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -705,6 +705,6 @@ jobs: - name: the test id: localstack - run: > + run: | export SHA=${{ steps.vars.outputs.sha_short }} go test -run TestPerformanceTracker \ No newline at end of file From 056020512aa7effffdb8c5c292e3f56d638bab63 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 20:03:51 +0000 Subject: [PATCH 020/122] fixed path --- .github/workflows/integrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 6c7c156079..486ee41e68 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -690,7 +690,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: integration/terraform/ec2/localstack + working-directory: integration/test/performance_tracker outputs: local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} steps: From e0563eb3774624e0652cf903d59946cccc3497fc Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 20:06:37 +0000 Subject: [PATCH 021/122] brute force test --- .github/workflows/integrationTest.yml | 2 +- integration/test/performance_tracker/mainTest.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 486ee41e68..7e4453fbec 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -707,4 +707,4 @@ jobs: id: localstack run: | export SHA=${{ steps.vars.outputs.sha_short }} - go test -run TestPerformanceTracker \ No newline at end of file + go run mainTest.go \ No newline at end of file diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index 6b90f1be4a..88d4dc9300 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -1,6 +1,6 @@ //go:build linux && integration // +build linux,integration -package performance_tracker +package main import ( "os" From 9a05c1e7bb11f8e13a3d9b6140380bc0efc7b330 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 20:11:21 +0000 Subject: [PATCH 022/122] typo --- integration/test/performance_tracker/mainTest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index 88d4dc9300..c38f21edfa 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -9,5 +9,5 @@ import ( func TestPerformanceTracker(t * testing.T){ t.Log("Hello World") - t.log("Hash", os.Getenv("SHA")) + t.Log("Hash", os.Getenv("SHA")) } \ No newline at end of file From c5dc0d8b2c94fb60b49305f061f15db33b564951 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 20:13:37 +0000 Subject: [PATCH 023/122] small change --- integration/test/performance_tracker/mainTest.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index c38f21edfa..1e8f3ac1cf 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -3,6 +3,7 @@ package main import ( + "fmt" "os" "testing" ) @@ -10,4 +11,10 @@ import ( func TestPerformanceTracker(t * testing.T){ t.Log("Hello World") t.Log("Hash", os.Getenv("SHA")) +} + + +func main(){ + fmt.Println("Hello World") + fmt.Println("Hash", os.Getenv("SHA")) } \ No newline at end of file From 8b697967712c09d09ed609ed40d3a838438ea073 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 20:16:36 +0000 Subject: [PATCH 024/122] trying different export --- .github/workflows/integrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 7e4453fbec..c19d55d6c3 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -706,5 +706,5 @@ jobs: - name: the test id: localstack run: | - export SHA=${{ steps.vars.outputs.sha_short }} + export SHA=${var.github_sha} go run mainTest.go \ No newline at end of file From 4cd00c82362b9a3b3795441f3ff2eee7cfce9892 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 21 Jun 2022 20:19:58 +0000 Subject: [PATCH 025/122] trying with git command --- .github/workflows/integrationTest.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index c19d55d6c3..45cb2243d8 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -702,9 +702,13 @@ jobs: aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} aws-region: us-west-2 - + - name: Set outputs + id: vars + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Check outputs + run: echo ${{ steps.vars.outputs.sha_short }} - name: the test id: localstack run: | - export SHA=${var.github_sha} + export SHA=${{ steps.vars.outputs.sha_short }} go run mainTest.go \ No newline at end of file From 1f548d329a07637ca316f93f1856964caa093ee8 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 22 Jun 2022 15:13:11 +0000 Subject: [PATCH 026/122] added sha date test --- .github/workflows/integrationTest.yml | 18 ++++++++++-------- .../test/performance_tracker/mainTest.go | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 45cb2243d8..3c0508a211 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -702,13 +702,15 @@ jobs: aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} aws-region: us-west-2 - - name: Set outputs - id: vars + - name: Get SHA + id: sha run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Check outputs - run: echo ${{ steps.vars.outputs.sha_short }} - - name: the test - id: localstack + - name: Get git date + id: sha_date + run: echo "::set-output name=sha_date::$(git show -s --format=%ci ${{ steps.sha.outputs.sha_short }} )" + - name: MainTestRun + id: MainTestRUn run: | - export SHA=${{ steps.vars.outputs.sha_short }} - go run mainTest.go \ No newline at end of file + export SHA=${{ steps.sha.outputs.sha_short }} + export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} + go run mainTest.go diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go index 1e8f3ac1cf..ed3efabe73 100644 --- a/integration/test/performance_tracker/mainTest.go +++ b/integration/test/performance_tracker/mainTest.go @@ -16,5 +16,5 @@ func TestPerformanceTracker(t * testing.T){ func main(){ fmt.Println("Hello World") - fmt.Println("Hash", os.Getenv("SHA")) + fmt.Println("Hash", os.Getenv("SHA"), "Commit Date:",os.Getenv("SHA_DATE")) } \ No newline at end of file From e47af381434e75cb4aeb5716ae197f6d45c15761 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 22 Jun 2022 15:17:36 +0000 Subject: [PATCH 027/122] switched time to epoch time --- .github/workflows/integrationTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 3c0508a211..a05cbb094b 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -707,7 +707,7 @@ jobs: run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Get git date id: sha_date - run: echo "::set-output name=sha_date::$(git show -s --format=%ci ${{ steps.sha.outputs.sha_short }} )" + run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" - name: MainTestRun id: MainTestRUn run: | From 2394e356afb3f150e9ca76bd7f28748b5a383713 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 22 Jun 2022 16:30:15 +0000 Subject: [PATCH 028/122] implemented git integration to transmitter --- .../performance_tracker/transmitter/transmitter.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/integration/test/performance_tracker/transmitter/transmitter.go b/integration/test/performance_tracker/transmitter/transmitter.go index c2b35f2c58..c46aa3a831 100644 --- a/integration/test/performance_tracker/transmitter/transmitter.go +++ b/integration/test/performance_tracker/transmitter/transmitter.go @@ -1,12 +1,13 @@ package transmitter import ( + "context" "encoding/json" + "errors" "fmt" "math" + "os" "time" - "context" - "errors" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/session" @@ -206,10 +207,8 @@ func (transmitter * TransmitterAPI) Parser(data []byte) (map[string]interface{}, return nil,err } packet := make(map[string]interface{}) - //@TODO: add git integration temp solution - packet["Hash"] = fmt.Sprintf("%d",time.Now().UnixNano()) - packet["CommitDate"] = fmt.Sprintf("%d",time.Now().UnixNano()) - /// will remove + packet["Hash"] = os.Getenv("SHA") + packet["CommitDate"] = os.Getenv("SHA_DATE") for _,rawMetricData:= range dataHolder{ numDataPoints := float64(len(rawMetricData.Timestamps)) // @TODO: Export this part to GetMetricStatistics after merging with data collection code From 1ff58b163b2afe526b981432716735821a9f83bd Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 15:15:43 +0000 Subject: [PATCH 029/122] merge first try --- .github/workflows/integrationTest.yml | 59 +++-- go.mod | 17 +- go.sum | 30 ++- .../test/performance_tracker/mainTest.go | 20 -- ...ce_metrics_test.go => performance_test.go} | 4 +- .../test/performance_tracker/transmitter.go | 219 ++++++++++++++++ .../transmitter/transmitter.go | 235 ------------------ 7 files changed, 280 insertions(+), 304 deletions(-) delete mode 100644 integration/test/performance_tracker/mainTest.go rename integration/test/performance_tracker/{performance_metrics_test.go => performance_test.go} (96%) create mode 100644 integration/test/performance_tracker/transmitter.go delete mode 100644 integration/test/performance_tracker/transmitter/transmitter.go diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 2586001cf4..0eaa43d07e 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -654,7 +654,6 @@ jobs: retry_wait_seconds: 5 command: | cd integration/terraform/ec2/linux - export $SHA = ${var.github_sha} terraform init if terraform apply --auto-approve \ -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ @@ -685,32 +684,32 @@ jobs: retry_wait_seconds: 5 command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve - DummySHATest: - name: 'DummySHATest' - runs-on: ubuntu-latest - defaults: - run: - working-directory: integration/test/performance_tracker - outputs: - local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} - steps: - - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - name: Get SHA - id: sha - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Get git date - id: sha_date - run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" - - name: MainTestRun - id: MainTestRUn - run: | - export SHA=${{ steps.sha.outputs.sha_short }} - export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} - go run mainTest.go + # DummySHATest: + # name: 'DummySHATest' + # runs-on: ubuntu-latest + # defaults: + # run: + # working-directory: integration/test/performance_tracker + # outputs: + # local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} + # steps: + # - uses: actions/checkout@v2 + + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + # aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + # aws-region: us-west-2 + # - name: Get SHA + # id: sha + # run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + # - name: Get git date + # id: sha_date + # run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" + # - name: MainTestRun + # id: MainTestRUn + # run: | + # export SHA=${{ steps.sha.outputs.sha_short }} + # export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} + # go test -run TestPerformance diff --git a/go.mod b/go.mod index cb8cbb148f..52a5097775 100644 --- a/go.mod +++ b/go.mod @@ -54,18 +54,20 @@ require ( github.com/Jeffail/gabs v1.4.0 github.com/Rican7/retry v0.1.1-0.20160712041035-272ad122d6e5 github.com/aws/aws-sdk-go v1.44.16 - github.com/aws/aws-sdk-go-v2 v1.16.3 + github.com/aws/aws-sdk-go-v2 v1.16.5 github.com/aws/aws-sdk-go-v2/config v1.15.3 + github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.4 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3 github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.18.1 github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.4 + github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.7 github.com/aws/aws-sdk-go-v2/service/ec2 v1.29.0 - github.com/aws/smithy-go v1.11.2 + github.com/aws/smithy-go v1.11.3 github.com/bigkevmcd/go-configparser v0.0.0-20200217161103-d137835d2579 github.com/go-kit/kit v0.11.0 github.com/gobwas/glob v0.2.3 github.com/google/cadvisor v0.44.0 - github.com/google/go-cmp v0.5.7 + github.com/google/go-cmp v0.5.8 github.com/hashicorp/golang-lru v0.5.4 github.com/influxdata/telegraf v0.0.0-00010101000000-000000000000 github.com/influxdata/toml v0.0.0-20190415235208-270119a8ce65 @@ -121,11 +123,12 @@ require ( github.com/armon/go-metrics v0.3.10 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.11.2 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.12 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.6 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.3 // indirect + github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.7 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.2 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.6 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 // indirect github.com/aws/aws-sdk-go-v2/service/s3 v1.26.5 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.11.3 // indirect diff --git a/go.sum b/go.sum index 417458747d..a83633fd1c 100644 --- a/go.sum +++ b/go.sum @@ -226,8 +226,8 @@ github.com/aws/aws-sdk-go-v2 v1.7.0/go.mod h1:tb9wi5s61kTDA5qCkcDbt3KRVV74GGslQk github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2 v1.13.0/go.mod h1:L6+ZpqHaLbAaxsqV0L4cvxZY7QupWJB4fhkf8LXvC7w= github.com/aws/aws-sdk-go-v2 v1.16.2/go.mod h1:ytwTPBG6fXTZLxxeeCCWj2/EMYp/xDUgX+OET6TLNNU= -github.com/aws/aws-sdk-go-v2 v1.16.3 h1:0W1TSJ7O6OzwuEvIXAtJGvOeQ0SGAhcpxPN2/NK5EhM= -github.com/aws/aws-sdk-go-v2 v1.16.3/go.mod h1:ytwTPBG6fXTZLxxeeCCWj2/EMYp/xDUgX+OET6TLNNU= +github.com/aws/aws-sdk-go-v2 v1.16.5 h1:Ah9h1TZD9E2S1LzHpViBO3Jz9FPL5+rmflmb8hXirtI= +github.com/aws/aws-sdk-go-v2 v1.16.5/go.mod h1:Wh7MEsmEApyL5hrWzpDkba4gwAPc5/piwLVLFnCxp48= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 h1:SdK4Ppk5IzLs64ZMvr6MrSficMtjY2oS0WOORXTlxwU= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1/go.mod h1:n8Bs1ElDD2wJ9kCRTczA83gYbBmjSwZp3umc6zF4EeM= github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= @@ -236,16 +236,20 @@ github.com/aws/aws-sdk-go-v2/config v1.15.3/go.mod h1:9YL3v07Xc/ohTsxFXzan9ZpFpd github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= github.com/aws/aws-sdk-go-v2/credentials v1.11.2 h1:RQQ5fzclAKJyY5TvF+fkjJEwzK4hnxQCLOu5JXzDmQo= github.com/aws/aws-sdk-go-v2/credentials v1.11.2/go.mod h1:j8YsY9TXTm31k4eFhspiQicfXPLZ0gYXA50i4gxPE8g= +github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.4 h1:EoyeSOfbSuKh+bQIDoZaVJjON6PF+dsSn5w1RhIpMD0= +github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.4/go.mod h1:bfCL7OwZS6owS06pahfGxhcgpLWj2W1sQASoYRuenag= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3 h1:LWPg5zjHV9oz/myQr4wMs0gi4CjnDN/ILmyZUFYXZsU= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3/go.mod h1:uk1vhHHERfSVCUnqSqz8O48LBYDSC+k6brng09jcMOk= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.3 h1:0O72494cCsazjpsGfo+LXezru6PMSp0HUB1m5UfpaRU= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.4/go.mod h1:XHgQ7Hz2WY2GAn//UXHofLfPXWh+s62MbMOijrg12Lw= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9 h1:onz/VaaxZ7Z4V+WIN9Txly9XLTmoOh1oJ8XcAC3pako= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9/go.mod h1:AnVH5pvai0pAF4lXRq0bmhbes1u9R8wTE+g+183bZNM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.12 h1:Zt7DDk5V7SyQULUUwIKzsROtVzp/kVvcz15uQx/Tkow= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.12/go.mod h1:Afj/U8svX6sJ77Q+FPWMzabJ9QjbwP32YlopgKALUpg= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.2.0/go.mod h1:BsCSJHx5DnDXIrOcqB8KN1/B+hXLG/bi4Y6Vjcx/x9E= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3 h1:9stUQR/u2KXU6HkFJYlqnZEjBnbgrVbG6I5HN09xZh0= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3/go.mod h1:ssOhaLpRlh88H3UmEcsBoVKq309quMvm3Ds8e9d4eJM= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.6 h1:eeXdGVtXEe+2Jc49+/vAzna3FAQnUD4AagAw8tzbmfc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.6/go.mod h1:FwpAKI+FBPIELJIdmQzlLtRe8LQSOreMcM2wBsPMvvc= github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 h1:by9P+oy3P/CwggN4ClnW2D4oL91QV7pBzBICi1chZvQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10/go.mod h1:8DcYQcz0+ZJaSxANlHIsbbi6S+zMwjwdDqwW3r9AzaE= @@ -257,15 +261,19 @@ github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.18.1 h1:8PHGmLw1QbTdXfgEpXclO github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.18.1/go.mod h1:Z+8JhhltQDM1vIHvEtQLr1wVVAqQVLpvCDMVqYBrwr8= github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.4 h1:mBqjBKtZzvAc9j7gU+FEHbhTKSr02iqMOdQIL/7GZ78= github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.4/go.mod h1:R49Py2lGoKH7bCpwhjN9l7MfR/PU6zHXn1tCRR8cwOs= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.14.0 h1:P+eF8PKkeaiTfN/VBe5GI3uNdhwCPVYCQxchRewJcWk= +github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.7 h1:Ls6kDGWNr3wxE8JypXgTTonHpQ1eRVCGNqaFHY2UASw= +github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.7/go.mod h1:+v2jeT4/39fCXUQ0ZfHQHMMiJljnmiuj16F03uAd9DY= +github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.7 h1:o2HKntJx3vr3y11NK58RA6tYKZKQo5PWWt/bs0rWR0U= +github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.7/go.mod h1:FAVtDKEl/8WxRDQ33e2fz16RO1t4zeEwWIU5kR29xXs= github.com/aws/aws-sdk-go-v2/service/ec2 v1.29.0 h1:7jk4NfzDnnSbaR9E4mOBWRZXQThq5rsqjlDC+uu9dsI= github.com/aws/aws-sdk-go-v2/service/ec2 v1.29.0/go.mod h1:HoTu0hnXGafTpKIZQ60jw0ybhhCH1QYf20oL7GEJFdg= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 h1:T4pFel53bkHjL2mMo+4DKE6r6AuoZnM0fg7k1/ratr4= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1/go.mod h1:GeUru+8VzrTXV/83XyMJ80KpH8xO89VPoUileyNQ+tc= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.2 h1:T/ywkX1ed+TsZVQccu/8rRJGxKZF/t0Ivgrb4MHTSeo= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.2/go.mod h1:RnloUnyZ4KN9JStGY1LuQ7Wzqh7V0f8FinmRdHYtuaA= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.3 h1:I0dcwWitE752hVSMrsLCxqNQ+UdEp3nACx2bYNMQq+k= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.3/go.mod h1:Seb8KNmD6kVTjwRjVEgOT5hPin6sq+v4C2ycJQDwuH8= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.3 h1:JUbFrnq5mEeM2anIJ2PUkaHpKPW/D+RYAQVv5HXYQg4= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.3/go.mod h1:lgGDXBzoot238KmAAn6zf9lkoxcYtJECnYURSbvNlfc= +github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.6 h1:JGrc3+kkyr848/wpG2+kWuzHK3H4Fyxj2jnXj8ijQ/Y= +github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.6/go.mod h1:zwvTysbXES8GDwFcwCPB8NkC+bCdio1abH+E+BRe/xg= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.7.0/go.mod h1:K/qPe6AP2TGYv4l6n7c88zh9jWBDf6nHhvg1fx/EWfU= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 h1:Gh1Gpyh01Yvn7ilO/b/hr01WgNpaszfbKMUgqM186xQ= @@ -289,8 +297,9 @@ github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.3.2 h1:1s/RRA5Owuz4/G/eW github.com/aws/smithy-go v1.5.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/aws/smithy-go v1.10.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/aws/smithy-go v1.11.2 h1:eG/N+CcUMAvsdffgMvjMKwfyDzIkjM6pfxMJ8Mzc6mE= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= +github.com/aws/smithy-go v1.11.3 h1:DQixirEFM9IaKxX1olZ3ke3nvxRS2xMDteKIDWxozW8= +github.com/aws/smithy-go v1.11.3/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/telegraf v0.10.2-0.20220502160831-c20ebe67c5ef h1:O53nKbZm2XpdudUywNdqbohwUxje9k4vE0xRXWeIVbE= github.com/aws/telegraf v0.10.2-0.20220502160831-c20ebe67c5ef/go.mod h1:6maU8S0L0iMSa0ZvH5b2W7dBX1xjK0D5ONAqe7WTqXc= github.com/aws/telegraf/patches/gopsutil/v3 v3.0.0-20220502160831-c20ebe67c5ef h1:iiO0qNErnQgaU6mJY+PRlwnoHp+s9VTk2Ax1A8KRoG4= @@ -881,8 +890,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0= github.com/google/go-github/v32 v32.1.0 h1:GWkQOdXqviCPx7Q7Fj+KyPoGm4SwHRh8rheoPhd27II= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= diff --git a/integration/test/performance_tracker/mainTest.go b/integration/test/performance_tracker/mainTest.go deleted file mode 100644 index ed3efabe73..0000000000 --- a/integration/test/performance_tracker/mainTest.go +++ /dev/null @@ -1,20 +0,0 @@ -//go:build linux && integration -// +build linux,integration -package main - -import ( - "fmt" - "os" - "testing" -) - -func TestPerformanceTracker(t * testing.T){ - t.Log("Hello World") - t.Log("Hash", os.Getenv("SHA")) -} - - -func main(){ - fmt.Println("Hello World") - fmt.Println("Hash", os.Getenv("SHA"), "Commit Date:",os.Getenv("SHA_DATE")) -} \ No newline at end of file diff --git a/integration/test/performance_tracker/performance_metrics_test.go b/integration/test/performance_tracker/performance_test.go similarity index 96% rename from integration/test/performance_tracker/performance_metrics_test.go rename to integration/test/performance_tracker/performance_test.go index 6119fec63d..8cf8bda139 100644 --- a/integration/test/performance_tracker/performance_metrics_test.go +++ b/integration/test/performance_tracker/performance_test.go @@ -8,7 +8,6 @@ import( "time" "log" "context" - "github.com/aws/amazon-cloudwatch-agent/integration/test" ) @@ -18,7 +17,7 @@ const ( agentRuntimeMinutes = 20 ) -func PerformanceTest(t *testing.T) { +func TestPerformance(t *testing.T) { agentContext := context.TODO() instanceId := test.GetInstanceId() log.Printf("Instance ID used for performance metrics : %s\n", instanceId) @@ -41,6 +40,7 @@ func PerformanceTest(t *testing.T) { } //------Placeholder to put data into database------// + //useless code so data get used and compiler isn't mad if data == nil { t.Fatalf("No data") diff --git a/integration/test/performance_tracker/transmitter.go b/integration/test/performance_tracker/transmitter.go new file mode 100644 index 0000000000..752868dfb9 --- /dev/null +++ b/integration/test/performance_tracker/transmitter.go @@ -0,0 +1,219 @@ +package performancetest + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "os" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" + "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" +) + +const METRIC_PERIOD = 300.0 // this const is in seconds , 5 mins + +type TransmitterAPI struct { + dynamoDbClient *dynamodb.Client + DataBaseName string // this is the name of the table when test is run +} + +// this is the packet that will be sent converted to DynamoItem +type Metric struct { + Average float64 + P99 float64 //99% percent process + Max float64 + Min float64 + Period int //in seconds + Data []float64 +} + +type collectorData []struct { // this is the struct data collector passes in + Id string `json:"Id"` + Label string `json:Label` + Messages string `json:Messages` + StatusCode string `json:StatusCode` + Timestamps []string `json:Timestamps` + Values []float64 `json:Values` +} + +/* +InitializeTransmitterAPI +Desc: Initializes the transmitter class +Side effects: Creates a dynamodb table if it doesn't already exist +*/ +func InitializeTransmitterAPI(DataBaseName string) *TransmitterAPI { + //setup aws session + cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(os.Getenv("AWS_REGION"))) + if err != nil { + fmt.Printf("Error: Loading in config %s\n", err) + } + transmitter := TransmitterAPI{ + dynamoDbClient: dynamodb.NewFromConfig(cfg), + DataBaseName: DataBaseName, + } + // check if the dynamo table exist if not create it + tableExist, err := transmitter.TableExist() + if err != nil { + return nil + } + if !tableExist { + fmt.Println("Table doesn't exist") + err := transmitter.CreateTable() + if err != nil { + return nil + } + } + fmt.Println("API ready") + return &transmitter + +} + +/* +CreateTable() +Desc: Will create a DynamoDB Table with given param. and config +*/ + //add secondary index space vs time +func (transmitter *TransmitterAPI) CreateTable() error { + _, err := transmitter.dynamoDbClient.CreateTable( + context.TODO(), &dynamodb.CreateTableInput{ + AttributeDefinitions: []types.AttributeDefinition{ + { + AttributeName: aws.String("Hash"), + AttributeType: types.ScalarAttributeTypeS, + }, + }, + KeySchema: []types.KeySchemaElement{ + { + AttributeName: aws.String("Hash"), + KeyType: types.KeyTypeHash, + }, + }, + ProvisionedThroughput: &types.ProvisionedThroughput{ + ReadCapacityUnits: aws.Int64(10), + WriteCapacityUnits: aws.Int64(10), + }, + TableName: aws.String(transmitter.DataBaseName), + }) // this is the config for the new table) + if err != nil { + fmt.Printf("Error calling CreateTable: %s", err) + return err + } + + fmt.Println("Created the table", transmitter.DataBaseName) + return nil +} + +/* +AddItem() +Desc: Takes in a packet and +will convert to dynamodb format and upload to dynamodb table. +Param: + packet * map[string]interface{}: is a map with data collection data +Side effects: + Adds an item to dynamodb table +*/ +func (transmitter *TransmitterAPI) AddItem(packet map[string]interface{}) (string, error) { + item, err := attributevalue.MarshalMap(packet) + if err != nil { + panic(err) + } + _, err = transmitter.dynamoDbClient.PutItem(context.TODO(), + &dynamodb.PutItemInput{ + Item: item, + TableName: aws.String(transmitter.DataBaseName), + }) + if err != nil { + fmt.Printf("Error adding item to table. %v\n", err) + } + return fmt.Sprintf("%v", item), err +} + +/* +TableExist() +Desc: Checks if the the table exist and returns the value +//https://github.com/awsdocs/aws-doc-sdk-examples/blob/05a89da8c2f2e40781429a7c34cf2f2b9ae35f89/gov2/dynamodb/actions/table_basics.go +*/ +func (transmitter *TransmitterAPI) TableExist() (bool, error) { + // l,err := transmitter.ListTables() + // for i:=0; i< len(l); i++{ + // if transmitter.DataBaseName == l[i]{ + // return true,nil + // } + // } + // return false,err + exists := true + _, err := transmitter.dynamoDbClient.DescribeTable( + context.TODO(), &dynamodb.DescribeTableInput{TableName: aws.String(transmitter.DataBaseName)}, + ) + if err != nil { + var notFoundEx *types.ResourceNotFoundException + if errors.As(err, ¬FoundEx) { + fmt.Printf("Table %v does not exist.\n", transmitter.DataBaseName) + err = nil + } else { + fmt.Printf("Couldn't determine existence of table %v. Here's why: %v\n", transmitter.DataBaseName, err) + } + exists = false + } + return exists, err +} + +/* +RemoveTable() +Desc: Removes the table that was craeted with initialization. +*/ +func (transmitter *TransmitterAPI) RemoveTable() error { + _, err := transmitter.dynamoDbClient.DeleteTable(context.TODO(), + &dynamodb.DeleteTableInput{TableName: aws.String(transmitter.DataBaseName)}) + if err != nil { + fmt.Println(err) + } + return err +} + +/* +SendItem() +Desc: Parses the input data and adds it to the dynamo table +Param: data []byte is the data collected by data collector +*/ +func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { + // return nil + packet, err := transmitter.Parser(data) + if err != nil { + return "", err + } + sentItem, err := transmitter.AddItem(packet) + return sentItem, err +} + +func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, error) { + dataHolder := collectorData{} + err := json.Unmarshal(data, &dataHolder) + if err != nil { + return nil, err + } + packet := make(map[string]interface{}) + //@TODO: add git integration temp solution + packet["Hash"] = fmt.Sprintf("%d", time.Now().UnixNano()) + packet["CommitDate"] = fmt.Sprintf("%d", time.Now().UnixNano()) + /// will remove + for _, rawMetricData := range dataHolder { + numDataPoints := float64(len(rawMetricData.Timestamps)) + // @TODO:ADD GetMetricStatistics after merging with data collection code + //---------------- + metric := Metric{ + Average: 0.0, + Max: 100.0, + Min: 0.0, + P99: 0.0, + Period: int(METRIC_PERIOD / (numDataPoints)), + Data: rawMetricData.Values} + packet[rawMetricData.Label] = metric + } + return packet, nil +} diff --git a/integration/test/performance_tracker/transmitter/transmitter.go b/integration/test/performance_tracker/transmitter/transmitter.go deleted file mode 100644 index c46aa3a831..0000000000 --- a/integration/test/performance_tracker/transmitter/transmitter.go +++ /dev/null @@ -1,235 +0,0 @@ -package transmitter - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "math" - "os" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/session" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" - "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbattribute" - "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbiface" - "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" -) -const METRIC_PERIOD= 300.0 // this const is in seconds , 5 mins - -type TransmitterAPI struct{ - dynamoDbClient dynamodbiface.DynamoDBAPI - DataBaseName string // this is the name of the table when test is run -} -// this is the packet that will be sent converted to DynamoItem -type Metric struct{ - Average float64 - StandardDev float64 - Period int //in seconds - Data []float64 -} - -type collectorData []struct{ // this is the struct data collector passes in - Id string `json:"Id"` - Label string `json:Label` - Messages string `json:Messages` - StatusCode string `json:StatusCode` - Timestamps []string `json:Timestamps` - Values []float64 `json:Values` -} - -/* -InitializeTransmitterAPI -Desc: Initializes the transmitter class -Side effects: Creates a dynamodb table if it doesn't already exist -*/ -func InitializeTransmitterAPI(DataBaseName string) * TransmitterAPI{ - //setup aws session - session := session.Must(session.NewSessionWithOptions(session.Options{ - SharedConfigState: session.SharedConfigEnable, - })) - transmitter := TransmitterAPI{ - dynamoDbClient: dynamodb.new(session), - DataBaseName: DataBaseName, - } - // check if the dynamo table exist if not create it - tableExist, err:= transmitter.TableExist() - if err !=nil{ - return nil - } - if !tableExist{ - fmt.Println("Table doesn't exist") - err := transmitter.CreateTable() - if err != nil{ - return nil - } - } - fmt.Println("API ready") - return &transmitter - -} -/* -CreateTable() -Desc: Will create a DynamoDB Table with given param. and config -*/ -func (transmitter * TransmitterAPI) CreateTable() error{ - input := &dynamodb.CreateTableInput{ - AttributeDefinitions: []*dynamodb.AttributeDefinition{ - { - AttributeName: aws.String("Hash"), - AttributeType: aws.String("S"), - }, - }, - KeySchema: []*dynamodb.KeySchemaElement{ - { - AttributeName: aws.String("Hash"), - KeyType: aws.String("HASH"), - }, - }, - ProvisionedThroughput: &dynamodb.ProvisionedThroughput{ - ReadCapacityUnits: aws.Int64(10), - WriteCapacityUnits: aws.Int64(10), - }, - TableName: aws.String(transmitter.DataBaseName), - } // this is the config for the new table - - _, err := transmitter.dynamoDbClient.CreateTable(input) - if err != nil { - fmt.Printf("Error calling CreateTable: %s", err) - return err - } - - fmt.Println("Created the table", transmitter.DataBaseName) - return nil -} -/* -AddItem() -Desc: Takes in a packet and -will convert to dynamodb format and upload to dynamodb table. -Param: - packet * map[string]interface{}: is a map with data collection data -Side effects: - Adds an item to dynamodb table -*/ -func (transmitter * TransmitterAPI) AddItem(packet map[string]interface{})(string,error){ - item, err := dynamodbattribute.MarshalMap(packet) - if err != nil { - panic(err) - } - dbItem := &dynamodb.PutItemInput{ - Item: item, - TableName: aws.String(transmitter.DataBaseName), - } - _, err = transmitter.dynamoDbClient.PutItem(dbItem) - if err != nil { - fmt.Printf("Error adding item to table. %v\n", err) - } - return fmt.Sprintf("%v",item),err -} -/* -TableExist() -Desc: Checks if the the table exist and returns the value -//https://github.com/awsdocs/aws-doc-sdk-examples/blob/05a89da8c2f2e40781429a7c34cf2f2b9ae35f89/gov2/dynamodb/actions/table_basics.go -*/ -func (transmitter * TransmitterAPI) TableExist() (bool,error){ - // l,err := transmitter.ListTables() - // for i:=0; i< len(l); i++{ - // if transmitter.DataBaseName == l[i]{ - // return true,nil - // } - // } - // return false,err - exists := true - _, err := transmitter.dynamoDbClient.DescribeTable( - context.TODO(), &dynamodb.DescribeTableInput{TableName: aws.String(transmitter.DataBaseName)}, - ) - if err != nil { - var notFoundEx *types.ResourceNotFoundException - if errors.As(err, ¬FoundEx) { - fmt.Printf("Table %v does not exist.\n", transmitter.DataBaseName) - err = nil - } else { - fmt.Printf("Couldn't determine existence of table %v. Here's why: %v\n",transmitter.DataBaseName, err) - } - exists = false - } - return exists, err -} -/* -RemoveTable() -Desc: Removes the table that was craeted with initialization. -*/ -func (transmitter * TransmitterAPI) RemoveTable() error{ - input := dynamodb.DeleteTableInput{TableName: aws.String(transmitter.DataBaseName)} - - _,err:=transmitter.dynamoDbClient.DeleteTable(&input) - if err !=nil{ - fmt.Println(err) - } - return err -} -// ListTables lists the DynamoDB table names for the current account. -func (transmitter * TransmitterAPI) ListTables() ([]string, error) { - var tableNames []string - input := &dynamodb.ListTablesInput{} - tables, err := transmitter.dynamoDbClient.ListTables( - input) - if err != nil { - fmt.Printf("Error listing tables: %v\n", err) - } else { - for i:=0; i< len(tables.TableNames); i++{ - tableNames = append(tableNames,*tables.TableNames[i]) - } - - } - return tableNames, err -} -/* -SendItem() -Desc: Parses the input data and adds it to the dynamo table -Param: data []byte is the data collected by data collector -*/ -func (transmitter * TransmitterAPI) SendItem(data []byte) (string,error) { - // return nil - packet, err := transmitter.Parser(data) - if err != nil{ - return "",err - } - sentItem,err := transmitter.AddItem(packet) - return sentItem,err -} - -func (transmitter * TransmitterAPI) Parser(data []byte) (map[string]interface{},error){ - dataHolder := collectorData{} - err := json.Unmarshal(data,&dataHolder) - if err !=nil{ - return nil,err - } - packet := make(map[string]interface{}) - packet["Hash"] = os.Getenv("SHA") - packet["CommitDate"] = os.Getenv("SHA_DATE") - for _,rawMetricData:= range dataHolder{ - numDataPoints := float64(len(rawMetricData.Timestamps)) - // @TODO: Export this part to GetMetricStatistics after merging with data collection code - sum :=0.0 - for _,val := range rawMetricData.Values { - sum += val - } - avg := sum /numDataPoints - // calculate diff between mean and values - diffSum := 0.0 - for _,val := range rawMetricData.Values{ - diffSum = diffSum + (avg - val) - } - //---------------- - metric := Metric{ - Average: avg, - StandardDev: math.Sqrt(math.Pow(diffSum,2)/float64(numDataPoints)), - Period: int(METRIC_PERIOD/(numDataPoints)), - Data: rawMetricData.Values} - packet[rawMetricData.Label] = metric - } - return packet,nil -} - From 609780ee9093ddd416225c4c25e8678120a654f3 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 15:21:42 +0000 Subject: [PATCH 030/122] added fast test --- .github/workflows/integrationTest.yml | 65 ++++++++++++++------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 0eaa43d07e..d1e4b80093 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -643,7 +643,12 @@ jobs: - name: Verify Terraform version run: terraform --version - + - name: Get SHA + id: sha + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Get git date + id: sha_date + run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" # nick-invision/retry@v2 starts at base dir - name: Terraform apply if: steps.performance-tracking.outputs.cache-hit != 'true' @@ -684,32 +689,32 @@ jobs: retry_wait_seconds: 5 command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve - # DummySHATest: - # name: 'DummySHATest' - # runs-on: ubuntu-latest - # defaults: - # run: - # working-directory: integration/test/performance_tracker - # outputs: - # local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} - # steps: - # - uses: actions/checkout@v2 - - # - name: Configure AWS Credentials - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} - # aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} - # aws-region: us-west-2 - # - name: Get SHA - # id: sha - # run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - # - name: Get git date - # id: sha_date - # run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" - # - name: MainTestRun - # id: MainTestRUn - # run: | - # export SHA=${{ steps.sha.outputs.sha_short }} - # export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} - # go test -run TestPerformance + NonTerraformTest: + name: 'DummySHATest' + runs-on: ubuntu-latest + defaults: + run: + working-directory: integration/test/performance_tracker + outputs: + local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Get SHA + id: sha + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Get git date + id: sha_date + run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" + - name: MainTestRun + id: MainTestRUn + run: | + export SHA=${{ steps.sha.outputs.sha_short }} + export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} + go test -run TestPerformance From 6d095aca2a87dc2ac17234fda9559bed06a3129b Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 15:31:46 +0000 Subject: [PATCH 031/122] fast test --- .github/workflows/fastPeformanceTest.yml | 59 +++++++++++++++++++ .github/workflows/integrationTest.yml | 29 --------- .../performance_tracker/performance_test.go | 4 +- 3 files changed, 61 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/fastPeformanceTest.yml diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml new file mode 100644 index 0000000000..a8dc1c8dfd --- /dev/null +++ b/.github/workflows/fastPeformanceTest.yml @@ -0,0 +1,59 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: MIT + +name: Run Integration Tests +env: + PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }} + TERRAFORM_AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + TERRAFORM_AWS_SECRET_ACCESS_KEY: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + S3_INTEGRATION_BUCKET: ${{ secrets.S3_INTEGRATION_BUCKET }} + KEY_NAME: ${{ secrets.KEY_NAME }} + VPC_SECURITY_GROUPS_IDS: ${{ secrets.VPC_SECURITY_GROUPS_IDS }} + IAM_ROLE: ${{ secrets.IAM_ROLE }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} + GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} + GPG_TTY: $(tty) + ECR_INTEGRATION_TEST_REPO: "cwagent-integration-test" + +on: + push: + branches: + - workflow + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + NonTerraformTest: + name: 'DummySHATest' + runs-on: ubuntu-latest + defaults: + run: + working-directory: integration/test/performance_tracker + outputs: + local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Get SHA + id: sha + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Get git date + id: sha_date + run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" + - name: MainTestRun + id: MainTestRUn + run: | + export SHA=${{ steps.sha.outputs.sha_short }} + export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} + go test -run TestPerformance diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index d1e4b80093..062cf8daf5 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -689,32 +689,3 @@ jobs: retry_wait_seconds: 5 command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve - NonTerraformTest: - name: 'DummySHATest' - runs-on: ubuntu-latest - defaults: - run: - working-directory: integration/test/performance_tracker - outputs: - local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} - steps: - - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - name: Get SHA - id: sha - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Get git date - id: sha_date - run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" - - name: MainTestRun - id: MainTestRUn - run: | - export SHA=${{ steps.sha.outputs.sha_short }} - export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} - go test -run TestPerformance diff --git a/integration/test/performance_tracker/performance_test.go b/integration/test/performance_tracker/performance_test.go index 8cf8bda139..06b67376a0 100644 --- a/integration/test/performance_tracker/performance_test.go +++ b/integration/test/performance_tracker/performance_test.go @@ -1,5 +1,5 @@ -//go:build linux && integration -// +build linux,integration +//// go:build linux && integration +//// +build linux,integration package performancetest From efc19e6ad44aa2f6acf28bdda94e391596911867 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 15:35:38 +0000 Subject: [PATCH 032/122] commens are back --- integration/test/performance_tracker/performance_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/test/performance_tracker/performance_test.go b/integration/test/performance_tracker/performance_test.go index 06b67376a0..beccb138f0 100644 --- a/integration/test/performance_tracker/performance_test.go +++ b/integration/test/performance_tracker/performance_test.go @@ -1,5 +1,5 @@ -//// go:build linux && integration -//// +build linux,integration +// go:build linux && integration +// +build linux,integration package performancetest From c389077cb3a2d4fbb3ca260cd30edf2878339dfd Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 16:09:17 +0000 Subject: [PATCH 033/122] fixed --- .github/workflows/fastPeformanceTest.yml | 2 +- .../test/performance_tracker/performance_query_utils.go | 2 +- integration/test/performance_tracker/performance_test.go | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index a8dc1c8dfd..b6f57591ae 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -56,4 +56,4 @@ jobs: run: | export SHA=${{ steps.sha.outputs.sha_short }} export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} - go test -run TestPerformance + go test-p 1 -v --tags=integration" diff --git a/integration/test/performance_tracker/performance_query_utils.go b/integration/test/performance_tracker/performance_query_utils.go index bb4500268a..39e6538d04 100644 --- a/integration/test/performance_tracker/performance_query_utils.go +++ b/integration/test/performance_tracker/performance_query_utils.go @@ -19,7 +19,7 @@ const ( DimensionName = "InstanceId" Stat = "Average" Period = 30 - configPath = "./resources/config.json" + // configPath = "./resources/config.json" ) /* diff --git a/integration/test/performance_tracker/performance_test.go b/integration/test/performance_tracker/performance_test.go index beccb138f0..a523369486 100644 --- a/integration/test/performance_tracker/performance_test.go +++ b/integration/test/performance_tracker/performance_test.go @@ -15,6 +15,7 @@ const ( configPath = "resources/config.json" configOutputPath = "/opt/aws/amazon-cloudwatch-agent/bin/config.json" agentRuntimeMinutes = 20 + ) func TestPerformance(t *testing.T) { @@ -33,9 +34,9 @@ func TestPerformance(t *testing.T) { test.StopAgent() //collect data - data, err := GetPerformanceMetrics(instanceId, agentRuntime, agentContext) + data, err := GetPerformanceMetrics(instanceId, agentRuntimeMinutes, agentContext) if err != nil { - log.Println("Error: " + err) + log.Println("Error: ", err) t.Fatalf("Error: %v", err) } From 046626831e81a1e6ef4432237e5dd48677e379d3 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 16:13:02 +0000 Subject: [PATCH 034/122] typo --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index b6f57591ae..20bcacff92 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -56,4 +56,4 @@ jobs: run: | export SHA=${{ steps.sha.outputs.sha_short }} export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} - go test-p 1 -v --tags=integration" + go test-p 1 -v --tags="integration" From c4cc42d4373358d8f46be1f35a264fd0ef3bce32 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 16:14:14 +0000 Subject: [PATCH 035/122] typo2 --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 20bcacff92..276a2670ea 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -56,4 +56,4 @@ jobs: run: | export SHA=${{ steps.sha.outputs.sha_short }} export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} - go test-p 1 -v --tags="integration" + go test -p 1 -v --tags="integration" From 0ee978f7a4b2922bfc43c4f95650758a37dad9fe Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 17:43:13 +0000 Subject: [PATCH 036/122] created a alone performance test -changed test dir --- .github/workflows/fastPeformanceTest.yml | 263 ++++++++++++++++++++--- 1 file changed, 233 insertions(+), 30 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 276a2670ea..181a99f875 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -1,7 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT -name: Run Integration Tests +name: Fast Performance Test env: PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }} TERRAFORM_AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} @@ -28,32 +28,235 @@ concurrency: cancel-in-progress: true jobs: - NonTerraformTest: - name: 'DummySHATest' - runs-on: ubuntu-latest - defaults: - run: - working-directory: integration/test/performance_tracker - outputs: - local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} - steps: - - uses: actions/checkout@v2 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - name: Get SHA - id: sha - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Get git date - id: sha_date - run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" - - name: MainTestRun - id: MainTestRUn - run: | - export SHA=${{ steps.sha.outputs.sha_short }} - export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} - go test -p 1 -v --tags="integration" + MakeBinary: + name: 'MakeBinary' + runs-on: ubuntu-latest + steps: + # Set up building environment, patch the dev repo code on dispatch events. + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ~1.18.3 + + - name: Install rpm + run: sudo apt install rpm + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Check out code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: 'true' + + - name: Cache go + id: cached_go + uses: actions/cache@v2 + env: + cache-name: cached_go_modules + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: v1-go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }} + + - name: Cache binaries + id: cached_binaries + uses: actions/cache@v2 + with: + key: "cached_binaries_${{ github.sha }}" + path: go.mod + + - name: Build Binaries + if: steps.cached_binaries.outputs.cache-hit != 'true' + run: make build package-rpm package-deb package-win package-darwin + + - uses: olafurpg/setup-gpg@v3 + + - name: Sign packages + if: steps.cached_binaries.outputs.cache-hit != 'true' + run: | + echo "${GPG_PRIVATE_KEY}" | gpg --batch --import - + for f in $(find build/bin/); do if [ ! -d $f ]; then echo "Signing file $f" && echo "${PASSPHRASE}" | gpg --detach-sign --passphrase-fd 0 --batch --default-key "${GPG_KEY_NAME}" $f ; fi ; done + + - name: Upload to s3 + if: steps.cached_binaries.outputs.cache-hit != 'true' + run: aws s3 cp build/bin s3://${S3_INTEGRATION_BUCKET}/integration-test/binary/${{ github.sha }} --recursive + + GenerateTestMatrix: + name: 'GenerateTestMatrix' + runs-on: ubuntu-latest + outputs: + ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }} + ec2_windows_matrix: ${{ steps.set-matrix.outputs.ec2_windows_matrix }} + ecs_fargate_matrix: ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} + steps: + - uses: actions/checkout@v2 + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ~1.18.3 + + - name: Generate matrix + id: set-matrix + run: | + go run --tags=generator integration/generator/test_case_generator.go + echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" + echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" + echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" + + - name: Echo test plan matrix + run: | + echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} + echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} + echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} + + StartLocalStack: + name: 'StartLocalStack' + runs-on: ubuntu-latest + defaults: + run: + working-directory: integration/terraform/ec2/localstack + outputs: + local_stack_host_name: ${{ steps.localstack.outputs.local_stack_host_name }} + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Verify Terraform version + run: terraform --version + + - name: Terraform init + run: terraform init + + - name: Terraform apply + id: localstack + run: > + echo run terraform and execute test code && + terraform apply --auto-approve + -var="ssh_key=${PRIVATE_KEY}" + -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + -var="github_sha=${GITHUB_SHA}" + -var="s3_bucket=${S3_INTEGRATION_BUCKET}" + -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" + -var="key_name=${KEY_NAME}" + -var="iam_instance_profile=${IAM_ROLE}" && + LOCAL_STACK_HOST_NAME=$(terraform output -raw public_dns) && + echo $LOCAL_STACK_HOST_NAME && + echo "::set-output name=local_stack_host_name::$LOCAL_STACK_HOST_NAME" && + aws s3 cp terraform.tfstate s3://${S3_INTEGRATION_BUCKET}/integration-test/local-stack-terraform-state/${GITHUB_SHA}/terraform.tfstate + + StopLocalStack: + name: 'StopLocalStack' + runs-on: ubuntu-latest + if: ${{ always() }} + needs: [StartLocalStack, EC2LinuxIntegrationTest] + defaults: + run: + working-directory: integration/terraform/ec2/localstack + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Copy state + run: aws s3 cp s3://${S3_INTEGRATION_BUCKET}/integration-test/local-stack-terraform-state/${GITHUB_SHA}/terraform.tfstate . + + - name: Verify Terraform version + run: terraform --version + + - name: Terraform init + run: terraform init + + - name: Terraform destroy + run: terraform destroy --auto-approve + + PerformanceTrackingTest: + name: "PerformanceTrackingTest" + needs: [MakeBinary, StartLocalStack, GenerateTestMatrix] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Cache if success + id: performance-tracking + uses: actions/cache@v2 + with: + path: go.mod + key: performance-tracking-test-${{ github.sha }} + + - name: Echo Test Info + run: echo run performance-tracking + + - name: Verify Terraform version + run: terraform --version + - name: Get SHA + id: sha + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Get git date + id: sha_date + run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" + # nick-invision/retry@v2 starts at base dir + - name: Terraform apply + if: steps.performance-tracking.outputs.cache-hit != 'true' + uses: nick-invision/retry@v2 + with: + max_attempts: 1 + timeout_minutes: 30 + retry_wait_seconds: 5 + command: | + cd integration/terraform/ec2/linux + terraform init + if terraform apply --auto-approve \ + -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ + -var="github_sha=${GITHUB_SHA}" -var="install_agent=rpm -U ./amazon-cloudwatch-agent.rpm" \ + -var="user=ec2-user" \ + -var="ami=cloudwatch-agent-integration-test-al2*" \ + -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ + -var="arc=amd64" \ + -var="binary_name=amazon-cloudwatch-agent.rpm" \ + -var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \ + -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ + -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ + -var="key_name=${KEY_NAME}" \ + -var="test_name=cw-integ-test-al2" \ + -var="iam_instance_profile=${IAM_ROLE}" \ + -var="test_dir=performance_tracker" ; then terraform destroy -auto-approve + else + terraform destroy -auto-approve && exit 1 + fi + + #This is here just in case workflow cancel + - name: Terraform destroy + if: ${{ cancelled() && steps.performance-tracking.outputs.cache-hit != 'true' }} + uses: nick-invision/retry@v2 + with: + max_attempts: 3 + timeout_minutes: 8 + retry_wait_seconds: 5 + command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve + From f2f2a8b4fbbfe86375b17a4b4df800b35d91765c Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 17:44:26 +0000 Subject: [PATCH 037/122] fixed workflow error --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 181a99f875..b8b7c0c286 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -162,7 +162,7 @@ jobs: name: 'StopLocalStack' runs-on: ubuntu-latest if: ${{ always() }} - needs: [StartLocalStack, EC2LinuxIntegrationTest] + needs: [StartLocalStack, PerformanceTrackingTest] defaults: run: working-directory: integration/terraform/ec2/localstack From 2e2ce1a0cd1380fc67ade7cac27c851e1a4671d1 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 18:13:23 +0000 Subject: [PATCH 038/122] changed packet name and dir name --- .github/workflows/fastPeformanceTest.yml | 2 +- .../performance_query_utils.go | 0 .../performance_test.go | 0 .../resources/config.json | 0 .../{performance_tracker => performancetest}/transmitter.go | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename integration/test/{performance_tracker => performancetest}/performance_query_utils.go (100%) rename integration/test/{performance_tracker => performancetest}/performance_test.go (100%) rename integration/test/{performance_tracker => performancetest}/resources/config.json (100%) rename integration/test/{performance_tracker => performancetest}/transmitter.go (100%) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index b8b7c0c286..a588641323 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -245,7 +245,7 @@ jobs: -var="key_name=${KEY_NAME}" \ -var="test_name=cw-integ-test-al2" \ -var="iam_instance_profile=${IAM_ROLE}" \ - -var="test_dir=performance_tracker" ; then terraform destroy -auto-approve + -var="test_dir=performancetest" ; then terraform destroy -auto-approve else terraform destroy -auto-approve && exit 1 fi diff --git a/integration/test/performance_tracker/performance_query_utils.go b/integration/test/performancetest/performance_query_utils.go similarity index 100% rename from integration/test/performance_tracker/performance_query_utils.go rename to integration/test/performancetest/performance_query_utils.go diff --git a/integration/test/performance_tracker/performance_test.go b/integration/test/performancetest/performance_test.go similarity index 100% rename from integration/test/performance_tracker/performance_test.go rename to integration/test/performancetest/performance_test.go diff --git a/integration/test/performance_tracker/resources/config.json b/integration/test/performancetest/resources/config.json similarity index 100% rename from integration/test/performance_tracker/resources/config.json rename to integration/test/performancetest/resources/config.json diff --git a/integration/test/performance_tracker/transmitter.go b/integration/test/performancetest/transmitter.go similarity index 100% rename from integration/test/performance_tracker/transmitter.go rename to integration/test/performancetest/transmitter.go From 866ab4c38de43194432f6becafcfa5b33958eaa7 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 18:45:55 +0000 Subject: [PATCH 039/122] temp --- .github/workflows/fastPeformanceTest.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index a588641323..3fbdfa1e6a 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -211,7 +211,8 @@ jobs: - name: Echo Test Info run: echo run performance-tracking - + -name: TEMP TEST LOOKUP + run: echo ${{ matrix.arrays.test_dir }}" - name: Verify Terraform version run: terraform --version - name: Get SHA From 608669b9262541fae278d46bc0d95a86f0789a30 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 18:47:20 +0000 Subject: [PATCH 040/122] temp2 --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 3fbdfa1e6a..4e4e42608e 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -212,7 +212,7 @@ jobs: - name: Echo Test Info run: echo run performance-tracking -name: TEMP TEST LOOKUP - run: echo ${{ matrix.arrays.test_dir }}" + run: echo ${{ matrix.arrays.test_dir}} - name: Verify Terraform version run: terraform --version - name: Get SHA From 43dc9eb0e98e06fee6ad46ccfbc2c97308816ca1 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 18:47:49 +0000 Subject: [PATCH 041/122] typo --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 4e4e42608e..a06a9dce1d 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -212,7 +212,7 @@ jobs: - name: Echo Test Info run: echo run performance-tracking -name: TEMP TEST LOOKUP - run: echo ${{ matrix.arrays.test_dir}} + run: echo "${{ matrix.arrays.test_dir}}"" - name: Verify Terraform version run: terraform --version - name: Get SHA From 3d5c3e35dc81af701466fa6d3d5f5dfacaba893e Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 18:48:16 +0000 Subject: [PATCH 042/122] typo --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index a06a9dce1d..ecec5444e9 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -212,7 +212,7 @@ jobs: - name: Echo Test Info run: echo run performance-tracking -name: TEMP TEST LOOKUP - run: echo "${{ matrix.arrays.test_dir}}"" + run: echo "${{ matrix.arrays.test_dir}}" - name: Verify Terraform version run: terraform --version - name: Get SHA From 4e90bd39d6d1a515bc597e683e43d793e2e77d80 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 18:49:54 +0000 Subject: [PATCH 043/122] temp --- .github/workflows/fastPeformanceTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index ecec5444e9..190790b783 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -116,6 +116,8 @@ jobs: echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} + - name: TEMP TEST LOOKUP + run: echo "${{ matrix.arrays.test_dir}}" StartLocalStack: name: 'StartLocalStack' @@ -211,8 +213,6 @@ jobs: - name: Echo Test Info run: echo run performance-tracking - -name: TEMP TEST LOOKUP - run: echo "${{ matrix.arrays.test_dir}}" - name: Verify Terraform version run: terraform --version - name: Get SHA From ac8b18357fbb38c7129a1a2be0079310fd02db3d Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 19:02:38 +0000 Subject: [PATCH 044/122] debuggin --- .github/workflows/fastPeformanceTest.yml | 3 +-- .github/workflows/integrationTest.yml | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 190790b783..0b00f21a44 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -116,8 +116,7 @@ jobs: echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} - - name: TEMP TEST LOOKUP - run: echo "${{ matrix.arrays.test_dir}}" + StartLocalStack: name: 'StartLocalStack' diff --git a/.github/workflows/integrationTest.yml b/.github/workflows/integrationTest.yml index 062cf8daf5..07d9c35e38 100644 --- a/.github/workflows/integrationTest.yml +++ b/.github/workflows/integrationTest.yml @@ -402,6 +402,8 @@ jobs: matrix: arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_linux_matrix) }} steps: + - name: TEMP TEST LOOKUP + run: echo "${{ matrix.arrays.test_dir}}" - uses: actions/checkout@v2 - name: Configure AWS Credentials From 300cd4828260ac2d76aa6501393ddb0996858851 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 19:12:01 +0000 Subject: [PATCH 045/122] path change --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 0b00f21a44..e8f87a9503 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -245,7 +245,7 @@ jobs: -var="key_name=${KEY_NAME}" \ -var="test_name=cw-integ-test-al2" \ -var="iam_instance_profile=${IAM_ROLE}" \ - -var="test_dir=performancetest" ; then terraform destroy -auto-approve + -var="test_dir=./integration/test/performancetest" ; then terraform destroy -auto-approve else terraform destroy -auto-approve && exit 1 fi From e961a1802176c88a60854f6529e30d9947240474 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 19:40:05 +0000 Subject: [PATCH 046/122] added dyanmo --- .github/workflows/fastPeformanceTest.yml | 2 +- integration/test/performancetest/performance_test.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index e8f87a9503..23aa5cc513 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -226,7 +226,7 @@ jobs: uses: nick-invision/retry@v2 with: max_attempts: 1 - timeout_minutes: 30 + timeout_minutes: 50 retry_wait_seconds: 5 command: | cd integration/terraform/ec2/linux diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index a523369486..585cdf9556 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -14,7 +14,7 @@ import( const ( configPath = "resources/config.json" configOutputPath = "/opt/aws/amazon-cloudwatch-agent/bin/config.json" - agentRuntimeMinutes = 20 + agentRuntimeMinutes = 5 //20 def ) @@ -41,9 +41,17 @@ func TestPerformance(t *testing.T) { } //------Placeholder to put data into database------// - //useless code so data get used and compiler isn't mad if data == nil { t.Fatalf("No data") } + //data base + dynamoDB := InitializeTransmitterAPI("CWAPerformanceMetrics") //add cwa version here + if dynamoDB == nil{ + t.Fatalf("Error: generating dynamo table") + } + _, err = dynamoDB.SendItem(data) + if err !=nil{ + t.Fatalf("Error: couldnt upload metric data to table") + } } \ No newline at end of file From 38cb967a4b4f5efe9a9cc12b82a4daf62059fb8d Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 19:57:10 +0000 Subject: [PATCH 047/122] added sleep to transmitter --- integration/test/performancetest/transmitter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 752868dfb9..c764d1d02c 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -103,7 +103,7 @@ func (transmitter *TransmitterAPI) CreateTable() error { fmt.Printf("Error calling CreateTable: %s", err) return err } - + time.Sleep(10*time.Second) fmt.Println("Created the table", transmitter.DataBaseName) return nil } From 55617ed3905b009b6924d094f667d82e21795f6a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 20:20:52 +0000 Subject: [PATCH 048/122] fixed hash bug --- integration/test/performancetest/transmitter.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index c764d1d02c..db5575f270 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -199,15 +199,20 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, } packet := make(map[string]interface{}) //@TODO: add git integration temp solution - packet["Hash"] = fmt.Sprintf("%d", time.Now().UnixNano()) - packet["CommitDate"] = fmt.Sprintf("%d", time.Now().UnixNano()) + packet["Hash"] = os.Getenv("SHA") //fmt.Sprintf("%d", time.Now().UnixNano()) + packet["CommitDate"] = os.Getenv("SHA_DATE")//fmt.Sprintf("%d", time.Now().UnixNano()) /// will remove for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) // @TODO:ADD GetMetricStatistics after merging with data collection code + sum :=0.0 + for _,val := range rawMetricData.Values { + sum += val + } + avg := sum /numDataPoints //---------------- metric := Metric{ - Average: 0.0, + Average: avg, Max: 100.0, Min: 0.0, P99: 0.0, From 73ea34999715a1b408dfdbb1fb29d9ff92b795f9 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 20:45:16 +0000 Subject: [PATCH 049/122] added export --- .github/workflows/fastPeformanceTest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 23aa5cc513..8a26f9e460 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -229,6 +229,8 @@ jobs: timeout_minutes: 50 retry_wait_seconds: 5 command: | + export SHA=${{ steps.sha.outputs.sha_short }} + export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} cd integration/terraform/ec2/linux terraform init if terraform apply --auto-approve \ From 46d0127ea0009f3f7f837a7aa98fd6f1326732a7 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 23 Jun 2022 21:05:04 +0000 Subject: [PATCH 050/122] testing export --- integration/test/performancetest/transmitter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index db5575f270..e4af999301 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -199,6 +199,7 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, } packet := make(map[string]interface{}) //@TODO: add git integration temp solution + fmt.Println(os.Getenv("SHA"),os.Getenv("SHA_DATE")) packet["Hash"] = os.Getenv("SHA") //fmt.Sprintf("%d", time.Now().UnixNano()) packet["CommitDate"] = os.Getenv("SHA_DATE")//fmt.Sprintf("%d", time.Now().UnixNano()) /// will remove From 3afdcc6185028fe2d0a6061f04c1014606c77ab1 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 13:28:56 +0000 Subject: [PATCH 051/122] Moved env vars to terraform --- .github/workflows/fastPeformanceTest.yml | 4 ++-- integration/terraform/ec2/linux/main.tf | 2 ++ integration/terraform/ec2/linux/variables.tf | 8 ++++++++ integration/test/performancetest/transmitter.go | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 8a26f9e460..a6e2d3adb8 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -229,8 +229,6 @@ jobs: timeout_minutes: 50 retry_wait_seconds: 5 command: | - export SHA=${{ steps.sha.outputs.sha_short }} - export SHA_DATE=${{ steps.sha_date.outputs.sha_date }} cd integration/terraform/ec2/linux terraform init if terraform apply --auto-approve \ @@ -248,6 +246,8 @@ jobs: -var="test_name=cw-integ-test-al2" \ -var="iam_instance_profile=${IAM_ROLE}" \ -var="test_dir=./integration/test/performancetest" ; then terraform destroy -auto-approve + -var="sha=${{ steps.sha.outputs.sha_short }}" + -var="sha_date=${{ steps.sha_date.outputs.sha_date }}" else terraform destroy -auto-approve && exit 1 fi diff --git a/integration/terraform/ec2/linux/main.tf b/integration/terraform/ec2/linux/main.tf index a9df329b8b..f65c78b69a 100644 --- a/integration/terraform/ec2/linux/main.tf +++ b/integration/terraform/ec2/linux/main.tf @@ -9,6 +9,8 @@ resource "aws_instance" "integration-test" { "cloud-init status --wait", "echo clone and install agent", "export PATH=$PATH:/usr/local/go/bin", + "export SHA=${{var.sha }}", + "export SHA_DATE=${{ var.sha_date }}", "git clone ${var.github_repo}", "cd amazon-cloudwatch-agent", "git reset --hard ${var.github_sha}", diff --git a/integration/terraform/ec2/linux/variables.tf b/integration/terraform/ec2/linux/variables.tf index fdbf017df9..1d4083fc9d 100644 --- a/integration/terraform/ec2/linux/variables.tf +++ b/integration/terraform/ec2/linux/variables.tf @@ -87,4 +87,12 @@ variable "test_name" { variable "test_dir" { type = string default = "" +} +variable "sha" { + type = string + default = "" +} +variable "sha_date"{ + type = string + default = "" } \ No newline at end of file diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index e4af999301..ac60b62479 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -199,7 +199,7 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, } packet := make(map[string]interface{}) //@TODO: add git integration temp solution - fmt.Println(os.Getenv("SHA"),os.Getenv("SHA_DATE")) + fmt.Println("SHA:",os.Getenv("SHA"),"DATE:",os.Getenv("SHA_DATE")) packet["Hash"] = os.Getenv("SHA") //fmt.Sprintf("%d", time.Now().UnixNano()) packet["CommitDate"] = os.Getenv("SHA_DATE")//fmt.Sprintf("%d", time.Now().UnixNano()) /// will remove From 387818a3b7340f812408a9706497b980798d03e0 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 13:37:08 +0000 Subject: [PATCH 052/122] typo fix in main.tf --- integration/terraform/ec2/linux/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/terraform/ec2/linux/main.tf b/integration/terraform/ec2/linux/main.tf index f65c78b69a..755471ec5a 100644 --- a/integration/terraform/ec2/linux/main.tf +++ b/integration/terraform/ec2/linux/main.tf @@ -9,8 +9,8 @@ resource "aws_instance" "integration-test" { "cloud-init status --wait", "echo clone and install agent", "export PATH=$PATH:/usr/local/go/bin", - "export SHA=${{var.sha }}", - "export SHA_DATE=${{ var.sha_date }}", + "export SHA=${var.sha}", + "export SHA_DATE=${var.sha_date}", "git clone ${var.github_repo}", "cd amazon-cloudwatch-agent", "git reset --hard ${var.github_sha}", From 39788928fc398dd193acca693355f1dddc39ff34 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 13:55:16 +0000 Subject: [PATCH 053/122] sanity check --- .github/workflows/fastPeformanceTest.yml | 2 ++ integration/test/performancetest/performance_test.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index a6e2d3adb8..efd9c1937a 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -220,6 +220,8 @@ jobs: - name: Get git date id: sha_date run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" + - name: Check env + run: echo "SHA ${{ steps.sha.outputs.sha_short }} | Date ${{ steps.sha_date.outputs.sha_date }} " # nick-invision/retry@v2 starts at base dir - name: Terraform apply if: steps.performance-tracking.outputs.cache-hit != 'true' diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 585cdf9556..0c92b73173 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -14,7 +14,7 @@ import( const ( configPath = "resources/config.json" configOutputPath = "/opt/aws/amazon-cloudwatch-agent/bin/config.json" - agentRuntimeMinutes = 5 //20 def + agentRuntimeMinutes = 2 //20 def ) From c98e6909d713b0876421dc0e54702f4b1ecd624b Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 14:05:46 +0000 Subject: [PATCH 054/122] changed export pos --- integration/terraform/ec2/linux/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/terraform/ec2/linux/main.tf b/integration/terraform/ec2/linux/main.tf index 755471ec5a..73ee20b818 100644 --- a/integration/terraform/ec2/linux/main.tf +++ b/integration/terraform/ec2/linux/main.tf @@ -9,8 +9,6 @@ resource "aws_instance" "integration-test" { "cloud-init status --wait", "echo clone and install agent", "export PATH=$PATH:/usr/local/go/bin", - "export SHA=${var.sha}", - "export SHA_DATE=${var.sha_date}", "git clone ${var.github_repo}", "cd amazon-cloudwatch-agent", "git reset --hard ${var.github_sha}", @@ -28,6 +26,8 @@ resource "aws_instance" "integration-test" { "echo run tests with the tag integration, one at a time, and verbose", "cd ~/amazon-cloudwatch-agent", "echo run sanity test && go test ./integration/test/sanity -p 1 -v --tags=integration", + "export SHA=${var.sha}", + "export SHA_DATE=${var.sha_date}", "go test ${var.test_dir} -p 1 -v --tags=integration" ] connection { From 3201e406ffa0a7e99f519ec24810e5c30cb859fa Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 14:23:13 +0000 Subject: [PATCH 055/122] added \ and changed locatin of var --- .github/workflows/fastPeformanceTest.yml | 5 +++-- integration/terraform/ec2/linux/main.tf | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index efd9c1937a..a99756506b 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -247,9 +247,10 @@ jobs: -var="key_name=${KEY_NAME}" \ -var="test_name=cw-integ-test-al2" \ -var="iam_instance_profile=${IAM_ROLE}" \ + -var="sha=${{ steps.sha.outputs.sha_short }}" \ + -var="sha_date=${{ steps.sha_date.outputs.sha_date }}" \ -var="test_dir=./integration/test/performancetest" ; then terraform destroy -auto-approve - -var="sha=${{ steps.sha.outputs.sha_short }}" - -var="sha_date=${{ steps.sha_date.outputs.sha_date }}" + else terraform destroy -auto-approve && exit 1 fi diff --git a/integration/terraform/ec2/linux/main.tf b/integration/terraform/ec2/linux/main.tf index 73ee20b818..b13a7e7b74 100644 --- a/integration/terraform/ec2/linux/main.tf +++ b/integration/terraform/ec2/linux/main.tf @@ -6,6 +6,7 @@ resource "aws_instance" "integration-test" { vpc_security_group_ids = var.vpc_security_group_ids provisioner "remote-exec" { inline = [ + "echo sha ${var.sha}", "cloud-init status --wait", "echo clone and install agent", "export PATH=$PATH:/usr/local/go/bin", From fd461fc303057a8f6e9a237f25bdca6eea4dad9a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 14:46:38 +0000 Subject: [PATCH 056/122] debugging --- integration/test/performancetest/transmitter.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index ac60b62479..68342b8563 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -187,6 +187,7 @@ func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { if err != nil { return "", err } + fmt.Printf("%+v",packet) sentItem, err := transmitter.AddItem(packet) return sentItem, err } @@ -201,7 +202,7 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, //@TODO: add git integration temp solution fmt.Println("SHA:",os.Getenv("SHA"),"DATE:",os.Getenv("SHA_DATE")) packet["Hash"] = os.Getenv("SHA") //fmt.Sprintf("%d", time.Now().UnixNano()) - packet["CommitDate"] = os.Getenv("SHA_DATE")//fmt.Sprintf("%d", time.Now().UnixNano()) + packet["CommitDate"] = fmt.Sprintf("%d", os.Getenv("SHA_DATE")) /// will remove for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) From a5ac8a1b6563ee403c0468d15c30bb205388a79b Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 14:58:03 +0000 Subject: [PATCH 057/122] type fix --- integration/test/performancetest/transmitter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 68342b8563..a93265a7a3 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -202,7 +202,7 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, //@TODO: add git integration temp solution fmt.Println("SHA:",os.Getenv("SHA"),"DATE:",os.Getenv("SHA_DATE")) packet["Hash"] = os.Getenv("SHA") //fmt.Sprintf("%d", time.Now().UnixNano()) - packet["CommitDate"] = fmt.Sprintf("%d", os.Getenv("SHA_DATE")) + packet["CommitDate"] =os.Getenv("SHA_DATE") /// will remove for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) From 11131aa39a66b6ca7787b7d8eca854306d59d754 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 15:44:27 +0000 Subject: [PATCH 058/122] Running Test for 10 mins --- .../test/performancetest/performance_test.go | 2 +- .../test/performancetest/transmitter.go | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 0c92b73173..4af193e5d0 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -14,7 +14,7 @@ import( const ( configPath = "resources/config.json" configOutputPath = "/opt/aws/amazon-cloudwatch-agent/bin/config.json" - agentRuntimeMinutes = 2 //20 def + agentRuntimeMinutes = 10 //20 def ) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index a93265a7a3..ca24d7cbfa 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -199,19 +199,23 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, return nil, err } packet := make(map[string]interface{}) - //@TODO: add git integration temp solution - fmt.Println("SHA:",os.Getenv("SHA"),"DATE:",os.Getenv("SHA_DATE")) + packet["Hash"] = os.Getenv("SHA") //fmt.Sprintf("%d", time.Now().UnixNano()) packet["CommitDate"] =os.Getenv("SHA_DATE") /// will remove for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) - // @TODO:ADD GetMetricStatistics after merging with data collection code - sum :=0.0 - for _,val := range rawMetricData.Values { - sum += val + var avg float64 + if numDataPoints <= 0{ + avg = 0.0 + }else{ + // @TODO:ADD GetMetricStatistics after merging with data collection code + sum :=0.0 + for _,val := range rawMetricData.Values { + sum += val + } + avg = sum /numDataPoints } - avg := sum /numDataPoints //---------------- metric := Metric{ Average: avg, From 388e95b12bb4dec2c56da062de22d8faf6ff85b6 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 16:08:47 +0000 Subject: [PATCH 059/122] switched back to 5 mins --- integration/test/performancetest/performance_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 4af193e5d0..585cdf9556 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -14,7 +14,7 @@ import( const ( configPath = "resources/config.json" configOutputPath = "/opt/aws/amazon-cloudwatch-agent/bin/config.json" - agentRuntimeMinutes = 10 //20 def + agentRuntimeMinutes = 5 //20 def ) From a46f4a920392f340a7f59e3bbf81b77aa56041cb Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 16:16:24 +0000 Subject: [PATCH 060/122] increased timeout in go test --- integration/terraform/ec2/linux/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/terraform/ec2/linux/main.tf b/integration/terraform/ec2/linux/main.tf index b13a7e7b74..6fdb8aa871 100644 --- a/integration/terraform/ec2/linux/main.tf +++ b/integration/terraform/ec2/linux/main.tf @@ -29,7 +29,7 @@ resource "aws_instance" "integration-test" { "echo run sanity test && go test ./integration/test/sanity -p 1 -v --tags=integration", "export SHA=${var.sha}", "export SHA_DATE=${var.sha_date}", - "go test ${var.test_dir} -p 1 -v --tags=integration" + "go test ${var.test_dir} -p 1 -timeout 30m -v --tags=integration " ] connection { type = "ssh" From b25f8bba32646a9b2fdd410221efaff6dca13208 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 16:44:48 +0000 Subject: [PATCH 061/122] added commit date as a sort key --- integration/test/performancetest/transmitter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index ca24d7cbfa..3b9246cb34 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -92,6 +92,10 @@ func (transmitter *TransmitterAPI) CreateTable() error { AttributeName: aws.String("Hash"), KeyType: types.KeyTypeHash, }, + { + AttributeName: aws.String("CommitDate"), + KeyType: types.KeyTypeRange, + }, }, ProvisionedThroughput: &types.ProvisionedThroughput{ ReadCapacityUnits: aws.Int64(10), From 0efb4ba0ba8cfd798ea6235926f6af0c5995c7f0 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 17:16:54 +0000 Subject: [PATCH 062/122] fix --- integration/test/performancetest/transmitter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 3b9246cb34..512819d894 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -86,6 +86,10 @@ func (transmitter *TransmitterAPI) CreateTable() error { AttributeName: aws.String("Hash"), AttributeType: types.ScalarAttributeTypeS, }, + { + AttributeName: aws.String("CommitDate"), + AttributeType: types.ScalarAttributeTypeS, + }, }, KeySchema: []types.KeySchemaElement{ { From 5a9590341195f561214bab7ec03ffb334b259099 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 24 Jun 2022 17:35:51 +0000 Subject: [PATCH 063/122] changing const --- integration/test/performancetest/transmitter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 512819d894..50b7732172 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -15,7 +15,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -const METRIC_PERIOD = 300.0 // this const is in seconds , 5 mins +const METRIC_PERIOD = agentRuntimeMinutes * 60 // this const is in seconds , 5 mins type TransmitterAPI struct { dynamoDbClient *dynamodb.Client From 9953e1e90ddd6b648a15eb47a7cd254dfc561c69 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 28 Jun 2022 17:08:37 +0000 Subject: [PATCH 064/122] testing new create table --- .../test/performancetest/transmitter.go | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 50b7732172..dc2047d54b 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -101,6 +101,24 @@ func (transmitter *TransmitterAPI) CreateTable() error { KeyType: types.KeyTypeRange, }, }, + GlobalSecondaryIndexes: []types.GlobalSecondaryIndex{ + { + IndexName: aws.String("CommitDate-index"), + KeySchema: []types.KeySchemaElement{ + { + AttributeName: aws.String("CommitDate"), + KeyType: types.KeyTypeHash, + }, + }, + Projection: &types.Projection{ + ProjectionType : "ALL", + }, + ProvisionedThroughput: &types.ProvisionedThroughput{ + ReadCapacityUnits: aws.Int64(10), + WriteCapacityUnits: aws.Int64(10), + }, + }, + }, ProvisionedThroughput: &types.ProvisionedThroughput{ ReadCapacityUnits: aws.Int64(10), WriteCapacityUnits: aws.Int64(10), @@ -111,11 +129,19 @@ func (transmitter *TransmitterAPI) CreateTable() error { fmt.Printf("Error calling CreateTable: %s", err) return err } - time.Sleep(10*time.Second) + // time.Sleep(10*time.Second) //@Todo add buffer check instead of sleep before final product. + //https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.CreateTable.html + waiter := dynamodb.NewTableExistsWaiter(transmitter.dynamoDbClient) + err = waiter.Wait(context.TODO(), &dynamodb.DescribeTableInput{ + TableName: aws.String(transmitter.DataBaseName)}, 5* time.Minute) + if err != nil { + log.Printf("Wait for table exists failed. Here's why: %v\n", err) + } fmt.Println("Created the table", transmitter.DataBaseName) return nil } + /* AddItem() Desc: Takes in a packet and From 542ddfe31542ebd6ef2d56651340065151b8163d Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 28 Jun 2022 18:00:01 +0000 Subject: [PATCH 065/122] typo --- integration/test/performancetest/transmitter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index dc2047d54b..f3c59c6a3b 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "time" + "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" From fe36e57c4c47a1a113e92745d27015c4f1a6db11 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 28 Jun 2022 18:17:51 +0000 Subject: [PATCH 066/122] typo --- integration/test/performancetest/transmitter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index f3c59c6a3b..2d82de993c 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -89,7 +89,7 @@ func (transmitter *TransmitterAPI) CreateTable() error { }, { AttributeName: aws.String("CommitDate"), - AttributeType: types.ScalarAttributeTypeS, + AttributeType: types.ScalarAttributeTypeN, }, }, KeySchema: []types.KeySchemaElement{ From ea17719a54c5890388a26332446a4bd2b2f2219a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 28 Jun 2022 19:04:21 +0000 Subject: [PATCH 067/122] fix --- .../test/performancetest/transmitter.go | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 2d82de993c..da00fc01b3 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "time" + "strconv" "log" "github.com/aws/aws-sdk-go-v2/aws" @@ -16,8 +17,13 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) -const METRIC_PERIOD = agentRuntimeMinutes * 60 // this const is in seconds , 5 mins - +const ( + METRIC_PERIOD = agentRuntimeMinutes * 60 // this const is in seconds , 5 mins + HASH = "Hash" + COMMIT_DATE= "CommitDate" + SHA_ENV = "SHA" + SHA_DATE_ENV = "SHA_DATE" +) type TransmitterAPI struct { dynamoDbClient *dynamodb.Client DataBaseName string // this is the name of the table when test is run @@ -49,7 +55,7 @@ Side effects: Creates a dynamodb table if it doesn't already exist */ func InitializeTransmitterAPI(DataBaseName string) *TransmitterAPI { //setup aws session - cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(os.Getenv("AWS_REGION"))) + cfg, err := config.LoadDefaultConfig(context.TODO()) if err != nil { fmt.Printf("Error: Loading in config %s\n", err) } @@ -73,13 +79,12 @@ func InitializeTransmitterAPI(DataBaseName string) *TransmitterAPI { return &transmitter } - /* CreateTable() Desc: Will create a DynamoDB Table with given param. and config */ //add secondary index space vs time -func (transmitter *TransmitterAPI) CreateTable() error { + func (transmitter *TransmitterAPI) CreateTable() error { _, err := transmitter.dynamoDbClient.CreateTable( context.TODO(), &dynamodb.CreateTableInput{ AttributeDefinitions: []types.AttributeDefinition{ @@ -141,8 +146,6 @@ func (transmitter *TransmitterAPI) CreateTable() error { fmt.Println("Created the table", transmitter.DataBaseName) return nil } - - /* AddItem() Desc: Takes in a packet and @@ -174,13 +177,6 @@ Desc: Checks if the the table exist and returns the value //https://github.com/awsdocs/aws-doc-sdk-examples/blob/05a89da8c2f2e40781429a7c34cf2f2b9ae35f89/gov2/dynamodb/actions/table_basics.go */ func (transmitter *TransmitterAPI) TableExist() (bool, error) { - // l,err := transmitter.ListTables() - // for i:=0; i< len(l); i++{ - // if transmitter.DataBaseName == l[i]{ - // return true,nil - // } - // } - // return false,err exists := true _, err := transmitter.dynamoDbClient.DescribeTable( context.TODO(), &dynamodb.DescribeTableInput{TableName: aws.String(transmitter.DataBaseName)}, @@ -191,25 +187,13 @@ func (transmitter *TransmitterAPI) TableExist() (bool, error) { fmt.Printf("Table %v does not exist.\n", transmitter.DataBaseName) err = nil } else { - fmt.Printf("Couldn't determine existence of table %v. Here's why: %v\n", transmitter.DataBaseName, err) + fmt.Printf("Couldn't determine existence of table %v. Error: %v\n", transmitter.DataBaseName, err) } exists = false } return exists, err } -/* -RemoveTable() -Desc: Removes the table that was craeted with initialization. -*/ -func (transmitter *TransmitterAPI) RemoveTable() error { - _, err := transmitter.dynamoDbClient.DeleteTable(context.TODO(), - &dynamodb.DeleteTableInput{TableName: aws.String(transmitter.DataBaseName)}) - if err != nil { - fmt.Println(err) - } - return err -} /* SendItem() @@ -235,14 +219,15 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, } packet := make(map[string]interface{}) - packet["Hash"] = os.Getenv("SHA") //fmt.Sprintf("%d", time.Now().UnixNano()) - packet["CommitDate"] =os.Getenv("SHA_DATE") - /// will remove + packet[HASH] = os.Getenv(SHA_ENV) //fmt.Sprintf("%d", time.Now().UnixNano()) + packet[COMMIT_DATE],_ = strconv.Atoi(os.Getenv(SHA_DATE_ENV)) + for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) var avg float64 if numDataPoints <= 0{ avg = 0.0 + log.Fatalf("Error there is no data points") }else{ // @TODO:ADD GetMetricStatistics after merging with data collection code sum :=0.0 @@ -262,4 +247,4 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, packet[rawMetricData.Label] = metric } return packet, nil -} +} \ No newline at end of file From b161b4c524a2407b412a2d5f1359c7ddfa01707e Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 30 Jun 2022 22:48:40 +0000 Subject: [PATCH 068/122] changed backend --- .../test/performancetest/transmitter.go | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index da00fc01b3..1d5e4663b8 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "math/rand" "os" "time" "strconv" @@ -18,7 +19,8 @@ import ( ) const ( - METRIC_PERIOD = agentRuntimeMinutes * 60 // this const is in seconds , 5 mins + METRIC_PERIOD = 5 * 60 // this const is in seconds , 5 mins + PARTITION_KEY ="Year" HASH = "Hash" COMMIT_DATE= "CommitDate" SHA_ENV = "SHA" @@ -36,6 +38,7 @@ type Metric struct { Max float64 Min float64 Period int //in seconds + Std float64 Data []float64 } @@ -55,7 +58,7 @@ Side effects: Creates a dynamodb table if it doesn't already exist */ func InitializeTransmitterAPI(DataBaseName string) *TransmitterAPI { //setup aws session - cfg, err := config.LoadDefaultConfig(context.TODO()) + cfg, err := config.LoadDefaultConfig(context.TODO(),config.WithRegion("us-west-2")) if err != nil { fmt.Printf("Error: Loading in config %s\n", err) } @@ -79,18 +82,19 @@ func InitializeTransmitterAPI(DataBaseName string) *TransmitterAPI { return &transmitter } + /* CreateTable() Desc: Will create a DynamoDB Table with given param. and config */ //add secondary index space vs time - func (transmitter *TransmitterAPI) CreateTable() error { +func (transmitter *TransmitterAPI) CreateTable() error { _, err := transmitter.dynamoDbClient.CreateTable( context.TODO(), &dynamodb.CreateTableInput{ AttributeDefinitions: []types.AttributeDefinition{ { - AttributeName: aws.String("Hash"), - AttributeType: types.ScalarAttributeTypeS, + AttributeName: aws.String(PARTITION_KEY), + AttributeType: types.ScalarAttributeTypeN, }, { AttributeName: aws.String("CommitDate"), @@ -99,7 +103,7 @@ Desc: Will create a DynamoDB Table with given param. and config }, KeySchema: []types.KeySchemaElement{ { - AttributeName: aws.String("Hash"), + AttributeName: aws.String(PARTITION_KEY), KeyType: types.KeyTypeHash, }, { @@ -107,24 +111,7 @@ Desc: Will create a DynamoDB Table with given param. and config KeyType: types.KeyTypeRange, }, }, - GlobalSecondaryIndexes: []types.GlobalSecondaryIndex{ - { - IndexName: aws.String("CommitDate-index"), - KeySchema: []types.KeySchemaElement{ - { - AttributeName: aws.String("CommitDate"), - KeyType: types.KeyTypeHash, - }, - }, - Projection: &types.Projection{ - ProjectionType : "ALL", - }, - ProvisionedThroughput: &types.ProvisionedThroughput{ - ReadCapacityUnits: aws.Int64(10), - WriteCapacityUnits: aws.Int64(10), - }, - }, - }, + ProvisionedThroughput: &types.ProvisionedThroughput{ ReadCapacityUnits: aws.Int64(10), WriteCapacityUnits: aws.Int64(10), @@ -135,7 +122,6 @@ Desc: Will create a DynamoDB Table with given param. and config fmt.Printf("Error calling CreateTable: %s", err) return err } - // time.Sleep(10*time.Second) //@Todo add buffer check instead of sleep before final product. //https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.CreateTable.html waiter := dynamodb.NewTableExistsWaiter(transmitter.dynamoDbClient) err = waiter.Wait(context.TODO(), &dynamodb.DescribeTableInput{ @@ -146,6 +132,7 @@ Desc: Will create a DynamoDB Table with given param. and config fmt.Println("Created the table", transmitter.DataBaseName) return nil } + /* AddItem() Desc: Takes in a packet and @@ -206,11 +193,10 @@ func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { if err != nil { return "", err } - fmt.Printf("%+v",packet) + // fmt.Printf("%+v",packet) sentItem, err := transmitter.AddItem(packet) return sentItem, err } - func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, error) { dataHolder := collectorData{} err := json.Unmarshal(data, &dataHolder) @@ -218,30 +204,42 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, return nil, err } packet := make(map[string]interface{}) - + packet[PARTITION_KEY] = time.Now().Year() packet[HASH] = os.Getenv(SHA_ENV) //fmt.Sprintf("%d", time.Now().UnixNano()) packet[COMMIT_DATE],_ = strconv.Atoi(os.Getenv(SHA_DATE_ENV)) for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) var avg float64 + var max float64 + var min float64 if numDataPoints <= 0{ avg = 0.0 + max = 0.0 + min = 0.0 log.Fatalf("Error there is no data points") }else{ // @TODO:ADD GetMetricStatistics after merging with data collection code sum :=0.0 for _,val := range rawMetricData.Values { sum += val + if max < val{ + max = val + } + if min > val { + min = val + } } + avg = sum /numDataPoints } //---------------- metric := Metric{ Average: avg, - Max: 100.0, - Min: 0.0, + Max: max, + Min: min, P99: 0.0, + Std: rand.Float64(), Period: int(METRIC_PERIOD / (numDataPoints)), Data: rawMetricData.Values} packet[rawMetricData.Label] = metric From 0c71b045f5041156c08347260cb9f3c3bac6e51b Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 30 Jun 2022 22:58:21 +0000 Subject: [PATCH 069/122] demo-0 --- integration/test/performancetest/demo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 integration/test/performancetest/demo.txt diff --git a/integration/test/performancetest/demo.txt b/integration/test/performancetest/demo.txt new file mode 100644 index 0000000000..10b2bc904a --- /dev/null +++ b/integration/test/performancetest/demo.txt @@ -0,0 +1 @@ +commitCount=0 \ No newline at end of file From 0be1641ae69e76f8c7df90724d2513add6676277 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 30 Jun 2022 23:00:44 +0000 Subject: [PATCH 070/122] demo-1 --- integration/test/performancetest/demo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/demo.txt b/integration/test/performancetest/demo.txt index 10b2bc904a..981f5309e8 100644 --- a/integration/test/performancetest/demo.txt +++ b/integration/test/performancetest/demo.txt @@ -1 +1 @@ -commitCount=0 \ No newline at end of file +commitCount=1 \ No newline at end of file From 13b2cae48c50e1989d7b17dcbaca4ef3dc62598f Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 30 Jun 2022 23:15:45 +0000 Subject: [PATCH 071/122] demo-2 --- integration/test/performancetest/demo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/demo.txt b/integration/test/performancetest/demo.txt index 981f5309e8..12219787ef 100644 --- a/integration/test/performancetest/demo.txt +++ b/integration/test/performancetest/demo.txt @@ -1 +1 @@ -commitCount=1 \ No newline at end of file +commitCount=2 \ No newline at end of file From 94954d1b5c891eb2ebbd6b418b23fd4e8315492e Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 30 Jun 2022 23:36:16 +0000 Subject: [PATCH 072/122] small bug with min and max --- integration/test/performancetest/transmitter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 1d5e4663b8..5edc0d94f2 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -211,8 +211,8 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) var avg float64 - var max float64 - var min float64 + max := 0.0 + min := 10000.0 if numDataPoints <= 0{ avg = 0.0 max = 0.0 From d091aa6c6cc1c494b95698e1a556fa324a232ea5 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 30 Jun 2022 23:38:27 +0000 Subject: [PATCH 073/122] demo-3 --- integration/test/performancetest/demo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/demo.txt b/integration/test/performancetest/demo.txt index 12219787ef..ded1475a0e 100644 --- a/integration/test/performancetest/demo.txt +++ b/integration/test/performancetest/demo.txt @@ -1 +1 @@ -commitCount=2 \ No newline at end of file +commitCount=3 \ No newline at end of file From fd59d15448539b6338be2679141bafc41a58ce80 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 1 Jul 2022 00:13:51 +0000 Subject: [PATCH 074/122] demo-4 --- integration/test/performancetest/demo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/demo.txt b/integration/test/performancetest/demo.txt index ded1475a0e..d08e3ac127 100644 --- a/integration/test/performancetest/demo.txt +++ b/integration/test/performancetest/demo.txt @@ -1 +1 @@ -commitCount=3 \ No newline at end of file +commitCount=4 \ No newline at end of file From 48caf6528375c1c057a6344065ff9c583128499a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 1 Jul 2022 00:39:52 +0000 Subject: [PATCH 075/122] demo-5 --- integration/test/performancetest/demo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/demo.txt b/integration/test/performancetest/demo.txt index d08e3ac127..3ee6fbe414 100644 --- a/integration/test/performancetest/demo.txt +++ b/integration/test/performancetest/demo.txt @@ -1 +1 @@ -commitCount=4 \ No newline at end of file +commitCount=5 \ No newline at end of file From 78ae8900b17921611d84a4071fd99029a8f754e2 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Tue, 12 Jul 2022 22:00:08 +0000 Subject: [PATCH 076/122] matrix test --- .github/workflows/fastPeformanceTest.yml | 30 ++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index a99756506b..14fe73dfc4 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -222,46 +222,42 @@ jobs: run: echo "::set-output name=sha_date::$(git show -s --format=%ct ${{ steps.sha.outputs.sha_short }} )" - name: Check env run: echo "SHA ${{ steps.sha.outputs.sha_short }} | Date ${{ steps.sha_date.outputs.sha_date }} " - # nick-invision/retry@v2 starts at base dir + # - name: Terraform apply - if: steps.performance-tracking.outputs.cache-hit != 'true' + if: steps.ec2-linux-integration-test.outputs.cache-hit != 'true' uses: nick-invision/retry@v2 with: - max_attempts: 1 - timeout_minutes: 50 + max_attempts: 3 + timeout_minutes: 30 retry_wait_seconds: 5 command: | cd integration/terraform/ec2/linux terraform init if terraform apply --auto-approve \ -var="ssh_key=${PRIVATE_KEY}" -var="github_repo=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ - -var="github_sha=${GITHUB_SHA}" -var="install_agent=rpm -U ./amazon-cloudwatch-agent.rpm" \ - -var="user=ec2-user" \ - -var="ami=cloudwatch-agent-integration-test-al2*" \ - -var="ca_cert_path=/etc/ssl/certs/ca-bundle.crt" \ - -var="arc=amd64" \ - -var="binary_name=amazon-cloudwatch-agent.rpm" \ + -var="github_sha=${GITHUB_SHA}" -var="install_agent=${{ matrix.arrays.installAgentCommand }}" \ + -var="user=${{ matrix.arrays.username }}" \ + -var="ami=${{ matrix.arrays.ami }}" \ + -var="ca_cert_path=${{ matrix.arrays.caCertPath }}" \ + -var="arc=${{ matrix.arrays.arc }}" \ + -var="binary_name=${{ matrix.arrays.binaryName }}" \ -var="local_stack_host_name=${{ needs.StartLocalStack.outputs.local_stack_host_name }}" \ -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ -var="key_name=${KEY_NAME}" \ - -var="test_name=cw-integ-test-al2" \ + -var="test_name=cw-integ-test-${{ matrix.arrays.os }}" \ -var="iam_instance_profile=${IAM_ROLE}" \ - -var="sha=${{ steps.sha.outputs.sha_short }}" \ - -var="sha_date=${{ steps.sha_date.outputs.sha_date }}" \ - -var="test_dir=./integration/test/performancetest" ; then terraform destroy -auto-approve - + -var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve else terraform destroy -auto-approve && exit 1 fi #This is here just in case workflow cancel - name: Terraform destroy - if: ${{ cancelled() && steps.performance-tracking.outputs.cache-hit != 'true' }} + if: ${{ cancelled() && steps.ec2-linux-integration-test.outputs.cache-hit != 'true' }} uses: nick-invision/retry@v2 with: max_attempts: 3 timeout_minutes: 8 retry_wait_seconds: 5 command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve - From 644caf8a9b032bf9cf422882bf01a03d80c9c561 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 14:10:50 +0000 Subject: [PATCH 077/122] testing parallel running performancetest --- .github/workflows/fastPeformanceTest.yml | 7 +++++ .../resources/ec2_performance_test.json | 29 +++++++++++++++++++ integration/generator/test_case_generator.go | 4 +++ 3 files changed, 40 insertions(+) create mode 100644 integration/generator/resources/ec2_performance_test.json diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 14fe73dfc4..bc6fdc3eac 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -93,6 +93,7 @@ jobs: runs-on: ubuntu-latest outputs: ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }} + ec2_performance_matrix: ${{step.set-matrix.output.ec2_performancetest_matrix}} ec2_windows_matrix: ${{ steps.set-matrix.outputs.ec2_windows_matrix }} ecs_fargate_matrix: ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} steps: @@ -108,12 +109,14 @@ jobs: run: | go run --tags=generator integration/generator/test_case_generator.go echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" + echo "::set-output name=ec2_performancetest_matrix::${{echo $(cat integration/generator/resources/ec2_performancetest_matrx.json)}}" echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" - name: Echo test plan matrix run: | echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} + echo ${{ steps.set-matrix.output.ec2_performancetest_matrix}} echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} @@ -193,6 +196,10 @@ jobs: name: "PerformanceTrackingTest" needs: [MakeBinary, StartLocalStack, GenerateTestMatrix] runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_performancetest_matrix) }} steps: - uses: actions/checkout@v2 diff --git a/integration/generator/resources/ec2_performance_test.json b/integration/generator/resources/ec2_performance_test.json new file mode 100644 index 0000000000..f2331d2025 --- /dev/null +++ b/integration/generator/resources/ec2_performance_test.json @@ -0,0 +1,29 @@ +[ + { + "os": "al2", + "username": "ec2-user", + "installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", + "ami": "cloudwatch-agent-integration-test-al2*", + "caCertPath": "/etc/ssl/certs/ca-bundle.crt", + "arc": "amd64", + "binaryName": "amazon-cloudwatch-agent.rpm" + }, + { + "os": "al2", + "username": "ec2-user", + "installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", + "ami": "cloudwatch-agent-integration-test-al2*", + "caCertPath": "/etc/ssl/certs/ca-bundle.crt", + "arc": "amd64", + "binaryName": "amazon-cloudwatch-agent.rpm" + }, + { + "os": "al2", + "username": "ec2-user", + "installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", + "ami": "cloudwatch-agent-integration-test-al2*", + "caCertPath": "/etc/ssl/certs/ca-bundle.crt", + "arc": "amd64", + "binaryName": "amazon-cloudwatch-agent.rpm" + } +] \ No newline at end of file diff --git a/integration/generator/test_case_generator.go b/integration/generator/test_case_generator.go index 456c0e5f08..67a2847f08 100644 --- a/integration/generator/test_case_generator.go +++ b/integration/generator/test_case_generator.go @@ -26,6 +26,10 @@ var osToTestDirMap = map[string][]string{ "./integration/test/metrics_number_dimension", }, // @TODO add real tests + //@TODO add new dict, and specify performancetest instead of ca_bundle + "ec2_performance_test":{ + "./integration/test/performancetest", + }, "ec2_windows": {""}, "ec2_mac": {}, "ecs_fargate": { From 5bde19ded0f32307bce4b4444273960b44d434b7 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 14:11:46 +0000 Subject: [PATCH 078/122] typo fix --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index bc6fdc3eac..dc21ad3972 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-latest outputs: ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }} - ec2_performance_matrix: ${{step.set-matrix.output.ec2_performancetest_matrix}} + ec2_performance_matrix: ${{steps.set-matrix.output.ec2_performancetest_matrix}} ec2_windows_matrix: ${{ steps.set-matrix.outputs.ec2_windows_matrix }} ecs_fargate_matrix: ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} steps: From 46e95a24b25de8766a878333fe2bc615050c0707 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 14:13:51 +0000 Subject: [PATCH 079/122] typo fix --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index dc21ad3972..70f4516769 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,7 +109,7 @@ jobs: run: | go run --tags=generator integration/generator/test_case_generator.go echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" - echo "::set-output name=ec2_performancetest_matrix::${{echo $(cat integration/generator/resources/ec2_performancetest_matrx.json)}}" + echo "::set-output name=ec2_performancetest_matrix::$(echo $(cat integration/generator/resources/ec2_performancetest_matrx.json))" echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" From 8a4ac529e1af27fa79ca8fd8b4c10e8a039125e1 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 14:15:19 +0000 Subject: [PATCH 080/122] change test name in go generator --- integration/generator/test_case_generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/generator/test_case_generator.go b/integration/generator/test_case_generator.go index 67a2847f08..c17e76e6d6 100644 --- a/integration/generator/test_case_generator.go +++ b/integration/generator/test_case_generator.go @@ -27,7 +27,7 @@ var osToTestDirMap = map[string][]string{ }, // @TODO add real tests //@TODO add new dict, and specify performancetest instead of ca_bundle - "ec2_performance_test":{ + "ec2_performance":{ "./integration/test/performancetest", }, "ec2_windows": {""}, From 579ae66b1de63143157a787b2c9a7026e5210832 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 14:18:26 +0000 Subject: [PATCH 081/122] rename --- .github/workflows/fastPeformanceTest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 70f4516769..16cd85f1e8 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-latest outputs: ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }} - ec2_performance_matrix: ${{steps.set-matrix.output.ec2_performancetest_matrix}} + ec2_performance_matrix: ${{steps.set-matrix.output.ec2_performance_matrix}} ec2_windows_matrix: ${{ steps.set-matrix.outputs.ec2_windows_matrix }} ecs_fargate_matrix: ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} steps: @@ -109,14 +109,14 @@ jobs: run: | go run --tags=generator integration/generator/test_case_generator.go echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" - echo "::set-output name=ec2_performancetest_matrix::$(echo $(cat integration/generator/resources/ec2_performancetest_matrx.json))" + echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete__matrx.json))" echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" - name: Echo test plan matrix run: | echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} - echo ${{ steps.set-matrix.output.ec2_performancetest_matrix}} + echo ${{ steps.set-matrix.output.ec2_performance_matrix}} echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} @@ -199,7 +199,7 @@ jobs: strategy: fail-fast: false matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_performancetest_matrix) }} + arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_performance_matrix) }} steps: - uses: actions/checkout@v2 From 7c27c817427005b679bdfea703344b6a01b45ac4 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 14:22:38 +0000 Subject: [PATCH 082/122] rename file --- .github/workflows/fastPeformanceTest.yml | 2 +- ...2_performance_test.json => ec2_performance_test_matrix.json} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename integration/generator/resources/{ec2_performance_test.json => ec2_performance_test_matrix.json} (100%) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 16cd85f1e8..f50c208ca2 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,7 +109,7 @@ jobs: run: | go run --tags=generator integration/generator/test_case_generator.go echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" - echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete__matrx.json))" + echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrx.json))" echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" diff --git a/integration/generator/resources/ec2_performance_test.json b/integration/generator/resources/ec2_performance_test_matrix.json similarity index 100% rename from integration/generator/resources/ec2_performance_test.json rename to integration/generator/resources/ec2_performance_test_matrix.json From b546e68d5e5fb14621e4691e492b404664c5705b Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 14:49:19 +0000 Subject: [PATCH 083/122] typo fix --- .github/workflows/fastPeformanceTest.yml | 2 +- integration/generator/test_case_generator.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index f50c208ca2..eb68c2b8ce 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,7 +109,7 @@ jobs: run: | go run --tags=generator integration/generator/test_case_generator.go echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" - echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrx.json))" + echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrix.json))" echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" diff --git a/integration/generator/test_case_generator.go b/integration/generator/test_case_generator.go index c17e76e6d6..146bc09193 100644 --- a/integration/generator/test_case_generator.go +++ b/integration/generator/test_case_generator.go @@ -26,7 +26,6 @@ var osToTestDirMap = map[string][]string{ "./integration/test/metrics_number_dimension", }, // @TODO add real tests - //@TODO add new dict, and specify performancetest instead of ca_bundle "ec2_performance":{ "./integration/test/performancetest", }, From 627127edfff2c69160483adee0c42b69e491204a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 16:08:02 +0000 Subject: [PATCH 084/122] debug --- .github/workflows/fastPeformanceTest.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index eb68c2b8ce..d965be575c 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -119,7 +119,9 @@ jobs: echo ${{ steps.set-matrix.output.ec2_performance_matrix}} echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} - + - name: Echo performance matrix + run: | + echo ${{ steps.set-matrix.output.ec2_performance_matrix}} StartLocalStack: name: 'StartLocalStack' From 1998c6a534dd8cf5f971924cf99f1c9f842ac029 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 16:15:46 +0000 Subject: [PATCH 085/122] debug2 --- .github/workflows/fastPeformanceTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index d965be575c..90d8e3a05b 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -122,6 +122,7 @@ jobs: - name: Echo performance matrix run: | echo ${{ steps.set-matrix.output.ec2_performance_matrix}} + echo ${cat integration/generator/resources/ec2_performance_complete_test_matrix.json} StartLocalStack: name: 'StartLocalStack' From 3e5150189ffa28c319affbaeb972eb3ea4e88fd5 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 16:32:23 +0000 Subject: [PATCH 086/122] typo --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 90d8e3a05b..63e880eb9d 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -122,7 +122,7 @@ jobs: - name: Echo performance matrix run: | echo ${{ steps.set-matrix.output.ec2_performance_matrix}} - echo ${cat integration/generator/resources/ec2_performance_complete_test_matrix.json} + echo ${{cat integration/generator/resources/ec2_performance_complete_test_matrix.json}} StartLocalStack: name: 'StartLocalStack' From 8f82eb3ab8c944e3e0260d8568c2a69b741bb3c0 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 16:33:10 +0000 Subject: [PATCH 087/122] optim --- .github/workflows/fastPeformanceTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 63e880eb9d..0f80a639f7 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -29,6 +29,7 @@ concurrency: jobs: MakeBinary: + needs: [ GenerateTestMatrix]] name: 'MakeBinary' runs-on: ubuntu-latest steps: From 9d4389f55d746ff4d61d6f622ef90d359f2a5faf Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 16:33:19 +0000 Subject: [PATCH 088/122] typo --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 0f80a639f7..fbd3ff7ffe 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -29,7 +29,7 @@ concurrency: jobs: MakeBinary: - needs: [ GenerateTestMatrix]] + needs: [ GenerateTestMatrix] name: 'MakeBinary' runs-on: ubuntu-latest steps: From 34913fa9ef4d590b99bf1ecc120a6381b9114f39 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 16:36:24 +0000 Subject: [PATCH 089/122] test --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index fbd3ff7ffe..e0a6e7cab2 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -123,7 +123,7 @@ jobs: - name: Echo performance matrix run: | echo ${{ steps.set-matrix.output.ec2_performance_matrix}} - echo ${{cat integration/generator/resources/ec2_performance_complete_test_matrix.json}} + cat integration/generator/resources/ec2_performance_complete_test_matrix.json StartLocalStack: name: 'StartLocalStack' From f8af2dafc8bd6b1bfd18a242163f4e6de7034f82 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 16:53:53 +0000 Subject: [PATCH 090/122] test --- .github/workflows/fastPeformanceTest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index e0a6e7cab2..4e184d2d4f 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,10 +109,10 @@ jobs: id: set-matrix run: | go run --tags=generator integration/generator/test_case_generator.go - echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" + # echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrix.json))" - echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" - echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" + # echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" + # echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" - name: Echo test plan matrix run: | From 8d0e219fcd11d567acbbd6dbda5215db932229b4 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 17:04:03 +0000 Subject: [PATCH 091/122] test --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 4e184d2d4f..661009ecf5 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,7 +109,7 @@ jobs: id: set-matrix run: | go run --tags=generator integration/generator/test_case_generator.go - # echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" + echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrix.json))" # echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" # echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" From 586935316c3756ad14e775b70e880fdbc290d5f6 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 17:42:19 +0000 Subject: [PATCH 092/122] debug 3 --- .github/workflows/fastPeformanceTest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 661009ecf5..e9530a16ed 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,17 +109,17 @@ jobs: id: set-matrix run: | go run --tags=generator integration/generator/test_case_generator.go - echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" + # echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrix.json))" # echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" # echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" - name: Echo test plan matrix run: | - echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} + # echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} echo ${{ steps.set-matrix.output.ec2_performance_matrix}} - echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} - echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} + # echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} + # echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} - name: Echo performance matrix run: | echo ${{ steps.set-matrix.output.ec2_performance_matrix}} From c65232a076e7dd7a26ae3883f41021b1f6410497 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 17:51:04 +0000 Subject: [PATCH 093/122] debug pure performance removed everything else --- .github/workflows/fastPeformanceTest.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index e9530a16ed..2e5b8fda73 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,17 +109,10 @@ jobs: id: set-matrix run: | go run --tags=generator integration/generator/test_case_generator.go - # echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrix.json))" - # echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" - # echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" - - name: Echo test plan matrix run: | - # echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} echo ${{ steps.set-matrix.output.ec2_performance_matrix}} - # echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} - # echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} - name: Echo performance matrix run: | echo ${{ steps.set-matrix.output.ec2_performance_matrix}} From d87f9748dd9791c4c6fc00a148f996cbae4cf44a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 18:06:16 +0000 Subject: [PATCH 094/122] with linux --- .github/workflows/fastPeformanceTest.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 2e5b8fda73..c515fc683f 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -109,10 +109,17 @@ jobs: id: set-matrix run: | go run --tags=generator integration/generator/test_case_generator.go + echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrix.json))" + # echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" + # echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" + - name: Echo test plan matrix run: | + echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} echo ${{ steps.set-matrix.output.ec2_performance_matrix}} + # echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} + # echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} - name: Echo performance matrix run: | echo ${{ steps.set-matrix.output.ec2_performance_matrix}} From b5589628ac48a51d8cb34da65a632323ee659f3a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 18:13:23 +0000 Subject: [PATCH 095/122] :( --- .github/workflows/fastPeformanceTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index c515fc683f..47c34fd852 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -117,12 +117,12 @@ jobs: - name: Echo test plan matrix run: | echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} - echo ${{ steps.set-matrix.output.ec2_performance_matrix}} + echo ${{ steps.set-matrix.outputs.ec2_performance_matrix}} # echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} # echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} - name: Echo performance matrix run: | - echo ${{ steps.set-matrix.output.ec2_performance_matrix}} + echo ${{ steps.set-matrix.outputs.ec2_performance_matrix}} cat integration/generator/resources/ec2_performance_complete_test_matrix.json StartLocalStack: From 962fb649d905c6ff85c2a4c948a832c7484cc698 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 18:41:57 +0000 Subject: [PATCH 096/122] typo fix --- .github/workflows/fastPeformanceTest.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 47c34fd852..60543640b8 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -29,7 +29,6 @@ concurrency: jobs: MakeBinary: - needs: [ GenerateTestMatrix] name: 'MakeBinary' runs-on: ubuntu-latest steps: @@ -94,7 +93,7 @@ jobs: runs-on: ubuntu-latest outputs: ec2_linux_matrix: ${{ steps.set-matrix.outputs.ec2_linux_matrix }} - ec2_performance_matrix: ${{steps.set-matrix.output.ec2_performance_matrix}} + ec2_performance_matrix: ${{steps.set-matrix.outputs.ec2_performance_matrix}} ec2_windows_matrix: ${{ steps.set-matrix.outputs.ec2_windows_matrix }} ecs_fargate_matrix: ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} steps: @@ -111,19 +110,18 @@ jobs: go run --tags=generator integration/generator/test_case_generator.go echo "::set-output name=ec2_linux_matrix::$(echo $(cat integration/generator/resources/ec2_linux_complete_test_matrix.json))" echo "::set-output name=ec2_performance_matrix::$(echo $(cat integration/generator/resources/ec2_performance_complete_test_matrix.json))" - # echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" - # echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" + echo "::set-output name=ec2_windows_matrix::$(echo $(cat integration/generator/resources/ec2_windows_complete_test_matrix.json))" + echo "::set-output name=ecs_fargate_matrix::$(echo $(cat integration/generator/resources/ecs_fargate_complete_test_matrix.json))" - name: Echo test plan matrix run: | echo ${{ steps.set-matrix.outputs.ec2_linux_matrix }} echo ${{ steps.set-matrix.outputs.ec2_performance_matrix}} - # echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} - # echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} + echo ${{ steps.set-matrix.outputs.ec2_windows_matrix }} + echo ${{ steps.set-matrix.outputs.ecs_fargate_matrix }} - name: Echo performance matrix run: | echo ${{ steps.set-matrix.outputs.ec2_performance_matrix}} - cat integration/generator/resources/ec2_performance_complete_test_matrix.json StartLocalStack: name: 'StartLocalStack' From cabd1b595d77cdc22b84f1664002e16d153ae863 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 20:09:26 +0000 Subject: [PATCH 097/122] added performance n logs config --- .../resources/ec2_performance_test_matrix.json | 10 +++++++--- integration/terraform/ec2/linux/main.tf | 1 + integration/terraform/ec2/linux/variables.tf | 4 ++++ integration/test/performancetest/performance_test.go | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/integration/generator/resources/ec2_performance_test_matrix.json b/integration/generator/resources/ec2_performance_test_matrix.json index f2331d2025..016c2d22cb 100644 --- a/integration/generator/resources/ec2_performance_test_matrix.json +++ b/integration/generator/resources/ec2_performance_test_matrix.json @@ -6,7 +6,8 @@ "ami": "cloudwatch-agent-integration-test-al2*", "caCertPath": "/etc/ssl/certs/ca-bundle.crt", "arc": "amd64", - "binaryName": "amazon-cloudwatch-agent.rpm" + "binaryName": "amazon-cloudwatch-agent.rpm", + "performance_number_of_logs": "10" }, { "os": "al2", @@ -15,7 +16,9 @@ "ami": "cloudwatch-agent-integration-test-al2*", "caCertPath": "/etc/ssl/certs/ca-bundle.crt", "arc": "amd64", - "binaryName": "amazon-cloudwatch-agent.rpm" + "binaryName": "amazon-cloudwatch-agent.rpm", + "performance_number_of_logs": "100" + }, { "os": "al2", @@ -24,6 +27,7 @@ "ami": "cloudwatch-agent-integration-test-al2*", "caCertPath": "/etc/ssl/certs/ca-bundle.crt", "arc": "amd64", - "binaryName": "amazon-cloudwatch-agent.rpm" + "binaryName": "amazon-cloudwatch-agent.rpm", + "performance_number_of_logs": "1000" } ] \ No newline at end of file diff --git a/integration/terraform/ec2/linux/main.tf b/integration/terraform/ec2/linux/main.tf index 6fdb8aa871..b4b8936714 100644 --- a/integration/terraform/ec2/linux/main.tf +++ b/integration/terraform/ec2/linux/main.tf @@ -29,6 +29,7 @@ resource "aws_instance" "integration-test" { "echo run sanity test && go test ./integration/test/sanity -p 1 -v --tags=integration", "export SHA=${var.sha}", "export SHA_DATE=${var.sha_date}", + "export PERFORMANCE_NUMBER_OF_LOGS=${var.performance_number_of_logs}" "go test ${var.test_dir} -p 1 -timeout 30m -v --tags=integration " ] connection { diff --git a/integration/terraform/ec2/linux/variables.tf b/integration/terraform/ec2/linux/variables.tf index 1d4083fc9d..9b4cc9cab6 100644 --- a/integration/terraform/ec2/linux/variables.tf +++ b/integration/terraform/ec2/linux/variables.tf @@ -95,4 +95,8 @@ variable "sha" { variable "sha_date"{ type = string default = "" +} +variable "performance_number_of_logs"{ + type = string + default = "" } \ No newline at end of file diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 585cdf9556..92fd84fb3f 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -8,6 +8,7 @@ import( "time" "log" "context" + "os" "github.com/aws/amazon-cloudwatch-agent/integration/test" ) @@ -26,7 +27,7 @@ func TestPerformance(t *testing.T) { test.CopyFile(configPath, configOutputPath) test.StartAgent(configOutputPath, true) - + fmt.Println("N_Logs",os.Getenv("PERFORMANCE_NUMBER_OF_LOGS")) agentRunDuration := agentRuntimeMinutes * time.Minute //let agent run before collecting performance metrics on it time.Sleep(agentRunDuration) From 75a50fe51684a097e65c2eb78a9f7bd87d75d1d7 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Wed, 13 Jul 2022 20:38:54 +0000 Subject: [PATCH 098/122] coma fix --- integration/terraform/ec2/linux/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/terraform/ec2/linux/main.tf b/integration/terraform/ec2/linux/main.tf index b4b8936714..ec50d41b06 100644 --- a/integration/terraform/ec2/linux/main.tf +++ b/integration/terraform/ec2/linux/main.tf @@ -29,7 +29,7 @@ resource "aws_instance" "integration-test" { "echo run sanity test && go test ./integration/test/sanity -p 1 -v --tags=integration", "export SHA=${var.sha}", "export SHA_DATE=${var.sha_date}", - "export PERFORMANCE_NUMBER_OF_LOGS=${var.performance_number_of_logs}" + "export PERFORMANCE_NUMBER_OF_LOGS=${var.performance_number_of_logs}", "go test ${var.test_dir} -p 1 -timeout 30m -v --tags=integration " ] connection { From 1168549cbfe011720fabc03142a701891a7d22ba Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 17:11:33 +0000 Subject: [PATCH 099/122] releaseTest --- .github/workflows/releaseTest.yml | 36 ++++++++ go.mod | 19 +++-- go.sum | 20 +++++ .../test/performancetest/performance_test.go | 15 +++- .../test/performancetest/transmitter.go | 83 ++++++++++++++++++- 5 files changed, 160 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/releaseTest.yml diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml new file mode 100644 index 0000000000..6e315c764b --- /dev/null +++ b/.github/workflows/releaseTest.yml @@ -0,0 +1,36 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: MIT + +name: Fast Performance Test +env: + PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }} + TERRAFORM_AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + TERRAFORM_AWS_SECRET_ACCESS_KEY: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + S3_INTEGRATION_BUCKET: ${{ secrets.S3_INTEGRATION_BUCKET }} + KEY_NAME: ${{ secrets.KEY_NAME }} + VPC_SECURITY_GROUPS_IDS: ${{ secrets.VPC_SECURITY_GROUPS_IDS }} + IAM_ROLE: ${{ secrets.IAM_ROLE }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} + GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} + GPG_TTY: $(tty) + ECR_INTEGRATION_TEST_REPO: "cwagent-integration-test" + +on: + release: + types: [created] + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + Update Performance Metrics: + name: "UpdatePerformanceMetrics" + steps: + - name: "Set env var" + run: "export SHA=$GITHUB_SHA" + - name: Run Golang Update Function + run: "go test ./integration/test/performancetest -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration" \ No newline at end of file diff --git a/go.mod b/go.mod index 52a5097775..5436e497dc 100644 --- a/go.mod +++ b/go.mod @@ -54,15 +54,15 @@ require ( github.com/Jeffail/gabs v1.4.0 github.com/Rican7/retry v0.1.1-0.20160712041035-272ad122d6e5 github.com/aws/aws-sdk-go v1.44.16 - github.com/aws/aws-sdk-go-v2 v1.16.5 + github.com/aws/aws-sdk-go-v2 v1.16.7 github.com/aws/aws-sdk-go-v2/config v1.15.3 - github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.4 + github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.6 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3 github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.18.1 github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.4 - github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.7 + github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.9 github.com/aws/aws-sdk-go-v2/service/ec2 v1.29.0 - github.com/aws/smithy-go v1.11.3 + github.com/aws/smithy-go v1.12.0 github.com/bigkevmcd/go-configparser v0.0.0-20200217161103-d137835d2579 github.com/go-kit/kit v0.11.0 github.com/gobwas/glob v0.2.3 @@ -123,12 +123,13 @@ require ( github.com/armon/go-metrics v0.3.10 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.11.2 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.12 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.6 // indirect + github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.4.12 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 // indirect - github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.2 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.6 // indirect + github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.9 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.3 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.8 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 // indirect github.com/aws/aws-sdk-go-v2/service/s3 v1.26.5 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.11.3 // indirect diff --git a/go.sum b/go.sum index a83633fd1c..6d295f00cc 100644 --- a/go.sum +++ b/go.sum @@ -228,6 +228,8 @@ github.com/aws/aws-sdk-go-v2 v1.13.0/go.mod h1:L6+ZpqHaLbAaxsqV0L4cvxZY7QupWJB4f github.com/aws/aws-sdk-go-v2 v1.16.2/go.mod h1:ytwTPBG6fXTZLxxeeCCWj2/EMYp/xDUgX+OET6TLNNU= github.com/aws/aws-sdk-go-v2 v1.16.5 h1:Ah9h1TZD9E2S1LzHpViBO3Jz9FPL5+rmflmb8hXirtI= github.com/aws/aws-sdk-go-v2 v1.16.5/go.mod h1:Wh7MEsmEApyL5hrWzpDkba4gwAPc5/piwLVLFnCxp48= +github.com/aws/aws-sdk-go-v2 v1.16.7 h1:zfBwXus3u14OszRxGcqCDS4MfMCv10e8SMJ2r8Xm0Ns= +github.com/aws/aws-sdk-go-v2 v1.16.7/go.mod h1:6CpKuLXg2w7If3ABZCl/qZ6rEgwtjZTn4eAf4RcEyuw= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 h1:SdK4Ppk5IzLs64ZMvr6MrSficMtjY2oS0WOORXTlxwU= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1/go.mod h1:n8Bs1ElDD2wJ9kCRTczA83gYbBmjSwZp3umc6zF4EeM= github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= @@ -238,6 +240,10 @@ github.com/aws/aws-sdk-go-v2/credentials v1.11.2 h1:RQQ5fzclAKJyY5TvF+fkjJEwzK4h github.com/aws/aws-sdk-go-v2/credentials v1.11.2/go.mod h1:j8YsY9TXTm31k4eFhspiQicfXPLZ0gYXA50i4gxPE8g= github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.4 h1:EoyeSOfbSuKh+bQIDoZaVJjON6PF+dsSn5w1RhIpMD0= github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.4/go.mod h1:bfCL7OwZS6owS06pahfGxhcgpLWj2W1sQASoYRuenag= +github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.6 h1:vlEfSyZ2pZjOZe7zsPIAFem17w2HeeFULk7TPVWoDR4= +github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.9.6/go.mod h1:+/KXTIzLmrjdlQVgiE14/jhy9GyDZnmMGQoykod99Lw= +github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.4.12 h1:sH0SffGPiNpvYCCfEF0dN0K9OC72KXBjW4HmiFvMVf0= +github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.4.12/go.mod h1:0vvQ0FQRjyNB8EIkRdwT9tduJbkUdh00SnmuKnZRYLA= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3 h1:LWPg5zjHV9oz/myQr4wMs0gi4CjnDN/ILmyZUFYXZsU= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3/go.mod h1:uk1vhHHERfSVCUnqSqz8O48LBYDSC+k6brng09jcMOk= @@ -246,10 +252,14 @@ github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.4/go.mod h1:XHgQ7Hz2WY2 github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9/go.mod h1:AnVH5pvai0pAF4lXRq0bmhbes1u9R8wTE+g+183bZNM= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.12 h1:Zt7DDk5V7SyQULUUwIKzsROtVzp/kVvcz15uQx/Tkow= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.12/go.mod h1:Afj/U8svX6sJ77Q+FPWMzabJ9QjbwP32YlopgKALUpg= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 h1:2C0pYHcUBmdzPj+EKNC4qj97oK6yjrUhc1KoSodglvk= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14/go.mod h1:kdjrMwHwrC3+FsKhNcCMJ7tUVj/8uSD5CZXeQ4wV6fM= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.2.0/go.mod h1:BsCSJHx5DnDXIrOcqB8KN1/B+hXLG/bi4Y6Vjcx/x9E= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3/go.mod h1:ssOhaLpRlh88H3UmEcsBoVKq309quMvm3Ds8e9d4eJM= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.6 h1:eeXdGVtXEe+2Jc49+/vAzna3FAQnUD4AagAw8tzbmfc= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.6/go.mod h1:FwpAKI+FBPIELJIdmQzlLtRe8LQSOreMcM2wBsPMvvc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 h1:2J+jdlBJWEmTyAwC82Ym68xCykIvnSnIN18b8xHGlcc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8/go.mod h1:ZIV8GYoC6WLBW5KGs+o4rsc65/ozd+eQ0L31XF5VDwk= github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 h1:by9P+oy3P/CwggN4ClnW2D4oL91QV7pBzBICi1chZvQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10/go.mod h1:8DcYQcz0+ZJaSxANlHIsbbi6S+zMwjwdDqwW3r9AzaE= @@ -263,17 +273,25 @@ github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.4 h1:mBqjBKtZzvAc9j7gU github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.4/go.mod h1:R49Py2lGoKH7bCpwhjN9l7MfR/PU6zHXn1tCRR8cwOs= github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.7 h1:Ls6kDGWNr3wxE8JypXgTTonHpQ1eRVCGNqaFHY2UASw= github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.7/go.mod h1:+v2jeT4/39fCXUQ0ZfHQHMMiJljnmiuj16F03uAd9DY= +github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.9 h1:QTPDno4J5TyfpPi3dqCZpD+y7wbHtHhUQwnNGUHUGvg= +github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.9/go.mod h1:Req/32OLRbXpPX5TxHkwf2Ln9qclJCV6n1S7v0v+FWo= github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.7 h1:o2HKntJx3vr3y11NK58RA6tYKZKQo5PWWt/bs0rWR0U= github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.7/go.mod h1:FAVtDKEl/8WxRDQ33e2fz16RO1t4zeEwWIU5kR29xXs= +github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.9 h1:5wt4xEuHFV6ymSb19N0+T9iPYs9TqzHW2Sz4p3bKAlA= +github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.13.9/go.mod h1:Meb0gqL2SgBbh3xHtcak5GPJDZ1QGwRcGPEo7w1G2vg= github.com/aws/aws-sdk-go-v2/service/ec2 v1.29.0 h1:7jk4NfzDnnSbaR9E4mOBWRZXQThq5rsqjlDC+uu9dsI= github.com/aws/aws-sdk-go-v2/service/ec2 v1.29.0/go.mod h1:HoTu0hnXGafTpKIZQ60jw0ybhhCH1QYf20oL7GEJFdg= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1/go.mod h1:GeUru+8VzrTXV/83XyMJ80KpH8xO89VPoUileyNQ+tc= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.2 h1:T/ywkX1ed+TsZVQccu/8rRJGxKZF/t0Ivgrb4MHTSeo= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.2/go.mod h1:RnloUnyZ4KN9JStGY1LuQ7Wzqh7V0f8FinmRdHYtuaA= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.3 h1:4n4KCtv5SUoT5Er5XV41huuzrCqepxlW3SDI9qHQebc= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.3/go.mod h1:gkb2qADY+OHaGLKNTYxMaQNacfeyQpZ4csDTQMeFmcw= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.3 h1:I0dcwWitE752hVSMrsLCxqNQ+UdEp3nACx2bYNMQq+k= github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.3/go.mod h1:Seb8KNmD6kVTjwRjVEgOT5hPin6sq+v4C2ycJQDwuH8= github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.6 h1:JGrc3+kkyr848/wpG2+kWuzHK3H4Fyxj2jnXj8ijQ/Y= github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.6/go.mod h1:zwvTysbXES8GDwFcwCPB8NkC+bCdio1abH+E+BRe/xg= +github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.8 h1:x4I8/XPnHOV+1BzZfaqRb8QfrY6AK7bKmEbHVwyctXo= +github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.7.8/go.mod h1:xfchFk5f70DzZZaH/QYaqMLF+PDH/fg7gGbkIeeaMJM= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.7.0/go.mod h1:K/qPe6AP2TGYv4l6n7c88zh9jWBDf6nHhvg1fx/EWfU= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 h1:Gh1Gpyh01Yvn7ilO/b/hr01WgNpaszfbKMUgqM186xQ= @@ -300,6 +318,8 @@ github.com/aws/smithy-go v1.10.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiA github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/aws/smithy-go v1.11.3 h1:DQixirEFM9IaKxX1olZ3ke3nvxRS2xMDteKIDWxozW8= github.com/aws/smithy-go v1.11.3/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.12.0 h1:gXpeZel/jPoWQ7OEmLIgCUnhkFftqNfwWUwAHSlp1v0= +github.com/aws/smithy-go v1.12.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/telegraf v0.10.2-0.20220502160831-c20ebe67c5ef h1:O53nKbZm2XpdudUywNdqbohwUxje9k4vE0xRXWeIVbE= github.com/aws/telegraf v0.10.2-0.20220502160831-c20ebe67c5ef/go.mod h1:6maU8S0L0iMSa0ZvH5b2W7dBX1xjK0D5ONAqe7WTqXc= github.com/aws/telegraf/patches/gopsutil/v3 v3.0.0-20220502160831-c20ebe67c5ef h1:iiO0qNErnQgaU6mJY+PRlwnoHp+s9VTk2Ax1A8KRoG4= diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 92fd84fb3f..85fb8f2271 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -8,6 +8,7 @@ import( "time" "log" "context" + "fmt" "os" "github.com/aws/amazon-cloudwatch-agent/integration/test" ) @@ -55,4 +56,16 @@ func TestPerformance(t *testing.T) { if err !=nil{ t.Fatalf("Error: couldnt upload metric data to table") } -} \ No newline at end of file +} + +func TestUpdateCommit(t*testing.T){ + fmt.Println("Updating Release Commit") + dynamoDB := InitializeTransmitterAPI("CWAPerformanceMetrics") //add cwa version here + testHash := os.Getenv(SHA_ENV) + if dynamoDB == nil{ + t.Fatalf("Error: generating dynamo table") + return + } + //@TODO figure out how to get date + dynamoDB.UpdateReleaseTag(2022,testHash) +} diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 5edc0d94f2..69d249eec3 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -16,6 +16,7 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" + // "github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression" ) const ( @@ -100,6 +101,10 @@ func (transmitter *TransmitterAPI) CreateTable() error { AttributeName: aws.String("CommitDate"), AttributeType: types.ScalarAttributeTypeN, }, + { + AttributeName: aws.String("Hash"), + AttributeType: types.ScalarAttributeTypeS, + }, }, KeySchema: []types.KeySchemaElement{ { @@ -111,7 +116,28 @@ func (transmitter *TransmitterAPI) CreateTable() error { KeyType: types.KeyTypeRange, }, }, - + GlobalSecondaryIndexes: []types.GlobalSecondaryIndex{ + { + IndexName: aws.String("Hash-index"), + KeySchema: []types.KeySchemaElement{ + { + AttributeName: aws.String("Hash"), + KeyType: types.KeyTypeHash, + }, + { + AttributeName: aws.String("CommitDate"), + KeyType: types.KeyTypeRange, + }, + }, + Projection: &types.Projection{ + ProjectionType : "ALL", + }, + ProvisionedThroughput: &types.ProvisionedThroughput{ + ReadCapacityUnits: aws.Int64(10), + WriteCapacityUnits: aws.Int64(10), + }, + }, + }, ProvisionedThroughput: &types.ProvisionedThroughput{ ReadCapacityUnits: aws.Int64(10), WriteCapacityUnits: aws.Int64(10), @@ -207,7 +233,7 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, packet[PARTITION_KEY] = time.Now().Year() packet[HASH] = os.Getenv(SHA_ENV) //fmt.Sprintf("%d", time.Now().UnixNano()) packet[COMMIT_DATE],_ = strconv.Atoi(os.Getenv(SHA_DATE_ENV)) - + packet["isRelease"] = false for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) var avg float64 @@ -245,4 +271,55 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, packet[rawMetricData.Label] = metric } return packet, nil -} \ No newline at end of file +} + +/* + +*/ +func (transmitter * TransmitterAPI) UpdateReleaseTag(year int, hash string) error{ + var err error + item,err := transmitter.Query(year,hash) + commitDate := fmt.Sprintf("%d",int(item[0]["CommitDate"].(float64))) + fmt.Println(commitDate) + _, err = transmitter.dynamoDbClient.UpdateItem(context.TODO(), &dynamodb.UpdateItemInput{ + TableName: aws.String(transmitter.DataBaseName), + Key: map[string]types.AttributeValue{ + "Year": &types.AttributeValueMemberN{Value: "2022"}, + "CommitDate": &types.AttributeValueMemberN{Value: commitDate }, + }, + UpdateExpression: aws.String("set isRelease = :release"), + ExpressionAttributeValues: map[string]types.AttributeValue{ + ":release": &types.AttributeValueMemberBOOL{Value: true}, + }, + }) + + if err != nil { + panic(err) + } + + return err +} + +func (transmitter* TransmitterAPI) Query(year int, hash string) ([]map[string]interface{}, error) { + var err error + // var response *dynamodb.QueryOutput + var packets []map[string]interface{} + out, err := transmitter.dynamoDbClient.Query(context.TODO(), &dynamodb.QueryInput{ + TableName: aws.String(transmitter.DataBaseName), + IndexName: aws.String("Hash-index"), + KeyConditionExpression: aws.String("#hash = :hash"), + ExpressionAttributeValues: map[string]types.AttributeValue{ + ":hash": &types.AttributeValueMemberS{Value: hash}, + }, + ExpressionAttributeNames: map[string]string{ + "#hash": "Hash", + }, + ScanIndexForward: aws.Bool(true), // true or false to sort by "date" Sort/Range key ascending or descending + }) + if err != nil { + panic(err) + } + // fmt.Println(out.Items) + attributevalue.UnmarshalListOfMaps(out.Items,&packets) + return packets, err +} From c1479d4b12f0d190c5a1284d343e844577ed64a4 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 18:26:48 +0000 Subject: [PATCH 100/122] reverted to old terraform --- .github/workflows/fastPeformanceTest.yml | 6 ++++-- .../ec2_performance_test_matrix.json | 21 ------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 60543640b8..df2c952f6f 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -236,7 +236,7 @@ jobs: if: steps.ec2-linux-integration-test.outputs.cache-hit != 'true' uses: nick-invision/retry@v2 with: - max_attempts: 3 + max_attempts: 1 timeout_minutes: 30 retry_wait_seconds: 5 command: | @@ -254,6 +254,8 @@ jobs: -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ -var="key_name=${KEY_NAME}" \ + -var="sha=${{ steps.sha.outputs.sha_short }}" \ + -var="sha_date=${{ steps.sha_date.outputs.sha_date }}" \ -var="test_name=cw-integ-test-${{ matrix.arrays.os }}" \ -var="iam_instance_profile=${IAM_ROLE}" \ -var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve @@ -266,7 +268,7 @@ jobs: if: ${{ cancelled() && steps.ec2-linux-integration-test.outputs.cache-hit != 'true' }} uses: nick-invision/retry@v2 with: - max_attempts: 3 + max_attempts: 1 timeout_minutes: 8 retry_wait_seconds: 5 command: cd integration/terraform/ec2/linux && terraform destroy --auto-approve diff --git a/integration/generator/resources/ec2_performance_test_matrix.json b/integration/generator/resources/ec2_performance_test_matrix.json index 016c2d22cb..08b8b02c2d 100644 --- a/integration/generator/resources/ec2_performance_test_matrix.json +++ b/integration/generator/resources/ec2_performance_test_matrix.json @@ -8,26 +8,5 @@ "arc": "amd64", "binaryName": "amazon-cloudwatch-agent.rpm", "performance_number_of_logs": "10" - }, - { - "os": "al2", - "username": "ec2-user", - "installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", - "ami": "cloudwatch-agent-integration-test-al2*", - "caCertPath": "/etc/ssl/certs/ca-bundle.crt", - "arc": "amd64", - "binaryName": "amazon-cloudwatch-agent.rpm", - "performance_number_of_logs": "100" - - }, - { - "os": "al2", - "username": "ec2-user", - "installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", - "ami": "cloudwatch-agent-integration-test-al2*", - "caCertPath": "/etc/ssl/certs/ca-bundle.crt", - "arc": "amd64", - "binaryName": "amazon-cloudwatch-agent.rpm", - "performance_number_of_logs": "1000" } ] \ No newline at end of file From 1d99bdafdc6dbf9dee4d24d5699ca5b1c826651a Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 18:51:57 +0000 Subject: [PATCH 101/122] proper test --- .github/workflows/releaseTest.yml | 5 ++++- integration/test/performancetest/performance_test.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index 6e315c764b..c788cc3046 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -29,8 +29,11 @@ concurrency: jobs: Update Performance Metrics: name: "UpdatePerformanceMetrics" + runs-on: ubuntu-latest steps: - - name: "Set env var" + - name: "Set the Hash var" run: "export SHA=$GITHUB_SHA" + - name: "Set release var" + run: "export IS_RELEASE=true" - name: Run Golang Update Function run: "go test ./integration/test/performancetest -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration" \ No newline at end of file diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 85fb8f2271..e413cfd424 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -17,6 +17,7 @@ const ( configPath = "resources/config.json" configOutputPath = "/opt/aws/amazon-cloudwatch-agent/bin/config.json" agentRuntimeMinutes = 5 //20 def + ) @@ -57,8 +58,10 @@ func TestPerformance(t *testing.T) { t.Fatalf("Error: couldnt upload metric data to table") } } - func TestUpdateCommit(t*testing.T){ + if(os.Getenv("IS_RELEASE") ==""){ + t.Skip("") + } fmt.Println("Updating Release Commit") dynamoDB := InitializeTransmitterAPI("CWAPerformanceMetrics") //add cwa version here testHash := os.Getenv(SHA_ENV) From 30198f3d0fd49fc88c359a89301831fbe2eaa2dd Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 18:53:51 +0000 Subject: [PATCH 102/122] release typo --- .github/workflows/releaseTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index c788cc3046..6c8de1c6d0 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -27,7 +27,7 @@ concurrency: cancel-in-progress: true jobs: - Update Performance Metrics: + UpdatePerformanceMetrics: name: "UpdatePerformanceMetrics" runs-on: ubuntu-latest steps: From 868ed6ce980cbca7d5e687c7e70acfeab7f8e0f0 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:01:20 +0000 Subject: [PATCH 103/122] changed command --- .github/workflows/releaseTest.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index 6c8de1c6d0..0574b06d9e 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -36,4 +36,6 @@ jobs: - name: "Set release var" run: "export IS_RELEASE=true" - name: Run Golang Update Function - run: "go test ./integration/test/performancetest -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration" \ No newline at end of file + command: | + cd integration/test/performancetest + "go test -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration" \ No newline at end of file From abc699e442172a3a71448f1675368b351e5a4c98 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:02:51 +0000 Subject: [PATCH 104/122] retry --- .github/workflows/releaseTest.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index 0574b06d9e..c174dde11b 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -36,6 +36,10 @@ jobs: - name: "Set release var" run: "export IS_RELEASE=true" - name: Run Golang Update Function - command: | - cd integration/test/performancetest - "go test -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration" \ No newline at end of file + with: + max_attempts: 1 + timeout_minutes: 30 + retry_wait_seconds: 5 + command: | + cd integration/test/performancetest + go test -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration \ No newline at end of file From f9ab0792e3d24ce1760a714c1d1869ac66496d98 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:04:19 +0000 Subject: [PATCH 105/122] uses added --- .github/workflows/releaseTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index c174dde11b..5e4ea73eef 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -30,6 +30,7 @@ jobs: UpdatePerformanceMetrics: name: "UpdatePerformanceMetrics" runs-on: ubuntu-latest + uses: nick-invision/retry@v2 steps: - name: "Set the Hash var" run: "export SHA=$GITHUB_SHA" From a6329a5dcac51a4a1ac34f80eb281ade2d728467 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:19:07 +0000 Subject: [PATCH 106/122] release changed --- .github/workflows/releaseTest.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index 5e4ea73eef..53d000deed 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -30,17 +30,18 @@ jobs: UpdatePerformanceMetrics: name: "UpdatePerformanceMetrics" runs-on: ubuntu-latest - uses: nick-invision/retry@v2 steps: + - uses: actions/checkout@v2 + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ~1.18.3 - name: "Set the Hash var" run: "export SHA=$GITHUB_SHA" - name: "Set release var" run: "export IS_RELEASE=true" - name: Run Golang Update Function - with: - max_attempts: 1 - timeout_minutes: 30 - retry_wait_seconds: 5 - command: | + run: | cd integration/test/performancetest go test -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration \ No newline at end of file From 03e6248cb58d5f46743ca755a27682c07be21cc0 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:32:47 +0000 Subject: [PATCH 107/122] fix --- .github/workflows/releaseTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index 53d000deed..8235e0c420 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -44,4 +44,4 @@ jobs: - name: Run Golang Update Function run: | cd integration/test/performancetest - go test -run TestUpdateCommit -p 1 -timeout 30m -v --tags=integration \ No newline at end of file + go test -run TestUpdateCommit -p 1 -v --tags=integration IS_RELEASE=true \ No newline at end of file From 76b487e92492c4c30071075927ed4c1d9bd59d22 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:34:27 +0000 Subject: [PATCH 108/122] fix --- .github/workflows/releaseTest.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index 8235e0c420..bfd65a2753 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -39,9 +39,8 @@ jobs: go-version: ~1.18.3 - name: "Set the Hash var" run: "export SHA=$GITHUB_SHA" - - name: "Set release var" - run: "export IS_RELEASE=true" - name: Run Golang Update Function run: | cd integration/test/performancetest + export IS_RELEASE=true go test -run TestUpdateCommit -p 1 -v --tags=integration IS_RELEASE=true \ No newline at end of file From adb25c12758fc15ab1398a2004e32ae31e4b0ce4 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:35:45 +0000 Subject: [PATCH 109/122] fix --- .github/workflows/releaseTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index bfd65a2753..d1d0501d84 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -43,4 +43,4 @@ jobs: run: | cd integration/test/performancetest export IS_RELEASE=true - go test -run TestUpdateCommit -p 1 -v --tags=integration IS_RELEASE=true \ No newline at end of file + go test -run TestUpdateCommit -p 1 -v --tags=integration \ No newline at end of file From 7c5a13d4f9a76fad0ca7702eed95c9186f7a8463 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 19:44:02 +0000 Subject: [PATCH 110/122] added creds --- .github/workflows/releaseTest.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/releaseTest.yml b/.github/workflows/releaseTest.yml index d1d0501d84..4938c6b37d 100644 --- a/.github/workflows/releaseTest.yml +++ b/.github/workflows/releaseTest.yml @@ -37,10 +37,16 @@ jobs: uses: actions/setup-go@v2 with: go-version: ~1.18.3 - - name: "Set the Hash var" - run: "export SHA=$GITHUB_SHA" + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Run Golang Update Function run: | cd integration/test/performancetest export IS_RELEASE=true + export SHA=$GITHUB_SHA go test -run TestUpdateCommit -p 1 -v --tags=integration \ No newline at end of file From da5d4724944f14bbf69f09742870beb8abd99b13 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 20:33:02 +0000 Subject: [PATCH 111/122] added error msgs --- integration/test/performancetest/transmitter.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 69d249eec3..7e75613d0f 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -278,7 +278,12 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, */ func (transmitter * TransmitterAPI) UpdateReleaseTag(year int, hash string) error{ var err error + fmt.Println("Updating:",year, "hash:",hash) item,err := transmitter.Query(year,hash) + if len(item) ==0{ + fmt.Println(item) + return errors.New("Hash not in dynamo") + } commitDate := fmt.Sprintf("%d",int(item[0]["CommitDate"].(float64))) fmt.Println(commitDate) _, err = transmitter.dynamoDbClient.UpdateItem(context.TODO(), &dynamodb.UpdateItemInput{ From 2dc1ced4d5aecc6883cb25b1161ad44057ed17c2 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 20:34:34 +0000 Subject: [PATCH 112/122] print --- integration/test/performancetest/performance_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index e413cfd424..8407242f9a 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -62,7 +62,7 @@ func TestUpdateCommit(t*testing.T){ if(os.Getenv("IS_RELEASE") ==""){ t.Skip("") } - fmt.Println("Updating Release Commit") + fmt.Println("Updating Release Commit",os.Getenv(SHA_ENV)) dynamoDB := InitializeTransmitterAPI("CWAPerformanceMetrics") //add cwa version here testHash := os.Getenv(SHA_ENV) if dynamoDB == nil{ From 98e2ae3ad7fc7b1077f54eca75be7627047f28d9 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 20:55:15 +0000 Subject: [PATCH 113/122] switched from short to long hash --- .github/workflows/fastPeformanceTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index df2c952f6f..5352ca62be 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -254,7 +254,7 @@ jobs: -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ -var="vpc_security_group_ids=${VPC_SECURITY_GROUPS_IDS}" \ -var="key_name=${KEY_NAME}" \ - -var="sha=${{ steps.sha.outputs.sha_short }}" \ + -var="sha=${GITHUB_SHA}" \ -var="sha_date=${{ steps.sha_date.outputs.sha_date }}" \ -var="test_name=cw-integ-test-${{ matrix.arrays.os }}" \ -var="iam_instance_profile=${IAM_ROLE}" \ From 7f4207d8b44fb2000affc31e865b1e2e0ceede3e Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 21:20:34 +0000 Subject: [PATCH 114/122] release checker test --- integration/test/performancetest/performance_test.go | 2 +- integration/test/performancetest/transmitter.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 8407242f9a..139b72c869 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -70,5 +70,5 @@ func TestUpdateCommit(t*testing.T){ return } //@TODO figure out how to get date - dynamoDB.UpdateReleaseTag(2022,testHash) + dynamoDB.UpdateReleaseTag(testHash) } diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 7e75613d0f..79392db563 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -276,20 +276,20 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, /* */ -func (transmitter * TransmitterAPI) UpdateReleaseTag(year int, hash string) error{ +func (transmitter * TransmitterAPI) UpdateReleaseTag(hash string) error{ var err error - fmt.Println("Updating:",year, "hash:",hash) - item,err := transmitter.Query(year,hash) + fmt.Println("Updating:",hash) + item,err := transmitter.Query(hash) if len(item) ==0{ - fmt.Println(item) return errors.New("Hash not in dynamo") } commitDate := fmt.Sprintf("%d",int(item[0]["CommitDate"].(float64))) + year := fmt.Sprintf("%d",item[0]["Year"]) fmt.Println(commitDate) _, err = transmitter.dynamoDbClient.UpdateItem(context.TODO(), &dynamodb.UpdateItemInput{ TableName: aws.String(transmitter.DataBaseName), Key: map[string]types.AttributeValue{ - "Year": &types.AttributeValueMemberN{Value: "2022"}, + "Year": &types.AttributeValueMemberN{Value: year}, "CommitDate": &types.AttributeValueMemberN{Value: commitDate }, }, UpdateExpression: aws.String("set isRelease = :release"), @@ -305,7 +305,7 @@ func (transmitter * TransmitterAPI) UpdateReleaseTag(year int, hash string) erro return err } -func (transmitter* TransmitterAPI) Query(year int, hash string) ([]map[string]interface{}, error) { +func (transmitter* TransmitterAPI) Query(hash string) ([]map[string]interface{}, error) { var err error // var response *dynamodb.QueryOutput var packets []map[string]interface{} From 4affa871ea7f8a9460afdc33bebfbdb99346c135 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Fri, 15 Jul 2022 21:42:40 +0000 Subject: [PATCH 115/122] float bug fix --- integration/test/performancetest/transmitter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 79392db563..cd3f0f5785 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -284,7 +284,7 @@ func (transmitter * TransmitterAPI) UpdateReleaseTag(hash string) error{ return errors.New("Hash not in dynamo") } commitDate := fmt.Sprintf("%d",int(item[0]["CommitDate"].(float64))) - year := fmt.Sprintf("%d",item[0]["Year"]) + year := fmt.Sprintf("%d",int(item[0]["Year"].(float64))) fmt.Println(commitDate) _, err = transmitter.dynamoDbClient.UpdateItem(context.TODO(), &dynamodb.UpdateItemInput{ TableName: aws.String(transmitter.DataBaseName), From 61d5b9f1fa2227cc4ddc6c0df9ac21788abd2ba3 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 18 Jul 2022 15:33:57 +0000 Subject: [PATCH 116/122] added tps, etc. and made dynamic update item --- .../ec2_performance_test_matrix.json | 20 ++++++++ .../test/performancetest/performance_test.go | 2 +- .../test/performancetest/transmitter.go | 50 +++++++++++++------ 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/integration/generator/resources/ec2_performance_test_matrix.json b/integration/generator/resources/ec2_performance_test_matrix.json index 08b8b02c2d..bbf859543a 100644 --- a/integration/generator/resources/ec2_performance_test_matrix.json +++ b/integration/generator/resources/ec2_performance_test_matrix.json @@ -8,5 +8,25 @@ "arc": "amd64", "binaryName": "amazon-cloudwatch-agent.rpm", "performance_number_of_logs": "10" + }, + { + "os": "al2", + "username": "ec2-user", + "installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", + "ami": "cloudwatch-agent-integration-test-al2*", + "caCertPath": "/etc/ssl/certs/ca-bundle.crt", + "arc": "amd64", + "binaryName": "amazon-cloudwatch-agent.rpm", + "performance_number_of_logs": "100" + }, + { + "os": "al2", + "username": "ec2-user", + "installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", + "ami": "cloudwatch-agent-integration-test-al2*", + "caCertPath": "/etc/ssl/certs/ca-bundle.crt", + "arc": "amd64", + "binaryName": "amazon-cloudwatch-agent.rpm", + "performance_number_of_logs": "100" } ] \ No newline at end of file diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 139b72c869..1a5e558649 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -69,6 +69,6 @@ func TestUpdateCommit(t*testing.T){ t.Fatalf("Error: generating dynamo table") return } - //@TODO figure out how to get date + dynamoDB.UpdateReleaseTag(testHash) } diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index cd3f0f5785..98f0c0749a 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -10,7 +10,7 @@ import ( "time" "strconv" "log" - + "strings" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" @@ -26,6 +26,8 @@ const ( COMMIT_DATE= "CommitDate" SHA_ENV = "SHA" SHA_DATE_ENV = "SHA_DATE" + NUMBER_OF_LOGS_MONITORED = "NumberOfLogsMonitored" + TPS = "TPS" ) type TransmitterAPI struct { dynamoDbClient *dynamodb.Client @@ -234,6 +236,8 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, packet[HASH] = os.Getenv(SHA_ENV) //fmt.Sprintf("%d", time.Now().UnixNano()) packet[COMMIT_DATE],_ = strconv.Atoi(os.Getenv(SHA_DATE_ENV)) packet["isRelease"] = false + packet[NUMBER_OF_LOGS_MONITORED] = os.Getenv("PERFORMANCE_NUMBER_OF_LOGS") + packet[TPS] = 10 for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) var avg float64 @@ -273,41 +277,59 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, return packet, nil } -/* - -*/ -func (transmitter * TransmitterAPI) UpdateReleaseTag(hash string) error{ +func (transmitter * TransmitterAPI) UpdateItem(hash string,targetAttributes map[string]types.AttributeValue) error{ var err error fmt.Println("Updating:",hash) - item,err := transmitter.Query(hash) + item,err := transmitter.Query(hash) // O(1) bcs of global sec. idx. if len(item) ==0{ - return errors.New("Hash not in dynamo") + return errors.New("ERROR: Hash is not found in dynamo") } commitDate := fmt.Sprintf("%d",int(item[0]["CommitDate"].(float64))) year := fmt.Sprintf("%d",int(item[0]["Year"].(float64))) - fmt.Println(commitDate) + expressionAttributeValues := make(map[string]types.AttributeValue) + expression := "" + n_expression := len(targetAttributes) + i :=0 + for attribute, value := range targetAttributes{ + expressionName := ":" +strings.ToLower(attribute) + expression = fmt.Sprintf("set %s = %s",attribute,expressionName) + expressionAttributeValues[expressionName] = value + if(n_expression -1 >i){ + expression += "and" + } + i++ + } _, err = transmitter.dynamoDbClient.UpdateItem(context.TODO(), &dynamodb.UpdateItemInput{ TableName: aws.String(transmitter.DataBaseName), Key: map[string]types.AttributeValue{ "Year": &types.AttributeValueMemberN{Value: year}, "CommitDate": &types.AttributeValueMemberN{Value: commitDate }, }, - UpdateExpression: aws.String("set isRelease = :release"), - ExpressionAttributeValues: map[string]types.AttributeValue{ - ":release": &types.AttributeValueMemberBOOL{Value: true}, - }, + UpdateExpression: aws.String(expression), + ExpressionAttributeValues: expressionAttributeValues, }) if err != nil { panic(err) } - return err } +/* +UpdateReleaseTag() +Desc: This function takes in a commit hash and updates the release value to true +Param: commit hash in terms of string +*/ +func (transmitter * TransmitterAPI) UpdateReleaseTag(hash string) error{ + attributes := map[string]types.AttributeValue{ + "isRelease":&types.AttributeValueMemberBOOL{Value: true}, + } + err := transmitter.UpdateItem(hash,attributes) + return err +} + func (transmitter* TransmitterAPI) Query(hash string) ([]map[string]interface{}, error) { var err error - // var response *dynamodb.QueryOutput var packets []map[string]interface{} out, err := transmitter.dynamoDbClient.Query(context.TODO(), &dynamodb.QueryInput{ TableName: aws.String(transmitter.DataBaseName), From 1376892999038de27754381c3162ffde379a9287 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 18 Jul 2022 16:03:53 +0000 Subject: [PATCH 117/122] update terraform vars --- .github/workflows/fastPeformanceTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fastPeformanceTest.yml b/.github/workflows/fastPeformanceTest.yml index 5352ca62be..7f1342d458 100644 --- a/.github/workflows/fastPeformanceTest.yml +++ b/.github/workflows/fastPeformanceTest.yml @@ -258,6 +258,7 @@ jobs: -var="sha_date=${{ steps.sha_date.outputs.sha_date }}" \ -var="test_name=cw-integ-test-${{ matrix.arrays.os }}" \ -var="iam_instance_profile=${IAM_ROLE}" \ + -var="performance_number_of_logs=${{ matrix.arrays.performance_number_of_logs}}"\ -var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve else terraform destroy -auto-approve && exit 1 From 5e5246d071c68e7c7f21851a2b2dc92a6cc8e8b6 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 18 Jul 2022 18:50:45 +0000 Subject: [PATCH 118/122] testing concurrent SendItem --- .../test/performancetest/performance_test.go | 2 +- .../test/performancetest/transmitter.go | 42 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 1a5e558649..8553670ac1 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -64,7 +64,7 @@ func TestUpdateCommit(t*testing.T){ } fmt.Println("Updating Release Commit",os.Getenv(SHA_ENV)) dynamoDB := InitializeTransmitterAPI("CWAPerformanceMetrics") //add cwa version here - testHash := os.Getenv(SHA_ENV) + testHash := "61d5b9f1fa2227cc4ddc6c0df9ac21788abd2ba3"//os.Getenv(SHA_ENV) if dynamoDB == nil{ t.Fatalf("Error: generating dynamo table") return diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 98f0c0749a..0a78645838 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -218,11 +218,26 @@ Param: data []byte is the data collected by data collector func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { // return nil packet, err := transmitter.Parser(data) + var sentItem string if err != nil { return "", err } - // fmt.Printf("%+v",packet) - sentItem, err := transmitter.AddItem(packet) + // check if hash exists + item,err := transmitter.Query(packet[HASH].(string)) + if err!=nil { + return "",err + } + if len(item)==0{ // if doesnt exit addItem + sentItem, err = transmitter.AddItem(packet) + } + // item already exist so update + //temp solution VVVVVV + testSettings := fmt.Sprintf("%s-%s",os.Getenv("PERFORMANCE_NUMBER_OF_LOGS"),"10") + testSettingValue, _ := attributevalue.MarshalMap(packet[testSettings]) + newAttributes := map[string]types.AttributeValue{ + testSettings : &types.AttributeValueMemberM{Value : testSettingValue}, + } + transmitter.UpdateItem(packet[HASH].(string),newAttributes) return sentItem, err } func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, error) { @@ -236,8 +251,8 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, packet[HASH] = os.Getenv(SHA_ENV) //fmt.Sprintf("%d", time.Now().UnixNano()) packet[COMMIT_DATE],_ = strconv.Atoi(os.Getenv(SHA_DATE_ENV)) packet["isRelease"] = false - packet[NUMBER_OF_LOGS_MONITORED] = os.Getenv("PERFORMANCE_NUMBER_OF_LOGS") - packet[TPS] = 10 + testSettings := fmt.Sprintf("%s-%s",os.Getenv("PERFORMANCE_NUMBER_OF_LOGS"),"10") + var testMetricResults map[string]Metric for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) var avg float64 @@ -272,8 +287,9 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, Std: rand.Float64(), Period: int(METRIC_PERIOD / (numDataPoints)), Data: rawMetricData.Values} - packet[rawMetricData.Label] = metric + testMetricResults[rawMetricData.Label] = metric } + packet[testSettings] = testMetricResults return packet, nil } @@ -350,3 +366,19 @@ func (transmitter* TransmitterAPI) Query(hash string) ([]map[string]interface{}, attributevalue.UnmarshalListOfMaps(out.Items,&packets) return packets, err } + + +// func (transmitter*TransmitterAPI) HashExist(hash string) (bool, error){ +// if hash==""{ +// return false,errors.New("Invalid hash") +// } +// item,err := transmitter.Query(hash) +// if err != nil{ +// return false,err +// } +// if len(item) == 0{ +// return false,nil +// } +// return true,err + +// } \ No newline at end of file From 4bb4d562fe24a56f56e608bed03f8caeb45a9847 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 18 Jul 2022 20:40:43 +0000 Subject: [PATCH 119/122] trying concurrent tests --- .../test/performancetest/performance_test.go | 2 +- .../test/performancetest/transmitter.go | 41 +++++++++++++++---- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 8553670ac1..1a5e558649 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -64,7 +64,7 @@ func TestUpdateCommit(t*testing.T){ } fmt.Println("Updating Release Commit",os.Getenv(SHA_ENV)) dynamoDB := InitializeTransmitterAPI("CWAPerformanceMetrics") //add cwa version here - testHash := "61d5b9f1fa2227cc4ddc6c0df9ac21788abd2ba3"//os.Getenv(SHA_ENV) + testHash := os.Getenv(SHA_ENV) if dynamoDB == nil{ t.Fatalf("Error: generating dynamo table") return diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 0a78645838..dfe161bfa6 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -218,25 +218,52 @@ Param: data []byte is the data collected by data collector func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { // return nil packet, err := transmitter.Parser(data) + var sentItem string if err != nil { return "", err } // check if hash exists - item,err := transmitter.Query(packet[HASH].(string)) + itemList,err := transmitter.Query(packet[HASH].(string)) + if err!=nil { return "",err } - if len(item)==0{ // if doesnt exit addItem + fmt.Println(itemList,packet[HASH].(string)) + if len(itemList)==0{ // if doesnt exit addItem sentItem, err = transmitter.AddItem(packet) + return sentItem, err } + // item already exist so update //temp solution VVVVVV testSettings := fmt.Sprintf("%s-%s",os.Getenv("PERFORMANCE_NUMBER_OF_LOGS"),"10") - testSettingValue, _ := attributevalue.MarshalMap(packet[testSettings]) + item := itemList[0]["Results"].(map[string]interface{}) + _,isPresent := item[testSettings] // check if we already had this test + if isPresent{ // no diff + return "",errors.New("Nothing to update") + } + testSettingValue, err := attributevalue.MarshalMap(packet[testSettings]) + if err !=nil{ + fmt.Println(err) + } + tempResults := make(map[string]interface{}) + for attribute,value := range item{ + _, isPresent := packet["Results"].(map[string]map[string]Metric)[attribute] + if(isPresent){continue} + tempResults[attribute] = value + + } + + tempResults[testSettings] = testSettingValue + fmt.Println("temp",len(tempResults)) + results, _ := attributevalue.MarshalMap(tempResults) newAttributes := map[string]types.AttributeValue{ - testSettings : &types.AttributeValueMemberM{Value : testSettingValue}, + "Results" : &types.AttributeValueMemberM{ + Value: results, + }, } + transmitter.UpdateItem(packet[HASH].(string),newAttributes) return sentItem, err } @@ -252,7 +279,7 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, packet[COMMIT_DATE],_ = strconv.Atoi(os.Getenv(SHA_DATE_ENV)) packet["isRelease"] = false testSettings := fmt.Sprintf("%s-%s",os.Getenv("PERFORMANCE_NUMBER_OF_LOGS"),"10") - var testMetricResults map[string]Metric + testMetricResults := make(map[string]Metric) for _, rawMetricData := range dataHolder { numDataPoints := float64(len(rawMetricData.Timestamps)) var avg float64 @@ -289,10 +316,9 @@ func (transmitter *TransmitterAPI) Parser(data []byte) (map[string]interface{}, Data: rawMetricData.Values} testMetricResults[rawMetricData.Label] = metric } - packet[testSettings] = testMetricResults + packet["Results"] = map[string]map[string]Metric{ testSettings: testMetricResults} return packet, nil } - func (transmitter * TransmitterAPI) UpdateItem(hash string,targetAttributes map[string]types.AttributeValue) error{ var err error fmt.Println("Updating:",hash) @@ -315,6 +341,7 @@ func (transmitter * TransmitterAPI) UpdateItem(hash string,targetAttributes map[ } i++ } + fmt.Println(expression) _, err = transmitter.dynamoDbClient.UpdateItem(context.TODO(), &dynamodb.UpdateItemInput{ TableName: aws.String(transmitter.DataBaseName), Key: map[string]types.AttributeValue{ From 0648e82fb61b9e6780fb69f5ec9df2fc3db7cd28 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 18 Jul 2022 21:24:54 +0000 Subject: [PATCH 120/122] fixed --- integration/test/performancetest/performance_test.go | 2 +- integration/test/performancetest/transmitter.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integration/test/performancetest/performance_test.go b/integration/test/performancetest/performance_test.go index 1a5e558649..99815f16f0 100644 --- a/integration/test/performancetest/performance_test.go +++ b/integration/test/performancetest/performance_test.go @@ -55,7 +55,7 @@ func TestPerformance(t *testing.T) { } _, err = dynamoDB.SendItem(data) if err !=nil{ - t.Fatalf("Error: couldnt upload metric data to table") + t.Fatalf("Error: couldnt upload metric data to table %s",err) } } func TestUpdateCommit(t*testing.T){ diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index dfe161bfa6..564c375655 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -243,7 +243,8 @@ func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { if isPresent{ // no diff return "",errors.New("Nothing to update") } - testSettingValue, err := attributevalue.MarshalMap(packet[testSettings]) + testSettingValue, err := attributevalue.MarshalMap(packet["Results"].(map[string]map[string]Metric)[testSettings]) + fmt.Println("test value",testSettingValue) if err !=nil{ fmt.Println(err) } @@ -256,7 +257,6 @@ func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { } tempResults[testSettings] = testSettingValue - fmt.Println("temp",len(tempResults)) results, _ := attributevalue.MarshalMap(tempResults) newAttributes := map[string]types.AttributeValue{ "Results" : &types.AttributeValueMemberM{ From 471995bd7666df10b77fc8d93d52434f9f718516 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 18 Jul 2022 21:54:19 +0000 Subject: [PATCH 121/122] added debug print --- integration/test/performancetest/transmitter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/test/performancetest/transmitter.go b/integration/test/performancetest/transmitter.go index 564c375655..3aaf321aaf 100644 --- a/integration/test/performancetest/transmitter.go +++ b/integration/test/performancetest/transmitter.go @@ -238,6 +238,7 @@ func (transmitter *TransmitterAPI) SendItem(data []byte) (string, error) { // item already exist so update //temp solution VVVVVV testSettings := fmt.Sprintf("%s-%s",os.Getenv("PERFORMANCE_NUMBER_OF_LOGS"),"10") + fmt.Println("The test is",testSettings) item := itemList[0]["Results"].(map[string]interface{}) _,isPresent := item[testSettings] // check if we already had this test if isPresent{ // no diff From 49dc026d87f717f4acca8158d17cc39aa5747462 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Mon, 18 Jul 2022 22:17:07 +0000 Subject: [PATCH 122/122] fixed generator --- .../generator/resources/ec2_performance_test_matrix.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/generator/resources/ec2_performance_test_matrix.json b/integration/generator/resources/ec2_performance_test_matrix.json index bbf859543a..357095c196 100644 --- a/integration/generator/resources/ec2_performance_test_matrix.json +++ b/integration/generator/resources/ec2_performance_test_matrix.json @@ -27,6 +27,6 @@ "caCertPath": "/etc/ssl/certs/ca-bundle.crt", "arc": "amd64", "binaryName": "amazon-cloudwatch-agent.rpm", - "performance_number_of_logs": "100" + "performance_number_of_logs": "1000" } ] \ No newline at end of file