diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml index ace35f56f..57c6d54ec 100644 --- a/.github/workflows/build-check.yml +++ b/.github/workflows/build-check.yml @@ -25,6 +25,9 @@ jobs: - name: Lint Terraform if: runner.os == 'Linux' run: cd terraform && make check-fmt + - name: Lint Go + if: runner.os == 'Linux' + run: make simple-lint - name: Compile tests run: | echo "Compile tests" diff --git a/Makefile b/Makefile index 625211eb2..59ccb8485 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,16 @@ BASE_SPACE=$(shell pwd) BUILD_SPACE=$(BASE_SPACE)/build +IMPORT_PATH=github.com/aws/amazon-cloudwatch-agent-test +ALL_SRC := $(shell find . -name '*.go' -type f | sort) TOOLS_BIN_DIR := $(abspath ./build/tools) + +GOIMPORTS = $(TOOLS_BIN_DIR)/goimports LINTER = $(TOOLS_BIN_DIR)/golangci-lint +IMPI = $(TOOLS_BIN_DIR)/impi +ADDLICENSE = $(TOOLS_BIN_DIR)/addlicense + +GOIMPORTS_OPT?= -w -local $(IMPORT_PATH) WIN_BUILD = GOOS=windows GOARCH=amd64 go build -trimpath -o $(BUILD_SPACE) LINUX_AMD64_BUILD = CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -o $(BUILD_SPACE) @@ -22,14 +30,56 @@ LOADGEN_LINUX_ARM64_BUILD = $(LINUX_ARM64_BUILD)/linux/arm64 LOADGEN_DARWIN_AMD64_BUILD = $(DARWIN_AMD64_BUILD)/darwin/amd64 LOADGEN_DARWIN_ARM64_BUILD = $(DARWIN_ARM64_BUILD)/darwin/arm64 -install-tools: +install-goimports: + GOBIN=$(TOOLS_BIN_DIR) go install golang.org/x/tools/cmd/goimports + +install-impi: + GOBIN=$(TOOLS_BIN_DIR) go install github.com/pavius/impi/cmd/impi@v0.0.3 + +install-addlicense: + # Using 04bfe4e to get SPDX template changes that are not present in the most recent tag v1.0.0 + # This is required to be able to easily omit the year in our license header. + GOBIN=$(TOOLS_BIN_DIR) go install github.com/google/addlicense@04bfe4e + +install-golang-lint: #Install from source for golangci-lint is not recommended based on https://golangci-lint.run/usage/install/#install-from-source so using binary #installation curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN_DIR) v1.50.1 -lint: install-tools +fmt: install-goimports addlicense + go fmt ./... + @echo $(ALL_SRC) | xargs -n 10 $(GOIMPORTS) $(GOIMPORTS_OPT) + +impi: install-impi + @echo $(ALL_SRC) | xargs -n 10 $(IMPI) --local $(IMPORT_PATH) --scheme stdThirdPartyLocal + @echo "Check import order/grouping finished" + +simple-lint: checklicense impi + +lint: install-golang-lint simple-lint ${LINTER} run ./... +addlicense: install-addlicense + @ADDLICENSEOUT=`$(ADDLICENSE) -y="" -s=only -l="mit" -c="Amazon.com, Inc. or its affiliates. All Rights Reserved." $(ALL_SRC) 2>&1`; \ + if [ "$$ADDLICENSEOUT" ]; then \ + echo "$(ADDLICENSE) FAILED => add License errors:\n"; \ + echo "$$ADDLICENSEOUT\n"; \ + exit 1; \ + else \ + echo "Add License finished successfully"; \ + fi + +checklicense: install-addlicense + @ADDLICENSEOUT=`$(ADDLICENSE) -check $(ALL_SRC) 2>&1`; \ + if [ "$$ADDLICENSEOUT" ]; then \ + echo "$(ADDLICENSE) FAILED => add License errors:\n"; \ + echo "$$ADDLICENSEOUT\n"; \ + echo "Use 'make addlicense' to fix this."; \ + exit 1; \ + else \ + echo "Check License finished successfully"; \ + fi + compile: # this is a workaround to compile and cache all of the tests without actually running any of them go test -run=NO_MATCH ./... diff --git a/cmd/emf-generator/emf-generator.go b/cmd/emf-generator/emf-generator.go index cf0d0604c..175a0b4ae 100644 --- a/cmd/emf-generator/emf-generator.go +++ b/cmd/emf-generator/emf-generator.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package main import ( diff --git a/cmd/log-generator/log-generator.go b/cmd/log-generator/log-generator.go index 007db4b49..041849a46 100644 --- a/cmd/log-generator/log-generator.go +++ b/cmd/log-generator/log-generator.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package main import ( diff --git a/cmd/statsd-generator/statsd-generator.go b/cmd/statsd-generator/statsd-generator.go index 37ab94c98..6b0458499 100644 --- a/cmd/statsd-generator/statsd-generator.go +++ b/cmd/statsd-generator/statsd-generator.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package main import ( diff --git a/filesystem/unix_permission.go b/filesystem/unix_permission.go index ad029c024..67e382808 100644 --- a/filesystem/unix_permission.go +++ b/filesystem/unix_permission.go @@ -7,8 +7,9 @@ package filesystem import ( "fmt" - "golang.org/x/sys/unix" "os/user" + + "golang.org/x/sys/unix" ) type FilePermission string diff --git a/filesystem/windows_permission.go b/filesystem/windows_permission.go index 65820157a..23f680de5 100644 --- a/filesystem/windows_permission.go +++ b/filesystem/windows_permission.go @@ -7,9 +7,10 @@ package filesystem import ( "fmt" - "golang.org/x/sys/windows" "os" "unsafe" + + "golang.org/x/sys/windows" ) // CheckFileRights check that the given filename has access controls and system permission for Administrator, Local System diff --git a/install/install_agent.go b/install/install_agent.go index f8c52af01..afced242b 100644 --- a/install/install_agent.go +++ b/install/install_agent.go @@ -11,16 +11,16 @@ import ( ) const ( - retryNumber = 10 - retryTime = 30 * time.Second - debInstall = "deb" - rpmInstall = "rpm" + retryNumber = 10 + retryTime = 30 * time.Second + debInstall = "deb" + rpmInstall = "rpm" ) func main() { installType := os.Args[1] installCommand := "" - + debInstallCommand := "sudo dpkg -i -E ./amazon-cloudwatch-agent.deb" rpmInstallCommand := "sudo rpm -U ./amazon-cloudwatch-agent.rpm" if os.Geteuid() == 0 { diff --git a/test/acceptance/filepermissions_test.go b/test/acceptance/filepermissions_test.go index 22d37693c..64e7d5635 100644 --- a/test/acceptance/filepermissions_test.go +++ b/test/acceptance/filepermissions_test.go @@ -6,14 +6,16 @@ package acceptance import ( "fmt" + "log" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/filesystem" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/stretchr/testify/assert" - "log" - "testing" - "time" ) func init() { diff --git a/test/acceptance/filepermissions_windows.go b/test/acceptance/filepermissions_windows.go index e7048a644..1e98828d9 100644 --- a/test/acceptance/filepermissions_windows.go +++ b/test/acceptance/filepermissions_windows.go @@ -10,9 +10,10 @@ import ( "log" "time" + "go.uber.org/multierr" + "github.com/aws/amazon-cloudwatch-agent-test/filesystem" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "go.uber.org/multierr" ) const ( diff --git a/test/assume_role/assume_role_unix.go b/test/assume_role/assume_role_unix.go index 787d61cda..d8ec171ef 100644 --- a/test/assume_role/assume_role_unix.go +++ b/test/assume_role/assume_role_unix.go @@ -8,14 +8,15 @@ package assume_role import ( "log" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" ) const ( diff --git a/test/assume_role/assume_role_windows.go b/test/assume_role/assume_role_windows.go index 8626283fa..76a8409a8 100644 --- a/test/assume_role/assume_role_windows.go +++ b/test/assume_role/assume_role_windows.go @@ -10,12 +10,13 @@ import ( "log" "time" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/filesystem" "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" ) const ( diff --git a/test/ca_bundle/ca_bundle_test.go b/test/ca_bundle/ca_bundle_test.go index 9efb1d860..a0de9481f 100644 --- a/test/ca_bundle/ca_bundle_test.go +++ b/test/ca_bundle/ca_bundle_test.go @@ -8,16 +8,17 @@ package ca_bundle import ( "context" "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/feature/s3/manager" - "github.com/aws/aws-sdk-go-v2/service/s3" "log" "os" "strings" "testing" "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/s3/manager" + "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/util/common" ) diff --git a/test/canary/canary_test.go b/test/canary/canary_test.go index 9adeb2a5b..d0d92ab04 100644 --- a/test/canary/canary_test.go +++ b/test/canary/canary_test.go @@ -12,11 +12,12 @@ import ( "strings" "testing" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + "github.com/stretchr/testify/require" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" - "github.com/stretchr/testify/require" ) const ( diff --git a/test/cloudformation/cloudformation_test.go b/test/cloudformation/cloudformation_test.go index 183d1bfe0..da5a63d79 100644 --- a/test/cloudformation/cloudformation_test.go +++ b/test/cloudformation/cloudformation_test.go @@ -8,15 +8,17 @@ package cloudformation import ( "context" "flag" - "github.com/aws/amazon-cloudwatch-agent-test/test/metric" - "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" "log" "os" "testing" "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" + + "github.com/aws/amazon-cloudwatch-agent-test/test/metric" + "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" ) const ( diff --git a/test/ecs/ecs_metadata/ecs_metadata_test.go b/test/ecs/ecs_metadata/ecs_metadata_test.go index 738e9020a..0e132bd9a 100644 --- a/test/ecs/ecs_metadata/ecs_metadata_test.go +++ b/test/ecs/ecs_metadata/ecs_metadata_test.go @@ -7,12 +7,12 @@ import ( _ "embed" "flag" "fmt" - "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" "log" "strings" "testing" "time" + "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" "github.com/stretchr/testify/assert" "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" diff --git a/test/emf/emf_container_test.go b/test/emf/emf_container_test.go index 5ddf5fdfd..488b1963a 100644 --- a/test/emf/emf_container_test.go +++ b/test/emf/emf_container_test.go @@ -1,15 +1,20 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + //go:build !windows package emf import ( + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" - "time" ) type EMFTestRunner struct { diff --git a/test/emf/emf_test.go b/test/emf/emf_test.go index 35f45ec69..3ba31cec8 100644 --- a/test/emf/emf_test.go +++ b/test/emf/emf_test.go @@ -7,14 +7,16 @@ package emf import ( "fmt" + "log" + "testing" + + "github.com/stretchr/testify/suite" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" - "github.com/stretchr/testify/suite" - "log" - "testing" ) type MetricBenchmarkTestSuite struct { diff --git a/test/emf_concurrent/emf_concurrent_test.go b/test/emf_concurrent/emf_concurrent_test.go index 1ddd145eb..4c7a2802f 100644 --- a/test/emf_concurrent/emf_concurrent_test.go +++ b/test/emf_concurrent/emf_concurrent_test.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package emf_concurrent import ( diff --git a/test/emf_concurrent/emitter.go b/test/emf_concurrent/emitter.go index 77f3eb29f..0883a697b 100644 --- a/test/emf_concurrent/emitter.go +++ b/test/emf_concurrent/emitter.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package emf_concurrent import ( diff --git a/test/fips/fips_test.go b/test/fips/fips_test.go index 1ab918d5a..cb26ff2f1 100644 --- a/test/fips/fips_test.go +++ b/test/fips/fips_test.go @@ -9,12 +9,13 @@ import ( "testing" "time" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/aws/aws-sdk-go-v2/aws" ) const ( diff --git a/test/lvm/lvm_test.go b/test/lvm/lvm_test.go index 569adfd26..306c739ce 100644 --- a/test/lvm/lvm_test.go +++ b/test/lvm/lvm_test.go @@ -9,13 +9,14 @@ import ( "os" "testing" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/aws/aws-sdk-go-v2/aws" ) const namespace = "LVMTest" diff --git a/test/metric/dimension/container_insights_provider.go b/test/metric/dimension/container_insights_provider.go index 555f01bde..32cb8d8e0 100644 --- a/test/metric/dimension/container_insights_provider.go +++ b/test/metric/dimension/container_insights_provider.go @@ -6,11 +6,13 @@ package dimension import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" + "log" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" - "log" + + "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" ) type ContainerInsightsDimensionProvider struct { diff --git a/test/metric/dimension/emf_ecs_dimension_provider.go b/test/metric/dimension/emf_ecs_dimension_provider.go index 657dacffd..f3c510f41 100644 --- a/test/metric/dimension/emf_ecs_dimension_provider.go +++ b/test/metric/dimension/emf_ecs_dimension_provider.go @@ -6,9 +6,10 @@ package dimension import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + + "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" ) type EMFECSDimensionProvider struct { diff --git a/test/metric/dimension/host_provider.go b/test/metric/dimension/host_provider.go index a489e2b03..c90fcf5a6 100644 --- a/test/metric/dimension/host_provider.go +++ b/test/metric/dimension/host_provider.go @@ -6,10 +6,12 @@ package dimension import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" + "os" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" - "os" + + "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" ) type HostDimensionProvider struct { diff --git a/test/metric/dimension/imageid_provider.go b/test/metric/dimension/imageid_provider.go index 8f31f113c..1473bf97f 100644 --- a/test/metric/dimension/imageid_provider.go +++ b/test/metric/dimension/imageid_provider.go @@ -6,10 +6,11 @@ package dimension import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + + "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" ) type LocalImageIdDimensionProvider struct { diff --git a/test/metric/dimension/instanceid_provider.go b/test/metric/dimension/instanceid_provider.go index 218208013..3ecdbf377 100644 --- a/test/metric/dimension/instanceid_provider.go +++ b/test/metric/dimension/instanceid_provider.go @@ -6,11 +6,13 @@ package dimension import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" + "log" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" - "log" + + "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" ) type ECSInstanceIdDimensionProvider struct { diff --git a/test/metric/dimension/instancetype_provider.go b/test/metric/dimension/instancetype_provider.go index b5374a660..0f241b163 100644 --- a/test/metric/dimension/instancetype_provider.go +++ b/test/metric/dimension/instancetype_provider.go @@ -6,10 +6,11 @@ package dimension import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + + "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" ) type LocalInstanceTypeDimensionProvider struct { diff --git a/test/metric/dimension/provider.go b/test/metric/dimension/provider.go index 10daf8b7b..6d6a200c8 100644 --- a/test/metric/dimension/provider.go +++ b/test/metric/dimension/provider.go @@ -8,8 +8,9 @@ package dimension import ( "log" - "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + + "github.com/aws/amazon-cloudwatch-agent-test/environment" ) type ExpectedDimensionValue struct { diff --git a/test/metric/metric_validation_util.go b/test/metric/metric_validation_util.go index 4cd362b97..e6eb4813e 100644 --- a/test/metric/metric_validation_util.go +++ b/test/metric/metric_validation_util.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package metric import "log" diff --git a/test/metric/statsd_util.go b/test/metric/statsd_util.go index 395767342..60a70be35 100644 --- a/test/metric/statsd_util.go +++ b/test/metric/statsd_util.go @@ -6,12 +6,14 @@ package metric import ( - "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" - "github.com/aws/amazon-cloudwatch-agent-test/test/status" - "github.com/aws/aws-sdk-go-v2/aws" "log" "strings" "time" + + "github.com/aws/aws-sdk-go-v2/aws" + + "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" + "github.com/aws/amazon-cloudwatch-agent-test/test/status" ) const ( diff --git a/test/metric_dimension/aggregation_dimensions_test.go b/test/metric_dimension/aggregation_dimensions_test.go index 8bc340a2a..7c68a441d 100644 --- a/test/metric_dimension/aggregation_dimensions_test.go +++ b/test/metric_dimension/aggregation_dimensions_test.go @@ -8,11 +8,12 @@ package metric_dimension import ( "log" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" - "github.com/aws/aws-sdk-go-v2/aws" ) type AggregationDimensionsTestRunner struct { diff --git a/test/metric_dimension/drop_original_test.go b/test/metric_dimension/drop_original_test.go index 172722ea9..6b66bb83a 100644 --- a/test/metric_dimension/drop_original_test.go +++ b/test/metric_dimension/drop_original_test.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + //go:build !windows package metric_dimension diff --git a/test/metric_dimension/global_append_dimensions_test.go b/test/metric_dimension/global_append_dimensions_test.go index d77776a46..cfc524a07 100644 --- a/test/metric_dimension/global_append_dimensions_test.go +++ b/test/metric_dimension/global_append_dimensions_test.go @@ -6,12 +6,14 @@ package metric_dimension import ( + "log" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" - "github.com/aws/aws-sdk-go-v2/aws" - "log" ) type GlobalAppendDimensionsTestRunner struct { diff --git a/test/metric_dimension/metrics_dimension_test.go b/test/metric_dimension/metrics_dimension_test.go index 0021021f3..097f563ac 100644 --- a/test/metric_dimension/metrics_dimension_test.go +++ b/test/metric_dimension/metrics_dimension_test.go @@ -10,11 +10,12 @@ import ( "log" "testing" + "github.com/stretchr/testify/suite" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" - "github.com/stretchr/testify/suite" ) type MetricsAppendDimensionTestSuite struct { diff --git a/test/metric_value_benchmark/eks_deployment_prometheus_test.go b/test/metric_value_benchmark/eks_deployment_prometheus_test.go index 967b8148e..383d56d05 100644 --- a/test/metric_value_benchmark/eks_deployment_prometheus_test.go +++ b/test/metric_value_benchmark/eks_deployment_prometheus_test.go @@ -6,10 +6,11 @@ package metric_value_benchmark import ( - "github.com/aws/aws-sdk-go-v2/aws" "log" "time" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" diff --git a/test/metric_value_benchmark/eks_resources/util.go b/test/metric_value_benchmark/eks_resources/util.go index 06b90ceed..537183575 100644 --- a/test/metric_value_benchmark/eks_resources/util.go +++ b/test/metric_value_benchmark/eks_resources/util.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package eks_resources import _ "embed" diff --git a/test/metric_value_benchmark/emf_test.go b/test/metric_value_benchmark/emf_test.go index a69a785c0..ab29f00d3 100644 --- a/test/metric_value_benchmark/emf_test.go +++ b/test/metric_value_benchmark/emf_test.go @@ -10,13 +10,14 @@ import ( "log" "time" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" "github.com/aws/amazon-cloudwatch-agent-test/util/common" - "github.com/aws/aws-sdk-go-v2/aws" ) type EMFTestRunner struct { diff --git a/test/metric_value_benchmark/net_test.go b/test/metric_value_benchmark/net_test.go index 89828bca2..daf31182c 100644 --- a/test/metric_value_benchmark/net_test.go +++ b/test/metric_value_benchmark/net_test.go @@ -6,13 +6,13 @@ package metric_value_benchmark import ( - "github.com/aws/amazon-cloudwatch-agent-test/util/common" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" + "github.com/aws/amazon-cloudwatch-agent-test/util/common" ) type NetTestRunner struct { diff --git a/test/metric_value_benchmark/statsd_test.go b/test/metric_value_benchmark/statsd_test.go index 089c87efa..9ecd011cb 100644 --- a/test/metric_value_benchmark/statsd_test.go +++ b/test/metric_value_benchmark/statsd_test.go @@ -6,11 +6,12 @@ package metric_value_benchmark import ( - "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "strings" "time" "github.com/DataDog/datadog-go/statsd" + + "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" ) diff --git a/test/otlp/trace_test.go b/test/otlp/trace_test.go index fd68dd95e..90aa89d9c 100644 --- a/test/otlp/trace_test.go +++ b/test/otlp/trace_test.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package otlp import ( @@ -5,11 +8,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/otel/attribute" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/otlp" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/otel/attribute" ) const ( diff --git a/test/proxy/proxy_unix_test.go b/test/proxy/proxy_unix_test.go index 47da5ae56..720df73cc 100644 --- a/test/proxy/proxy_unix_test.go +++ b/test/proxy/proxy_unix_test.go @@ -6,10 +6,11 @@ package proxy import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment" - "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" + + "github.com/aws/amazon-cloudwatch-agent-test/environment" + "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" ) const commonConfigPath = "/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml" diff --git a/test/soak/soak_test.go b/test/soak/soak_test.go index 2594332f2..57a3e6102 100644 --- a/test/soak/soak_test.go +++ b/test/soak/soak_test.go @@ -9,10 +9,11 @@ import ( "strings" "testing" - "github.com/aws/amazon-cloudwatch-agent-test/environment" - "github.com/aws/amazon-cloudwatch-agent-test/util/common" "github.com/shirou/gopsutil/v3/process" "github.com/stretchr/testify/require" + + "github.com/aws/amazon-cloudwatch-agent-test/environment" + "github.com/aws/amazon-cloudwatch-agent-test/util/common" ) func init() { diff --git a/test/statsd/default_test.go b/test/statsd/default_test.go index ac18f7ea6..6754895a1 100644 --- a/test/statsd/default_test.go +++ b/test/statsd/default_test.go @@ -6,11 +6,12 @@ package statsd import ( + "strings" + "time" + "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" - "strings" - "time" ) const testRetryCount = 3 diff --git a/test/statsd/statsd_test.go b/test/statsd/statsd_test.go index 0c80c800e..66aac7a98 100644 --- a/test/statsd/statsd_test.go +++ b/test/statsd/statsd_test.go @@ -7,13 +7,13 @@ package statsd import ( "fmt" - "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" "log" "testing" "github.com/stretchr/testify/suite" "github.com/aws/amazon-cloudwatch-agent-test/environment" + "github.com/aws/amazon-cloudwatch-agent-test/environment/computetype" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" "github.com/aws/amazon-cloudwatch-agent-test/test/test_runner" diff --git a/test/test_runner/ecs_test_runner.go b/test/test_runner/ecs_test_runner.go index 591ca4e90..e034edced 100644 --- a/test/test_runner/ecs_test_runner.go +++ b/test/test_runner/ecs_test_runner.go @@ -7,13 +7,13 @@ package test_runner import ( "fmt" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" "log" "os" "time" "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/test/status" + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" ) type IAgentRunStrategy interface { diff --git a/test/test_runner/eks_test_runner.go b/test/test_runner/eks_test_runner.go index dc2f10f51..2d832d584 100644 --- a/test/test_runner/eks_test_runner.go +++ b/test/test_runner/eks_test_runner.go @@ -6,10 +6,11 @@ package test_runner import ( - "github.com/aws/amazon-cloudwatch-agent-test/environment" - "github.com/aws/amazon-cloudwatch-agent-test/test/status" "log" "time" + + "github.com/aws/amazon-cloudwatch-agent-test/environment" + "github.com/aws/amazon-cloudwatch-agent-test/test/status" ) type EKSTestRunner struct { diff --git a/test/test_runner/test_suite.go b/test/test_runner/test_suite.go index 21cdf8dee..e26f62281 100644 --- a/test/test_runner/test_suite.go +++ b/test/test_runner/test_suite.go @@ -7,6 +7,7 @@ package test_runner import ( "fmt" + "github.com/aws/amazon-cloudwatch-agent-test/test/status" ) diff --git a/test/userdata/userdata_test.go b/test/userdata/userdata_test.go index de0bad257..e11b4e49b 100644 --- a/test/userdata/userdata_test.go +++ b/test/userdata/userdata_test.go @@ -8,9 +8,9 @@ import ( "log" "testing" - "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/test/metric" "github.com/aws/amazon-cloudwatch-agent-test/test/metric/dimension" "github.com/aws/amazon-cloudwatch-agent-test/test/status" diff --git a/test/xray/trace_test.go b/test/xray/trace_test.go index 430a147b4..0de9cb67f 100644 --- a/test/xray/trace_test.go +++ b/test/xray/trace_test.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package xray import ( @@ -5,10 +8,11 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/aws/amazon-cloudwatch-agent-test/environment" "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/xray" - "github.com/stretchr/testify/require" ) const ( diff --git a/util/awsservice/cloudformation.go b/util/awsservice/cloudformation.go index 7d36f9683..c67ad0727 100644 --- a/util/awsservice/cloudformation.go +++ b/util/awsservice/cloudformation.go @@ -1,13 +1,17 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package awsservice import ( "context" + "log" + "time" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" "github.com/google/uuid" - "log" - "time" ) const instanceIdKey = "InstanceId" diff --git a/util/awsservice/constant.go b/util/awsservice/constant.go index ff2a313d7..1009a08e2 100644 --- a/util/awsservice/constant.go +++ b/util/awsservice/constant.go @@ -5,11 +5,11 @@ package awsservice import ( "context" - "github.com/aws/aws-sdk-go-v2/service/cloudformation" "time" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" + "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/aws/aws-sdk-go-v2/service/cloudwatch" "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs" "github.com/aws/aws-sdk-go-v2/service/dynamodb" diff --git a/util/common/logs.go b/util/common/logs.go index 92a4e9ca1..60f8ea164 100644 --- a/util/common/logs.go +++ b/util/common/logs.go @@ -14,8 +14,9 @@ import ( "runtime" "time" - "github.com/aws/amazon-cloudwatch-agent-test/validator/models" "go.uber.org/multierr" + + "github.com/aws/amazon-cloudwatch-agent-test/validator/models" ) const logLine = "# %d - This is a log line. \n" diff --git a/util/common/traces/base/base.go b/util/common/traces/base/base.go index 72c43baa0..7bb59f595 100644 --- a/util/common/traces/base/base.go +++ b/util/common/traces/base/base.go @@ -1,17 +1,22 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package base import ( "context" "encoding/json" - "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" - "github.com/aws/amazon-cloudwatch-agent-test/util/common" + "reflect" + "testing" + "time" + "github.com/aws/aws-sdk-go-v2/service/xray/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" - "reflect" - "testing" - "time" + + "github.com/aws/amazon-cloudwatch-agent-test/util/awsservice" + "github.com/aws/amazon-cloudwatch-agent-test/util/common" ) const ( diff --git a/util/common/traces/generate.go b/util/common/traces/generate.go index 55a2857d0..04ab964e9 100644 --- a/util/common/traces/generate.go +++ b/util/common/traces/generate.go @@ -1,10 +1,14 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package traces import ( "fmt" + "time" + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/xray" - "time" ) func StartTraceGeneration(receiver string, agentConfigPath string, agentRuntime time.Duration, traceSendingInterval time.Duration) error { diff --git a/util/common/traces/otlp/generator.go b/util/common/traces/otlp/generator.go index 017fb3f4c..98e41eca9 100644 --- a/util/common/traces/otlp/generator.go +++ b/util/common/traces/otlp/generator.go @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package otlp import ( @@ -5,7 +8,6 @@ import ( "errors" "time" - "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" "go.opentelemetry.io/contrib/propagators/aws/xray" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" @@ -15,6 +17,8 @@ import ( semconv "go.opentelemetry.io/otel/semconv/v1.17.0" "go.opentelemetry.io/otel/trace" "golang.org/x/exp/maps" + + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" ) var generatorError = errors.New("Generator error") diff --git a/util/common/traces/xray/generator.go b/util/common/traces/xray/generator.go index 344202877..872c012b5 100644 --- a/util/common/traces/xray/generator.go +++ b/util/common/traces/xray/generator.go @@ -1,16 +1,21 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + package xray import ( "context" "errors" - "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" - "github.com/aws/aws-xray-sdk-go/strategy/sampling" - "github.com/aws/aws-xray-sdk-go/xray" - "github.com/aws/aws-xray-sdk-go/xraylog" "log" "os" "path" "time" + + "github.com/aws/aws-xray-sdk-go/strategy/sampling" + "github.com/aws/aws-xray-sdk-go/xray" + "github.com/aws/aws-xray-sdk-go/xraylog" + + "github.com/aws/amazon-cloudwatch-agent-test/util/common/traces/base" ) var generatorError = errors.New("Generator error") diff --git a/validator/validators/performance/performance_validator.go b/validator/validators/performance/performance_validator.go index b1e98f032..cb9482e14 100644 --- a/validator/validators/performance/performance_validator.go +++ b/validator/validators/performance/performance_validator.go @@ -5,11 +5,11 @@ package performance import ( "fmt" - "github.com/aws/aws-sdk-go-v2/service/cloudwatch" "log" "strings" "time" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" "github.com/aws/aws-sdk-go/aws" "github.com/cenkalti/backoff/v4" diff --git a/validator/validators/util/common.go b/validator/validators/util/common.go index 048abe9fe..cfac9b029 100644 --- a/validator/validators/util/common.go +++ b/validator/validators/util/common.go @@ -5,6 +5,7 @@ package util import ( "fmt" + "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" ) @@ -17,4 +18,3 @@ func LogCloudWatchDimension(dims []types.Dimension) string { } return dimension } -