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

internal/apps: better tagging #2425

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test-apps-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
secrets: inherit
with:
"arg: scenario_duration": "10m"
"arg: tags": "trigger:nightly"

weekly:
if: github.event.schedule == '0 0 * * 2'
uses: ./.github/workflows/test-apps.yml
secrets: inherit
with:
"arg: scenario_duration": "1h"
"arg: scenario_duration": "1h"
"arg: tags": "trigger:weekly"
35 changes: 21 additions & 14 deletions .github/workflows/test-apps.cue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// See /internal/apps/README.md for more information.
import "encoding/json"

#scenarios: [
{
Expand All @@ -24,21 +25,24 @@
type: "number",
description: "Requests per second",
default: 5,
pr_default: default,
},
scenario_duration: {
env: "DD_TEST_APPS_TOTAL_DURATION",
type: "string",
description: "Scenario duration",
default: "10m",
pr_default: "60s",
},
profile_period: {
env: "DD_TEST_APPS_PROFILE_PERIOD",
type: "string",
description: "Profile period",
default: "60s",
pr_default: "10s",
},
tags: {
env: false,
type: "string",
description: "Extra DD_TAGS",
default: "trigger:manual",
},
}

Expand Down Expand Up @@ -74,13 +78,15 @@
},
}

for scenario in #scenarios {
"scenario: \(scenario.name)": {
type: "boolean",
default: true | false,
}
}

scenarios: {
type: "string",
default: json.Marshal([
for scenario in #scenarios {
scenario.name
}
]),
description: "Scenarios to run"
},
}
}

Expand All @@ -106,7 +112,7 @@ on: {

env: {
DD_ENV: "github",
DD_TAGS: "github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }}",
DD_TAGS: "github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} ${{ inputs['arg: tags'] }}",
}

jobs: {
Expand All @@ -116,7 +122,7 @@ jobs: {
name: "\(scenario.name) (\(env.name))",
"runs-on": "ubuntu-latest",

#if_scenario: "inputs['scenario: \(scenario.name)']",
#if_scenario: "contains(fromJSON(inputs['scenarios']), '\(scenario.name)')",
#if_env: "inputs['env: \(env.name)']",

if: "\(#if_scenario) && \(#if_env)"
Expand Down Expand Up @@ -146,8 +152,9 @@ jobs: {
{
name: "Run Scenario"
env: {
for name, arg in #args {
"\(arg.env)": "${{ inputs['arg: \(name)'] || '\(arg.pr_default)' }}",
// args.env is (string|false), so we use null coalescing to type cast to string
for name, arg in #args if (*(arg.env&string) | "") != "" {
"\(arg.env)": "${{ inputs['arg: \(name)'] }}",
}
},
run: "cd ./internal/apps && ./run-scenario.bash '\(scenario.name)'"
Expand Down
128 changes: 57 additions & 71 deletions .github/workflows/test-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Test Apps
"on":
workflow_call:
inputs:
scenarios:
type: string
default: '["unit-of-work/v1","unit-of-work/v2","memory-leak/goroutine","memory-leak/heap","memory-leak/goroutine-heap"]'
description: Scenarios to run
ref:
description: The branch to run the workflow on
required: false
Expand All @@ -25,23 +29,16 @@ name: Test Apps
type: string
default: 60s
description: Profile period
'scenario: unit-of-work/v1':
type: boolean
default: true
'scenario: unit-of-work/v2':
type: boolean
default: true
'scenario: memory-leak/goroutine':
type: boolean
default: true
'scenario: memory-leak/heap':
type: boolean
default: true
'scenario: memory-leak/goroutine-heap':
type: boolean
default: true
'arg: tags':
type: string
default: trigger:manual
description: Extra DD_TAGS
workflow_dispatch:
inputs:
scenarios:
type: string
default: '["unit-of-work/v1","unit-of-work/v2","memory-leak/goroutine","memory-leak/heap","memory-leak/goroutine-heap"]'
description: Scenarios to run
'env: prod':
type: boolean
default: true
Expand All @@ -60,29 +57,18 @@ name: Test Apps
type: string
default: 60s
description: Profile period
'scenario: unit-of-work/v1':
type: boolean
default: false
'scenario: unit-of-work/v2':
type: boolean
default: false
'scenario: memory-leak/goroutine':
type: boolean
default: false
'scenario: memory-leak/heap':
type: boolean
default: false
'scenario: memory-leak/goroutine-heap':
type: boolean
default: false
'arg: tags':
type: string
default: trigger:manual
description: Extra DD_TAGS
env:
DD_ENV: github
DD_TAGS: github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }}
DD_TAGS: 'github_run_id:${{ github.run_id }} github_run_number:${{ github.run_number }} ${{ inputs[''arg: tags''] }}'
jobs:
job-0-0:
name: unit-of-work/v1 (prod)
runs-on: ubuntu-latest
if: 'inputs[''scenario: unit-of-work/v1''] && inputs[''env: prod'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v1'') && inputs[''env: prod'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -101,14 +87,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v1'
job-0-1:
name: unit-of-work/v1 (staging)
runs-on: ubuntu-latest
if: 'inputs[''scenario: unit-of-work/v1''] && inputs[''env: staging'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v1'') && inputs[''env: staging'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -127,14 +113,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v1'
job-1-0:
name: unit-of-work/v2 (prod)
runs-on: ubuntu-latest
if: 'inputs[''scenario: unit-of-work/v2''] && inputs[''env: prod'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v2'') && inputs[''env: prod'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -153,14 +139,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v2'
job-1-1:
name: unit-of-work/v2 (staging)
runs-on: ubuntu-latest
if: 'inputs[''scenario: unit-of-work/v2''] && inputs[''env: staging'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''unit-of-work/v2'') && inputs[''env: staging'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -179,14 +165,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'unit-of-work/v2'
job-2-0:
name: memory-leak/goroutine (prod)
runs-on: ubuntu-latest
if: 'inputs[''scenario: memory-leak/goroutine''] && inputs[''env: prod'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine'') && inputs[''env: prod'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -205,14 +191,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine'
job-2-1:
name: memory-leak/goroutine (staging)
runs-on: ubuntu-latest
if: 'inputs[''scenario: memory-leak/goroutine''] && inputs[''env: staging'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine'') && inputs[''env: staging'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -231,14 +217,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine'
job-3-0:
name: memory-leak/heap (prod)
runs-on: ubuntu-latest
if: 'inputs[''scenario: memory-leak/heap''] && inputs[''env: prod'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/heap'') && inputs[''env: prod'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -257,14 +243,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/heap'
job-3-1:
name: memory-leak/heap (staging)
runs-on: ubuntu-latest
if: 'inputs[''scenario: memory-leak/heap''] && inputs[''env: staging'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/heap'') && inputs[''env: staging'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -283,14 +269,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/heap'
job-4-0:
name: memory-leak/goroutine-heap (prod)
runs-on: ubuntu-latest
if: 'inputs[''scenario: memory-leak/goroutine-heap''] && inputs[''env: prod'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine-heap'') && inputs[''env: prod'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -309,14 +295,14 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine-heap'
job-4-1:
name: memory-leak/goroutine-heap (staging)
runs-on: ubuntu-latest
if: 'inputs[''scenario: memory-leak/goroutine-heap''] && inputs[''env: staging'']'
if: 'contains(fromJSON(inputs[''scenarios'']), ''memory-leak/goroutine-heap'') && inputs[''env: staging'']'
steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand All @@ -335,7 +321,7 @@ jobs:
cache: true
- name: Run Scenario
env:
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] || ''5'' }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] || ''60s'' }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] || ''10s'' }}'
DD_TEST_APPS_REQUESTS_PER_SECOND: '${{ inputs[''arg: rps''] }}'
DD_TEST_APPS_TOTAL_DURATION: '${{ inputs[''arg: scenario_duration''] }}'
DD_TEST_APPS_PROFILE_PERIOD: '${{ inputs[''arg: profile_period''] }}'
run: cd ./internal/apps && ./run-scenario.bash 'memory-leak/goroutine-heap'
Loading