Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add win user data test #377

Merged
merged 2 commits into from
Nov 13, 2023
Merged

Add win user data test #377

merged 2 commits into from
Nov 13, 2023

Conversation

sethAmazon
Copy link
Contributor

Description of the issue

We do not have a windows user data test.

Description of changes

Add a windows userdata test

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Ran integration tests
https://github.com/aws/amazon-cloudwatch-agent/actions/runs/6801520646/job/18568980590

@sethAmazon sethAmazon requested a review from a team as a code owner November 10, 2023 16:38
@@ -122,6 +122,10 @@ var testTypeToTestConfig = map[string][]testConfig{
{testDir: "../../../test/restart"},
{testDir: "../../../test/acceptance"},
{testDir: "../../../test/feature/windows/event_logs"},
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to run this on all platforms.
The latest "win-2022" has both a test for ssm and non ssm.
Meaning this will be tested the same 2 times.
This test will only use ssm since it makes the ps1 command simpler.

}

# Size of windows json is too large thus can't use standard tier
resource "aws_ssm_parameter" "upload_ssm" {
count = var.use_ssm == true && length(regexall("/feature/windows", var.test_dir)) > 0 ? 1 : 0
count = length(regexall("/feature/windows", var.test_dir)) > 0 ? 1 : 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can upload the value to ssm for all feature tests since it will be deleted by terraform destroy anyway. This will allow us to use ssm for userdata test.

template = file("install_and_start_agent.tpl")

vars = {
copy_object = "Copy-S3Object -BucketName ${var.s3_bucket} -Key integration-test/packaging/${var.cwa_github_sha}/amazon-cloudwatch-agent.msi -region ${var.region} -LocalFile $cwAgentInstaller"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason var replacement was not working for the internal vars of this command and started working when I added the entire command as the var.

},
"force_flush_interval": 30
},
"logs": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not testing logs the validator will fail if there is no logs config.

# Metric that the test needs to validate; moreover, the stress validation already has
# InstanceID dimension; therefore, does not need to validate it
# https://github.com/aws/amazon-cloudwatch-agent-test/pull/109/files#diff-47c87373e751dd9fd5ce504e44b320765c8b84d6cde524a4e8a32cfa34674165R124-R135
metric_namespace: "CloudWatchAgentWinFeature"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only test metrics since this is more of a sanity test that we can install and start the agent via userdata thus no need to test logs.

@@ -17,4 +17,4 @@ func main() {
binary.BigEndian.PutUint32(r[0:4], uint32(epochNow))
rand.Read(r[4:])
fmt.Printf("%s", hex.EncodeToString(r[:]))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This come from running make fmt

@@ -47,6 +47,7 @@ install-golang-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN_DIR) v1.50.1

fmt: install-goimports addlicense
terraform fmt -recursive
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to have to run this command in terminal when I get terraform fmt error. I should be able to run it via make.

null_resource.integration_test_wait,
]

connection {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are using EC2 "userdata" to launch the instance and install the agent, then do we still need winrm access to the instance?

In other words, after launching a Windows EC2 instance with the agent installed with user-data, what additional steps occur?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs the validator, it does not reinstall / restart the agent. The validator runs on the ec2 instance.

adam-mateen
adam-mateen previously approved these changes Nov 10, 2023
@sethAmazon sethAmazon merged commit d06c821 into aws:main Nov 13, 2023
2 checks passed
@sethAmazon sethAmazon deleted the win-userdata branch November 13, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants