Repository navigation
205 lines (178 loc) · 6.9 KB
/
Copy pathstress-test.yml
File metadata and controls
205 lines (178 loc) · 6.9 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# Stress test umbrella workflow.
#
# Each job is one stress scenario, filtered by NUnit Category. Add new
# scenarios by adding a sibling job below with the same seed-generation
# pattern and the same 'if' gate.
#
# Opt-in: nightly, manual, and pull requests labelled 'stress'. It is not a
# required check. Adding the label starts a run; every later push to the
# labelled pull request starts a new one and cancels the run in progress.
name: Stress Tests
on:
schedule:
# Run nightly at 3:00 AM UTC.
- cron: '0 3 * * *'
workflow_dispatch:
inputs:
seed:
description: 'Optional ChaosTCP seed. Leave empty to generate a random seed.'
required: false
default: ''
type: string
pull_request:
types: [labeled, synchronize, opened, reopened]
permissions:
contents: read
# A pull request run is superseded by the next push. A 'labeled' event for any
# other label gets a group of its own so it cannot cancel a run in progress.
concurrency:
group: ${{ github.workflow }}-${{ github.event.action == 'labeled' && github.event.label.name != 'stress' && github.run_id || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
contract-integration:
name: Contract and Integration
# Same gate as the Chaos TCP job below.
if: >-
github.event_name != 'pull_request' ||
(contains(github.event.pull_request.labels.*.name, 'stress') &&
(github.event.action != 'labeled' || github.event.label.name == 'stress'))
runs-on: ubuntu-latest
timeout-minutes: 30
env:
TARGET_FRAMEWORK: 'net10.0'
CONFIGURATION: 'Release'
CUSTOM_TEST_TARGET: 'net10.0'
STRESS_PROJECT: './tests/Opc.Ua.Stress.Tests/Opc.Ua.Stress.Tests.csproj'
TESTRESULTS: './TestResults/contract-integration'
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup .NET from global.json
uses: ./.github/actions/setup-repository-dotnet
with:
dotnet-version: 10.0.x
- name: Set Cloud Version
shell: pwsh
run: ./.azurepipelines/set-version.ps1
- name: Restore dependencies
run: dotnet restore 'UA.slnx'
- name: Build Stress Tests
run: >
dotnet build ${{ env.STRESS_PROJECT }}
--framework ${{ env.TARGET_FRAMEWORK }}
--configuration ${{ env.CONFIGURATION }}
--no-restore
/p:CustomTestTarget=${{ env.CUSTOM_TEST_TARGET }}
- name: Run Contract and Integration tests
shell: pwsh
run: |
dotnet test $env:STRESS_PROJECT `
--configuration $env:CONFIGURATION `
--no-build `
--framework $env:TARGET_FRAMEWORK `
--filter "Category=Contract|Category=Integration" `
--logger "trx;LogFileName=contract-integration.trx" `
--logger "console;verbosity=normal" `
--results-directory $env:TESTRESULTS `
/p:CustomTestTarget=$env:CUSTOM_TEST_TARGET
- name: Check that the Contract and Integration tests ran
shell: pwsh
run: ./.github/scripts/assert-tests-ran.ps1 -ResultsDirectory $env:TESTRESULTS
- name: Upload Contract and Integration results
uses: actions/upload-artifact@v7
with:
name: contract-integration
path: ${{ env.TESTRESULTS }}
if: always()
chaos-tcp:
name: Chaos TCP
# On a pull request only when it carries the 'stress' label, and not again
# when some other label is added to it.
if: >-
github.event_name != 'pull_request' ||
(contains(github.event.pull_request.labels.*.name, 'stress') &&
(github.event.action != 'labeled' || github.event.label.name == 'stress'))
runs-on: ubuntu-latest
timeout-minutes: 120
env:
TARGET_FRAMEWORK: 'net10.0'
CONFIGURATION: 'Release'
CUSTOM_TEST_TARGET: 'net10.0'
STRESS_PROJECT: './tests/Opc.Ua.Stress.Tests/Opc.Ua.Stress.Tests.csproj'
TESTRESULTS: './TestResults/chaos-tcp'
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup .NET from global.json
uses: ./.github/actions/setup-repository-dotnet
with:
dotnet-version: 10.0.x
- name: Set Cloud Version
shell: pwsh
run: ./.azurepipelines/set-version.ps1
- name: Restore dependencies
run: dotnet restore 'UA.slnx'
- name: Build Stress Tests
run: >
dotnet build ${{ env.STRESS_PROJECT }}
--framework ${{ env.TARGET_FRAMEWORK }}
--configuration ${{ env.CONFIGURATION }}
--no-restore
/p:CustomTestTarget=${{ env.CUSTOM_TEST_TARGET }}
- name: Generate ChaosTCP seed
id: seed
shell: pwsh
env:
INPUT_SEED: ${{ github.event.inputs.seed }}
run: |
$configuredSeed = $env:INPUT_SEED
if ([string]::IsNullOrWhiteSpace($configuredSeed))
{
$seed = [System.Security.Cryptography.RandomNumberGenerator]::GetInt32([int]::MaxValue)
}
else
{
$seed = [int]::Parse($configuredSeed, [System.Globalization.CultureInfo]::InvariantCulture)
}
New-Item -ItemType Directory -Force -Path $env:TESTRESULTS | Out-Null
"OPCUA_CHAOS_SEED=$seed" | Out-File -FilePath $env:GITHUB_ENV -Append
"OPCUA_TEST_SEED=$seed" | Out-File -FilePath $env:GITHUB_ENV -Append
"seed=$seed" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
$repro = @(
"ChaosTCP seed: $seed",
'',
'Reproduce locally from the repository root:',
'PowerShell:',
" `$env:OPCUA_CHAOS_SEED = '$seed'",
" `$env:OPCUA_TEST_SEED = '$seed'",
' dotnet test .\tests\Opc.Ua.Stress.Tests\Opc.Ua.Stress.Tests.csproj --framework net10.0 --configuration Release --filter "Category=ChaosTCP"',
'',
'Bash:',
" OPCUA_CHAOS_SEED=$seed OPCUA_TEST_SEED=$seed dotnet test ./tests/Opc.Ua.Stress.Tests/Opc.Ua.Stress.Tests.csproj --framework net10.0 --configuration Release --filter 'Category=ChaosTCP'")
$repro | Set-Content -Path (Join-Path $env:TESTRESULTS 'chaos-seed.txt')
Write-Host "ChaosTCP seed: $seed"
- name: Run ChaosTCP tests
shell: pwsh
run: |
dotnet test $env:STRESS_PROJECT `
--configuration $env:CONFIGURATION `
--no-build `
--framework $env:TARGET_FRAMEWORK `
--filter "Category=ChaosTCP" `
--logger "trx;LogFileName=chaos-tcp.trx" `
--logger "console;verbosity=detailed" `
--results-directory $env:TESTRESULTS `
/p:CustomTestTarget=$env:CUSTOM_TEST_TARGET
- name: Check that the ChaosTCP tests ran
shell: pwsh
run: ./.github/scripts/assert-tests-ran.ps1 -ResultsDirectory $env:TESTRESULTS
- name: Upload ChaosTCP results
uses: actions/upload-artifact@v7
with:
name: chaos-tcp-${{ steps.seed.outputs.seed }}
path: ${{ env.TESTRESULTS }}
if: always()