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

Enable all net48 integration tests and stabilise tests #1456

Merged
merged 9 commits into from
Aug 2, 2024

Conversation

scott-xu
Copy link
Collaborator

No description provided.

@Rob-Hague
Copy link
Collaborator

We can merge this one next assuming it passes. No need to create and resolve conflicts in the other branches

@scott-xu
Copy link
Collaborator Author

Deal 🥂

@scott-xu
Copy link
Collaborator Author

public static System.Security.Cryptography.ECDsa Create(System.Security.Cryptography.ECParameters parameters) applies to net47 and above.

See https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.ecdsa.create?view=net-8.0#system-security-cryptography-ecdsa-create(system-security-cryptography-ecparameters)

@scott-xu scott-xu changed the title Enable all net48 integration tests Add net47 target framework and enable all net48 integration tests Jul 25, 2024
@scott-xu
Copy link
Collaborator Author

@scott-xu scott-xu force-pushed the net48_integration-test branch from 1ebd2ed to 0f194c3 Compare July 25, 2024 15:13
@scott-xu scott-xu changed the title Add net47 target framework and enable all net48 integration tests Enable all net48 integration tests Jul 25, 2024
@WojciechNagorski
Copy link
Collaborator

So we can run them on Windows. What do you think?

@Rob-Hague
Copy link
Collaborator

Unfortunately, Mono doesn't implement ECDsa. See https://github.com/mono/mono/blob/main/mcs/class/referencesource/System.Core/System/Security/Cryptography/ECDsa.cs#L32

It is the reason behind #1406

So we can run them on Windows. What do you think?

I tried a while back. The problem is running a Linux container on a Windows host, which doesn't seem so easy on CI machines (the way to do it is WSL2 AFAIK but most Windows server images do not come with WSL2). But I'd welcome anyone to try because I'd very much like to see it happen.

@Rob-Hague
Copy link
Collaborator

It might be possible now that Windows Server 2022 includes WSL2. The problems I ran into were seemingly related to LCOW (#1220 (comment)). I wouldn't know if it is possible to run docker via WSL2 rather than LCOW in appveyor (I don't really know much about this stuff)

@scott-xu scott-xu force-pushed the net48_integration-test branch from 95e65ba to 8d58888 Compare July 26, 2024 01:07
@Rob-Hague
Copy link
Collaborator

I think there's some work involved here to make sure we don't introduce more unstable tests

@Rob-Hague Rob-Hague mentioned this pull request Jul 27, 2024
@scott-xu
Copy link
Collaborator Author

Unfortunately, Mono doesn't implement ECDsa. See https://github.com/mono/mono/blob/main/mcs/class/referencesource/System.Core/System/Security/Cryptography/ECDsa.cs#L32

It is the reason behind #1406

We can consider using BouncyCastle as a fallback when in Mono. (https://www.mono-project.com/docs/faq/technical/#how-can-i-detect-if-am-running-in-mono)

Then we can split the code into 3 implementations.

  1. Bcl implementation (.NET Framework 4.7+ and not Mono)
  2. Cng implementation (.NET Framework 4.6.2 and not Mono)
  3. BouncyCastle implementation (.NET Framework and Mono)

I can have a try when I have time.

@scott-xu
Copy link
Collaborator Author

It seems not easy to split EcdsaKey into three implementations because it is public already with ECDsaCng Ecdsa and CngAlgorithm HashAlgorithm properties when target to .NET Framework.

@Rob-Hague
Copy link
Collaborator

I kind of expected mono to use a .NET Standard build, but I guess it can use a .NET Framework build as well. The error in #1406 comes from calling ECDsa.Create(ECParameters) which only occurs #if !NET_FRAMEWORK.

Anyway I think it's fine to tweak the public members at this level if needed, especially if it doesn't work in the first place.

I'll run the CI on this a couple more times to check for any more misbehaving tests

@scott-xu scott-xu force-pushed the net48_integration-test branch from 2ed3e9d to 73ab12d Compare August 1, 2024 12:01
@scott-xu scott-xu force-pushed the net48_integration-test branch from 73ab12d to 43319dd Compare August 1, 2024 12:04
@scott-xu
Copy link
Collaborator Author

scott-xu commented Aug 1, 2024

Any idea to stabilize this test? @Rob-Hague

  Failed Test_ExecuteAsync_CancellationToken [1 s]
  Error Message:
   Assert.AreEqual failed. Expected:<TERM>. Actual:<(null)>. 
  Stack Trace:
     at Renci.SshNet.IntegrationTests.OldIntegrationTests.SshCommandTest.Test_ExecuteAsync_CancellationToken() in /home/appveyor/projects/ssh-net/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs:line 139

https://ci.appveyor.com/project/drieseng/ssh-net/builds/50322490/job/yo6pooiew5j86wcw

The 500ms wait may not enough in unit test.
See https://github.com/sshnet/SSH.NET/blob/develop/src/Renci.SshNet/SshCommand.cs#L446

@Rob-Hague
Copy link
Collaborator

Hmm, I would not expect the 500ms to be relevant here because we know OpenSSH implements signals. I think we can ignore that one and see if it happens more often

Copy link
Collaborator

@Rob-Hague Rob-Hague left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Rob-Hague Rob-Hague merged commit 889f4f6 into sshnet:develop Aug 2, 2024
1 check passed
@scott-xu scott-xu deleted the net48_integration-test branch August 2, 2024 13:18
Rob-Hague added a commit that referenced this pull request Aug 4, 2024
@scott-xu scott-xu changed the title Enable all net48 integration tests Enable all net48 integration tests and stabilise tests Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants