Skip to content

Commit ebdcb3e

Browse files
mus65Rob-Hague
andauthored
CI: add Windows Integration Tests for .NET (#1704)
* CI: add Windows Integration Tests for .NET see #1702 (comment) * fix podman setup with Windows and .NET * debug * x * x * x * revert * Run Windows .NET tests in separate job so they run in parallel and we avoid the Common_CreateMoreChannelsThanMaxSessions test failure. * fix coverlet artifacts * fix missing PermitTTY in RemoteSshdConfig Reset this fixes a test failure in Common_CreateMoreChannelsThanMaxSessions when running the tests multiple times against the same SSH server instance. see #1704 (comment) * speed up Windows tests turns out this is caused by DNS resolution taking about 2 seconds on every new connection... * add windows integration tests to Publish needs: --------- Co-authored-by: Rob Hague <rob.hague00@gmail.com> Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
1 parent af279d2 commit ebdcb3e

File tree

4 files changed

+65
-17
lines changed

4 files changed

+65
-17
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fetch-depth: 0 # needed for Nerdbank.GitVersioning
1616

1717
- name: Setup .NET
18-
uses: actions/setup-dotnet@v4
18+
uses: actions/setup-dotnet@v5
1919

2020
- name: Build Unit Tests .NET
2121
run: dotnet build -f net9.0 test/Renci.SshNet.Tests/
@@ -62,7 +62,7 @@ jobs:
6262
fetch-depth: 0 # needed for Nerdbank.GitVersioning
6363

6464
- name: Setup .NET
65-
uses: actions/setup-dotnet@v4
65+
uses: actions/setup-dotnet@v5
6666

6767
- name: Build Solution
6868
run: dotnet build Renci.SshNet.sln
@@ -103,8 +103,8 @@ jobs:
103103
-p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml `
104104
test/Renci.SshNet.Tests/
105105
106-
Windows-Integration-Tests:
107-
name: Windows Integration Tests
106+
Windows-Integration-Tests-NetFramework:
107+
name: Windows Integration Tests .NET Framework
108108
runs-on: windows-2025
109109
steps:
110110
- name: Checkout
@@ -113,7 +113,7 @@ jobs:
113113
fetch-depth: 0 # needed for Nerdbank.GitVersioning
114114

115115
- name: Setup .NET
116-
uses: actions/setup-dotnet@v4
116+
uses: actions/setup-dotnet@v5
117117

118118
- name: Setup WSL2
119119
uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0
@@ -142,7 +142,49 @@ jobs:
142142
- name: Archive Coverlet Results
143143
uses: actions/upload-artifact@v4
144144
with:
145-
name: Coverlet Results Windows
145+
name: Coverlet Results Windows .NET Framework
146+
path: coverlet
147+
148+
Windows-Integration-Tests-Net:
149+
name: Windows Integration Tests .NET
150+
runs-on: windows-2025
151+
steps:
152+
- name: Checkout
153+
uses: actions/checkout@v5
154+
with:
155+
fetch-depth: 0 # needed for Nerdbank.GitVersioning
156+
157+
- name: Setup .NET
158+
uses: actions/setup-dotnet@v5
159+
160+
- name: Setup WSL2
161+
uses: Vampire/setup-wsl@6a8db447be7ed35f2f499c02c6e60ff77ef11278 # v6.0.0
162+
with:
163+
distribution: Ubuntu-24.04
164+
165+
- name: Setup SSH Server
166+
shell: wsl-bash {0}
167+
run: |
168+
apt-get update && apt-get upgrade -y
169+
apt-get install -y podman
170+
podman build -t renci-ssh-tests-server-image -f test/Renci.SshNet.IntegrationTests/Dockerfile test/Renci.SshNet.IntegrationTests/
171+
podman run --rm -h renci-ssh-tests-server -d -p 2222:22 renci-ssh-tests-server-image
172+
173+
- name: Run Integration Tests .NET
174+
run:
175+
dotnet test `
176+
-f net9.0 `
177+
--logger "console;verbosity=normal" `
178+
--logger GitHubActions `
179+
-p:CollectCoverage=true `
180+
-p:CoverletOutputFormat=cobertura `
181+
-p:CoverletOutput=..\..\coverlet\windows_integration_test_net_9_coverage.xml `
182+
test\Renci.SshNet.IntegrationTests\
183+
184+
- name: Archive Coverlet Results
185+
uses: actions/upload-artifact@v4
186+
with:
187+
name: Coverlet Results Windows .NET
146188
path: coverlet
147189

148190
Publish:
@@ -153,6 +195,8 @@ jobs:
153195
needs:
154196
- Windows
155197
- Linux
198+
- Windows-Integration-Tests-NetFramework
199+
- Windows-Integration-Tests-Net
156200
steps:
157201
- name: Download NuGet Package
158202
uses: actions/download-artifact@v5

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
uses: actions/configure-pages@v5
2929

3030
- name: Setup .NET
31-
uses: actions/setup-dotnet@v4
31+
uses: actions/setup-dotnet@v5
3232

3333
- name: Setup docfx
3434
run: dotnet tool update -g docfx

test/Renci.SshNet.IntegrationTests/Common/RemoteSshdConfigExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static void Reset(this RemoteSshdConfig remoteSshdConfig)
2323
.ClearHostKeyAlgorithms()
2424
.ClearPublicKeyAcceptedAlgorithms()
2525
.ClearMessageAuthenticationCodeAlgorithms()
26+
.PermitTTY(true)
2627
.WithUsePAM(true)
2728
.Update()
2829
.Restart();

test/Renci.SshNet.IntegrationTests/TestsFixtures/InfrastructureFixture.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using DotNet.Testcontainers.Builders;
1+
using System.Runtime.InteropServices;
2+
3+
using DotNet.Testcontainers.Builders;
24
using DotNet.Testcontainers.Containers;
35
using DotNet.Testcontainers.Images;
46

@@ -28,26 +30,27 @@ private InfrastructureFixture()
2830

2931
private IFutureDockerImage _sshServerImage;
3032

31-
public string SshServerHostName { get; set; }
33+
public string SshServerHostName { get; private set; }
3234

33-
public ushort SshServerPort { get; set; }
35+
public ushort SshServerPort { get; private set; }
3436

35-
public SshUser AdminUser = new SshUser("sshnetadm", "ssh4ever");
37+
public SshUser AdminUser { get; } = new SshUser("sshnetadm", "ssh4ever");
3638

37-
public SshUser User = new SshUser("sshnet", "ssh4ever");
39+
public SshUser User { get; } = new SshUser("sshnet", "ssh4ever");
3840

3941
public async Task InitializeAsync()
4042
{
41-
// for the .NET Framework Tests in CI, the Container is set up in WSL2 with Podman
42-
#if NETFRAMEWORK
43-
if (Environment.GetEnvironmentVariable("CI") == "true")
43+
#pragma warning disable MA0144 // use System.OperatingSystem to check the current OS
44+
// for the Windows Tests in CI, the Container is set up in WSL2 with Podman
45+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
46+
Environment.GetEnvironmentVariable("CI") == "true")
47+
#pragma warning restore MA0144 // use System.OperatingSystem to check the current OS
4448
{
4549
SshServerPort = 2222;
46-
SshServerHostName = "localhost";
50+
SshServerHostName = "127.0.0.1";
4751
await Task.Delay(1_000);
4852
return;
4953
}
50-
#endif
5154

5255
var containerLogger = _loggerFactory.CreateLogger("testcontainers");
5356

0 commit comments

Comments
 (0)