[#32] Client: Add life tests
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
2e56c13946
commit
75cdb2e912
6 changed files with 353 additions and 235 deletions
132
src/FrostFS.SDK.Tests/Smoke/ContainerTests/ContainerTests.cs
Normal file
132
src/FrostFS.SDK.Tests/Smoke/ContainerTests/ContainerTests.cs
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using FrostFS.SDK.Client;
|
||||||
|
|
||||||
|
namespace FrostFS.SDK.Tests.Smoke;
|
||||||
|
|
||||||
|
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "Default Value is correct for tests")]
|
||||||
|
[SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "No secure purpose")]
|
||||||
|
public class ContainerTests : SmokeTestsBase
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async void CreateContanerTest()
|
||||||
|
{
|
||||||
|
var options = ClientOptions;
|
||||||
|
var client = FrostFSClient.GetInstance(options, GrpcChannel);
|
||||||
|
|
||||||
|
await Cleanup(client);
|
||||||
|
|
||||||
|
var ctx = new CallContext(TimeSpan.FromSeconds(20));
|
||||||
|
|
||||||
|
FrostFsContainerId containerId = await CreateContainer(client, unique: true, backupFactor: 1, selectors: [], filter: [], new FrostFsReplica(3));
|
||||||
|
|
||||||
|
Assert.NotNull(containerId);
|
||||||
|
|
||||||
|
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
||||||
|
Assert.NotNull(container);
|
||||||
|
|
||||||
|
Assert.Single(container.Attributes);
|
||||||
|
Assert.Equal("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", container.Attributes[0].Key);
|
||||||
|
Assert.Equal("true", container.Attributes[0].Value);
|
||||||
|
|
||||||
|
Assert.True(container.PlacementPolicy.HasValue);
|
||||||
|
|
||||||
|
Assert.Equal(1u, container.PlacementPolicy.Value.BackupFactor);
|
||||||
|
Assert.True(container.PlacementPolicy.Value.Unique);
|
||||||
|
Assert.Empty(container.PlacementPolicy.Value.Selectors);
|
||||||
|
Assert.Empty(container.PlacementPolicy.Value.Filters);
|
||||||
|
|
||||||
|
Assert.Single(container.PlacementPolicy.Value.Replicas);
|
||||||
|
Assert.Equal(3, container.PlacementPolicy.Value.Replicas[0].Count);
|
||||||
|
Assert.Equal(0u, container.PlacementPolicy.Value.Replicas[0].EcParityCount);
|
||||||
|
Assert.Equal(0u, container.PlacementPolicy.Value.Replicas[0].EcDataCount);
|
||||||
|
Assert.Equal("", container.PlacementPolicy.Value.Replicas[0].Selector);
|
||||||
|
|
||||||
|
Assert.Equal(OwnerId.ToString(), container.Owner.Value);
|
||||||
|
|
||||||
|
Assert.Equal(Version.Major, container.Version.Major);
|
||||||
|
Assert.Equal(Version.Minor, container.Version.Minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(1)]
|
||||||
|
[InlineData(3 * 1024 * 1024)] // exactly one chunk size - 3MB
|
||||||
|
[InlineData(6 * 1024 * 1024 + 100)]
|
||||||
|
public async void SimpleScenarioWithSessionTest(int objectSize)
|
||||||
|
{
|
||||||
|
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
||||||
|
|
||||||
|
var token = await client.CreateSessionAsync(new PrmSessionCreate(int.MaxValue), default);
|
||||||
|
|
||||||
|
await Cleanup(client);
|
||||||
|
|
||||||
|
var ctx = new CallContext(TimeSpan.FromSeconds(20));
|
||||||
|
|
||||||
|
var createContainerParam = new PrmContainerCreate(
|
||||||
|
new FrostFsContainerInfo(
|
||||||
|
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(3)),
|
||||||
|
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
||||||
|
PrmWait.DefaultParams);
|
||||||
|
|
||||||
|
var container = await client.CreateContainerAsync(createContainerParam, ctx);
|
||||||
|
|
||||||
|
var containerInfo = await client.GetContainerAsync(new PrmContainerGet(container), ctx);
|
||||||
|
Assert.NotNull(containerInfo);
|
||||||
|
|
||||||
|
await AddObjectRules(client, container);
|
||||||
|
|
||||||
|
var bytes = GetRandomBytes(objectSize);
|
||||||
|
|
||||||
|
var param = new PrmObjectPut(
|
||||||
|
new FrostFsObjectHeader(
|
||||||
|
containerId: container,
|
||||||
|
type: FrostFsObjectType.Regular,
|
||||||
|
[new FrostFsAttributePair("fileName", "test")]),
|
||||||
|
sessionToken: token);
|
||||||
|
|
||||||
|
var stream = await client.PutObjectAsync(param, default).ConfigureAwait(true);
|
||||||
|
|
||||||
|
await stream.WriteAsync(bytes.AsMemory());
|
||||||
|
var objectId = await stream.CompleteAsync();
|
||||||
|
|
||||||
|
var filter = new FilterByAttributePair(FrostFsMatchType.Equals, "fileName", "test");
|
||||||
|
|
||||||
|
bool hasObject = false;
|
||||||
|
await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(container, token, [], filter), default))
|
||||||
|
{
|
||||||
|
hasObject = true;
|
||||||
|
|
||||||
|
var res = await client.GetObjectHeadAsync(new PrmObjectHeadGet(container, objectId, false, token), default);
|
||||||
|
|
||||||
|
var objHeader = res.HeaderInfo;
|
||||||
|
Assert.NotNull(objHeader);
|
||||||
|
Assert.Equal((ulong)bytes.Length, objHeader.PayloadLength);
|
||||||
|
Assert.NotNull(objHeader.Attributes);
|
||||||
|
Assert.Single(objHeader.Attributes);
|
||||||
|
Assert.Equal("fileName", objHeader.Attributes.First().Key);
|
||||||
|
Assert.Equal("test", objHeader.Attributes.First().Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.True(hasObject);
|
||||||
|
|
||||||
|
var @object = await client.GetObjectAsync(new PrmObjectGet(container, objectId, token), default);
|
||||||
|
|
||||||
|
var downloadedBytes = new byte[@object.Header.PayloadLength];
|
||||||
|
MemoryStream ms = new(downloadedBytes);
|
||||||
|
|
||||||
|
ReadOnlyMemory<byte>? chunk = null;
|
||||||
|
while ((chunk = await @object.ObjectReader!.ReadChunk()) != null)
|
||||||
|
{
|
||||||
|
ms.Write(chunk.Value.Span);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.Equal(SHA256.HashData(bytes), SHA256.HashData(downloadedBytes));
|
||||||
|
|
||||||
|
await Cleanup(client);
|
||||||
|
|
||||||
|
await foreach (var _ in client.ListContainersAsync(default, default))
|
||||||
|
{
|
||||||
|
Assert.Fail("Containers exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
111
src/FrostFS.SDK.Tests/Smoke/NetworkTests/NetworkTests.cs
Normal file
111
src/FrostFS.SDK.Tests/Smoke/NetworkTests/NetworkTests.cs
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using FrostFS.SDK.Client;
|
||||||
|
using FrostFS.SDK.SmokeTests;
|
||||||
|
|
||||||
|
namespace FrostFS.SDK.Tests.Smoke;
|
||||||
|
|
||||||
|
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "Default Value is correct for tests")]
|
||||||
|
[SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "No secure purpose")]
|
||||||
|
public class SmokeClientTests : SmokeTestsBase
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async void AccountTest()
|
||||||
|
{
|
||||||
|
var test = lightWait.Timeout;
|
||||||
|
|
||||||
|
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
||||||
|
|
||||||
|
var result = await client.GetBalanceAsync(default);
|
||||||
|
|
||||||
|
Assert.NotNull(result);
|
||||||
|
Assert.True(result.Value == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void NodeInfoTest()
|
||||||
|
{
|
||||||
|
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
||||||
|
|
||||||
|
var result = await client.GetNodeInfoAsync(default);
|
||||||
|
|
||||||
|
Assert.Equal(2, result.Version.Major);
|
||||||
|
Assert.Equal(13, result.Version.Minor);
|
||||||
|
Assert.Equal(NodeState.Online, result.State);
|
||||||
|
Assert.Equal(33, result.PublicKey.Length);
|
||||||
|
Assert.Equal(2, result.Addresses.Count);
|
||||||
|
Assert.Equal(11, result.Attributes.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void NodeInfoStatisticsTest()
|
||||||
|
{
|
||||||
|
var options = ClientOptions;
|
||||||
|
|
||||||
|
var callbackContent = string.Empty;
|
||||||
|
options.Value.Callback = (cs) => callbackContent = $"{cs.MethodName} took {cs.ElapsedMicroSeconds} microseconds";
|
||||||
|
|
||||||
|
var client = FrostFSClient.GetInstance(options, GrpcChannel);
|
||||||
|
|
||||||
|
var result = await client.GetNodeInfoAsync(default);
|
||||||
|
|
||||||
|
Assert.NotEmpty(callbackContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void NetworkSettingsTest()
|
||||||
|
{
|
||||||
|
var options = ClientOptions;
|
||||||
|
var client = FrostFSClient.GetInstance(options, GrpcChannel);
|
||||||
|
|
||||||
|
var result = await client.GetNetworkSettingsAsync(default);
|
||||||
|
|
||||||
|
Assert.NotNull(result);
|
||||||
|
|
||||||
|
Assert.True(0u < result.Epoch);
|
||||||
|
Assert.True(result.HomomorphicHashingDisabled);
|
||||||
|
Assert.True(result.MaintenanceModeAllowed);
|
||||||
|
Assert.True(0u < result.MagicNumber);
|
||||||
|
|
||||||
|
Assert.Equal(0u, result.AuditFee);
|
||||||
|
Assert.Equal(0u, result.BasicIncomeRate);
|
||||||
|
Assert.Equal(0u, result.ContainerAliasFee);
|
||||||
|
Assert.Equal(0u, result.ContainerFee);
|
||||||
|
Assert.Equal(75u, result.EpochDuration);
|
||||||
|
Assert.Equal(10_000_000_000u, result.InnerRingCandidateFee);
|
||||||
|
Assert.Equal(12u, result.MaxECDataCount);
|
||||||
|
Assert.Equal(4u, result.MaxECParityCount);
|
||||||
|
Assert.Equal(5242880u, result.MaxObjectSize);
|
||||||
|
Assert.Equal(8000u, result.MsPerBlock);
|
||||||
|
Assert.Equal(100_000_000u, result.WithdrawFee);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void NodeInfoCallbackAndInterceptorTest()
|
||||||
|
{
|
||||||
|
bool callbackInvoked = false;
|
||||||
|
bool interceptorInvoked = false;
|
||||||
|
|
||||||
|
var options = ClientOptions;
|
||||||
|
options.Value.Callback = (cs) =>
|
||||||
|
{
|
||||||
|
callbackInvoked = true;
|
||||||
|
Assert.True(cs.ElapsedMicroSeconds > 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
options.Value.Interceptors.Add(new CallbackInterceptor(s => interceptorInvoked = true));
|
||||||
|
|
||||||
|
var client = FrostFSClient.GetInstance(options, GrpcChannel);
|
||||||
|
|
||||||
|
var result = await client.GetNodeInfoAsync(default);
|
||||||
|
|
||||||
|
Assert.True(callbackInvoked);
|
||||||
|
Assert.True(interceptorInvoked);
|
||||||
|
|
||||||
|
Assert.Equal(2, result.Version.Major);
|
||||||
|
Assert.Equal(13, result.Version.Minor);
|
||||||
|
Assert.Equal(NodeState.Online, result.State);
|
||||||
|
Assert.Equal(33, result.PublicKey.Length);
|
||||||
|
Assert.NotNull(result.Addresses);
|
||||||
|
Assert.True(result.Attributes.Count > 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,79 +1,16 @@
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Text;
|
|
||||||
using FrostFS.Refs;
|
|
||||||
using FrostFS.SDK.Client;
|
using FrostFS.SDK.Client;
|
||||||
using FrostFS.SDK.Client.Interfaces;
|
using FrostFS.SDK.Client.Interfaces;
|
||||||
using FrostFS.SDK.Cryptography;
|
using FrostFS.SDK.Cryptography;
|
||||||
using FrostFS.SDK.SmokeTests;
|
using FrostFS.SDK.SmokeTests;
|
||||||
using FrostFS.Session;
|
|
||||||
using Google.Protobuf;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
namespace FrostFS.SDK.Tests.Smoke;
|
namespace FrostFS.SDK.Tests.Smoke;
|
||||||
|
|
||||||
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "Default Value is correct for tests")]
|
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "Default Value is correct for tests")]
|
||||||
[SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "No secure purpose")]
|
[SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "No secure purpose")]
|
||||||
public class SmokeClientTests : SmokeTestsBase
|
public class ObjectTests : SmokeTestsBase
|
||||||
{
|
{
|
||||||
private static readonly PrmWait lightWait = new(100, 1);
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void AccountTest()
|
|
||||||
{
|
|
||||||
var test = lightWait.Timeout;
|
|
||||||
|
|
||||||
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
|
||||||
|
|
||||||
var result = await client.GetBalanceAsync(default);
|
|
||||||
|
|
||||||
Assert.NotNull(result);
|
|
||||||
Assert.True(result.Value == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void NodeInfoTest()
|
|
||||||
{
|
|
||||||
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
|
||||||
|
|
||||||
var result = await client.GetNodeInfoAsync(default);
|
|
||||||
|
|
||||||
Assert.Equal(2, result.Version.Major);
|
|
||||||
Assert.Equal(13, result.Version.Minor);
|
|
||||||
Assert.Equal(NodeState.Online, result.State);
|
|
||||||
Assert.Equal(33, result.PublicKey.Length);
|
|
||||||
// Assert.Single(result.Addresses);
|
|
||||||
// Assert.Equal(9, result.Attributes.Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void NodeInfoStatisticsTest()
|
|
||||||
{
|
|
||||||
var options = ClientOptions;
|
|
||||||
|
|
||||||
var callbackContent = string.Empty;
|
|
||||||
options.Value.Callback = (cs) => callbackContent = $"{cs.MethodName} took {cs.ElapsedMicroSeconds} microseconds";
|
|
||||||
|
|
||||||
var client = FrostFSClient.GetInstance(options, GrpcChannel);
|
|
||||||
|
|
||||||
var result = await client.GetNodeInfoAsync(default);
|
|
||||||
|
|
||||||
Assert.NotEmpty(callbackContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void GetSessionTest()
|
|
||||||
{
|
|
||||||
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
|
||||||
|
|
||||||
var token = await client.CreateSessionAsync(new(100), default);
|
|
||||||
|
|
||||||
Assert.NotNull(token);
|
|
||||||
Assert.NotEqual(Guid.Empty, token.Id);
|
|
||||||
Assert.Equal(33, token.SessionKey.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void CreateObjectWithSessionToken()
|
public async void CreateObjectWithSessionToken()
|
||||||
{
|
{
|
||||||
|
@ -83,14 +20,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
var token = await client.CreateSessionAsync(new PrmSessionCreate(int.MaxValue), default);
|
var token = await client.CreateSessionAsync(new PrmSessionCreate(int.MaxValue), default);
|
||||||
|
|
||||||
var createContainerParam = new PrmContainerCreate(
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(3));
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(3)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
PrmWait.DefaultParams,
|
|
||||||
xheaders: ["key1", "value1"]);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, default);
|
|
||||||
|
|
||||||
await AddObjectRules(client, containerId);
|
await AddObjectRules(client, containerId);
|
||||||
|
|
||||||
|
@ -132,13 +62,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
await Cleanup(client);
|
await Cleanup(client);
|
||||||
|
|
||||||
var createContainerParam = new PrmContainerCreate(
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(3));
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(3)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
lightWait);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, default);
|
|
||||||
|
|
||||||
await AddObjectRules(client, containerId);
|
await AddObjectRules(client, containerId);
|
||||||
|
|
||||||
|
@ -220,14 +144,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
var ctx = new CallContext(TimeSpan.FromSeconds(20));
|
var ctx = new CallContext(TimeSpan.FromSeconds(20));
|
||||||
|
|
||||||
var createContainerParam = new PrmContainerCreate(
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(3));
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(3)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
PrmWait.DefaultParams,
|
|
||||||
xheaders: ["testKey", "testValue"]);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, ctx);
|
|
||||||
|
|
||||||
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
||||||
Assert.NotNull(container);
|
Assert.NotNull(container);
|
||||||
|
@ -300,16 +217,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
await Cleanup(client);
|
await Cleanup(client);
|
||||||
|
|
||||||
var ctx = new CallContext();
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(3));
|
||||||
|
|
||||||
var createContainerParam = new PrmContainerCreate(
|
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(3)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
PrmWait.DefaultParams,
|
|
||||||
xheaders: ["testKey1", "testValue1"]);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, ctx);
|
|
||||||
|
|
||||||
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
||||||
Assert.NotNull(container);
|
Assert.NotNull(container);
|
||||||
|
@ -370,14 +278,6 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async void CleanupTest()
|
|
||||||
{
|
|
||||||
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
|
||||||
|
|
||||||
await Cleanup(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async void PatchTest()
|
public async void PatchTest()
|
||||||
{
|
{
|
||||||
|
@ -385,14 +285,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
await Cleanup(client);
|
await Cleanup(client);
|
||||||
|
|
||||||
var createContainerParam = new PrmContainerCreate(
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(3));
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(1)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
PrmWait.DefaultParams,
|
|
||||||
xheaders: ["testKey", "testValue"]);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, default);
|
|
||||||
|
|
||||||
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
||||||
Assert.NotNull(container);
|
Assert.NotNull(container);
|
||||||
|
@ -469,14 +362,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
await Cleanup(client);
|
await Cleanup(client);
|
||||||
|
|
||||||
var createContainerParam = new PrmContainerCreate(
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(3));
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(3)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
PrmWait.DefaultParams,
|
|
||||||
xheaders: ["testKey", "testValue"]);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, default);
|
|
||||||
|
|
||||||
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
||||||
Assert.NotNull(container);
|
Assert.NotNull(container);
|
||||||
|
@ -522,14 +408,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
await Cleanup(client);
|
await Cleanup(client);
|
||||||
|
|
||||||
var createContainerParam = new PrmContainerCreate(
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(3));
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(3)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
PrmWait.DefaultParams,
|
|
||||||
xheaders: ["testKey", "testValue"]);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, default);
|
|
||||||
|
|
||||||
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
var container = await client.GetContainerAsync(new PrmContainerGet(containerId), default);
|
||||||
Assert.NotNull(container);
|
Assert.NotNull(container);
|
||||||
|
@ -660,13 +539,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
foreach (var rep in replicas)
|
foreach (var rep in replicas)
|
||||||
{
|
{
|
||||||
var createContainerParam = new PrmContainerCreate(
|
FrostFsContainerId containerId = await CreateContainer(client, unique:true, backupFactor: 1, selectors:[], filter:[], new FrostFsReplica(rep));
|
||||||
new FrostFsContainerInfo(
|
|
||||||
new FrostFsPlacementPolicy(true, 1, [], [], new FrostFsReplica(rep)),
|
|
||||||
[new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")]),
|
|
||||||
lightWait);
|
|
||||||
|
|
||||||
var containerId = await client.CreateContainerAsync(createContainerParam, default);
|
|
||||||
|
|
||||||
var ctx = new CallContext(TimeSpan.FromSeconds(10));
|
var ctx = new CallContext(TimeSpan.FromSeconds(10));
|
||||||
|
|
||||||
|
@ -678,7 +551,7 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
|
|
||||||
var mb = 1024 * 1024;
|
var mb = 1024 * 1024;
|
||||||
|
|
||||||
int[] objectSizes = [1, 1024, 64 * mb + 1]; //64 * mb, 64 * mb - 1, , 2 * 64 * mb + 256];
|
int[] objectSizes = [1, 1024, 6 * mb + 1]; //64 * mb, 64 * mb - 1, , 2 * 64 * mb + 256];
|
||||||
|
|
||||||
foreach (var objectSize in objectSizes)
|
foreach (var objectSize in objectSizes)
|
||||||
{
|
{
|
||||||
|
@ -738,92 +611,4 @@ public class SmokeClientTests : SmokeTestsBase
|
||||||
Assert.NotNull(result.Addresses);
|
Assert.NotNull(result.Addresses);
|
||||||
Assert.True(result.Attributes.Count > 0);
|
Assert.True(result.Attributes.Count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] GetRandomBytes(int size)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var bytes = new byte[size];
|
|
||||||
rnd.NextBytes(bytes);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IOptions<ClientSettings> GetClientOptions(string key, string url)
|
|
||||||
{
|
|
||||||
return Options.Create(new ClientSettings
|
|
||||||
{
|
|
||||||
Key = key,
|
|
||||||
Host = url
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static async Task Cleanup(IFrostFSClient client)
|
|
||||||
{
|
|
||||||
await foreach (var cid in client.ListContainersAsync(default, default))
|
|
||||||
{
|
|
||||||
await client.DeleteContainerAsync(new PrmContainerDelete(cid, lightWait), default);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task AddContainerRules(IFrostFSClient client, FrostFsContainerId containerId)
|
|
||||||
{
|
|
||||||
var addChainPrm = new PrmApeChainAdd(
|
|
||||||
new FrostFsChainTarget(FrostFsTargetType.Container, containerId.GetValue()),
|
|
||||||
new FrostFsChain
|
|
||||||
{
|
|
||||||
ID = Encoding.ASCII.GetBytes("chain-id-test1"),
|
|
||||||
Rules = [
|
|
||||||
new FrostFsRule
|
|
||||||
{
|
|
||||||
Status = RuleStatus.Allow,
|
|
||||||
Actions = new Actions(inverted: false, names: ["*"]),
|
|
||||||
Resources = new Resource (inverted: false, names: [$"native:container/*"]),
|
|
||||||
Any = false,
|
|
||||||
Conditions = []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
MatchType = RuleMatchType.DenyPriority
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await client.AddChainAsync(addChainPrm, default);
|
|
||||||
|
|
||||||
var listChainPrm = new PrmApeChainList(new FrostFsChainTarget(FrostFsTargetType.Container, containerId.GetValue()));
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
await Task.Delay(1000);
|
|
||||||
var chains = await client.ListChainAsync(listChainPrm, default);
|
|
||||||
|
|
||||||
if (chains.Length > 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Delay(8000);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task AddObjectRules(IFrostFSClient client, FrostFsContainerId containerId)
|
|
||||||
{
|
|
||||||
var addChainPrm = new PrmApeChainAdd(
|
|
||||||
new FrostFsChainTarget(FrostFsTargetType.Container, containerId.GetValue()),
|
|
||||||
new FrostFsChain
|
|
||||||
{
|
|
||||||
ID = Encoding.ASCII.GetBytes("chain-id-test"),
|
|
||||||
Rules = [
|
|
||||||
new FrostFsRule
|
|
||||||
{
|
|
||||||
Status = RuleStatus.Allow,
|
|
||||||
Actions = new Actions(inverted: false, names: ["*"]),
|
|
||||||
Resources = new Resource (inverted: false, names: [$"native:object/*"]),
|
|
||||||
Any = false,
|
|
||||||
Conditions = []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
MatchType = RuleMatchType.DenyPriority
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await client.AddChainAsync(addChainPrm, default);
|
|
||||||
|
|
||||||
await Task.Delay(8000);
|
|
||||||
}
|
|
||||||
}
|
}
|
21
src/FrostFS.SDK.Tests/Smoke/SessionTests/SessionTests.cs
Normal file
21
src/FrostFS.SDK.Tests/Smoke/SessionTests/SessionTests.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using FrostFS.SDK.Client;
|
||||||
|
|
||||||
|
namespace FrostFS.SDK.Tests.Smoke;
|
||||||
|
|
||||||
|
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "Default Value is correct for tests")]
|
||||||
|
[SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "No secure purpose")]
|
||||||
|
public class SessionTests : SmokeTestsBase
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async void GetSessionTest()
|
||||||
|
{
|
||||||
|
var client = FrostFSClient.GetInstance(ClientOptions, GrpcChannel);
|
||||||
|
|
||||||
|
var token = await client.CreateSessionAsync(new(100), default);
|
||||||
|
|
||||||
|
Assert.NotNull(token);
|
||||||
|
Assert.NotEqual(Guid.Empty, token.Id);
|
||||||
|
Assert.Equal(33, token.SessionKey.Length);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
using System.Security.Cryptography;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
using FrostFS.SDK.Client;
|
using FrostFS.SDK.Client;
|
||||||
|
using FrostFS.SDK.Client.Interfaces;
|
||||||
using FrostFS.SDK.Cryptography;
|
using FrostFS.SDK.Cryptography;
|
||||||
|
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
|
@ -9,20 +12,21 @@ using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace FrostFS.SDK.Tests.Smoke;
|
namespace FrostFS.SDK.Tests.Smoke;
|
||||||
|
|
||||||
|
[SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "Default Value is correct for tests")]
|
||||||
|
[SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "No secure purpose")]
|
||||||
public abstract class SmokeTestsBase
|
public abstract class SmokeTestsBase
|
||||||
{
|
{
|
||||||
// cluster Ori
|
// cluster Ori
|
||||||
internal readonly string url = "http://10.78.128.207:8080";
|
// internal readonly string url = "http://10.78.128.207:8080";
|
||||||
internal readonly string keyString = "L4JWLdedUd4b21sriRHtCPGkjG2Mryz2AWLiVqTBSNyxxyAUcc7s";
|
// internal readonly string keyString = "L4JWLdedUd4b21sriRHtCPGkjG2Mryz2AWLiVqTBSNyxxyAUcc7s";
|
||||||
|
|
||||||
|
|
||||||
// cluster
|
// cluster
|
||||||
// internal readonly string url = "http://10.78.128.190:8080";
|
internal readonly string url = "http://10.78.128.190:8080";
|
||||||
// internal readonly string keyString = "L47c3bunc6bJd7uEAfPUae2VkyupFR9nizoH6jfPonzQxijqH2Ba";
|
internal readonly string keyString = "L47c3bunc6bJd7uEAfPUae2VkyupFR9nizoH6jfPonzQxijqH2Ba";
|
||||||
|
|
||||||
// WSL2
|
// WSL2
|
||||||
// internal readonly string url = "http://172.29.238.97:8080";
|
// internal readonly string url = "http://172.29.238.97:8080";
|
||||||
//internal readonly string keyString = "KzPXA6669m2pf18XmUdoR8MnP1pi1PMmefiFujStVFnv7WR5SRmK";
|
// internal readonly string keyString = "KwHDAJ66o8FoLBjVbjP2sWBmgBMGjt7Vv4boA7xQrBoAYBE397Aq"; // "KzPXA6669m2pf18XmUdoR8MnP1pi1PMmefiFujStVFnv7WR5SRmK";
|
||||||
|
|
||||||
//"KwHDAJ66o8FoLBjVbjP2sWBmgBMGjt7Vv4boA7xQrBoAYBE397Aq";
|
//"KwHDAJ66o8FoLBjVbjP2sWBmgBMGjt7Vv4boA7xQrBoAYBE397Aq";
|
||||||
|
|
||||||
|
@ -44,4 +48,69 @@ public abstract class SmokeTestsBase
|
||||||
protected static Func<string, ChannelBase> GrpcChannel => (url) => Grpc.Net.Client.GrpcChannel.ForAddress(new Uri(url));
|
protected static Func<string, ChannelBase> GrpcChannel => (url) => Grpc.Net.Client.GrpcChannel.ForAddress(new Uri(url));
|
||||||
|
|
||||||
protected IOptions<ClientSettings> ClientOptions => Options.Create(new ClientSettings { Key = keyString, Host = url });
|
protected IOptions<ClientSettings> ClientOptions => Options.Create(new ClientSettings { Key = keyString, Host = url });
|
||||||
|
|
||||||
|
protected static readonly PrmWait lightWait = new(100, 1);
|
||||||
|
|
||||||
|
protected static byte[] GetRandomBytes(int size)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
var bytes = new byte[size];
|
||||||
|
rnd.NextBytes(bytes);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static async Task<FrostFsContainerId> CreateContainer(IFrostFSClient client,
|
||||||
|
bool unique,
|
||||||
|
uint backupFactor,
|
||||||
|
Collection<FrostFsSelector> selectors,
|
||||||
|
Collection<FrostFsFilter> filter,
|
||||||
|
params FrostFsReplica[] replicas)
|
||||||
|
{
|
||||||
|
var networkSettings = await client.GetNetworkSettingsAsync(default);
|
||||||
|
|
||||||
|
var containerInfo = new FrostFsContainerInfo(
|
||||||
|
new FrostFsPlacementPolicy(unique, backupFactor, selectors, filter, replicas),
|
||||||
|
networkSettings.HomomorphicHashingDisabled ? [new FrostFsAttributePair("__SYSTEM__DISABLE_HOMOMORPHIC_HASHING", "true")] : []);
|
||||||
|
|
||||||
|
var createContainerParam = new PrmContainerCreate(
|
||||||
|
containerInfo,
|
||||||
|
PrmWait.DefaultParams,
|
||||||
|
xheaders: ["key1", "value1"]);
|
||||||
|
|
||||||
|
return await client.CreateContainerAsync(createContainerParam, default);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static async Task Cleanup(IFrostFSClient client)
|
||||||
|
{
|
||||||
|
await foreach (var cid in client.ListContainersAsync(default, default))
|
||||||
|
{
|
||||||
|
await client.DeleteContainerAsync(new PrmContainerDelete(cid, lightWait), default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static async Task AddObjectRules(IFrostFSClient client, FrostFsContainerId containerId)
|
||||||
|
{
|
||||||
|
var addChainPrm = new PrmApeChainAdd(
|
||||||
|
new FrostFsChainTarget(FrostFsTargetType.Container, containerId.GetValue()),
|
||||||
|
new FrostFsChain
|
||||||
|
{
|
||||||
|
ID = Encoding.ASCII.GetBytes("chain-id-test"),
|
||||||
|
Rules = [
|
||||||
|
new FrostFsRule
|
||||||
|
{
|
||||||
|
Status = RuleStatus.Allow,
|
||||||
|
Actions = new Actions(inverted: false, names: ["*"]),
|
||||||
|
Resources = new Resource (inverted: false, names: [$"native:object/*"]),
|
||||||
|
Any = false,
|
||||||
|
Conditions = []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
MatchType = RuleMatchType.DenyPriority
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await client.AddChainAsync(addChainPrm, default);
|
||||||
|
|
||||||
|
await Task.Delay(8000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue