Capture pktmon counters before and after running tests #54
This file contains 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
# Copyright (c) Microsoft Corporation | |
# SPDX-License-Identifier: MIT | |
# This workflow will download the cts traffic generator and run it against a target. | |
name: cts_traffic | |
on: | |
# Permit manual runs of the workflow. | |
workflow_dispatch: | |
inputs: | |
profile: | |
description: 'Capture CPU profile' | |
required: false | |
default: false | |
type: boolean | |
tcp_ip_tracing: | |
description: 'Capture TCP/IP tracing' | |
required: false | |
default: false | |
type: boolean | |
duration: | |
description: 'Duration of the test in milliseconds' | |
required: false | |
default: 60000 | |
type: number | |
pull_request: | |
branches: | |
- main | |
paths: | |
- .github/workflows/cts_traffic.yml | |
concurrency: | |
group: ctstraffic-${{ github.event.client_payload.pr || github.event.client_payload.sha || inputs.ref || github.event.pull_request.number || 'main' }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: Build cts-traffic test tool | |
uses: microsoft/ctsTraffic/.github/workflows/reusable-build.yml@master | |
with: | |
build_artifact: cts-traffic | |
repository: 'microsoft/ctsTraffic' | |
configurations: '["Release"]' | |
ref: 'master' | |
test: | |
name: Test CTS Traffic | |
needs: [build] | |
strategy: | |
fail-fast: false | |
matrix: | |
vec: [ | |
# { env: "azure", os: "2022", arch: "x64" }, | |
# { env: "azure", os: "2025", arch: "x64" }, | |
{ env: "lab", os: "2022", arch: "x64" }, | |
] | |
runs-on: | |
- self-hosted | |
- ${{ matrix.vec.env }} | |
- os-windows-${{ matrix.vec.os }} | |
- ${{ matrix.vec.arch }} | |
steps: | |
- name: Setup workspace | |
run: | | |
Get-ChildItem | % { Remove-Item -Recurse $_ } | |
if (Test-Path ${{ github.workspace }}\xdp) { Remove-Item -Recurse -Force ${{ github.workspace }}\cts-traffic } | |
if (Test-Path ${{ github.workspace }}\ETL) { Remove-Item -Recurse -Force ${{ github.workspace }}\ETL } | |
New-item -ItemType Directory -Path ${{ github.workspace }}\cts-traffic | |
New-item -ItemType Directory -Path ${{ github.workspace }}\ETL | |
# Install the latest anti-malware signatures for Windows Defender to prevent false positives. | |
# Windows Defender incorrectly flags some of the test binaries as malware. | |
- name: Download latest anti-malware signatures for Windows Defender | |
run: | | |
Update-MpSignature -Verbose | |
Start-MpScan -ScanType QuickScan | |
Add-MpPreference -ExclusionPath ${{ github.workspace }} | |
- name: Download cts-traffic | |
uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d | |
with: | |
name: "cts-traffic Release" | |
path: ${{ github.workspace }}\cts-traffic | |
- name: Capture pktmon counters - start | |
run: | | |
pktmon stop | |
pktmon start --counters-only | |
pktmon counters -t all -z -i --json | Out-File -FilePath ${{ github.workspace }}\cts-traffic\pktmon_counters_start.json | |
- name: Start TCPIP tracing | |
if: inputs.tcp_ip_tracing == true | |
run: | | |
wpr -cancel 2>$null; $global:LASTEXITCODE = 0 | |
if (Test-Path "tcpip.wprp") { Remove-Item -Force "tcpip.wprp" } | |
Invoke-WebRequest -uri "https://raw.githubusercontent.com/microsoft/netperf/main/.github/workflows/tcpip.wprp" -OutFile "tcpip.wprp" | |
wpr -start tcpip.wprp -filemode | |
- name: Run CTS cts-traffic | |
working-directory: ${{ github.workspace }}\cts-traffic | |
run: | | |
$profile = 0 | |
$duration = ${{inputs.duration}} | |
if ("${{inputs.profile}}" -eq "true") { $profile = 1 } | |
$url = "https://raw.githubusercontent.com/microsoft/bpf_performance/main/scripts/two-machine-perf.ps1" | |
iex "& { $(irm $url) } -CpuProfile $profile -Duration $duration" | |
- name: Stop TCPIP tracing | |
if: inputs.tcp_ip_tracing == true | |
run: | | |
wpr -stop ${{ github.workspace }}\ETL\tcpip.etl | |
- name: Capture pktmon counters - end | |
run: | | |
pktmon counters -t all -z -i --json | Out-File -FilePath ${{ github.workspace }}\cts-traffic\pktmon_counters_end.json | |
pktmon stop | |
- name: Query NIC discard counters | |
run: | | |
get-counter "\Network Adapter(*)\packets received discarded" | |
- name: Query RSS settings | |
run: | | |
Get-NetAdapterRss | |
- name: Move ETL files to ETLfolder | |
working-directory: ${{ github.workspace }}\cts-traffic | |
run: | | |
dir . | |
if (Test-Path ${{ github.workspace }}\cts-traffic\cts_traffic_recv.etl) { Move-Item ${{ github.workspace }}\cts-traffic\cts_traffic_recv.etl ${{ github.workspace }}\ETL } | |
if (Test-Path ${{ github.workspace }}\cts-traffic\cts_traffic_send.etl) { Move-Item ${{ github.workspace }}\cts-traffic\cts_traffic_send.etl ${{ github.workspace }}\ETL } | |
if (Test-Path ${{ github.workspace }}\cts-traffic\tcpip_baseline.etl) { Move-Item ${{ github.workspace }}\cts-traffic\tcpip_baseline.etl ${{ github.workspace }}\ETL } | |
- name: Upload CTS cts-traffic results | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: cts_traffic_${{ matrix.vec.env }}_${{ matrix.vec.os }}_${{ matrix.vec.arch }} | |
path: ${{ github.workspace }}\cts-traffic\ctsTrafficResults.csv | |
- name: Upload ETL | |
if: inputs.profile == true || inputs.tcp_ip_tracing == true | |
uses: actions/upload-artifact@v2 | |
with: | |
name: cts_traffic_${{ matrix.vec.env }}_${{ matrix.vec.os }}_${{ matrix.vec.arch }}_ETL | |
path: ${{ github.workspace }}\ETL\*.etl | |
- name: Upload pktmon counters | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: cts_traffic_${{ matrix.vec.env }}_${{ matrix.vec.os }}_${{ matrix.vec.arch }}_pktmon_counters | |
path: ${{ github.workspace }}\cts-traffic\pktmon_counters_*.json | |
- name: Cleanup workspace | |
if: always() | |
run: | | |
if (Test-Path ${{ github.workspace }}\cts-traffic) { Remove-Item -Recurse -Force ${{ github.workspace }}\cts-traffic } | |
if (Test-Path ${{ github.workspace }}\ETL) { Remove-Item -Recurse -Force ${{ github.workspace }}\ETL } | |
- name: Restore Windows Defender exclusions | |
if: always() | |
run: | | |
Remove-MpPreference -ExclusionPath ${{ github.workspace }} | |
Update-MpSignature -Verbose | |
Start-MpScan -ScanType QuickScan |