-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix DetectAgentMode so auto resolves to onPrem if not ec2. (#652) * Add branch feature for ec2 test (#647) * Add branch feature for ec2 test * Add branch feature for everything * Update RELEASE_NOTES for 1.247356 (#649) Co-authored-by: Jeffrey Chien <[email protected]> Co-authored-by: Chena Lee <[email protected]> Co-authored-by: Adam <[email protected]> Co-authored-by: Kaushik Surya <[email protected]>
- Loading branch information
1 parent
47d76c1
commit f7ea3f0
Showing
4 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package util | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent/translator/config" | ||
) | ||
|
||
func TestDetectAgentModeAuto(t *testing.T) { | ||
testCases := map[string]struct { | ||
runInAws string | ||
ec2Region string | ||
ecsRegion string | ||
wantMode string | ||
}{ | ||
"WithRunInAWS": {runInAws: config.RUN_IN_AWS_TRUE, wantMode: config.ModeEC2}, | ||
"WithEC2Region": {ec2Region: "us-east-1", wantMode: config.ModeEC2}, | ||
"WithECSRegion": {ecsRegion: "us-east-1", wantMode: config.ModeEC2}, | ||
"WithNone": {wantMode: config.ModeOnPrem}, | ||
} | ||
for name, testCase := range testCases { | ||
t.Run(name, func(t *testing.T) { | ||
runInAws = testCase.runInAws | ||
DefaultEC2Region = func() string { return testCase.ec2Region } | ||
DefaultECSRegion = func() string { return testCase.ecsRegion } | ||
require.Equal(t, testCase.wantMode, DetectAgentMode("auto")) | ||
}) | ||
} | ||
} |