Skip to content

Commit

Permalink
internal/apps: Refactor and add memory-leak app (#2420)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge authored Dec 11, 2023
1 parent 30e1406 commit e29428a
Show file tree
Hide file tree
Showing 18 changed files with 1,122 additions and 370 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/Makefile
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 $<) > $@
22 changes: 22 additions & 0 deletions .github/workflows/test-apps-schedule.yml
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"
159 changes: 159 additions & 0 deletions .github/workflows/test-apps.cue
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)'"
},
]
}
},
},
}
Loading

0 comments on commit e29428a

Please sign in to comment.