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

[chore] Fix flakiness of tests on Windows requiring ports in the dynamic range #35061

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
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ jobs:
~\go\pkg\mod
~\AppData\Local\go-build
key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }}
- name: Ensure required ports in the dynamic range are available
run: |
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
- name: Run Unit tests
run: make -j2 gotest GROUP=${{ matrix.group }}
windows-unittest:
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/scripts/win-required-ports.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<#
.SYNOPSIS
This script ensures that the ports required by the default configuration of the collector are available.
.DESCRIPTION
Certain runs on GitHub Actions sometimes have ports required by the default configuration reserved by other
applications via the WinNAT service.
#>

#Requires -RunAsAdministrator

netsh interface ip show excludedportrange protocol=tcp

Stop-Service winnat

# Only port in the dynamic range that is being, from time to time, reserved by other applications.
netsh interface ip add excludedportrange protocol=tcp startport=55678 numberofports=2

Start-Service winnat

netsh interface ip show excludedportrange protocol=tcp
Loading