- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
test: add datadog monitor tests #60
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
base: main
Are you sure you want to change the base?
Conversation
Introduce a new Go-based integration test suite for the Datadog monitor component using cloudposse/test-helpers. Add all necessary fixtures, stack configs, and vendored dependencies to support local and CI testing. Remove placeholder files and scripts no longer needed.
          
WalkthroughIntroduces a test harness and fixtures for Atmos/Terraform: Git ignore updates, Atmos config and vendor manifest, test fixture stacks for Datadog and account-map, a Go-based component test suite using SSM/Terratest, and supporting module/dependency declarations. Changes
 Sequence Diagram(s)sequenceDiagram
    autonumber
    participant Runner as Test Runner
    participant Env as Env (CI / Local)
    participant SSM as AWS SSM
    participant Atmos as Atmos
    participant TF as Terraform
    participant Terratest as Terratest
    Runner->>Env: SetupSuite (load atmos.yaml, fixtures)
    Runner->>Env: validate DATADOG_API_KEY, DATADOG_APP_KEY
    Runner->>SSM: PutParameter(API_KEY), PutParameter(APP_KEY)
    Runner->>Atmos: Deploy component datadog-monitor/basic
    Atmos->>TF: terraform init/apply
    TF-->>Atmos: apply result
    Atmos-->>Runner: deployment complete
    Runner->>Terratest: run drift checks / assertions
    Terratest-->>Runner: test results
    alt cleanup
        Runner->>SSM: DeleteParameter(API_KEY), DeleteParameter(APP_KEY)
    end
    Runner->>Runner: TearDownSuite
    Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Suggested labels
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
 🚧 Files skipped from review as they are similar to previous changes (1)
 ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment   | 
    
| 
           Important Do not edit the  Please update the  Could you fix it @RoseSecurity? 🙏  | 
    
- Add handling for Datadog App key in test suite, storing it in SSM alongside the API key to avoid conflicts in parallel tests. - Refactor struct field names for consistency and clarity. - Update SSM parameter paths and cleanup logic for both API and App keys. - Fix stack fixture metadata and monitor config path globbing for improved test reliability.
| 
           /terratest  | 
    
    
      
        1 similar comment
      
    
  
    | 
           /terratest  | 
    
Comment out Datadog API and App key storage in tests.
| 
           /terratest  | 
    
| 
           /terratest  | 
    
| 
           /terratest  | 
    
    
      
        2 similar comments
      
    
  
    | 
           /terratest  | 
    
| 
           /terratest  | 
    
| 
           /terratest  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (3)
test/fixtures/vendor.yaml (1)
14-16: Simplify path patterns for clarity.The
included_paths: ["**/**"]pattern is redundant (use["**"]or omit), andexcluded_paths: []can be removed entirely when empty.targets: - "components/terraform/account-map" - included_paths: - - "**/**" - excluded_paths: []Apply the same simplification to lines 23-25.
Also applies to: 23-25
test/component_test.go (2)
28-30: Clarify intent behind redundant variable declarations.Both test methods redeclare
awsRegionand generate a newrandomID, even thoughs.awsRegionands.randomIDare available fromSetupSuite. If this is for test isolation (unique SSM paths per test), consider documenting that intent. Otherwise, use the suite-level fields consistently.Also applies to: 55-57
41-42: Uses.awsRegionconsistently.Lines 41-42 and 68-69 use the local
awsRegionconstant in cleanup defers, while lines 34, 38, 61, and 65 uses.awsRegion. Since both resolve to"us-east-2", this works but creates unnecessary inconsistency. Uses.awsRegionthroughout for clarity.defer func() { - awsTerratest.DeleteParameter(s.T(), awsRegion, apiKeyPath) - awsTerratest.DeleteParameter(s.T(), awsRegion, appKeyPath) + awsTerratest.DeleteParameter(s.T(), s.awsRegion, apiKeyPath) + awsTerratest.DeleteParameter(s.T(), s.awsRegion, appKeyPath) }()Also applies to: 68-69
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
test/go.sumis excluded by!**/*.sum
📒 Files selected for processing (13)
test/.gitignore(1 hunks)test/README.md(0 hunks)test/component_test.go(1 hunks)test/fixtures/atmos.yaml(1 hunks)test/fixtures/stacks/catalog/account-map.yaml(1 hunks)test/fixtures/stacks/catalog/datadog-configuration.yaml(1 hunks)test/fixtures/stacks/catalog/usecase/basic.yaml(1 hunks)test/fixtures/stacks/catalog/usecase/disabled.yaml(1 hunks)test/fixtures/stacks/orgs/default/test/_defaults.yaml(1 hunks)test/fixtures/stacks/orgs/default/test/tests.yaml(1 hunks)test/fixtures/vendor.yaml(1 hunks)test/go.mod(1 hunks)test/run.sh(0 hunks)
💤 Files with no reviewable changes (2)
- test/run.sh
 - test/README.md
 
🧰 Additional context used
📓 Path-based instructions (3)
test/fixtures/stacks/catalog/usecase/**
📄 CodeRabbit inference engine (AGENTS.md)
Add test scenarios under test/fixtures/stacks/catalog/usecase/
Files:
test/fixtures/stacks/catalog/usecase/basic.yamltest/fixtures/stacks/catalog/usecase/disabled.yaml
**/*.{yaml,yml,md}
📄 CodeRabbit inference engine (AGENTS.md)
Use 2-space indentation for YAML and Markdown files
Files:
test/fixtures/stacks/catalog/usecase/basic.yamltest/fixtures/stacks/catalog/usecase/disabled.yamltest/fixtures/stacks/catalog/datadog-configuration.yamltest/fixtures/stacks/catalog/account-map.yamltest/fixtures/stacks/orgs/default/test/_defaults.yamltest/fixtures/stacks/orgs/default/test/tests.yamltest/fixtures/vendor.yamltest/fixtures/atmos.yaml
test/**/*_test.go
📄 CodeRabbit inference engine (AGENTS.md)
test/**/*_test.go: Place Go Terratest files under test/ and name them *_test.go
Use Go Terratest with github.com/cloudposse/test-helpers and Atmos fixtures for integration tests
Files:
test/component_test.go
🪛 OSV Scanner (2.2.3)
test/go.mod
[HIGH] 1-1: golang.org/x/crypto 0.33.0: Potential denial of service in golang.org/x/crypto
(GO-2025-3487)
[HIGH] 1-1: golang.org/x/crypto 0.33.0: golang.org/x/crypto Vulnerable to Denial of Service (DoS) via Slow or Incomplete Key Exchange
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Summary
 
🔇 Additional comments (8)
test/fixtures/stacks/catalog/usecase/basic.yaml (1)
1-17: LGTM!Fixture is properly structured with 2-space YAML indentation and correctly places the Datadog monitor configuration in the
catalog/usecase/path per guidelines.test/fixtures/atmos.yaml (1)
1-77: LGTM!Comprehensive Atmos configuration with correct 2-space indentation throughout. The fixture appropriately enables test-friendly settings (auto-approve, auto-init, template engines) and follows standard stack discovery patterns.
test/fixtures/stacks/orgs/default/test/tests.yaml (1)
1-5: LGTM!Simple, well-structured import block with correct 2-space indentation. All referenced fixtures exist within the PR.
test/.gitignore (1)
1-5: LGTM!Standard test artifact ignores appropriate for Atmos/Terraform/Go test workflows.
test/fixtures/stacks/catalog/datadog-configuration.yaml (1)
1-11: LGTM!Datadog configuration fixture is properly structured with correct 2-space indentation. Configuration values (SSM store, site URL, region) are sensible test defaults.
test/fixtures/stacks/catalog/usecase/disabled.yaml (1)
1-16: LGTM!Disabled monitor variant is properly structured with correct 2-space indentation. Configuration is consistent with the basic variant, with the enabled flag correctly set to false for testing disabled-component scenarios.
test/fixtures/stacks/catalog/account-map.yaml (1)
1-46: LGTM!Account-map fixture is appropriately configured for test scenarios with 2-space indentation throughout. Static backend with empty account maps is well-documented as test-specific, and the notes about potential data gaps for certain components are helpful for future maintenance.
test/fixtures/stacks/orgs/default/test/_defaults.yaml (1)
44-44: Clarify the contradictoryekssettings.Line 44 sets
eks: truefor the account, but line 50 setstags.eks: false. This appears contradictory—verify whether this is intentional (e.g., account supports EKS but this test scenario doesn't use it).Also applies to: 50-50
| 
           /terratest  | 
    
| 
           I think these should be good for review @goruha  | 
    
what
test/component_test.gothat uses Cloud Posse'stest-helpersto deploy and test Atmos Terraform components, including tests for Datadog monitor components and enabled/disabled flags.go.modfile specifying dependencies for the test suite, includingtest-helpers,testify, and other indirect dependencies required for infrastructure testing.test/fixtures/atmos.yamlto define base paths, component and stack settings, logging, and template support for tests.test/fixtures/stacks/catalogandtest/fixtures/stacks/orgs/default/test.test/fixtures/vendor.yaml) to specify the sources and versions of vendored Terraform components used in the tests..gitignoreto exclude test state, cache, and other generated files from version control.test/README.mdandtest/run.sh.These changes collectively establish a robust and reproducible testing framework for Terraform components using Atmos and Cloud Posse conventions.
why
references
Summary by CodeRabbit
Tests
Chores