[#33] Client: Add extended life tests
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
2e56c13946
commit
bd8eb7cc60
24 changed files with 1020 additions and 976 deletions
|
@ -212,9 +212,15 @@ public class FrostFSClient : IFrostFSClient
|
|||
return GetContainerService().ListContainersAsync(args, ctx);
|
||||
}
|
||||
|
||||
[Obsolete("Use PutContainerAsync method")]
|
||||
public Task<FrostFsContainerId> CreateContainerAsync(PrmContainerCreate args, CallContext ctx)
|
||||
{
|
||||
return GetContainerService().CreateContainerAsync(args, ctx);
|
||||
return GetContainerService().PutContainerAsync(args, ctx);
|
||||
}
|
||||
|
||||
public Task<FrostFsContainerId> PutContainerAsync(PrmContainerCreate args, CallContext ctx)
|
||||
{
|
||||
return GetContainerService().PutContainerAsync(args, ctx);
|
||||
}
|
||||
|
||||
public Task DeleteContainerAsync(PrmContainerDelete args, CallContext ctx)
|
||||
|
@ -314,18 +320,6 @@ public class FrostFSClient : IFrostFSClient
|
|||
}
|
||||
#endregion
|
||||
|
||||
private async void CheckFrostFsVersionSupport(CallContext ctx)
|
||||
{
|
||||
var service = GetNetmapService();
|
||||
var localNodeInfo = await service.GetLocalNodeInfoAsync(ctx).ConfigureAwait(false);
|
||||
|
||||
if (!localNodeInfo.Version.IsSupported(ClientCtx.Version))
|
||||
{
|
||||
var msg = $"FrostFS {localNodeInfo.Version} is not supported.";
|
||||
throw new FrostFsException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private CallInvoker? CreateInvoker()
|
||||
{
|
||||
CallInvoker? callInvoker = null;
|
||||
|
@ -361,7 +355,7 @@ public class FrostFSClient : IFrostFSClient
|
|||
{
|
||||
var invoker = CreateInvoker();
|
||||
|
||||
NetmapServiceClient = NetmapServiceClient ?? (
|
||||
NetmapServiceClient ??= (
|
||||
invoker != null
|
||||
? new NetmapServiceClient(invoker)
|
||||
: new NetmapServiceClient(ClientCtx.Channel));
|
||||
|
@ -378,7 +372,7 @@ public class FrostFSClient : IFrostFSClient
|
|||
{
|
||||
var invoker = CreateInvoker();
|
||||
|
||||
SessionServiceClient = SessionServiceClient ?? (
|
||||
SessionServiceClient ??= (
|
||||
invoker != null
|
||||
? new SessionServiceClient(invoker)
|
||||
: new SessionServiceClient(ClientCtx.Channel));
|
||||
|
@ -387,7 +381,6 @@ public class FrostFSClient : IFrostFSClient
|
|||
}
|
||||
|
||||
return SessionServiceProvider;
|
||||
|
||||
}
|
||||
|
||||
private ApeManagerServiceProvider GetApeManagerService()
|
||||
|
@ -396,7 +389,7 @@ public class FrostFSClient : IFrostFSClient
|
|||
{
|
||||
var invoker = CreateInvoker();
|
||||
|
||||
ApeManagerServiceClient = ApeManagerServiceClient ?? (
|
||||
ApeManagerServiceClient ??= (
|
||||
invoker != null
|
||||
? new APEManagerServiceClient(invoker)
|
||||
: new APEManagerServiceClient(ClientCtx.Channel));
|
||||
|
@ -413,7 +406,7 @@ public class FrostFSClient : IFrostFSClient
|
|||
{
|
||||
var invoker = CreateInvoker();
|
||||
|
||||
AccountingServiceClient = AccountingServiceClient ?? (
|
||||
AccountingServiceClient ??= (
|
||||
invoker != null
|
||||
? new AccountingServiceClient(invoker)
|
||||
: new AccountingServiceClient(ClientCtx.Channel));
|
||||
|
@ -430,7 +423,7 @@ public class FrostFSClient : IFrostFSClient
|
|||
{
|
||||
var invoker = CreateInvoker();
|
||||
|
||||
ContainerServiceClient = ContainerServiceClient ?? (
|
||||
ContainerServiceClient ??= (
|
||||
invoker != null
|
||||
? new ContainerServiceClient(invoker)
|
||||
: new ContainerServiceClient(ClientCtx.Channel));
|
||||
|
|
|
@ -33,8 +33,11 @@ public interface IFrostFSClient
|
|||
|
||||
IAsyncEnumerable<FrostFsContainerId> ListContainersAsync(PrmContainerGetAll args, CallContext ctx);
|
||||
|
||||
[Obsolete("Use PutContainerAsync method")]
|
||||
Task<FrostFsContainerId> CreateContainerAsync(PrmContainerCreate args, CallContext ctx);
|
||||
|
||||
Task<FrostFsContainerId> PutContainerAsync(PrmContainerCreate args, CallContext ctx);
|
||||
|
||||
Task DeleteContainerAsync(PrmContainerDelete args, CallContext ctx);
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ public static class PlacementPolicyMapper
|
|||
return new FrostFsPlacementPolicy(
|
||||
placementPolicy.Unique,
|
||||
placementPolicy.ContainerBackupFactor,
|
||||
new System.Collections.ObjectModel.Collection<FrostFsSelector>(placementPolicy.Selectors.Select(selector => selector.ToModel()).ToList()),
|
||||
new System.Collections.ObjectModel.Collection<FrostFsFilter>(placementPolicy.Filters.Select(filter => filter.ToModel()).ToList()),
|
||||
placementPolicy.Replicas.Select(replica => replica.ToModel()).ToArray()
|
||||
[.. placementPolicy.Selectors.Select(s => s.ToModel())],
|
||||
[.. placementPolicy.Filters.Select(f => f.ToModel())],
|
||||
[.. placementPolicy.Replicas.Select(r => r.ToModel())]
|
||||
);
|
||||
}
|
||||
}
|
|
@ -50,13 +50,15 @@ public static class PolicyMapper
|
|||
throw new ArgumentNullException(nameof(selector));
|
||||
}
|
||||
|
||||
return new FrostFsSelector(selector.Name)
|
||||
var model = new FrostFsSelector(selector.Name)
|
||||
{
|
||||
Count = selector.Count,
|
||||
Clause = (int)selector.Clause,
|
||||
Attribute = selector.Attribute,
|
||||
Filter = selector.Filter
|
||||
};
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public static Filter ToMessage(this FrostFsFilter filter)
|
||||
|
@ -86,6 +88,13 @@ public static class PolicyMapper
|
|||
throw new ArgumentNullException(nameof(filter));
|
||||
}
|
||||
|
||||
return new FrostFsFilter(filter.Name, filter.Key, (int)filter.Op, filter.Value, filter.Filters.Select(f => f.ToModel()).ToArray());
|
||||
var model = new FrostFsFilter(
|
||||
filter.Name,
|
||||
filter.Key,
|
||||
(int)filter.Op,
|
||||
filter.Value,
|
||||
[.. filter.Filters.Select(f => f.ToModel())]);
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
|
@ -8,11 +8,6 @@ public static class ObjectAttributeMapper
|
|||
{
|
||||
public static Header.Types.Attribute ToMessage(this FrostFsAttributePair attribute)
|
||||
{
|
||||
if (attribute is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
return new Header.Types.Attribute
|
||||
{
|
||||
Key = attribute.Key,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
namespace FrostFS.SDK;
|
||||
using System.Linq;
|
||||
using FrostFS.Netmap;
|
||||
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsFilter(string name, string key, int operation, string value, FrostFsFilter[] filters) : IFrostFsFilter
|
||||
{
|
||||
|
@ -7,4 +10,19 @@ public class FrostFsFilter(string name, string key, int operation, string value,
|
|||
public int Operation { get; } = operation;
|
||||
public string Value { get; } = value;
|
||||
public FrostFsFilter[] Filters { get; } = filters;
|
||||
|
||||
internal Filter GetMessage()
|
||||
{
|
||||
var filter = new Filter()
|
||||
{
|
||||
Name = Name,
|
||||
Key = Key,
|
||||
Op = (Operation)Operation,
|
||||
Value = Value,
|
||||
};
|
||||
|
||||
filter.Filters.AddRange(Filters.Select(f => f.GetMessage()));
|
||||
|
||||
return filter;
|
||||
}
|
||||
}
|
|
@ -51,6 +51,16 @@ public struct FrostFsPlacementPolicy(bool unique,
|
|||
ContainerBackupFactor = BackupFactor
|
||||
};
|
||||
|
||||
if (Selectors != null && Selectors.Count > 0)
|
||||
{
|
||||
policy.Selectors.AddRange(Selectors.Select(s => s.GetMessage()));
|
||||
}
|
||||
|
||||
if (Filters != null && Filters.Count > 0)
|
||||
{
|
||||
policy.Filters.AddRange(Filters.Select(s => s.ToMessage()));
|
||||
}
|
||||
|
||||
foreach (var replica in Replicas)
|
||||
{
|
||||
policy.Replicas.Add(replica.ToMessage());
|
||||
|
|
|
@ -1,10 +1,24 @@
|
|||
namespace FrostFS.SDK;
|
||||
using FrostFS.Netmap;
|
||||
|
||||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsSelector(string name)
|
||||
{
|
||||
public string Name { get; set; } = name;
|
||||
public string Name { get; } = name;
|
||||
public uint Count { get; set; }
|
||||
public int Clause { get; set; }
|
||||
public string? Attribute { get; set; }
|
||||
public string? Filter { get; set; }
|
||||
|
||||
internal Selector GetMessage()
|
||||
{
|
||||
return new Selector()
|
||||
{
|
||||
Name = Name,
|
||||
Clause = (Clause)Clause,
|
||||
Count = Count,
|
||||
Filter = Filter ?? string.Empty,
|
||||
Attribute = Attribute ?? string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,36 @@
|
|||
namespace FrostFS.SDK;
|
||||
|
||||
public class FrostFsAttributePair(string key, string value)
|
||||
public struct FrostFsAttributePair(string key, string value) : System.IEquatable<FrostFsAttributePair>
|
||||
{
|
||||
public string Key { get; set; } = key;
|
||||
|
||||
public string Value { get; set; } = value;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || obj is not FrostFsAttributePair)
|
||||
return false;
|
||||
|
||||
return Equals((FrostFsAttributePair)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Key.GetHashCode() ^ Value.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(FrostFsAttributePair left, FrostFsAttributePair right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(FrostFsAttributePair left, FrostFsAttributePair right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public bool Equals(FrostFsAttributePair other)
|
||||
{
|
||||
return GetHashCode().Equals(other.GetHashCode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -568,10 +568,17 @@ public partial class Pool : IFrostFSClient
|
|||
return client.Client!.ListContainersAsync(args, ctx);
|
||||
}
|
||||
|
||||
[Obsolete("Use PutContainerAsync method")]
|
||||
public async Task<FrostFsContainerId> CreateContainerAsync(PrmContainerCreate args, CallContext ctx)
|
||||
{
|
||||
var client = Connection();
|
||||
return await client.Client!.CreateContainerAsync(args, ctx).ConfigureAwait(false);
|
||||
return await client.Client!.PutContainerAsync(args, ctx).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<FrostFsContainerId> PutContainerAsync(PrmContainerCreate args, CallContext ctx)
|
||||
{
|
||||
var client = Connection();
|
||||
return await client.Client!.PutContainerAsync(args, ctx).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task DeleteContainerAsync(PrmContainerDelete args, CallContext ctx)
|
||||
|
|
|
@ -71,7 +71,7 @@ internal sealed class ContainerServiceProvider(ContainerService.ContainerService
|
|||
}
|
||||
}
|
||||
|
||||
internal async Task<FrostFsContainerId> CreateContainerAsync(PrmContainerCreate args, CallContext ctx)
|
||||
internal async Task<FrostFsContainerId> PutContainerAsync(PrmContainerCreate args, CallContext ctx)
|
||||
{
|
||||
var grpcContainer = args.Container.GetContainer();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue