-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathaction.yml
More file actions
188 lines (176 loc) · 8.04 KB
/
action.yml
File metadata and controls
188 lines (176 loc) · 8.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Run Performance Test
description: >
Downloads the New Relic .NET agent (when requested) and runs the performance
test suite via run-perf-test.py, then uploads the results and log artifacts.
inputs:
run-label:
description: 'Short label for this run, used as the artifact name suffix (e.g. "no-agent", "latest-release")'
required: true
attach-agent:
description: 'Attach the New Relic .NET agent to the test app'
default: 'false'
agent-source:
description: 'Source of the agent binaries: github_release or build_artifact (only used when attach-agent is true)'
default: 'github_release'
agent-version:
description: 'Agent version to use, e.g. "10.49.0". Leave empty for latest. Only used with agent-source: github_release.'
default: ''
build-run-id:
description: 'Run ID of the all_solutions.yml workflow to pull agent homefolders from. Only used with agent-source: build_artifact.'
default: ''
test-duration:
description: 'How long to drive traffic (Locust --run-time format, e.g. "2m", "5m", "30s")'
default: '2m'
locust-users:
description: 'Number of concurrent Locust users'
default: '10'
locust-spawn-rate:
description: 'Locust users to spawn per second'
default: '2'
dotnet-version:
description: '.NET version for the test app container (e.g. "10.0", "8.0")'
default: '10.0'
license-key:
description: 'New Relic license key (only used when attach-agent is true)'
default: ''
collector-host:
description: 'New Relic collector host (only used when attach-agent is true)'
default: ''
agent-env:
description: 'Extra environment variables for the test app/agent, semicolon-separated NAME=VALUE pairs (e.g. VAR1=val1;VAR2=val2)'
default: ''
github-token:
description: 'GitHub token for downloading artifacts'
required: true
agent-app-name:
description: 'New Relic application name to use in the test (only used when attach-agent is true)'
default: 'dotnet-agent-perf-test'
runs:
using: composite
steps:
- name: Create agent-home directory
shell: bash
run: mkdir -p "${{ github.workspace }}/${{ env.PERF_TEST_DIR }}/agent-home"
# -------------------------------------------------------------------------
# Agent download — github_release path
# -------------------------------------------------------------------------
- name: Get agent release run ID
if: inputs.attach-agent == 'true' && inputs.agent-source == 'github_release'
id: get-release-run-id
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
run: |
VERSION="${{ inputs.agent-version }}"
if [ -z "$VERSION" ]; then
echo "Looking up latest release commit SHA..."
COMMIT_SHA=$(git rev-list -n 1 "$(gh release list --limit 1 | awk '{ print $1 }')")
else
echo "Looking up release v${VERSION} commit SHA..."
COMMIT_SHA=$(git rev-list -n 1 "v${VERSION}")
fi
if [ -z "$COMMIT_SHA" ]; then
echo "ERROR: Could not find commit SHA for release"
exit 1
fi
echo "Found commit SHA: $COMMIT_SHA"
WORKFLOW_RUN_ID=$(gh run list --commit "$COMMIT_SHA" --workflow all_solutions.yml --event release --status success --limit 1 --json databaseId --jq '.[0].databaseId')
if [ -z "$WORKFLOW_RUN_ID" ]; then
echo "ERROR: Could not find a successful all_solutions.yml run for commit $COMMIT_SHA"
exit 1
fi
echo "Found workflow run ID: $WORKFLOW_RUN_ID"
echo "run_id=$WORKFLOW_RUN_ID" >> "$GITHUB_OUTPUT"
- name: Download agent homefolders from release build
if: inputs.attach-agent == 'true' && inputs.agent-source == 'github_release'
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
github-token: ${{ inputs.github-token }}
run-id: ${{ steps.get-release-run-id.outputs.run_id }}
name: homefolders
path: ${{ github.workspace }}/agent-download
repository: ${{ github.repository }}
- name: Locate agent home from release build
if: inputs.attach-agent == 'true' && inputs.agent-source == 'github_release'
shell: bash
run: |
AGENT_HOME="${{ github.workspace }}/${{ env.PERF_TEST_DIR }}/agent-home"
SOURCE=$(find "${{ github.workspace }}/agent-download" -name "newrelichome_x64_coreclr_linux" -type d | head -1)
if [ -z "$SOURCE" ]; then
echo "ERROR: Could not find newrelichome_x64_coreclr_linux in downloaded artifact"
find "${{ github.workspace }}/agent-download" -type d | head -20
exit 1
fi
echo "Copying agent from: $SOURCE"
cp -r "$SOURCE/." "$AGENT_HOME/"
echo "Agent home contents:"
ls "$AGENT_HOME"
# -------------------------------------------------------------------------
# Agent download — build_artifact path
# -------------------------------------------------------------------------
- name: Download agent from build artifact
if: inputs.attach-agent == 'true' && inputs.agent-source == 'build_artifact'
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
github-token: ${{ inputs.github-token }}
run-id: ${{ inputs.build-run-id }}
name: homefolders
path: ${{ github.workspace }}/agent-download
repository: ${{ github.repository }}
- name: Locate agent home from build artifact
if: inputs.attach-agent == 'true' && inputs.agent-source == 'build_artifact'
shell: bash
run: |
AGENT_HOME="${{ github.workspace }}/${{ env.PERF_TEST_DIR }}/agent-home"
SOURCE=$(find "${{ github.workspace }}/agent-download" -name "newrelichome_x64_coreclr_linux" -type d | head -1)
if [ -z "$SOURCE" ]; then
echo "ERROR: Could not find newrelichome_x64_coreclr_linux in downloaded artifact"
find "${{ github.workspace }}/agent-download" -type d | head -20
exit 1
fi
echo "Copying agent from: $SOURCE"
cp -r "$SOURCE/." "$AGENT_HOME/"
echo "Agent home contents:"
ls "$AGENT_HOME"
# -------------------------------------------------------------------------
# Run the performance test suite
# -------------------------------------------------------------------------
- name: Run performance tests
shell: bash
working-directory: ${{ env.PERF_TEST_DIR }}
run: |
EXTRA_ENV_ARGS=()
IFS=';' read -ra ENV_PAIRS <<< "${{ inputs.agent-env }}"
for pair in "${ENV_PAIRS[@]}"; do
[[ -z "$pair" ]] && continue
echo "Adding extra environment variable: $pair"
EXTRA_ENV_ARGS+=("--env" "$pair")
done
python3 run-perf-test.py \
--attach-agent "${{ inputs.attach-agent }}" \
--agent-home "${{ github.workspace }}/${{ env.PERF_TEST_DIR }}/agent-home" \
--app-name "${{ inputs.agent-app-name }}" \
--test-duration "${{ inputs.test-duration }}" \
--locust-users "${{ inputs.locust-users }}" \
--locust-spawn-rate "${{ inputs.locust-spawn-rate }}" \
--dotnet-version "${{ inputs.dotnet-version }}" \
--license-key "${{ inputs.license-key }}" \
--collector-host "${{ inputs.collector-host }}" \
"${EXTRA_ENV_ARGS[@]}"
# -------------------------------------------------------------------------
# Upload artifacts
# -------------------------------------------------------------------------
- name: Upload perf results
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: perf-results-${{ inputs.run-label }}
path: ${{ env.PERF_TEST_DIR }}/results/
if-no-files-found: warn
- name: Upload perf logs
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: perf-logs-${{ inputs.run-label }}
path: ${{ env.PERF_TEST_DIR }}/logs/
if-no-files-found: warn