-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object Store use over leaf-hub domain #900
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
using System.Text; | ||
|
@@ -32,9 +33,9 @@ | |
namespace IntegrationTests | ||
{ | ||
[SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")] | ||
public class TestObjectStore : TestSuite<OneServerSuiteContext> | ||
public class TestObjectStore : TestSuite<ObjectStoreSuiteContext> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switching to a context that has support to run a hub and leaf |
||
{ | ||
public TestObjectStore(OneServerSuiteContext context) : base(context) { } | ||
public TestObjectStore(ObjectStoreSuiteContext context) : base(context) { } | ||
|
||
[Fact] | ||
public void TestWorkFlow() | ||
|
@@ -597,6 +598,67 @@ private void ValidateWatcher(object[] expecteds, TestObjectStoreWatcher watcher) | |
} | ||
} | ||
} | ||
|
||
[Fact] | ||
public void TestObjectStoreDomains() { | ||
Context.RunInJsHubLeaf((hubNc, leafNc) => | ||
{ | ||
IObjectStoreManagement hubOsm = hubNc.CreateObjectStoreManagementContext(); | ||
|
||
// Create main OS on HUB | ||
String hubBucket = Bucket(); | ||
ObjectStoreStatus hubStatus = hubOsm.Create(ObjectStoreConfiguration.Builder() | ||
.WithName(hubBucket) | ||
.WithStorageType(StorageType.Memory) | ||
.WithReplicas(1) | ||
.Build()); | ||
|
||
Assert.Equal(0U, hubStatus.Size); | ||
Assert.Equal(1, hubStatus.Replicas); | ||
|
||
IObjectStore hubOs = hubNc.CreateObjectStoreContext(hubBucket); | ||
IObjectStore leafOs = leafNc.CreateObjectStoreContext(hubBucket, | ||
ObjectStoreOptions.Builder().WithJsDomain(SuiteContext.HubDomain).Build()); | ||
|
||
String objectName = Name(); | ||
ObjectMeta meta = ObjectMeta.Builder(objectName) | ||
.WithChunkSize(8 * 1024) | ||
.Build(); | ||
|
||
Object[] input = GetInput(4 * 8 * 1024, ".", long.MaxValue, null); | ||
FileInfo fileInfo = (FileInfo)input[1]; | ||
hubOs.Put(meta, fileInfo.OpenRead()); | ||
|
||
hubStatus = hubOs.GetStatus(); | ||
Assert.True(hubStatus.Size > 0); | ||
|
||
ObjectStoreStatus leafStatus = leafOs.GetStatus(); | ||
|
||
Assert.Equal(hubStatus.BucketName, leafStatus.BucketName); | ||
Assert.Equal(hubStatus.Size, leafStatus.Size); | ||
|
||
ObjectInfo hubInfo = hubOs.GetInfo(objectName); | ||
ObjectInfo leafInfo = leafOs.GetInfo(objectName); | ||
|
||
Assert.Equal(hubInfo.Nuid, leafInfo.Nuid); | ||
Assert.Equal(hubInfo.Size, leafInfo.Size); | ||
Assert.Equal(hubInfo.ObjectMeta.ObjectName, leafInfo.ObjectMeta.ObjectName); | ||
|
||
MemoryStream hubMs = new MemoryStream(); | ||
ObjectInfo hubOi = hubOs.Get(objectName, hubMs); | ||
byte[] hubBytes = hubMs.ToArray(); | ||
|
||
MemoryStream leafMs = new MemoryStream(); | ||
ObjectInfo leafOi = leafOs.Get(objectName, leafMs); | ||
byte[] leafBytes = leafMs.ToArray(); | ||
|
||
Assert.Equal(hubBytes.Length, leafBytes.Length); | ||
for (int x = 0; x < hubBytes.Length; x++) | ||
{ | ||
Assert.Equal(hubBytes[x], leafBytes[x]); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
class TestObjectStoreWatcher : IObjectStoreWatcher | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,29 +226,35 @@ public void RunInJsServer(TestServerInfo testServerInfo, string config, Action<I | |
} | ||
} | ||
|
||
public const string HubDomain = "HUB"; | ||
public const string LeafDomain = "LEAF"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made const so can be known to tests |
||
|
||
public void RunInJsHubLeaf(TestServerInfo hubServerInfo, | ||
TestServerInfo hubLeafInfo, | ||
TestServerInfo leafServerInfo, Action<IConnection, IConnection> test) | ||
{ | ||
string hubConfFile = TestBase.TempConfFile(); | ||
StreamWriter streamWriter = File.CreateText(hubConfFile); | ||
streamWriter.WriteLine("port: " + hubServerInfo.Port); | ||
streamWriter.WriteLine("server_name: HUB"); | ||
streamWriter.WriteLine("server_name: " + HubDomain); | ||
streamWriter.WriteLine("jetstream {"); | ||
streamWriter.WriteLine(" domain: HUB"); | ||
streamWriter.WriteLine(" store_dir: " + TestBase.TempConfDir()); | ||
streamWriter.WriteLine(" domain: " + HubDomain); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the constant and specify a unique store dir for each server |
||
streamWriter.WriteLine("}"); | ||
streamWriter.WriteLine("leafnodes {"); | ||
streamWriter.WriteLine(" listen = 127.0.0.1:" + hubLeafInfo.Port); | ||
streamWriter.WriteLine("}"); | ||
streamWriter.Flush(); | ||
streamWriter.Close(); | ||
|
||
string leafConfFile = TestBase.TempConfFile(); | ||
string leafJsStoreDir = TestBase.TempConfDir(); | ||
streamWriter = File.CreateText(leafConfFile); | ||
streamWriter.WriteLine("port: " + leafServerInfo.Port); | ||
streamWriter.WriteLine("server_name: LEAF"); | ||
streamWriter.WriteLine("server_name: " + LeafDomain); | ||
streamWriter.WriteLine("jetstream {"); | ||
streamWriter.WriteLine(" domain: LEAF"); | ||
streamWriter.WriteLine(" store_dir: " + TestBase.TempConfDir()); | ||
streamWriter.WriteLine(" domain: " + LeafDomain); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the constant and specify a unique store dir for each server |
||
streamWriter.WriteLine("}"); | ||
streamWriter.WriteLine("leafnodes {"); | ||
streamWriter.WriteLine(" remotes = [ { url: \"leaf://127.0.0.1:" + hubLeafInfo.Port + "\" } ]"); | ||
|
@@ -473,8 +479,10 @@ public class JetStreamPublishSuiteContext : OneServerSuiteContext {} | |
public class JetStreamPushAsyncSuiteContext : OneServerSuiteContext {} | ||
public class JetStreamPushSyncSuiteContext : OneServerSuiteContext {} | ||
public class JetStreamPushSyncQueueSuiteContext : OneServerSuiteContext {} | ||
public class KeyValueSuiteContext : HubLeafSuiteContext {} | ||
public class ObjectStoreSuiteContext : HubLeafSuiteContext {} | ||
|
||
public class KeyValueSuiteContext : SuiteContext | ||
public class HubLeafSuiteContext : SuiteContext | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refactored for reuse since object store needs the same stuff |
||
{ | ||
private const int SeedPort = TestSeedPorts.KvSuite; | ||
|
||
|
@@ -489,7 +497,7 @@ public class KeyValueSuiteContext : SuiteContext | |
public void RunInJsHubLeaf(Action<IConnection, IConnection> test) => | ||
base.RunInJsHubLeaf(Server1, Server2, Server3, test); | ||
} | ||
|
||
public class OneServerSuiteContext : SuiteContext | ||
{ | ||
public readonly TestServerInfo Server1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix/bug