-
Notifications
You must be signed in to change notification settings - Fork 15
[SVLS-8054] add integration testing #946
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
Open
jchrostek-dd
wants to merge
7
commits into
main
Choose a base branch
from
john/integration-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5ad68e5
[SVLS-8054] add integration testing
jchrostek-dd a85263a
add java and python
jchrostek-dd 5eaffd1
remove java
jchrostek-dd db5d0ac
clean up tests
jchrostek-dd 5bc76bc
misc
jchrostek-dd 14d281c
clean up code
jchrostek-dd 4283e48
cleanup
jchrostek-dd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /bottlecap/target/ | ||
| bottlecap/target/ | ||
| integration-tests/ |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
| # CDK | ||
| *.js | ||
| !jest.config.js | ||
| !lambda/**/*.js | ||
| *.d.ts | ||
| node_modules | ||
| cdk.out | ||
| .cdk.staging | ||
|
|
||
| # Compiled output | ||
| dist/ | ||
| *.tsbuildinfo | ||
|
|
||
| # Logs | ||
| *.log | ||
| npm-debug.log* | ||
|
|
||
| # Testing | ||
| coverage/ | ||
| .nyc_output/ | ||
| test-results/ | ||
|
|
||
| # Environment | ||
| .env | ||
| .env.local | ||
|
|
||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Lambda artifacts | ||
| response.json | ||
| lambda-bundle.zip |
This file contains hidden or 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,70 @@ | ||
| # Datadog Lambda Extension Integration Tests | ||
|
|
||
| This directory contains integration tests for the Datadog Lambda Extension. | ||
|
|
||
| The general flow is: | ||
| 1. Deploy test setup using CDK. | ||
| 2. Invoke lambda functions. | ||
| 3. Wait for data to propagate to Datadog. | ||
| 4. Call Datadog to get telemetry data and check the data based on test requirements. | ||
|
|
||
| For simplicity, integraiton tests are setup to only test against ARM runtimes. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'd think that if this is intended to test the extension, then making sure that it is built correctly for arm vs. amd runtimes becomes important. or have we never seen architecture-dependent differences in our extension builds? |
||
|
|
||
| ## Guidelines | ||
|
|
||
| ### Naming | ||
| * An `identifier` is used to differentiate the different stacks. For local development, the identifier is automatically set using the command `whoami` and parses the user's first name. For gitlab pipelines, the identifier is the git commit short sha. | ||
| * Stacks should be named `integ-<identifier>-<stack name>` | ||
| * Lambda functions should be named `<stack-id>-<function name>` | ||
|
|
||
| ### Stacks | ||
| * Stacks automatically get destroyed at the end of the gitlab integration tests step. Stack should be setup to not retain resources. A helper function `createLogGroup` exists with `removalPolicy: cdk.RemovalPolicy.DESTROY`. | ||
|
|
||
|
|
||
| ## Local Development | ||
|
|
||
| ### Prerequisites Set env variables | ||
| **Datadog API Keys**: Set environment variables | ||
| ```bash | ||
| export DD_API_KEY="your-datadog-api-key" | ||
| export DD_APP_KEY="your-datadog-app-key" | ||
| export DATADOG_API_SECRET_ARN="arn:aws:secretsmanager:us-east-1:ACCOUNT_ID:secret:YOUR_SECRET" | ||
| ``` | ||
|
|
||
| ### 1. Build and Deploy Extension Layer | ||
|
|
||
| First, publish your extension layer. | ||
|
|
||
| ```bash | ||
| ./scripts/local_publish.sh | ||
| ``` | ||
|
|
||
| This will create and publish `Datadog-Extension-ARM-<your name>`. | ||
|
|
||
| ### 2. Deploy Test Stacks | ||
|
|
||
| Deploy the CDK stacks that create Lambda functions for testing. | ||
|
|
||
| ```bash | ||
| ./scripts/local_deploy.sh <stack name> | ||
| ``` | ||
|
|
||
| This will create `integ-<your name>-<stack name>`. The stacks will use the lambda extension created in the previous step. | ||
|
|
||
| ### 3. Run Integration Tests | ||
|
|
||
| Run Jest tests that invoke Lambda functions and verify Datadog telemetry: | ||
|
|
||
| ```bash | ||
| # All tests | ||
| npm test | ||
|
|
||
| # Single test | ||
| npm test -- <my test file> | ||
| ``` | ||
|
|
||
|
|
||
|
|
||
| **Note**: Tests wait for a few minutes after Lambda invocation to allow telemetry to appear in Datadog. | ||
|
|
||
|
|
||
This file contains hidden or 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,25 @@ | ||
| #!/usr/bin/env node | ||
| import 'source-map-support/register'; | ||
| import * as cdk from 'aws-cdk-lib'; | ||
| import { BaseNodeStack } from '../lib/stacks/base-node-stack'; | ||
| import { BasePythonStack } from '../lib/stacks/base-python-stack'; | ||
| import { getIdentifier } from '../tests/utils/config'; | ||
|
|
||
| const app = new cdk.App(); | ||
|
|
||
| const env = { | ||
| account: process.env.CDK_DEFAULT_ACCOUNT || process.env.AWS_ACCOUNT_ID, | ||
| region: process.env.CDK_DEFAULT_REGION || process.env.AWS_REGION || 'us-east-1', | ||
| }; | ||
|
|
||
| const identifier = getIdentifier(); | ||
|
|
||
| new BaseNodeStack(app, `integ-${identifier}-base-node`, { | ||
| env, | ||
| }); | ||
|
|
||
| new BasePythonStack(app, `integ-${identifier}-base-python`, { | ||
| env, | ||
| }); | ||
|
|
||
| app.synth(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
might be worth adding some notes here about the sorts of tests we should be including in this suite (vs the e2e test suite.)