-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/apps: Refactor and add memory-leak app (#2420)
- Loading branch information
Showing
18 changed files
with
1,122 additions
and
370 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SHELL:=/usr/bin/env bash | ||
|
||
.PHONY: all | ||
all: test-apps.yml | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf test-apps.yml | ||
|
||
test-apps.yml: test-apps.cue | ||
cat <(echo "# Code generated via \`make test-apps.yml\`; DO NOT EDIT.") <(cue export --out=yaml $<) > $@ |
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,22 @@ | ||
# See /internal/apps/README.md for more information. | ||
name: "Test Apps Schedule" | ||
on: | ||
workflow_dispatch: # manually (just for testing the cron) | ||
schedule: | ||
- cron: "0 0 * * *" # nightly | ||
- cron: "0 0 * * 2" # weekly (tuesdays) | ||
|
||
jobs: | ||
nightly: | ||
if: github.event.schedule == '0 0 * * *' | ||
uses: ./.github/workflows/test-apps.yml | ||
secrets: inherit | ||
with: | ||
"arg: scenario_duration": "10m" | ||
|
||
weekly: | ||
if: github.event.schedule == '0 0 * * 2' | ||
uses: ./.github/workflows/test-apps.yml | ||
secrets: inherit | ||
with: | ||
"arg: scenario_duration": "1h" |
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,159 @@ | ||
// See /internal/apps/README.md for more information. | ||
|
||
#scenarios: [ | ||
{ | ||
name: "unit-of-work/v1", | ||
}, | ||
{ | ||
name: "unit-of-work/v2", | ||
}, | ||
{ | ||
name: "memory-leak/goroutine", | ||
}, | ||
{ | ||
name: "memory-leak/heap", | ||
}, | ||
{ | ||
name: "memory-leak/goroutine-heap" | ||
}, | ||
] | ||
|
||
#args: { | ||
rps: { | ||
env: "DD_TEST_APPS_REQUESTS_PER_SECOND", | ||
type: "number", | ||
description: "Requests per second", | ||
default: 5, | ||
pr_default: default, | ||
}, | ||
scenario_duration: { | ||
env: "DD_TEST_APPS_TOTAL_DURATION", | ||
type: "number", | ||
description: "Scenario duration", | ||
default: "10m", | ||
pr_default: "60s", | ||
}, | ||
profile_period: { | ||
env: "DD_TEST_APPS_PROFILE_PERIOD", | ||
type: "number", | ||
description: "Profile period", | ||
default: "60s", | ||
pr_default: "10s", | ||
}, | ||
} | ||
|
||
#envs: [ | ||
{ | ||
name: "prod", | ||
site: "datadoghq.com", | ||
key: "DD_TEST_APP_API_KEY", | ||
}, | ||
{ | ||
name: "staging", | ||
site: "datad0g.com", | ||
key: "DD_TEST_AND_DEMO_API_KEY", | ||
}, | ||
] | ||
|
||
#inputs: { | ||
inputs: { | ||
[string]: _, | ||
|
||
for env in #envs { | ||
"env: \(env.name)": { | ||
type: "boolean", | ||
default: true, | ||
}, | ||
} | ||
|
||
for name, arg in #args { | ||
"arg: \(name)": { | ||
type: arg.type, | ||
default: arg.default, | ||
description: arg.description, | ||
}, | ||
} | ||
|
||
for scenario in #scenarios { | ||
"scenario: \(scenario.name)": { | ||
type: "boolean", | ||
default: true | false, | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
name: "Test Apps" | ||
on: { | ||
// used by nightly cron schedule triggers | ||
workflow_call: #inputs & { | ||
inputs: { | ||
[=~ "scenario:"]: {default: true}, | ||
ref: { | ||
description: "The branch to run the workflow on", | ||
required: true, | ||
type: "string", | ||
}, | ||
} | ||
}, | ||
|
||
// used for manual triggering | ||
workflow_dispatch: #inputs & { | ||
inputs: {[=~ "scenario:"]: {default: false}} | ||
} | ||
} | ||
|
||
env: { | ||
DD_ENV: "github", | ||
DD_TAGS: "github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }}", | ||
} | ||
|
||
jobs: { | ||
for i, scenario in #scenarios { | ||
for j, env in #envs { | ||
"job-\(i)-\(j)": { | ||
name: "\(scenario.name) (\(env.name))", | ||
"runs-on": "ubuntu-latest", | ||
|
||
#if_scenario: "inputs['scenario: \(scenario.name)']", | ||
#if_env: "inputs['env: \(env.name)']", | ||
|
||
if: "\(#if_scenario) && \(#if_env)" | ||
steps: [ | ||
{ | ||
name: "Checkout Code", | ||
uses: "actions/checkout@v3", | ||
with: {ref: "${{ inputs.ref || github.ref }}"}, | ||
}, | ||
{ | ||
name: "Start Agent", | ||
uses: "datadog/[email protected]", | ||
with: { | ||
api_key: "${{ secrets['\(env.key)'] }}", | ||
datadog_site: "\(env.site)", | ||
}, | ||
}, | ||
{ | ||
name: "Setup Go" | ||
uses: "actions/setup-go@v3", | ||
with: { | ||
"go-version": "stable", | ||
"check-latest": true, | ||
cache: true, | ||
}, | ||
}, | ||
{ | ||
name: "Run Scenario" | ||
env: { | ||
for name, arg in #args { | ||
"\(arg.env)": "${{ inputs['arg: \(name)'] || '\(arg.pr_default)' }}", | ||
} | ||
}, | ||
run: "cd ./internal/apps && ./run-scenario.bash '\(scenario.name)'" | ||
}, | ||
] | ||
} | ||
}, | ||
}, | ||
} |
Oops, something went wrong.