Skip to content

Commit

Permalink
[chore] Fix flakiness of tests on Windows requiring ports in the dyna…
Browse files Browse the repository at this point in the history
…mic range (open-telemetry#35061)

**Description:**
The need for this was noticed due to the following CI failures on the
`receiver/opencensus` lifecycle tests:

*
https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/10723100311/job/29735640887#step:6:619
*
https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/10725662745/job/29744029983#step:6:318

The default port used by the `opencensusreceiver` is in a range that
Windows machines can excluded, or reserved to other services via the
`WinNAT` service. This change adds a PowerShell script to release the
default ports for the `opencensusreceiver` (55678) and the
`zpagesextension` (55679) on the Windows GH workflows. While this was
affecting only the `opencensusreceiver` at this time, the cost of
running this script is small, less than 5s, and later we can easly add
other ports if the need arrives. This was already added to the core repo
via open-telemetry/opentelemetry-collector#10839

**Link to tracking Issue:**
N/A

**Testing:**
CI

**Documentation:**
N/A
  • Loading branch information
pjanotti authored and f7o committed Sep 12, 2024
1 parent 60b7480 commit 0fbbad7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 0fbbad7

Please sign in to comment.