Skip to content

Commit

Permalink
Using configuration object to read options
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiakiteaneo committed Nov 6, 2024
1 parent 61a0b77 commit cce5624
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 678 deletions.
22 changes: 12 additions & 10 deletions packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;

using Microsoft.Extensions.Configuration;
using System.Threading.Tasks;

using ArmoniK.Api.Client.Options;
using ArmoniK.Api.Client.Submitter;

using Microsoft.Extensions.Configuration;

using Newtonsoft.Json.Linq;

using Org.BouncyCastle.X509;
Expand All @@ -49,11 +49,11 @@ public static GrpcClient GetChannelOptions()
var builder = new ConfigurationBuilder().AddEnvironmentVariables();
var configuration = builder.Build();
var options = configuration.GetRequiredSection(GrpcClient.SettingSection)
.Get<GrpcClient>();
.Get<GrpcClient>();
if (options!.AllowUnsafeConnection)
{
if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework") || options.HttpMessageHandler.ToLower()
.Contains("web"))
.Contains("web"))
{
options!.Endpoint = Environment.GetEnvironmentVariable("Http__Endpoint");
}
Expand All @@ -63,9 +63,9 @@ public static GrpcClient GetChannelOptions()
}

public static async Task<uint> RpcCalled(string service_name,
string rpc_name)
string rpc_name)
{
var options = GetChannelOptions();
var options = GetChannelOptions();

X509Certificate? caCert = null;
if (!string.IsNullOrWhiteSpace(options.CaCert) && !options.AllowUnsafeConnection)
Expand All @@ -92,6 +92,7 @@ public static async Task<uint> RpcCalled(string service_name,
{
handler.ClientCertificates.Add(clientCert!);
}

handler.ServerCertificateCustomValidationCallback = (httpRequestMessage,
cert,
certChain,
Expand All @@ -111,10 +112,11 @@ public static async Task<uint> RpcCalled(string service_name,
var call_endpoint = Environment.GetEnvironmentVariable("Http__Endpoint") + "/calls.json";
try
{
using HttpResponseMessage response = await client.GetAsync(call_endpoint);
using var response = await client.GetAsync(call_endpoint);
response.EnsureSuccessStatusCode();
string responseBody = response.Content.ReadAsStringAsync().Result;
JObject jsonResponse = JObject.Parse(responseBody);
var responseBody = response.Content.ReadAsStringAsync()
.Result;
var jsonResponse = JObject.Parse(responseBody);
return (uint)jsonResponse[service_name][rpc_name];

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Dereference of a possibly null reference.

Check warning on line 120 in packages/csharp/ArmoniK.Api.Client.Test/ConfTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Possible null reference argument for parameter 'value' in 'JToken.explicit operator uint(JToken value)'.
}
catch (HttpRequestException e)
Expand Down
37 changes: 4 additions & 33 deletions packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Linq;
using System.Runtime.InteropServices;

using ArmoniK.Api.Client.Options;
using ArmoniK.Api.Client.Submitter;
Expand All @@ -48,28 +46,9 @@ public class EventsClientTest
{
[SetUp]
public void SetUp()
{
certPath_ = Environment.GetEnvironmentVariable("Grpc__ClientCert") ?? "";
keyPath_ = Environment.GetEnvironmentVariable("Grpc__ClientKey") ?? "";
CaCertPath_ = Environment.GetEnvironmentVariable("Grpc__CaCert") ?? "";
MessageHandler_ = Environment.GetEnvironmentVariable("GrpcClient__HttpMessageHandler") ?? "";
endpoint_ = Environment.GetEnvironmentVariable("Grpc__Endpoint") ?? "";
isInsecure_ = Environment.GetEnvironmentVariable("Grpc__AllowUnsafeConnection") == "true";
if (isInsecure_)
{
endpoint_ = RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework") || MessageHandler_.ToLower()
.Contains("web")
? "http://localhost:4999"
: endpoint_;
}
}
=> options_ = ConfTest.GetChannelOptions();

private static string? endpoint_;
private static string? certPath_;
private static string? keyPath_;
private static string? CaCertPath_;
private static string? MessageHandler_;
private bool isInsecure_;
private GrpcClient options_;

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net8.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.8 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net6.0 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 51 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / Test API (C#, dotnet test -f net4.7 --logger "trx;LogFileName=test-results.trx", csharp/ArmoniK.A...

Non-nullable field 'options_' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

[Test]
public void TestGetEvents()
Expand All @@ -78,15 +57,7 @@ public void TestGetEvents()
"GetEvents")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
AllowUnsafeConnection = isInsecure_,
CertPem = certPath_!,
KeyPem = keyPath_!,
CaCert = CaCertPath_!,
HttpMessageHandler = MessageHandler_!,
});
var channel = GrpcChannelFactory.CreateChannel(options_);
var partition = "default";
var taskOptions = new TaskOptions
{
Expand Down Expand Up @@ -149,6 +120,6 @@ public void TestGetEvents()
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,

Check failure on line 122 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / ConnectivityTests ubuntu-latest

ArmoniK.Api.Client.Tests.EventsClientTest ► TestGetEvents

Failed test found in: ./packages/csharp/ArmoniK.Api.Client.Test/TestResults/test-results.trx Error: Expected: 0 But was: 1
Raw output
  Expected: 0
  But was:  1

   at ArmoniK.Api.Client.Tests.EventsClientTest.TestGetEvents() in /home/runner/work/ArmoniK.Api/ArmoniK.Api/packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs:line 122

1)    at ArmoniK.Api.Client.Tests.EventsClientTest.TestGetEvents() in /home/runner/work/ArmoniK.Api/ArmoniK.Api/packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs:line 122

0);
1);
}

Check failure on line 124 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / ConnectivityTests windows-latest

ArmoniK.Api.Client.Tests.EventsClientTest ► TestGetEvents

Failed test found in: ./packages/csharp/ArmoniK.Api.Client.Test/TestResults/test-results.trx Error: Expected: 0 But was: 1
Raw output
  Expected: 0
  But was:  1

   at ArmoniK.Api.Client.Tests.EventsClientTest.TestGetEvents() in D:\a\ArmoniK.Api\ArmoniK.Api\packages\csharp\ArmoniK.Api.Client.Test\EventsClientTest.cs:line 124

1)    at ArmoniK.Api.Client.Tests.EventsClientTest.TestGetEvents() in D:\a\ArmoniK.Api\ArmoniK.Api\packages\csharp\ArmoniK.Api.Client.Test\EventsClientTest.cs:line 124

Check failure on line 124 in packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs

View workflow job for this annotation

GitHub Actions / ConnectivityTests windows-2019

ArmoniK.Api.Client.Tests.EventsClientTest ► TestGetEvents

Failed test found in: ./packages/csharp/ArmoniK.Api.Client.Test/TestResults/test-results.trx Error: Expected: 0 But was: 1
Raw output
  Expected: 0
  But was:  1

   at ArmoniK.Api.Client.Tests.EventsClientTest.TestGetEvents() in D:\a\ArmoniK.Api\ArmoniK.Api\packages\csharp\ArmoniK.Api.Client.Test\EventsClientTest.cs:line 124

1)    at ArmoniK.Api.Client.Tests.EventsClientTest.TestGetEvents() in D:\a\ArmoniK.Api\ArmoniK.Api\packages\csharp\ArmoniK.Api.Client.Test\EventsClientTest.cs:line 124

}
39 changes: 4 additions & 35 deletions packages/csharp/ArmoniK.Api.Client.Test/HealthCheckTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Runtime.InteropServices;

using ArmoniK.Api.Client.Options;
using ArmoniK.Api.Client.Submitter;
using ArmoniK.Api.gRPC.V1.HealthChecks;
Expand All @@ -38,29 +35,9 @@ public class HealthCheckTest
{
[SetUp]
public void SetUp()
{
certPath_ = Environment.GetEnvironmentVariable("Grpc__ClientCert") ?? "";
keyPath_ = Environment.GetEnvironmentVariable("Grpc__ClientKey") ?? "";
CaCertPath_ = Environment.GetEnvironmentVariable("Grpc__CaCert") ?? "";
MessageHandler_ = Environment.GetEnvironmentVariable("GrpcClient__HttpMessageHandler") ?? "";
endpoint_ = Environment.GetEnvironmentVariable("Grpc__Endpoint") ?? "";
isInsecure_ = Environment.GetEnvironmentVariable("Grpc__AllowUnsafeConnection") == "true";

if (isInsecure_)
{
endpoint_ = RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework") || MessageHandler_.ToLower()
.Contains("web")
? "http://localhost:4999"
: endpoint_;
}
}
=> options_ = ConfTest.GetChannelOptions();

private static string? endpoint_;
private static string? certPath_;
private static string? keyPath_;
private static string? CaCertPath_;
private static string? MessageHandler_;
private bool isInsecure_;
private GrpcClient? options_;

[Test]
public void TestHealthCheck()
Expand All @@ -69,16 +46,8 @@ public void TestHealthCheck()
"CheckHealth")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
AllowUnsafeConnection = isInsecure_,
CertPem = certPath_!,
KeyPem = keyPath_!,
CaCert = CaCertPath_!,
HttpMessageHandler = MessageHandler_!,
});
var client = new HealthChecksService.HealthChecksServiceClient(channel);
var channel = GrpcChannelFactory.CreateChannel(options_!);
var client = new HealthChecksService.HealthChecksServiceClient(channel);
Assert.That(() => client.CheckHealth(new CheckHealthRequest()),
Throws.Nothing);
var after = ConfTest.RpcCalled("HealthChecks",
Expand Down
47 changes: 5 additions & 42 deletions packages/csharp/ArmoniK.Api.Client.Test/PartitionClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Runtime.InteropServices;

using ArmoniK.Api.Client.Options;
using ArmoniK.Api.Client.Submitter;
Expand All @@ -41,29 +40,9 @@ public class PartitionClientTest
{
[SetUp]
public void SetUp()
{
certPath_ = Environment.GetEnvironmentVariable("Grpc__ClientCert") ?? "";
keyPath_ = Environment.GetEnvironmentVariable("Grpc__ClientKey") ?? "";
CaCertPath_ = Environment.GetEnvironmentVariable("Grpc__CaCert") ?? "";
MessageHandler_ = Environment.GetEnvironmentVariable("GrpcClient__HttpMessageHandler") ?? "";
endpoint_ = Environment.GetEnvironmentVariable("Grpc__Endpoint") ?? "";
isInsecure_ = Environment.GetEnvironmentVariable("Grpc__AllowUnsafeConnection") == "true";

if (isInsecure_)
{
endpoint_ = RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework") || MessageHandler_.ToLower()
.Contains("web")
? "http://localhost:4999"
: endpoint_;
}
}
=> options_ = ConfTest.GetChannelOptions();

private static string? endpoint_;
private static string? certPath_;
private static string? keyPath_;
private static string? CaCertPath_;
private static string? MessageHandler_;
private bool isInsecure_;
private GrpcClient? options_;

[Test]
public void TestGetPartition()
Expand All @@ -72,15 +51,7 @@ public void TestGetPartition()
"GetPartition")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
AllowUnsafeConnection = isInsecure_,
CertPem = certPath_!,
KeyPem = keyPath_!,
CaCert = CaCertPath_!,
HttpMessageHandler = MessageHandler_!,
});
var channel = GrpcChannelFactory.CreateChannel(options_!);
var partition = "default";
var taskOptions = new TaskOptions
{
Expand Down Expand Up @@ -112,16 +83,8 @@ public void TestListPartitions()
"ListPartitions")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
AllowUnsafeConnection = isInsecure_,
CertPem = certPath_!,
KeyPem = keyPath_!,
CaCert = CaCertPath_!,
HttpMessageHandler = MessageHandler_!,
});
var client = new Partitions.PartitionsClient(channel);
var channel = GrpcChannelFactory.CreateChannel(options_!);
var client = new Partitions.PartitionsClient(channel);

Assert.That(() => client.ListPartitions(new ListPartitionsRequest
{
Expand Down
Loading

0 comments on commit cce5624

Please sign in to comment.