[#24] Client: Implement pool part1
first iteration - base classes and methods Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
d1271df207
commit
c9a75ea025
72 changed files with 2786 additions and 468 deletions
|
@ -1,55 +1,13 @@
|
|||
using System.Security.Cryptography;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using FrostFS.Netmap;
|
||||
using FrostFS.SDK.ClientV2;
|
||||
using FrostFS.SDK.ClientV2.Interfaces;
|
||||
using FrostFS.SDK.ClientV2;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FrostFS.SDK.Tests;
|
||||
|
||||
public abstract class NetworkTestsBase
|
||||
{
|
||||
protected readonly string key = "KwHDAJ66o8FoLBjVbjP2sWBmgBMGjt7Vv4boA7xQrBoAYBE397Aq";
|
||||
|
||||
protected IOptions<SingleOwnerClientSettings> Settings { get; set; }
|
||||
|
||||
protected FrostFsVersion Version { get; set; } = new FrostFsVersion(2, 13);
|
||||
|
||||
protected ECDsa ECDsaKey { get; set; }
|
||||
protected FrostFsOwner OwnerId { get; set; }
|
||||
protected NetworkMocker Mocker { get; set; }
|
||||
|
||||
protected NetworkTestsBase()
|
||||
{
|
||||
Settings = Options.Create(new SingleOwnerClientSettings
|
||||
{
|
||||
Key = key,
|
||||
Host = "http://localhost:8080"
|
||||
});
|
||||
|
||||
ECDsaKey = key.LoadWif();
|
||||
OwnerId = FrostFsOwner.FromKey(ECDsaKey);
|
||||
|
||||
Mocker = new NetworkMocker(this.key);
|
||||
}
|
||||
|
||||
protected IFrostFSClient GetClient()
|
||||
{
|
||||
return ClientV2.FrostFSClient.GetTestInstance(
|
||||
Settings,
|
||||
null,
|
||||
Mocker.GetMock().Object,
|
||||
new SessionMocker(this.key).GetMock().Object,
|
||||
new ContainerMocker(this.key).GetMock().Object,
|
||||
new ObjectMocker(this.key).GetMock().Object);
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "Default Value is correct for tests")]
|
||||
public class NetworkTest : NetworkTestsBase
|
||||
{
|
||||
[Theory]
|
||||
|
@ -57,27 +15,24 @@ public class NetworkTest : NetworkTestsBase
|
|||
[InlineData(true)]
|
||||
public async void NetworkSettingsTest(bool useContext)
|
||||
{
|
||||
Mocker.Parameters = new Dictionary<string, byte[]>
|
||||
{
|
||||
{ "AuditFee", [1] },
|
||||
{ "BasicIncomeRate", [2] },
|
||||
{ "ContainerFee", [3] },
|
||||
{ "ContainerAliasFee", [4] },
|
||||
{ "EpochDuration", [5] },
|
||||
{ "InnerRingCandidateFee", [6] },
|
||||
{ "MaxECDataCount", [7] },
|
||||
{ "MaxECParityCount", [8] },
|
||||
{ "MaxObjectSize", [9] },
|
||||
{ "WithdrawFee", [10] },
|
||||
{ "HomomorphicHashingDisabled", [1] },
|
||||
{ "MaintenanceModeAllowed", [1] },
|
||||
};
|
||||
Mocker.Parameters.Add("AuditFee", [1]);
|
||||
Mocker.Parameters.Add("BasicIncomeRate", [2]);
|
||||
Mocker.Parameters.Add("ContainerFee", [3]);
|
||||
Mocker.Parameters.Add("ContainerAliasFee", [4]);
|
||||
Mocker.Parameters.Add("EpochDuration", [5]);
|
||||
Mocker.Parameters.Add("InnerRingCandidateFee", [6]);
|
||||
Mocker.Parameters.Add("MaxECDataCount", [7]);
|
||||
Mocker.Parameters.Add("MaxECParityCount", [8]);
|
||||
Mocker.Parameters.Add("MaxObjectSize", [9]);
|
||||
Mocker.Parameters.Add("WithdrawFee", [10]);
|
||||
Mocker.Parameters.Add("HomomorphicHashingDisabled", [1]);
|
||||
Mocker.Parameters.Add("MaintenanceModeAllowed", [1]);
|
||||
|
||||
var param = new PrmNetworkSettings();
|
||||
|
||||
if (useContext)
|
||||
{
|
||||
param.Context = new Context
|
||||
param.Context = new CallContext
|
||||
{
|
||||
CancellationToken = Mocker.CancellationTokenSource.Token,
|
||||
Timeout = TimeSpan.FromSeconds(20),
|
||||
|
@ -119,6 +74,7 @@ public class NetworkTest : NetworkTestsBase
|
|||
}
|
||||
else
|
||||
{
|
||||
Assert.NotNull(Mocker.NetworkInfoRequest);
|
||||
Assert.Empty(Mocker.NetworkInfoRequest.MetaHeader.XHeaders);
|
||||
Assert.Null(Mocker.DateTime);
|
||||
}
|
||||
|
@ -127,6 +83,7 @@ public class NetworkTest : NetworkTestsBase
|
|||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
|
||||
public async void NetmapSnapshotTest(bool useContext)
|
||||
{
|
||||
var body = new NetmapSnapshotResponse.Types.Body
|
||||
|
@ -164,7 +121,7 @@ public class NetworkTest : NetworkTestsBase
|
|||
if (useContext)
|
||||
{
|
||||
param.XHeaders.Add("headerKey1", "headerValue1");
|
||||
param.Context = new Context
|
||||
param.Context = new CallContext
|
||||
{
|
||||
CancellationToken = Mocker.CancellationTokenSource.Token,
|
||||
Timeout = TimeSpan.FromSeconds(20),
|
||||
|
@ -210,6 +167,7 @@ public class NetworkTest : NetworkTestsBase
|
|||
|
||||
if (useContext)
|
||||
{
|
||||
Assert.NotNull(Mocker.NetmapSnapshotRequest);
|
||||
Assert.Single(Mocker.NetmapSnapshotRequest.MetaHeader.XHeaders);
|
||||
Assert.Equal(param.XHeaders.Keys[0], Mocker.NetmapSnapshotRequest.MetaHeader.XHeaders.First().Key);
|
||||
Assert.Equal(param.XHeaders[param.XHeaders.Keys[0]], Mocker.NetmapSnapshotRequest.MetaHeader.XHeaders.First().Value);
|
||||
|
@ -222,6 +180,7 @@ public class NetworkTest : NetworkTestsBase
|
|||
}
|
||||
else
|
||||
{
|
||||
Assert.NotNull(Mocker.NetmapSnapshotRequest);
|
||||
Assert.Empty(Mocker.NetmapSnapshotRequest.MetaHeader.XHeaders);
|
||||
Assert.Null(Mocker.DateTime);
|
||||
}
|
||||
|
@ -254,7 +213,7 @@ public class NetworkTest : NetworkTestsBase
|
|||
if (useContext)
|
||||
{
|
||||
param.XHeaders.Add("headerKey1", "headerValue1");
|
||||
param.Context = new Context
|
||||
param.Context = new CallContext
|
||||
{
|
||||
CancellationToken = Mocker.CancellationTokenSource.Token,
|
||||
Timeout = TimeSpan.FromSeconds(20),
|
||||
|
@ -282,6 +241,7 @@ public class NetworkTest : NetworkTestsBase
|
|||
Assert.Equal("value1", result.Attributes["key1"]);
|
||||
Assert.Equal("value2", result.Attributes["key2"]);
|
||||
|
||||
Assert.NotNull(Mocker.LocalNodeInfoRequest);
|
||||
if (useContext)
|
||||
{
|
||||
Assert.Single(Mocker.LocalNodeInfoRequest.MetaHeader.XHeaders);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue