-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathecs_servicediscovery_test.go
More file actions
72 lines (55 loc) · 2.18 KB
/
Copy pathecs_servicediscovery_test.go
File metadata and controls
72 lines (55 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
//go:build !windows
package ecs_sd
import (
"testing"
"github.com/stretchr/testify/suite"
"github.com/aws/amazon-cloudwatch-agent-test/environment"
"github.com/aws/amazon-cloudwatch-agent-test/test/status"
"github.com/aws/amazon-cloudwatch-agent-test/test/test_runner"
)
/*
Purpose:
1) Validate ECS ServiceDiscovery via DockerLabels by publishing Prometheus EMF to CW https://github.com/aws/amazon-cloudwatch-agent/blob/main/internal/ecsservicediscovery/README.md
2) Detect the changes in metadata endpoint for ECS Container Agent https://github.com/aws/amazon-cloudwatch-agent/blob/main/translator/util/ecsutil/ecsutil.go#L67-L75
Implementation:
1) Check if the LogGroupFormat correctly scrapes the clusterName from metadata endpoint (https://github.com/aws/amazon-cloudwatch-agent/blob/5ef3dba446cb56a4c2306878592b5d14300ae82f/translator/translate/otel/exporter/awsemf/prometheus.go#L38)
2) Check if expected Prometheus EMF data is correctly published as logs and metrics to CloudWatch
*/
var (
ecsTestRunners []*test_runner.ECSTestRunner
)
func getEcsTestRunners(env *environment.MetaData) []*test_runner.ECSTestRunner {
if len(ecsTestRunners) == 0 {
ecsTestRunners = []*test_runner.ECSTestRunner{
{
Runner: &ECSServiceDiscoveryTestRunner{},
RunStrategy: &test_runner.ECSAgentRunStrategy{},
Env: *env,
},
}
}
return ecsTestRunners
}
var _ test_runner.ITestRunner = (*ECSServiceDiscoveryTestRunner)(nil)
func init() {
environment.RegisterEnvironmentMetaDataFlags()
}
func TestECSServiceDiscoveryTestSuite(t *testing.T) {
suite.Run(t, new(ECSServiceDiscoveryTestSuite))
}
type ECSServiceDiscoveryTestSuite struct {
suite.Suite
test_runner.TestSuite
}
func (suite *ECSServiceDiscoveryTestSuite) GetSuiteName() string {
return "ECSServiceDiscovery"
}
func (suite *ECSServiceDiscoveryTestSuite) TestAllInSuite() {
env := environment.GetEnvironmentMetaData()
for _, ecsTestRunner := range getEcsTestRunners(env) {
ecsTestRunner.Run(suite, env)
}
suite.Assert().Equal(status.SUCCESSFUL, suite.Result.GetStatus(), "ECS ServiceDiscovery Test Suite Failed")
}