Stress Tests #5
This file contains hidden or 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
| # Stress test umbrella workflow. | |
| # | |
| # Each job is one stress scenario, runs nightly + on-demand, filtered | |
| # by NUnit Category. Add new scenarios by adding a sibling job below | |
| # with the same seed-generation pattern. | |
| 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 | |
| permissions: | |
| contents: read | |
| jobs: | |
| chaos-tcp: | |
| name: Chaos TCP | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| env: | |
| DOTNET_VERSION: '10.0.x' | |
| 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@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET ${{ env.DOTNET_VERSION }} | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - 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: Upload ChaosTCP results | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: chaos-tcp-${{ steps.seed.outputs.seed }} | |
| path: ${{ env.TESTRESULTS }} | |
| if: always() |