Skip to content

Commit a25cd01

Browse files
fixes
1 parent 753be9c commit a25cd01

File tree

9 files changed

+53
-38
lines changed

9 files changed

+53
-38
lines changed

src/CI/azp-initialization.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
steps:
2+
- powershell: |
3+
Write-Host "##vso[task.setvariable variable=DotnetRuntimeVersion;]8.0.0"
4+
Write-Host "##vso[task.setvariable variable=DOTNET_NOLOGO;]true"
5+
displayName: 'Use .NET Runtime 8.0.0'
6+
7+
- task: UseDotNet@2
8+
displayName: 'Use .NET SDK 6.0.317'
9+
inputs:
10+
packageType: 'sdk'
11+
version: '6.0.317'
212

313
- task: UseDotNet@2
4-
displayName: 'Use .NET SDK 5.0.408'
14+
displayName: 'Use .NET SDK 8.x'
515
inputs:
616
packageType: 'sdk'
7-
version: '5.0.408'
17+
version: 8.x
818

919
# Read $(Version) from the UiPath.CoreIpc.csproj file
1020
- powershell: |

src/CI/azp-nodejs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
condition: succeededOrFailed()
5555
inputs:
5656
testRunner: JUnit
57-
workingDir: $(NodeJS_ProjectPath)
57+
workingDir: $(NodeJS_ProjectPath)
5858
testResultsFiles: './src/Clients/js/reports/test/web/test-results.xml'
5959

6060
- task: PublishTestResults@2

src/CI/azp-start.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ variables:
2222
stages:
2323
- stage: Build
2424
displayName: '🏭 Build'
25-
jobs:
26-
# The following 3 jobs will run in parallel:
27-
25+
jobs:
26+
# The following 3 jobs will run in parallel:
2827
- job:
2928
displayName: '.NET on Windows'
3029
pool:

src/UiPath.CoreIpc.Tests/Implementation/SystemService.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public class SystemMessage : Message
3636
}
3737
public class CancelIoPipeMessage : Message
3838
{
39-
public CancelIoPipeMessage(int delayScecondCancel = 0)
40-
{
41-
DelayScecondCancel = delayScecondCancel;
42-
}
43-
public int DelayScecondCancel { get; set; }
39+
public int[]? MsDelays { get; set; }
4440
}
4541
public class SystemService : ISystemService
4642
{
@@ -190,16 +186,17 @@ public async Task<Stream> Echo(Stream input, CancellationToken cancellationToken
190186
public static extern bool CancelIoEx(IntPtr handle, IntPtr lpOverlapped);
191187
public async Task<bool> CancelIoPipe(CancelIoPipeMessage message = null, CancellationToken cancellationToken = default)
192188
{
189+
Debug.WriteLine("###################### CancelIoPipe");
193190
await Task.Delay(50);
194191
#if WINDOWS
195-
var networkPropertyInfo = message.Client.GetType().GetProperty("Network", BindingFlags.NonPublic | BindingFlags.Instance);
196-
var pipeStream = networkPropertyInfo.GetValue(message.Client, null) as PipeStream;
192+
var serverFieldInfo = message.Client.GetType().GetField("_server", BindingFlags.NonPublic | BindingFlags.Instance);
193+
var pipeStream = serverFieldInfo.GetValue(message.Client) as PipeStream;
197194

198195
var canceled = CancelIoEx(pipeStream.SafePipeHandle.DangerousGetHandle(), IntPtr.Zero);
199-
200-
if (message.DelayScecondCancel > 0)
196+
197+
foreach (var msDelay in message.MsDelays ?? [])
201198
{
202-
await Task.Delay(message.DelayScecondCancel);
199+
await Task.Delay(msDelay);
203200
canceled = CancelIoEx(pipeStream.SafePipeHandle.DangerousGetHandle(), IntPtr.Zero);
204201
}
205202

src/UiPath.CoreIpc.Tests/NamedPipeTests.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,35 @@ public async Task PipeSecurityForWindows()
4040
await CreateSystemService().DoNothing().ShouldThrowAsync<UnauthorizedAccessException>();
4141
}
4242

43-
[Fact]
44-
public async Task PipeCancelIoOnServer_TwiceTightly()
45-
{
46-
//Two cancel with less than 1 second in between should fail
47-
await _systemClient.CancelIoPipe(new(100)).ShouldThrowAsync<IOException>();
48-
}
43+
[Theory]
44+
[InlineData(new int[0])]
45+
[InlineData(100)]
46+
[InlineData(1100)]
47+
[InlineData(10, 10, 10, 10)]
48+
public async Task PipeCancelIoOnServer_AnyNoOfTimes(params int[] msDelays)
49+
{
50+
// Any number of kernel32.CancelIoEx calls should not cause the client to give up on the connection.
51+
(await _systemClient.CancelIoPipe(new() { MsDelays = msDelays })).ShouldBeTrue();
4952

50-
[Fact]
51-
public async Task PipeCancelIoOnClient()
52-
{
53-
(await _systemClient.Delay()).ShouldBeTrue();
53+
//Make sure the connection is still working
54+
(await _systemClient.Delay()).ShouldBeTrue();
55+
}
5456

55-
var delayTask = _systemClient.Delay(500);
56-
await Task.Delay(100);
57-
var pipeStream = ((IpcProxy)_systemClient).Connection.Network as PipeStream;
58-
SystemService.CancelIoEx(pipeStream.SafePipeHandle.DangerousGetHandle(), IntPtr.Zero).ShouldBeTrue();
57+
[Fact]
58+
public async Task PipeCancelIoOnClient()
59+
{
60+
(await _systemClient.Delay()).ShouldBeTrue();
61+
62+
var delayTask = _systemClient.Delay(500);
63+
await Task.Delay(100);
64+
var pipeStream = ((IpcProxy)_systemClient).Connection.Network as PipeStream;
65+
SystemService.CancelIoEx(pipeStream.SafePipeHandle.DangerousGetHandle(), IntPtr.Zero).ShouldBeTrue();
5966

60-
(await delayTask).ShouldBeTrue();
67+
(await delayTask).ShouldBeTrue();
6168

62-
//Make sure the connection is still working
63-
(await _systemClient.Delay()).ShouldBeTrue();
64-
}
69+
//Make sure the connection is still working
70+
(await _systemClient.Delay()).ShouldBeTrue();
71+
}
6572
#endif
6673
}
6774
public class ComputingNamedPipeTests : ComputingTests<NamedPipeClientBuilder<IComputingService, IComputingCallback>>

src/UiPath.CoreIpc.Tests/SystemTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace UiPath.CoreIpc.Tests;
55
public abstract class SystemTests<TBuilder> : TestBase where TBuilder : ServiceClientBuilder<TBuilder, ISystemService>
66
{
77
protected ServiceHost _systemHost;
8-
protected ISystemService _systemClient;
8+
protected readonly ISystemService _systemClient;
99
protected readonly SystemService _systemService;
1010
public SystemTests()
1111
{

src/UiPath.CoreIpc.Tests/TestBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ public abstract class TestBase : IDisposable
88
protected static int Count = -1;
99
public static readonly TimeSpan RequestTimeout =
1010
#if CI
11-
TimeSpan.FromSeconds(2) +
11+
TimeSpan.FromSeconds(3) +
1212
#endif
13-
(Debugger.IsAttached ? TimeSpan.FromDays(1) : TimeSpan.FromSeconds(2));
13+
TimeSpan.FromSeconds(3);
14+
// (Debugger.IsAttached ? TimeSpan.FromDays(1) : TimeSpan.FromSeconds(2));
1415
protected readonly IServiceProvider _serviceProvider;
1516
protected readonly AsyncContext _guiThread = new AsyncContextThread().Context;
1617

src/UiPath.CoreIpc.Tests/UiPath.CoreIpc.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<DefineConstants>$(DefineConstants);$(DefineConstantsEx)</DefineConstants>
77
<LangVersion>latest</LangVersion>
88
<ImplicitUsings>true</ImplicitUsings>
9+
<Nullable>annotations</Nullable>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/UiPath.CoreIpc.Tests/WebSocketTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace UiPath.CoreIpc.Tests;
33
public class SystemWebSocketTests : SystemTests<WebSocketClientBuilder<ISystemService>>
44
{
5-
int _port = 1313 + GetCount();
5+
int _port = 51313 + GetCount();
66
HttpSysWebSocketsListener _listener;
77
protected override ServiceHostBuilder Configure(ServiceHostBuilder serviceHostBuilder)
88
{

0 commit comments

Comments
 (0)