[#28] Client: Use external GRPC Channnel
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
9bb7b5eff8
commit
c9418a1894
27 changed files with 520 additions and 438 deletions
|
@ -16,10 +16,9 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
|
||||
private InitParameters GetDefaultParams()
|
||||
{
|
||||
return new InitParameters
|
||||
return new InitParameters((url) => Grpc.Net.Client.GrpcChannel.ForAddress(new Uri(url)))
|
||||
{
|
||||
Key = keyString.LoadWif(),
|
||||
|
||||
NodeParams = [new(1, url, 100.0f)],
|
||||
ClientBuilder = null,
|
||||
GracefulCloseOnSwitchTimeout = 30_000_000,
|
||||
|
@ -32,7 +31,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var options = GetDefaultParams();
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero));
|
||||
|
||||
|
@ -57,7 +56,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var options = GetDefaultParams();
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero));
|
||||
|
||||
|
@ -78,7 +77,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var callbackText = string.Empty;
|
||||
|
||||
var options = new InitParameters
|
||||
var options = new InitParameters((url) => Grpc.Net.Client.GrpcChannel.ForAddress(new Uri(url)))
|
||||
{
|
||||
Key = keyString.LoadWif(),
|
||||
NodeParams = [
|
||||
|
@ -91,7 +90,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
Callback = (cs) => callbackText = $"{cs.MethodName} took {cs.ElapsedMicroSeconds} microseconds"
|
||||
};
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var ctx = new CallContext(TimeSpan.Zero);
|
||||
|
||||
|
@ -99,9 +98,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
|
||||
Assert.Null(error);
|
||||
|
||||
using var client = FrostFSClient.GetInstance(GetSingleOwnerOptions(keyString, url));
|
||||
|
||||
var result = await client.GetNodeInfoAsync(default);
|
||||
var result = await pool.GetNodeInfoAsync(default);
|
||||
|
||||
var statistics = pool.Statistic();
|
||||
|
||||
|
@ -117,7 +114,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
var callbackText = string.Empty;
|
||||
options.Callback = (cs) => callbackText = $"{cs.MethodName} took {cs.ElapsedMicroSeconds} microseconds";
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var ctx = new CallContext(TimeSpan.Zero);
|
||||
|
||||
|
@ -125,9 +122,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
|
||||
Assert.Null(error);
|
||||
|
||||
using var client = FrostFSClient.GetInstance(GetSingleOwnerOptions(keyString, url));
|
||||
|
||||
var result = await client.GetNodeInfoAsync(default);
|
||||
var result = await pool.GetNodeInfoAsync(default);
|
||||
|
||||
Assert.False(string.IsNullOrEmpty(callbackText));
|
||||
Assert.Contains(" took ", callbackText, StringComparison.Ordinal);
|
||||
|
@ -138,7 +133,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var options = GetDefaultParams();
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero)).ConfigureAwait(true);
|
||||
|
||||
|
@ -160,7 +155,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var options = GetDefaultParams();
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero)).ConfigureAwait(true);
|
||||
|
||||
|
@ -184,19 +179,19 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
containerId: containerId,
|
||||
type: FrostFsObjectType.Regular,
|
||||
[new FrostFsAttributePair("fileName", "test")]),
|
||||
bufferMaxSize: 1024,
|
||||
payload: new MemoryStream(bytes),
|
||||
clientCut: false,
|
||||
sessionToken: token);
|
||||
|
||||
var objectId = await pool.PutObjectAsync(param, default).ConfigureAwait(true);
|
||||
var stream = await pool.PutObjectAsync(param, default).ConfigureAwait(true);
|
||||
|
||||
await stream.WriteAsync(bytes.AsMemory());
|
||||
var objectId = await stream.CompleteAsync();
|
||||
|
||||
var @object = await pool.GetObjectAsync(new PrmObjectGet(containerId, objectId), default);
|
||||
|
||||
var downloadedBytes = new byte[@object.Header.PayloadLength];
|
||||
MemoryStream ms = new(downloadedBytes);
|
||||
|
||||
ReadOnlyMemory<byte>? chunk = null;
|
||||
ReadOnlyMemory<byte>? chunk;
|
||||
while ((chunk = await @object.ObjectReader!.ReadChunk()) != null)
|
||||
{
|
||||
ms.Write(chunk.Value.Span);
|
||||
|
@ -212,7 +207,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var options = GetDefaultParams();
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero)).ConfigureAwait(true);
|
||||
|
||||
|
@ -240,11 +235,12 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
containerId: containerId,
|
||||
type: FrostFsObjectType.Regular,
|
||||
[new FrostFsAttributePair("fileName", "test")],
|
||||
new FrostFsSplit()),
|
||||
payload: new MemoryStream(bytes),
|
||||
clientCut: false);
|
||||
new FrostFsSplit()));
|
||||
|
||||
var objectId = await pool.PutObjectAsync(param, default);
|
||||
var stream = await pool.PutObjectAsync(param, default).ConfigureAwait(true);
|
||||
|
||||
await stream.WriteAsync(bytes.AsMemory());
|
||||
var objectId = await stream.CompleteAsync();
|
||||
|
||||
var head = await pool.GetObjectHeadAsync(new PrmObjectHeadGet(containerId, objectId, false), default);
|
||||
|
||||
|
@ -306,7 +302,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
Assert.True(cs.ElapsedMicroSeconds > 0);
|
||||
});
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero)).ConfigureAwait(true);
|
||||
|
||||
|
@ -331,11 +327,12 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
new FrostFsObjectHeader(
|
||||
containerId: createdContainer,
|
||||
type: FrostFsObjectType.Regular,
|
||||
[new FrostFsAttributePair("fileName", "test")]),
|
||||
payload: new MemoryStream(bytes),
|
||||
clientCut: false);
|
||||
[new FrostFsAttributePair("fileName", "test")]));
|
||||
|
||||
var objectId = await pool.PutObjectAsync(param, default);
|
||||
var stream = await pool.PutObjectAsync(param, default).ConfigureAwait(true);
|
||||
|
||||
await stream.WriteAsync(bytes.AsMemory());
|
||||
var objectId = await stream.CompleteAsync();
|
||||
|
||||
var filter = new FilterByAttributePair(FrostFsMatchType.Equals, "fileName", "test");
|
||||
|
||||
|
@ -385,7 +382,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var options = GetDefaultParams();
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
options.Callback = new((cs) => Assert.True(cs.ElapsedMicroSeconds > 0));
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero)).ConfigureAwait(true);
|
||||
|
@ -414,11 +411,12 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
containerId: container,
|
||||
type: FrostFsObjectType.Regular,
|
||||
[new FrostFsAttributePair("fileName", "test")]),
|
||||
payload: new MemoryStream(bytes),
|
||||
clientCut: false,
|
||||
sessionToken: token);
|
||||
|
||||
var objectId = await pool.PutObjectAsync(param, default);
|
||||
var stream = await pool.PutObjectAsync(param, default).ConfigureAwait(true);
|
||||
|
||||
await stream.WriteAsync(bytes.AsMemory());
|
||||
var objectId = await stream.CompleteAsync();
|
||||
|
||||
var filter = new FilterByAttributePair(FrostFsMatchType.Equals, "fileName", "test");
|
||||
|
||||
|
@ -472,7 +470,7 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
{
|
||||
var options = GetDefaultParams();
|
||||
|
||||
using var pool = new Pool(options);
|
||||
var pool = new Pool(options);
|
||||
|
||||
var error = await pool.Dial(new CallContext(TimeSpan.Zero)).ConfigureAwait(true);
|
||||
|
||||
|
@ -496,15 +494,14 @@ public class MultithreadPoolSmokeTests : SmokeTestsBase
|
|||
|
||||
byte[] bytes = GetRandomBytes(objectSize);
|
||||
|
||||
var param = new PrmObjectPut(
|
||||
var param = new PrmObjectClientCutPut(
|
||||
new FrostFsObjectHeader(
|
||||
containerId: containerId,
|
||||
type: FrostFsObjectType.Regular,
|
||||
[new FrostFsAttributePair("fileName", "test")]),
|
||||
payload: new MemoryStream(bytes),
|
||||
clientCut: true);
|
||||
payload: new MemoryStream(bytes));
|
||||
|
||||
var objectId = await pool.PutObjectAsync(param, default);
|
||||
var objectId = await pool.PutClientCutObjectAsync(param, default).ConfigureAwait(true);
|
||||
|
||||
var filter = new FilterByAttributePair(FrostFsMatchType.Equals, "fileName", "test");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue