-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added windows event log integration tests * added base test * extra logs * added dim value * testing with just cluster * test * test map * test metricData * stat period change * test metric sample count * test metric sample count * test metric sample count * changed the node scaling config to 2 * changed the node scaling config to 2 --------- Co-authored-by: Pooja Reddy Nathala <[email protected]>
- Loading branch information
1 parent
1b02a53
commit 3dce60e
Showing
9 changed files
with
262 additions
and
62 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
34 changes: 34 additions & 0 deletions
34
test/cloudwatchlogs/resources/config_windows_event_log.json
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,34 @@ | ||
{ | ||
"logs": { | ||
"logs_collected": { | ||
"files": { | ||
"collect_list": [ | ||
{ | ||
"file_path": "C:\\Users\\Administrator\\Desktop\\CWMetricsLogs", | ||
"log_group_name": "CWMetricsLogs", | ||
"log_stream_name": "{instance_id}", | ||
"retention_in_days": -1 | ||
} | ||
] | ||
}, | ||
"windows_events": { | ||
"collect_list": [ | ||
{ | ||
"event_format": "xml", | ||
"event_levels": [ | ||
"VERBOSE", | ||
"INFORMATION", | ||
"WARNING", | ||
"ERROR", | ||
"CRITICAL" | ||
], | ||
"event_name": "System", | ||
"log_group_name": "CloudWatchAgent", | ||
"log_stream_name": "{instance_id}", | ||
"retention_in_days": -1 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
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,65 @@ | ||
//go:build windows | ||
|
||
package cloudwatchlogs | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent-test/internal/awsservice" | ||
"github.com/aws/amazon-cloudwatch-agent-test/internal/common" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestWindowsEventLog(t *testing.T) { | ||
cfgFilePath := "resources/config_windows_event_log.json" | ||
|
||
instanceId := awsservice.GetInstanceId() | ||
log.Printf("Found instance id %s", instanceId) | ||
logGroup := "CloudWatchAgent" | ||
logStream := instanceId | ||
|
||
start := time.Now() | ||
common.CopyFile(cfgFilePath, configOutputPath) | ||
|
||
common.StartAgent(configOutputPath, true) | ||
|
||
// ensure that there is enough time from the "start" time and the first log line, | ||
// so we don't miss it in the GetLogEvents call | ||
time.Sleep(agentRuntime) | ||
t.Log("Writing logs from windows event log plugin") | ||
time.Sleep(agentRuntime) | ||
common.StopAgent() | ||
|
||
lines := []string{ | ||
fmt.Sprintf("{\"Metric\": \"%s\"}", strings.Repeat("12345", 10)), | ||
fmt.Sprintf("{\"Metric\": \"%s\"}", strings.Repeat("09876", 10)), | ||
fmt.Sprintf("{\"Metric\": \"%s\"}", strings.Repeat("1234567890", 10)), | ||
} | ||
|
||
end := time.Now() | ||
|
||
ok, err := awsservice.ValidateLogs(logGroup, logStream, &start, &end, func(logs []string) bool { | ||
log.Printf("logs length: %s ", len(logs)) | ||
if len(logs) != len(lines) { | ||
return false | ||
} | ||
|
||
for i := 0; i < len(logs); i++ { | ||
log.Printf("lines[%s] is %s", i, lines[i]) | ||
log.Printf("logs[%s] is %s", i, logs[i]) | ||
expected := strings.ReplaceAll(lines[i], "'", "\"") | ||
actual := strings.ReplaceAll(logs[i], "'", "\"") | ||
if expected != actual { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
}) | ||
assert.NoError(t, err) | ||
assert.True(t, ok) | ||
} |
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
Oops, something went wrong.