Skip to content

Commit

Permalink
Verify rpc call in all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiakiteaneo committed Nov 6, 2024
1 parent afe76e5 commit c070d8d
Show file tree
Hide file tree
Showing 8 changed files with 470 additions and 39 deletions.
23 changes: 10 additions & 13 deletions packages/csharp/ArmoniK.Api.Client.Test/EventsClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public void SetUp()
[Test]
public void TestGetEvents()
{
var before = ConfTest.RpcCalled("Events",
"GetEvents")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand Down Expand Up @@ -103,19 +107,6 @@ public void TestGetEvents()

var client = new Events.EventsClient(channel);

var resultId = new Results.ResultsClient(channel).CreateResultsMetaData(new CreateResultsMetaDataRequest
{
SessionId = session.SessionId,
Results =
{
new CreateResultsMetaDataRequest.Types.ResultCreate
{
Name = "Result",
},
},
})
.Results;

Assert.That(() => client.GetEvents(new EventSubscriptionRequest
{
SessionId = session.SessionId,
Expand Down Expand Up @@ -153,5 +144,11 @@ public void TestGetEvents()
},
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Events",
"GetEvents")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
0);
}
}
10 changes: 10 additions & 0 deletions packages/csharp/ArmoniK.Api.Client.Test/HealthCheckTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public void SetUp()
[Test]
public void TestHealthCheck()
{
var before = ConfTest.RpcCalled("HealthChecks",
"CheckHealth")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand All @@ -77,5 +81,11 @@ public void TestHealthCheck()
var client = new HealthChecksService.HealthChecksServiceClient(channel);
Assert.That(() => client.CheckHealth(new CheckHealthRequest()),
Throws.Nothing);
var after = ConfTest.RpcCalled("HealthChecks",
"CheckHealth")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}
}
28 changes: 20 additions & 8 deletions packages/csharp/ArmoniK.Api.Client.Test/PartitionClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public void SetUp()
[Test]
public void TestGetPartition()
{
var before = ConfTest.RpcCalled("Partitions",
"GetPartition")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand All @@ -93,11 +97,21 @@ public void TestGetPartition()
Id = taskOptions.PartitionId,
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Partitions",
"GetPartition")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestListPartitions()
{
var before = ConfTest.RpcCalled("Partitions",
"ListPartitions")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand All @@ -107,20 +121,18 @@ public void TestListPartitions()
CaCert = CaCertPath_!,
HttpMessageHandler = MessageHandler_!,
});
var partition = "default";
var taskOptions = new TaskOptions
{
MaxDuration = Duration.FromTimeSpan(TimeSpan.FromHours(1)),
MaxRetries = 2,
Priority = 1,
PartitionId = partition,
};
var client = new Partitions.PartitionsClient(channel);

Assert.That(() => client.ListPartitions(new ListPartitionsRequest
{
Filters = new Filters(),
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Partitions",
"ListPartitions")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}
}
106 changes: 90 additions & 16 deletions packages/csharp/ArmoniK.Api.Client.Test/ResultsClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public void SetUp()
[Test]
public void TestGetResult()
{
var before = ConfTest.RpcCalled("Results",
"GetResult")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand All @@ -90,11 +94,21 @@ public void TestGetResult()
ResultId = "result-name",
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"GetResult")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestGetOwnerTaskId()
{
var before = ConfTest.RpcCalled("Results",
"GetOwnerTaskId")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand Down Expand Up @@ -130,11 +144,21 @@ public void TestGetOwnerTaskId()
},
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"GetOwnerTaskId")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestCreateResultMetaData()
{
var before = ConfTest.RpcCalled("Results",
"CreateResultsMetaData")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand Down Expand Up @@ -173,11 +197,21 @@ public void TestCreateResultMetaData()
},
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"CreateResultsMetaData")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestCreateResult()
{
var before = ConfTest.RpcCalled("Results",
"CreateResults")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand Down Expand Up @@ -216,11 +250,21 @@ public void TestCreateResult()
},
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"CreateResults")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestListResults()
{
var before = ConfTest.RpcCalled("Results",
"ListResults")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand All @@ -230,23 +274,7 @@ public void TestListResults()
CaCert = CaCertPath_!,
HttpMessageHandler = MessageHandler_!,
});
var partition = "default";
var client = new Results.ResultsClient(channel);
var taskOptions = new TaskOptions
{
MaxDuration = Duration.FromTimeSpan(TimeSpan.FromHours(1)),
MaxRetries = 2,
Priority = 1,
PartitionId = partition,
};
var session = new Sessions.SessionsClient(channel).CreateSession(new CreateSessionRequest
{
DefaultTaskOption = taskOptions,
PartitionIds =
{
partition,
},
});
Assert.That(() => client.ListResults(new ListResultsRequest
{
Filters = new Filters
Expand Down Expand Up @@ -278,11 +306,21 @@ public void TestListResults()
},
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"ListResults")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestUploadResults()
{
var before = ConfTest.RpcCalled("Results",
"UploadResultData")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand Down Expand Up @@ -314,11 +352,21 @@ public void TestUploadResults()
"result-id",
Encoding.ASCII.GetBytes("result data")),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"UploadResultData")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestDownloadResults()
{
var before = ConfTest.RpcCalled("Results",
"DownloadResultData")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand Down Expand Up @@ -349,11 +397,21 @@ public void TestDownloadResults()
"result-id",
CancellationToken.None),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"DownloadResultData")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestDeleteResults()
{
var before = ConfTest.RpcCalled("Results",
"DeleteResultsData")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand Down Expand Up @@ -389,11 +447,21 @@ public void TestDeleteResults()
},
}),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"DeleteResultsData")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
1);
}

[Test]
public void TestWatchResults()
{
var before = ConfTest.RpcCalled("Results",
"WatchResults")
.GetAwaiter()
.GetResult();
var channel = GrpcChannelFactory.CreateChannel(new GrpcClient
{
Endpoint = endpoint_,
Expand All @@ -406,5 +474,11 @@ public void TestWatchResults()
var client = new Results.ResultsClient(channel);
Assert.That(() => client.WatchResults(),
Throws.Nothing);
var after = ConfTest.RpcCalled("Results",
"WatchResults")
.GetAwaiter()
.GetResult();
Assert.AreEqual(after - before,
0);
}
}
Loading

0 comments on commit c070d8d

Please sign in to comment.