You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2019/01/05 00:37:31 UTC
[geode-native] branch develop updated: GEODE-6241: Makes .NET
integration tests more consistent with C++ (#428)
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new a816ac9 GEODE-6241: Makes .NET integration tests more consistent with C++ (#428)
a816ac9 is described below
commit a816ac99cbbac557629686cb2542fdc74d464338
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Fri Jan 4 16:37:27 2019 -0800
GEODE-6241: Makes .NET integration tests more consistent with C++ (#428)
- Changes Gfsh wrapper:
- to be more stateless.
- use more explicit 1:1 mappings to actaual GFSH tool.
- Changes Cluster to keep more state previously held by Gfsh.
- Add support for XUnit's test output facility.
- Corrects async writes to test output after test ends.
---
clicache/integration-test2/CMakeLists.txt | 1 +
clicache/integration-test2/CacheXmlTests.cs | 89 ++---
clicache/integration-test2/Cluster.cs | 96 ++++--
clicache/integration-test2/ClusterTest.cs | 11 +-
clicache/integration-test2/CqOperationTest.cs | 69 ++--
.../{TestBase.cs => Framework.cs} | 38 +-
.../integration-test2/FunctionExecutionTest.cs | 161 ++++-----
clicache/integration-test2/Gfsh.cs | 144 +++++---
clicache/integration-test2/GfshExecute.cs | 182 ++++++----
clicache/integration-test2/GfshExecuteTest.cs | 383 +++++++++++----------
clicache/integration-test2/GfshTest.cs | 122 ++++---
clicache/integration-test2/QueryTest.cs | 327 +++++++++---------
clicache/integration-test2/RegionSSLTest.cs | 18 +-
clicache/integration-test2/RegionTest.cs | 25 +-
clicache/integration-test2/SerializationTests.cs | 49 ++-
clicache/integration-test2/TestBase.cs | 27 +-
tests/cli/PdxClassLibrary/PdxType.cs | 17 +-
.../cli/PdxClassLibrary/PdxTypesReflectionTest.cs | 13 +-
18 files changed, 932 insertions(+), 840 deletions(-)
diff --git a/clicache/integration-test2/CMakeLists.txt b/clicache/integration-test2/CMakeLists.txt
index 24cf0fe..b8a3e78 100644
--- a/clicache/integration-test2/CMakeLists.txt
+++ b/clicache/integration-test2/CMakeLists.txt
@@ -24,6 +24,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/packages.config ${CMAKE_CURRENT_BINAR
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cs.in ${CMAKE_CURRENT_BINARY_DIR}/Config.cs)
add_library( ${PROJECT_NAME} SHARED
+ Framework.cs
Cluster.cs
ClusterTest.cs
Config.cs.in
diff --git a/clicache/integration-test2/CacheXmlTests.cs b/clicache/integration-test2/CacheXmlTests.cs
index 4315d69..b9fa2b4 100644
--- a/clicache/integration-test2/CacheXmlTests.cs
+++ b/clicache/integration-test2/CacheXmlTests.cs
@@ -18,6 +18,7 @@
using System.IO;
using System.Threading;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
@@ -25,80 +26,50 @@ namespace Apache.Geode.Client.IntegrationTests
[Trait("Category", "Integration")]
public class CacheXmlTests : TestBase
{
+ public CacheXmlTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
+ {
+ }
+
[Fact]
public void ConstructAndGenerate()
{
- using (var gfsh = new GfshExecute())
- {
- try
- {
- string testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
+ string testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
- Assert.Equal(gfsh.start()
- .locator()
- .withDir(testDir)
- .withHttpServicePort(0)
- .execute(), 0);
- var template = new FileInfo("cache.xml");
- var cacheXml = new CacheXml(template, gfsh.LocatorPort);
- Assert.NotNull(cacheXml.File);
- Assert.True(cacheXml.File.Exists);
+ var template = new FileInfo("cache.xml");
+ var cacheXml = new CacheXml(template, 1234);
+ Assert.NotNull(cacheXml.File);
+ Assert.True(cacheXml.File.Exists);
- using (var input = cacheXml.File.OpenText())
- {
- var content = input.ReadToEnd();
- Assert.True(content.Contains(gfsh.LocatorPort.ToString()));
- }
- }
- finally
- {
- Assert.Equal(gfsh.shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
+ using (var input = cacheXml.File.OpenText())
+ {
+ var content = input.ReadToEnd();
+ Assert.True(content.Contains(1234.ToString()));
}
}
[Fact]
public void DisposeAndCleanup()
{
- using (var gfsh = new GfshExecute())
- {
- try
- {
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
- Assert.Equal(gfsh.start()
- .locator()
- .withDir(testDir)
- .withHttpServicePort(0)
- .execute(), 0);
- FileInfo file;
+ FileInfo file;
- var template = new FileInfo("cache.xml");
- using (var cacheXml = new CacheXml(template, gfsh.LocatorPort))
- {
- Assert.NotNull(cacheXml.File);
- file = cacheXml.File;
- Assert.True(file.Exists);
- }
+ var template = new FileInfo("cache.xml");
+ using (var cacheXml = new CacheXml(template, 1234))
+ {
+ Assert.NotNull(cacheXml.File);
+ file = cacheXml.File;
+ Assert.True(file.Exists);
+ }
- file.Refresh();
+ file.Refresh();
- // File deletion via File.Delete (inside the file.Refresh() call)
- // is not synchronous so we need to potentially wait until the file
- // has been deleted here
- Assert.True(SpinWait.SpinUntil(() => !file.Exists, 10000));
- }
- finally
- {
- Assert.Equal(gfsh.shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
- }
+ // File deletion via File.Delete (inside the file.Refresh() call)
+ // is not synchronous so we need to potentially wait until the file
+ // has been deleted here
+ Assert.True(SpinWait.SpinUntil(() => !file.Exists, 10000));
}
}
}
diff --git a/clicache/integration-test2/Cluster.cs b/clicache/integration-test2/Cluster.cs
index 3861b3d..4d59740 100644
--- a/clicache/integration-test2/Cluster.cs
+++ b/clicache/integration-test2/Cluster.cs
@@ -22,6 +22,7 @@ using System.Net;
using System.IO;
using System.Net.Sockets;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
@@ -33,37 +34,30 @@ namespace Apache.Geode.Client.IntegrationTests
private List<Locator> locators_;
private List<Server> servers_;
private string name_;
- private bool usessl_;
+ internal int jmxManagerPort = Framework.FreeTcpPort();
+ internal string keyStore_ = Environment.CurrentDirectory + "/ServerSslKeys/server_keystore.jks";
+ internal string keyStorePassword_ = "gemstone";
+ internal string trustStore_ = Environment.CurrentDirectory + "/ServerSslKeys/server_truststore.jks";
+ internal string trustStorePassword_ = "gemstone";
public Gfsh Gfsh { get; private set; }
- private const string sslPassword_ = "gemstone";
+ public bool UseSSL { get; set; }
- public bool UseSSL
+ internal PoolFactory ApplyLocators(PoolFactory poolFactory)
{
- get
+ foreach (var locator in locators_)
{
- return usessl_;
- }
- set
- {
- usessl_ = value;
- Gfsh.UseSSL = value;
- if (value)
- {
- var currentDir = Environment.CurrentDirectory;
- Gfsh.Keystore = currentDir + "/ServerSslKeys/server_keystore.jks";
- Gfsh.KeystorePassword = sslPassword_;
- Gfsh.Truststore = currentDir + "/ServerSslKeys/server_truststore.jks";
- Gfsh.TruststorePassword = sslPassword_;
- }
+ poolFactory.AddLocator(locator.Address.address, locator.Address.port);
}
+
+ return poolFactory;
}
- public Cluster(string name, int locatorCount, int serverCount)
+ public Cluster(ITestOutputHelper output, string name, int locatorCount, int serverCount)
{
started_ = false;
- Gfsh = new GfshExecute();
+ Gfsh = new GfshExecute(output);
UseSSL = false;
name_ = name;
locatorCount_ = locatorCount;
@@ -134,6 +128,32 @@ namespace Apache.Geode.Client.IntegrationTests
.execute();
}
}
+
+ public Cache CreateCache(IDictionary<string, string> properties)
+ {
+ var cacheFactory = new CacheFactory();
+
+ cacheFactory
+ .Set("log-level", "none")
+ .Set("statistic-sampling-enabled", "false");
+
+ foreach (var pair in properties)
+ {
+ cacheFactory.Set(pair.Key, pair.Value);
+ }
+
+ var cache = cacheFactory.Create();
+
+ ApplyLocators(cache.GetPoolFactory()).Create("default");
+
+ return cache;
+ }
+
+ public Cache CreateCache()
+ {
+ return CreateCache(new Dictionary<string, string>());
+ }
+
}
public struct Address
@@ -156,7 +176,7 @@ namespace Apache.Geode.Client.IntegrationTests
name_ = name;
var address = new Address();
address.address = "localhost";
- address.port = cluster.Gfsh.LocatorPort;
+ address.port = Framework.FreeTcpPort();
Address = address;
}
@@ -175,15 +195,35 @@ namespace Apache.Geode.Client.IntegrationTests
.withBindAddress(Address.address)
.withPort(Address.port)
.withMaxHeap("256m")
- .withJmxManagerPort(cluster_.Gfsh.JmxManagerPort)
+ .withJmxManagerPort(cluster_.jmxManagerPort)
+ .withJmxManagerStart(true)
.withHttpServicePort(0);
if (cluster_.UseSSL)
{
- locator.withUseSsl()
- .withConnect(false);
+ locator
+ .withConnect(false)
+ .withSslEnableComponents("locator,jmx")
+ .withSslKeyStore(cluster_.keyStore_)
+ .withSslKeyStorePassword(cluster_.keyStorePassword_)
+ .withSslTrustStore(cluster_.trustStore_)
+ .withSslTrustStorePassword(cluster_.trustStorePassword_);
}
result = locator.execute();
+
+ if (cluster_.UseSSL)
+ {
+ cluster_.Gfsh.connect()
+ .withJmxManager(Address.address, cluster_.jmxManagerPort)
+ .withUseSsl(true)
+ .withKeyStore(cluster_.keyStore_)
+ .withKeyStorePassword(cluster_.keyStorePassword_)
+ .withTrustStore(cluster_.trustStore_)
+ .withTrustStorePassword(cluster_.trustStorePassword_)
+ .execute();
+ }
+
started_ = true;
+
}
return result;
}
@@ -235,7 +275,13 @@ namespace Apache.Geode.Client.IntegrationTests
.withMaxHeap("1g");
if (cluster_.UseSSL)
{
- server.withUseSsl();
+ server
+ .withSslEnableComponents("server,locator,jmx")
+ .withSslKeyStore(cluster_.keyStore_)
+ .withSslKeyStorePassword(cluster_.keyStorePassword_)
+ .withSslTrustStore(cluster_.trustStore_)
+ .withSslTrustStorePassword(cluster_.trustStorePassword_);
+
}
result = server.execute();
started_ = true;
diff --git a/clicache/integration-test2/ClusterTest.cs b/clicache/integration-test2/ClusterTest.cs
index a7ab69d..358966d 100644
--- a/clicache/integration-test2/ClusterTest.cs
+++ b/clicache/integration-test2/ClusterTest.cs
@@ -19,12 +19,17 @@ using System;
using System.Diagnostics;
using System.Reflection;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
[Trait("Category", "Integration")]
public class ClusterTest : TestBase, IDisposable
{
+ public ClusterTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
+ {
+ }
+
public void Dispose()
{
@@ -33,7 +38,7 @@ namespace Apache.Geode.Client.IntegrationTests
[Fact]
public void ClusterStartTest()
{
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
Assert.True(cluster.Start());
}
@@ -42,7 +47,7 @@ namespace Apache.Geode.Client.IntegrationTests
[Fact]
public void ClusterStartWithTwoServersTest()
{
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 2))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 2))
{
Assert.True(cluster.Start());
}
@@ -51,7 +56,7 @@ namespace Apache.Geode.Client.IntegrationTests
[Fact]
public void ClusterStartWithSslTest()
{
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
cluster.UseSSL = true;
diff --git a/clicache/integration-test2/CqOperationTest.cs b/clicache/integration-test2/CqOperationTest.cs
index 2824df9..10a44df 100644
--- a/clicache/integration-test2/CqOperationTest.cs
+++ b/clicache/integration-test2/CqOperationTest.cs
@@ -20,6 +20,7 @@ using System.IO;
using Xunit;
using System.Diagnostics;
using System.Threading;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
@@ -175,42 +176,35 @@ namespace Apache.Geode.Client.IntegrationTests
}
[Trait("Category", "Integration")]
- public class CqOperationTest : TestBase, IDisposable
+ public class CqOperationTest : TestBase
{
- private readonly Cache cache_;
private static int waitInterval_ = 1000;
- public CqOperationTest()
+ public CqOperationTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
- var cacheFactory = new CacheFactory()
- .Set("log-level", "error");
- cache_ = cacheFactory.Create();
}
-
- public void Dispose()
- {
- cache_.Close();
- }
-
+
[Fact]
public void PdxSerializableNotificationsHaveCorrectValues()
{
- using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
- Assert.Equal(cluster_.Start(), true);
- Assert.Equal(cluster_.Gfsh.create()
+ Assert.True(cluster.Start());
+ Assert.Equal(0, cluster.Gfsh.create()
.region()
.withName("cqTestRegion")
.withType("REPLICATE")
- .execute(), 0);
- cache_.TypeRegistry.RegisterPdxType(MyOrder.CreateDeserializable);
- var poolFactory = cache_.GetPoolFactory()
- .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
- var pool = poolFactory
+ .execute());
+
+ var cache = cluster.CreateCache();
+
+ cache.TypeRegistry.RegisterPdxType(MyOrder.CreateDeserializable);
+
+ var pool = cluster.ApplyLocators(cache.GetPoolFactory())
.SetSubscriptionEnabled(true)
.Create("pool");
- var regionFactory = cache_.CreateRegionFactory(RegionShortcut.PROXY)
+ var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
.SetPoolName("pool");
var region = regionFactory.Create<string, MyOrder>("cqTestRegion");
@@ -257,38 +251,39 @@ namespace Apache.Geode.Client.IntegrationTests
Assert.True(cqListener.RegionClearEvent.WaitOne(waitInterval_), "Didn't receive expected CLEAR event");
Assert.False(cqListener.ReceivedUnknownEventType, "An unknown event was received by CQ listener");
+
+ cache.Close();
}
}
[Fact]
public void DataSerializableNotificationsHaveCorrectValues()
{
- using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
- Assert.Equal(cluster_.Start(), true);
- Assert.Equal(cluster_.Gfsh.deploy()
+ Assert.True(cluster.Start());
+ Assert.Equal(0, cluster.Gfsh.deploy()
.withJar(Config.JavaobjectJarPath)
- .execute(), 0);
- Assert.Equal(cluster_.Gfsh.create()
+ .execute());
+ Assert.Equal(0, cluster.Gfsh.create()
.region()
.withName("cqTestRegion")
.withType("REPLICATE")
- .execute(), 0);
-
- cluster_.Gfsh.executeFunction()
+ .execute());
+ Assert.Equal(0, cluster.Gfsh.executeFunction()
.withId("InstantiateDataSerializable")
- .withMember("DataSerializableNotificationsH_server_0")
- .execute();
+ .withMember("DataSerializableNotificationsHaveCorrectValues_server_0")
+ .execute());
+
+ var cache = cluster.CreateCache();
- cache_.TypeRegistry.RegisterType(Position.CreateDeserializable, 22);
+ cache.TypeRegistry.RegisterType(Position.CreateDeserializable, 22);
- var poolFactory = cache_.GetPoolFactory()
- .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
- var pool = poolFactory
+ var pool = cluster.ApplyLocators(cache.GetPoolFactory())
.SetSubscriptionEnabled(true)
.Create("pool");
- var regionFactory = cache_.CreateRegionFactory(RegionShortcut.PROXY)
+ var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
.SetPoolName("pool");
var region = regionFactory.Create<string, Position>("cqTestRegion");
@@ -336,6 +331,8 @@ namespace Apache.Geode.Client.IntegrationTests
Assert.True(cqListener.RegionClearEvent.WaitOne(waitInterval_), "Didn't receive expected CLEAR event");
Assert.False(cqListener.ReceivedUnknownEventType, "An unknown event was received by CQ listener");
+
+ cache.Close();
}
}
}
diff --git a/clicache/integration-test2/TestBase.cs b/clicache/integration-test2/Framework.cs
similarity index 51%
copy from clicache/integration-test2/TestBase.cs
copy to clicache/integration-test2/Framework.cs
index 40338de..027fd32 100644
--- a/clicache/integration-test2/TestBase.cs
+++ b/clicache/integration-test2/Framework.cs
@@ -15,39 +15,21 @@
* limitations under the License.
*/
-using System;
-using System.Diagnostics;
+ using System.Net;
using System.IO;
-using System.Reflection;
-using Xunit;
+using System.Net.Sockets;
namespace Apache.Geode.Client.IntegrationTests
{
- [Trait("Category", "Integration")]
- public class TestBase
+ public abstract class Framework
{
- private const int MaxAllowedDirectoryCharacters = 30;
-
- public void CleanTestCaseDirectory(string directory)
+ public static int FreeTcpPort()
{
- if (Directory.Exists(directory))
- {
- Directory.Delete(directory, true);
- }
- }
-
- public string CreateTestCaseDirectoryName()
- {
- var st = new StackTrace();
- var sf = st.GetFrame(1);
- var currentMethod = sf.GetMethod();
- var dirName = currentMethod.Name;
-
- if (dirName.Length > MaxAllowedDirectoryCharacters)
- {
- dirName = dirName.Substring(0, MaxAllowedDirectoryCharacters);
- }
- return dirName;
+ var tcpListner = new TcpListener(IPAddress.Loopback, 0);
+ tcpListner.Start();
+ var port = ((IPEndPoint)tcpListner.LocalEndpoint).Port;
+ tcpListner.Stop();
+ return port;
}
}
-}
+}
\ No newline at end of file
diff --git a/clicache/integration-test2/FunctionExecutionTest.cs b/clicache/integration-test2/FunctionExecutionTest.cs
index 69f59bd..6688d31 100644
--- a/clicache/integration-test2/FunctionExecutionTest.cs
+++ b/clicache/integration-test2/FunctionExecutionTest.cs
@@ -20,132 +20,117 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
- [Trait("Category", "Integration")]
+ [Trait("Category", "Integration")]
public class FunctionExecutionTest : TestBase
{
+ public FunctionExecutionTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
+ {
+ }
+
[Fact]
public void MultiGetFunctionExecutionWithFilter()
{
int expectedFilteredCount = 34;
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
- Assert.Equal(cluster.Start(), true);
- Assert.Equal(cluster.Gfsh.deploy()
+ Assert.True(cluster.Start());
+ Assert.Equal(0, cluster.Gfsh.deploy()
.withJar(Config.JavaobjectJarPath)
- .execute(), 0);
- Assert.Equal(cluster.Gfsh
- .create()
- .region()
+ .execute());
+ Assert.Equal(0, cluster.Gfsh.create().region()
.withName("testRegion1")
.withType("PARTITION")
- .execute(), 0);
-
- var cacheFactory = new CacheFactory();
- var cacheOne = cacheFactory.Create();
- cacheOne.GetPoolFactory()
- .AddLocator(cluster.Gfsh.LocatorBindAddress, cluster.Gfsh.LocatorPort)
- .Create("pool");
- var regionFactory = cacheOne.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
- var region = regionFactory.Create<object, object>("testRegion1");
-
- for (int i = 0; i < 230; i++)
+ .execute());
+
+ var cache = cluster.CreateCache();
+ var region = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default")
+ .Create<object, object>("testRegion1");
+
+ for (var i = 0; i < 230; i++)
{
region["KEY--" + i] = "VALUE--" + i;
}
- object args = true;
-
+ var args = true;
- Object[] oddKeyFilter = new Object[17];
- int j = 0;
- for (int i = 0; i < 34; i++)
+ var oddKeyFilter = new Object[17];
+ var j = 0;
+ for (var i = 0; i < 34; i++)
{
if (i % 2 == 0) continue;
oddKeyFilter[j] = "KEY--" + i;
j++;
}
- Apache.Geode.Client.Execution<object> exc = Client.FunctionService<object>.OnRegion<object, object>(region);
- Client.IResultCollector<object> rc = exc.WithArgs<object>(args).WithFilter<object>(oddKeyFilter).Execute("MultiGetFunction");
- ICollection<object> executeFunctionResult = rc.GetResult();
- List<object> resultList = new List<object>();
- foreach (List<object> item in executeFunctionResult)
+ var exc = Client.FunctionService<List<object>>.OnRegion<object, object>(region);
+ var rc = exc.WithArgs<bool>(args).WithFilter<object>(oddKeyFilter).Execute("MultiGetFunction");
+ var executeFunctionResult = rc.GetResult();
+ var resultList = new List<object>();
+
+ foreach (var item in executeFunctionResult)
{
foreach (object item2 in item)
{
resultList.Add(item2);
}
}
- Assert.True(resultList.Count == expectedFilteredCount, "result count check failed");
+ Assert.Equal(expectedFilteredCount, resultList.Count);
}
}
- [Fact]
- public void MultiGetIFunctionExecutionWithArgs()
- {
- int expectedResultCount = 17;
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
- {
- Assert.Equal(cluster.Start(), true);
- Assert.Equal(cluster.Gfsh.deploy()
- .withJar(Config.JavaobjectJarPath)
- .execute(), 0);
- Assert.Equal(cluster.Gfsh
- .create()
- .region()
- .withName("partition_region")
- .withType("PARTITION")
- .execute(), 0);
-
- var cacheFactory = new CacheFactory();
- var cacheOne = cacheFactory.Create();
- cacheOne.GetPoolFactory()
- .AddLocator(cluster.Gfsh.LocatorBindAddress, cluster.Gfsh.LocatorPort)
- .Create("pool");
- var regionFactory = cacheOne.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
- var region = regionFactory.Create<object, object>("partition_region");
-
- for (int i = 0; i < 230; i++)
+ [Fact]
+ public void MultiGetIFunctionExecutionWithArgs()
{
- region["KEY--" + i] = "VALUE--" + i;
- }
+ int expectedResultCount = 17;
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
+ {
+ Assert.True(cluster.Start());
+ Assert.Equal(0, cluster.Gfsh.deploy()
+ .withJar(Config.JavaobjectJarPath)
+ .execute());
+ Assert.Equal(0, cluster.Gfsh.create().region()
+ .withName("partition_region")
+ .withType("PARTITION")
+ .execute());
- object args = true;
- Object[] oddKeyFilter = new Object[17];
- int j = 0;
- for (int i = 0; i < 34; i++)
- {
- if (i % 2 == 0) continue;
- oddKeyFilter[j] = "KEY--" + i;
- j++;
- }
+ var cache = cluster.CreateCache();
- ArrayList oddKeyArgs = new ArrayList();
- for (int i = 0; i < oddKeyFilter.Length; i++)
- {
- oddKeyArgs.Add(oddKeyFilter[i]);
- }
- Apache.Geode.Client.Execution<object> exc = Client.FunctionService<object>.OnRegion<object, object>(region);
- Client.IResultCollector<object> rc = exc.WithArgs<ArrayList>(oddKeyArgs).Execute("MultiGetFunctionI");
- ICollection<object> executeFunctionResult = rc.GetResult();
- List<object> resultList = new List<object>();
+ var region = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default")
+ .Create<object, object>("partition_region");
- foreach (List<object> item in executeFunctionResult)
- {
- foreach (object item2 in item)
- {
- resultList.Add(item2);
- }
- }
- Assert.True(resultList.Count == expectedResultCount, "result count check failed");
+ for (var i = 0; i < 230; i++)
+ {
+ region["KEY--" + i] = "VALUE--" + i;
+ }
+
+ var oddKeyArgs = new ArrayList();
+ for (var i = 0; i < 34; i++)
+ {
+ if (i % 2 == 0) continue;
+ oddKeyArgs.Add("KEY--" + i);
+ }
- }
+ var exc = Client.FunctionService<List<object>>.OnRegion<object, object>(region);
+ var rc = exc.WithArgs<ArrayList>(oddKeyArgs).Execute("MultiGetFunctionI");
+ var executeFunctionResult = rc.GetResult();
+ var resultList = new List<object>();
+
+ foreach (var item in executeFunctionResult)
+ {
+ foreach (var item2 in item)
+ {
+ resultList.Add(item2);
+ }
+ }
+ Assert.Equal(expectedResultCount, resultList.Count);
+ }
+ }
}
- }
}
diff --git a/clicache/integration-test2/Gfsh.cs b/clicache/integration-test2/Gfsh.cs
index 08cbbd4..826c1fd 100644
--- a/clicache/integration-test2/Gfsh.cs
+++ b/clicache/integration-test2/Gfsh.cs
@@ -26,21 +26,8 @@ using System.Collections.Generic;
namespace Apache.Geode.Client.IntegrationTests
{
- public abstract class Gfsh : IDisposable
+ public abstract class Gfsh
{
- public string Name { get; private set; }
- public string LocatorBindAddress { get; set; }
- public int LocatorPort { get; private set; }
- public int JmxManagerPort { get; private set; }
- public int HttpServicePort { get; private set; }
- public string ServerBindAddress { get; private set; }
- public bool UseSSL { get; set; }
- public string Keystore { get; set; }
- public string KeystorePassword { get; set; }
- public string Truststore { get; set; }
- public string TruststorePassword { get; set; }
-
- public abstract void Dispose();
//TODO: Understand what C++ Command class is doing. Why is it a template,
//when the only <T> class we're passing is void? How can you call a ctor
@@ -52,6 +39,7 @@ namespace Apache.Geode.Client.IntegrationTests
gfsh_ = gfsh;
command_ = command;
}
+
public int execute()
{
return gfsh_.execute(command_);
@@ -79,6 +67,7 @@ namespace Apache.Geode.Client.IntegrationTests
{
gfsh_ = gfsh;
}
+
public Server withName(string name)
{
command_ += " --name=" + name;
@@ -93,7 +82,7 @@ namespace Apache.Geode.Client.IntegrationTests
public Server withBindAddress(string bindAddress)
{
- gfsh_.ServerBindAddress = bindAddress;
+ command_ += " --bind-address=" + bindAddress;
return this;
}
@@ -121,13 +110,33 @@ namespace Apache.Geode.Client.IntegrationTests
return this;
}
- public Server withUseSsl()
+ public Server withSslKeyStore(string keyStore)
+ {
+ command_ += " --J=-Dgemfire.ssl-keystore=" + keyStore;
+ return this;
+ }
+
+ public Server withSslKeyStorePassword(string keyStorePassword)
+ {
+ command_ += " --J=-Dgemfire.ssl-keystore-password=" + keyStorePassword;
+ return this;
+ }
+
+ public Server withSslTrustStore(string trustStore)
+ {
+ command_ += " --J=-Dgemfire.ssl-truststore=" + trustStore;
+ return this;
+ }
+
+ public Server withSslTrustStorePassword(string trustStorePassword)
+ {
+ command_ += " --J=-Dgemfire.ssl-truststore-password=" + trustStorePassword;
+ return this;
+ }
+
+ public Server withSslEnableComponents(string components)
{
- command_ += " --J=-Dgemfire.ssl-enabled-components=server,locator,jmx" +
- " --J=-Dgemfire.ssl-keystore=" + gfsh_.Keystore +
- " --J=-Dgemfire.ssl-keystore-password=" + gfsh_.KeystorePassword +
- " --J=-Dgemfire.ssl-truststore=" + gfsh_.Truststore +
- " --J=-Dgemfire.ssl-truststore-password=" + gfsh_.TruststorePassword;
+ command_ += " --J=-Dgemfire.ssl-enabled-components=" + components;
return this;
}
}
@@ -157,24 +166,31 @@ namespace Apache.Geode.Client.IntegrationTests
public Locator withBindAddress(string bindAddress)
{
- gfsh_.LocatorBindAddress = bindAddress;
+ command_ += " --bind-address=" + bindAddress;
return this;
}
public Locator withPort(int port)
{
- gfsh_.LocatorPort = port;
+ command_ += " --port=" + port;
return this;
}
+
public Locator withJmxManagerPort(int jmxManagerPort)
{
- gfsh_.JmxManagerPort = jmxManagerPort;
+ command_ += " --J=-Dgemfire.jmx-manager-port=" + jmxManagerPort;
return this;
}
- public Locator withHttpServicePort(short httpServicePort)
+ public Locator withJmxManagerStart(bool start)
{
- command_ += " --http-service-port=" + Convert.ToString(httpServicePort);
+ command_ += " --J=-Dgemfire.jmx-manager-start=" + (start ? "true" : "false");
+ return this;
+ }
+
+ public Locator withHttpServicePort(int httpServicePort)
+ {
+ command_ += " --http-service-port=" + httpServicePort;
return this;
}
@@ -197,13 +213,33 @@ namespace Apache.Geode.Client.IntegrationTests
return this;
}
- public Locator withUseSsl()
+ public Locator withSslKeyStore(string keyStore)
+ {
+ command_ += " --J=-Dgemfire.ssl-keystore=" + keyStore;
+ return this;
+ }
+
+ public Locator withSslKeyStorePassword(string keyStorePassword)
+ {
+ command_ += " --J=-Dgemfire.ssl-keystore-password=" + keyStorePassword;
+ return this;
+ }
+
+ public Locator withSslTrustStore(string trustStore)
{
- command_ += " --J=-Dgemfire.ssl-enabled-components=locator,jmx" +
- " --J=-Dgemfire.ssl-keystore=" + gfsh_.Keystore +
- " --J=-Dgemfire.ssl-keystore-password=" + gfsh_.KeystorePassword +
- " --J=-Dgemfire.ssl-truststore=" + gfsh_.Truststore +
- " --J=-Dgemfire.ssl-truststore-password=" + gfsh_.TruststorePassword;
+ command_ += " --J=-Dgemfire.ssl-truststore=" + trustStore;
+ return this;
+ }
+
+ public Locator withSslTrustStorePassword(string trustStorePassword)
+ {
+ command_ += " --J=-Dgemfire.ssl-truststore-password=" + trustStorePassword;
+ return this;
+ }
+
+ public Locator withSslEnableComponents(string components)
+ {
+ command_ += " --J=-Dgemfire.ssl-enabled-components=" + components;
return this;
}
}
@@ -227,6 +263,7 @@ namespace Apache.Geode.Client.IntegrationTests
{
gfsh_ = gfsh;
}
+
public class Locator : Command
{
public Locator(Gfsh gfsh) : base(gfsh, "stop locator")
@@ -250,6 +287,7 @@ namespace Apache.Geode.Client.IntegrationTests
{
return new Locator(gfsh_);
}
+
public class Server : Command
{
public Server(Gfsh gfsh) : base(gfsh, "stop server")
@@ -344,12 +382,33 @@ namespace Apache.Geode.Client.IntegrationTests
return this;
}
- public Connect withUseSsl()
+ public Connect withUseSsl(bool enable)
{
- command_ += " --use-ssl --key-store=" + gfsh_.Keystore +
- " --key-store-password=" + gfsh_.KeystorePassword +
- " --trust-store=" + gfsh_.Truststore +
- " --trust-store-password=" + gfsh_.TruststorePassword;
+ command_ += " --use-ssl=" + (enable ? "true" : "false");
+ return this;
+ }
+
+ public Connect withKeyStore(string keyStore)
+ {
+ command_ += " --key-store=" + keyStore;
+ return this;
+ }
+
+ public Connect withKeyStorePassword(string keyStorePassword)
+ {
+ command_ += " --key-store-password=" + keyStorePassword;
+ return this;
+ }
+
+ public Connect withTrustStore(string trustStore)
+ {
+ command_ += " --trust-store=" + trustStore;
+ return this;
+ }
+
+ public Connect withTrustStorePassword(string trustStorePassword)
+ {
+ command_ += " --trust-store-password=" + trustStorePassword;
return this;
}
}
@@ -426,17 +485,6 @@ namespace Apache.Geode.Client.IntegrationTests
return new ExecuteFunction(this);
}
- private static string defaultBindAddress = "localhost";
- private static int defaultHttpServicePort = 0;
- public Gfsh()
- {
- LocatorBindAddress = defaultBindAddress;
- HttpServicePort = defaultHttpServicePort;
- ServerBindAddress = defaultBindAddress;
- LocatorPort = FreeTcpPort();
- JmxManagerPort = FreeTcpPort();
- }
-
private static int FreeTcpPort()
{
var tcpListner = new TcpListener(IPAddress.Loopback, 0);
diff --git a/clicache/integration-test2/GfshExecute.cs b/clicache/integration-test2/GfshExecute.cs
index 034d0dc..54117df 100644
--- a/clicache/integration-test2/GfshExecute.cs
+++ b/clicache/integration-test2/GfshExecute.cs
@@ -21,82 +21,75 @@ using System.Net;
using System.IO;
using System.Net.Sockets;
using Xunit;
+using System.Collections;
+using System.Text.RegularExpressions;
+using System.Collections.Generic;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
public class GfshExecute : Gfsh
{
- public GfshExecute()
- {
- }
- public override void Dispose()
- {
- }
-
- private static string startLocator = "start locator";
- private static string startServer = "start server";
+ private String connectionCommand_ = null;
+ private ITestOutputHelper output;
- private string buildStartLocatorCommand(string options)
+ public GfshExecute(ITestOutputHelper output)
{
- var locatorCmd = startLocator;
- locatorCmd += " --port=" + LocatorPort;
- locatorCmd += " --bind-address=" + LocatorBindAddress;
- locatorCmd += " --J=-Dgemfire.jmx-manager-port=" + JmxManagerPort + " ";
- locatorCmd += " --J=-Dgemfire.jmx-manager-start=true";
- locatorCmd += options;
- return locatorCmd;
+ this.output = output;
}
- private string buildStartServerCommand(string options)
+ private void ExtractConnectionCommand(String command)
{
- var connectObject = connect()
- .withJmxManager(LocatorBindAddress, JmxManagerPort);
- if (UseSSL)
+ if (command.StartsWith("connect"))
{
- connectObject
- .withUseSsl();
+ connectionCommand_ = command;
}
- var serverCmd = "-e \"" + connectObject.ToString() + "\" -e \"" + startServer;
- serverCmd += " --bind-address=" + ServerBindAddress;
- serverCmd += options + "\"";
- return serverCmd;
- }
-
- private string buildConnectAndExecuteString(string options)
- {
- var connectObject = connect()
- .withJmxManager(LocatorBindAddress, JmxManagerPort);
- if (UseSSL)
+ else if (command.StartsWith("start locator"))
{
- connectObject
- .withUseSsl();
+ if (command.Contains("--connect=false"))
+ {
+ return;
+ }
+
+ var jmxManagerHost = "localhost";
+ var jmxManagerPort = "1099";
+
+ var jmxManagerHostRegex = new Regex(@"\bbind-address=([^\s])\b");
+ var jmxManagerHostMatch = jmxManagerHostRegex.Match(command);
+
+ if (jmxManagerHostMatch.Success)
+ {
+ jmxManagerHost = jmxManagerHostMatch.Groups[1].Value;
+ }
+
+ var jmxManagerPortRegex = new Regex(@"\bjmx-manager-port=(\d+)\b");
+ var jmxManagerPortMatch = jmxManagerPortRegex.Match(command);
+ if (jmxManagerPortMatch.Success)
+ {
+ jmxManagerPort = jmxManagerPortMatch.Groups[1].Value;
+ }
+
+ connectionCommand_ = new Connect(this).withJmxManager(jmxManagerHost, int.Parse(jmxManagerPort)).ToString();
}
- return "-e \"" + connectObject.ToString() + "\" -e \"" + options + "\"";
+
}
- private string BuildFullCommandString(string baseCmd)
+ public override int execute(string cmd)
{
- string fullCmd;
- if (baseCmd.IndexOf(startLocator) == 0)
- {
- fullCmd = buildStartLocatorCommand(baseCmd.Substring(startLocator.Length));
- }
- else if (baseCmd.IndexOf(startServer) == 0)
- {
- fullCmd = buildStartServerCommand(baseCmd.Substring(startServer.Length));
- }
- else
+ var commands = new List<string>();
+
+ if (null != connectionCommand_)
{
- fullCmd = buildConnectAndExecuteString(baseCmd);
+ commands.Add("-e");
+ commands.Add(connectionCommand_);
}
- return fullCmd;
- }
+ commands.Add("-e");
+ commands.Add(cmd);
- public override int execute(string cmd)
- {
- var fullCmd = BuildFullCommandString(cmd);
+ // TODO escape commands
+ var fullCmd = "\"" + string.Join("\" \"", commands) + "\"";
var gfsh = new Process
{
@@ -116,7 +109,7 @@ namespace Apache.Geode.Client.IntegrationTests
{
if (args.Data != null)
{
- Debug.WriteLine("GfshExecute: " + args.Data);
+ WriteLine("GfshExecute: " + args.Data);
}
};
@@ -124,7 +117,7 @@ namespace Apache.Geode.Client.IntegrationTests
{
if (args.Data != null)
{
- Debug.WriteLine("GfshExecute: ERROR: " + args.Data);
+ WriteLine("GfshExecute: ERROR: " + args.Data);
}
};
@@ -133,24 +126,81 @@ namespace Apache.Geode.Client.IntegrationTests
gfsh.BeginErrorReadLine();
if (gfsh.WaitForExit(60000))
{
- Debug.WriteLine("GeodeServer Start: gfsh.HasExited = {0}, gfsh.ExitCode = {1}",
+ WriteLine("GeodeServer Start: gfsh.HasExited = {0}, gfsh.ExitCode = {1}",
gfsh.HasExited,
gfsh.ExitCode);
}
else
{
- Debug.WriteLine("GeodeServer Start: gfsh failed to exit, force killing.");
- try
- {
- gfsh.Kill();
- }
- catch
- {
- // ignored
- }
+ WriteLine("GeodeServer Start: gfsh failed to exit, force killing.");
+ KillAndIgnore(gfsh);
}
+ CancelErrorReadAndIgnore(gfsh);
+ CancelOutputReadAndIgnore(gfsh);
+
+ ExtractConnectionCommand(cmd);
return gfsh.ExitCode;
}
+
+ private static void CancelOutputReadAndIgnore(Process gfsh)
+ {
+ try
+ {
+ gfsh.CancelOutputRead();
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+
+ private static void CancelErrorReadAndIgnore(Process gfsh)
+ {
+ try
+ {
+ gfsh.CancelErrorRead();
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+
+ private static void KillAndIgnore(Process gfsh)
+ {
+ try
+ {
+ gfsh.Kill();
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+
+ private void WriteLine(string format, params object[] args)
+ {
+ if (null == output)
+ {
+ Debug.WriteLine(format, args);
+ }
+ else
+ {
+ output.WriteLine(format, args);
+ }
+ }
+
+ private void WriteLine(string message)
+ {
+ if (null == output)
+ {
+ Debug.WriteLine(message);
+ }
+ else
+ {
+ output.WriteLine(message);
+ }
+ }
}
}
diff --git a/clicache/integration-test2/GfshExecuteTest.cs b/clicache/integration-test2/GfshExecuteTest.cs
index 105c3cf..399b58f 100644
--- a/clicache/integration-test2/GfshExecuteTest.cs
+++ b/clicache/integration-test2/GfshExecuteTest.cs
@@ -17,259 +17,270 @@
using System;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
[Trait("Category", "Integration")]
public class GfshExecuteTest : TestBase, IDisposable
{
- public void Dispose()
+ public GfshExecuteTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
-
}
- [Fact]
- public void GfshExecuteStartLocatorTest()
+ public void Dispose()
{
- using (var gfsh = new GfshExecute())
- {
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
- try
- {
- Assert.Equal(gfsh.start()
- .locator()
- .withDir(testDir)
- .withHttpServicePort(0)
- .withPort(gfsh.LocatorPort)
- .execute(), 0);
- }
- finally
- {
- Assert.Equal(gfsh
- .shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
- }
}
[Fact]
- public void GfshExecuteStartServerTest()
+ public void Start1Locator()
{
- using (var gfsh = new GfshExecute())
- {
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
-
- try
- {
- Assert.Equal(gfsh.start()
- .locator()
- .withDir(testDir)
- .withHttpServicePort(0)
- .withPort(gfsh.LocatorPort)
- .execute(), 0);
+ var gfsh = new GfshExecute(output);
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
- Assert.Equal(gfsh.start()
- .server()
- .withDir(testDir + "/server/0")
- .withPort(0)
- .execute(), 0);
- }
- finally
- {
- Assert.Equal(gfsh
- .shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
+ try
+ {
+ Assert.Equal(0, gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withPort(Framework.FreeTcpPort())
+ .withJmxManagerPort(Framework.FreeTcpPort())
+ .execute());
+ }
+ finally
+ {
+ Assert.Equal(0, gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute());
}
}
[Fact]
- public void GfshExecuteStartTwoServersTest()
+ public void Start1Locator1Server()
{
- using (var gfsh1 = new GfshExecute())
- {
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
-
- try
- {
- Assert.Equal(gfsh1.start()
- .locator()
- .withDir(testDir)
- .withHttpServicePort(0)
- .execute(), 0);
+ var gfsh = new GfshExecute(output);
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
- Assert.Equal(gfsh1.start()
- .server()
- .withDir(testDir + "/server/0")
- .withPort(0)
- .execute(), 0);
+ try
+ {
+ Assert.Equal(0, gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withPort(Framework.FreeTcpPort())
+ .withJmxManagerPort(Framework.FreeTcpPort())
+ .execute());
- Assert.Equal(gfsh1.start()
- .server()
- .withDir(testDir + "/server/1")
- .withPort(0)
- .execute(), 0);
- }
- finally
- {
- Assert.Equal(gfsh1.shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
+ Assert.Equal(0, gfsh.start()
+ .server()
+ .withDir(testDir + "/server/0")
+ .withPort(0)
+ .execute());
+ }
+ finally
+ {
+ Assert.Equal(0, gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute());
}
}
[Fact]
- public void GfshExecuteStartLocatorWithUseSslTest()
+ public void Start1Locator2Servers()
{
- using (var gfsh = new GfshExecute())
+ var gfsh = new GfshExecute(output);
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ try
{
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
+ Assert.Equal(0, gfsh.start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withPort(Framework.FreeTcpPort())
+ .withJmxManagerPort(Framework.FreeTcpPort())
+ .execute());
- var sslPassword = "gemstone";
- var currentDir = Environment.CurrentDirectory;
- gfsh.Keystore = currentDir + "/ServerSslKeys/server_keystore.jks";
- gfsh.KeystorePassword = sslPassword;
- gfsh.Truststore = currentDir + "/ServerSslKeys/server_truststore.jks";
- gfsh.TruststorePassword = sslPassword;
- gfsh.UseSSL = true;
+ Assert.Equal(0, gfsh.start()
+ .server()
+ .withDir(testDir + "/server/0")
+ .withPort(0)
+ .execute());
- try
- {
- var locator = gfsh
- .start()
- .locator()
- .withDir(testDir)
- .withHttpServicePort(0)
- .withUseSsl()
- .withConnect(false);
-
- Assert.Equal(locator.execute(), 0);
- }
- finally
- {
- Assert.Equal(gfsh
- .shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
+ Assert.Equal(0, gfsh.start()
+ .server()
+ .withDir(testDir + "/server/1")
+ .withPort(0)
+ .execute());
+ }
+ finally
+ {
+ Assert.Equal(0, gfsh.shutdown()
+ .withIncludeLocators(true)
+ .execute());
}
}
[Fact]
- public void GfshExecuteStartLocatorAndServerWithUseSslTest()
+ public void Start1LocatorWithSSL()
{
- using (var gfsh = new GfshExecute())
- {
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
+ var gfsh = new GfshExecute(output);
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
- var sslPassword = "gemstone";
- var currentDir = Environment.CurrentDirectory;
- gfsh.Keystore = currentDir + "/ServerSslKeys/server_keystore.jks";
- gfsh.KeystorePassword = sslPassword;
- gfsh.Truststore = currentDir + "/ServerSslKeys/server_truststore.jks";
- gfsh.TruststorePassword = sslPassword;
- gfsh.UseSSL = true;
+ var sslPassword = "gemstone";
+ var currentDir = Environment.CurrentDirectory;
+ var keystore = currentDir + @"\ServerSslKeys\server_keystore.jks";
+ var truststore = currentDir + @"\ServerSslKeys\server_truststore.jks";
+ var jmxManagerPort = Framework.FreeTcpPort();
- try
- {
- Assert.Equal(gfsh
- .start()
- .locator()
- .withDir(testDir)
- .withHttpServicePort(0)
- .withUseSsl()
- .withConnect(false)
- .execute(), 0);
+ try
+ {
+ Assert.Equal(0, gfsh
+ .start()
+ .locator()
+ .withDir(testDir)
+ .withHttpServicePort(0)
+ .withPort(Framework.FreeTcpPort())
+ .withJmxManagerPort(jmxManagerPort)
+ .withJmxManagerStart(true)
+ .withSslEnableComponents("locator,jmx")
+ .withSslKeyStore(keystore)
+ .withSslKeyStorePassword(sslPassword)
+ .withSslTrustStore(truststore)
+ .withSslTrustStorePassword(sslPassword)
+ .withConnect(false)
+ .execute());
- Assert.Equal(gfsh
- .start()
- .server()
- .withDir(testDir + "/server/0")
- .withPort(0)
- .withUseSsl()
- .execute(), 0);
- }
- finally
- {
- Assert.Equal(gfsh
- .shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
+ Assert.Equal(0, gfsh
+ .connect()
+ .withJmxManager("localhost", jmxManagerPort)
+ .withUseSsl(true)
+ .withKeyStore(keystore)
+ .withKeyStorePassword(sslPassword)
+ .withTrustStore(truststore)
+ .withTrustStorePassword(sslPassword)
+ .execute());
+ }
+ finally
+ {
+ Assert.Equal(0, gfsh
+ .shutdown()
+ .withIncludeLocators(true)
+ .execute());
}
}
[Fact]
- public void GfshExecuteStartLocatorAndVerifyPortTest()
+ public void Start1Locator1ServerWithSSL()
{
- using (var gfsh = new GfshExecute())
- {
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
+ var gfsh = new GfshExecute(output);
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
- Assert.Equal(gfsh.start()
+ var sslPassword = "gemstone";
+ var currentDir = Environment.CurrentDirectory;
+ var keystore = currentDir + @"\ServerSslKeys\server_keystore.jks";
+ var truststore = currentDir + @"\ServerSslKeys\server_truststore.jks";
+ var jmxManagerPort = Framework.FreeTcpPort();
+
+ try
+ {
+ Assert.Equal(0, gfsh
+ .start()
.locator()
.withDir(testDir)
.withHttpServicePort(0)
- .execute(), 0);
+ .withPort(Framework.FreeTcpPort())
+ .withJmxManagerPort(jmxManagerPort)
+ .withJmxManagerStart(true)
+ .withSslEnableComponents("locator,jmx")
+ .withSslKeyStore(keystore)
+ .withSslKeyStorePassword(sslPassword)
+ .withSslTrustStore(truststore)
+ .withSslTrustStorePassword(sslPassword)
+ .withConnect(false)
+ .execute());
- Assert.NotEqual(0, gfsh.LocatorPort);
+ Assert.Equal(0, gfsh
+ .connect()
+ .withJmxManager("localhost", jmxManagerPort)
+ .withUseSsl(true)
+ .withKeyStore(keystore)
+ .withKeyStorePassword(sslPassword)
+ .withTrustStore(truststore)
+ .withTrustStorePassword(sslPassword)
+ .execute());
- Assert.Equal(gfsh.shutdown()
+ Assert.Equal(0, gfsh
+ .start()
+ .server()
+ .withDir(testDir + "/server/0")
+ .withPort(0)
+ .withSslEnableComponents("server,locator,jmx")
+ .withSslKeyStore(keystore)
+ .withSslKeyStorePassword(sslPassword)
+ .withSslTrustStore(truststore)
+ .withSslTrustStorePassword(sslPassword)
+ .execute());
+ }
+ finally
+ {
+ Assert.Equal(0, gfsh
+ .shutdown()
.withIncludeLocators(true)
- .execute(), 0);
+ .execute());
}
}
[Fact]
- public void GfshExecuteStartTwoLocatorsTest()
+ public void Start2ClustersWith1Locator1ServerEach()
{
- using (var gfsh1 = new GfshExecute())
+ var gfsh1 = new GfshExecute(output);
+ var testDir = CreateTestCaseDirectoryName();
+ CleanTestCaseDirectory(testDir);
+
+ try
{
- var testDir = CreateTestCaseDirectoryName();
- CleanTestCaseDirectory(testDir);
+ Assert.Equal(0, gfsh1.start()
+ .locator()
+ .withDir(testDir + "/locator/0")
+ .withHttpServicePort(0)
+ .withPort(Framework.FreeTcpPort())
+ .withJmxManagerPort(Framework.FreeTcpPort())
+ .execute());
+ var gfsh2 = new GfshExecute(output);
try
{
- Assert.Equal(gfsh1.start()
+ Assert.Equal(0, gfsh2.start()
.locator()
- .withDir(testDir + "/locator/0")
+ .withDir(testDir + "/locator/1")
.withHttpServicePort(0)
- .execute(), 0);
-
- using (var gfsh2 = new GfshExecute())
- {
- try
- {
- Assert.Equal(gfsh2.start()
- .locator()
- .withDir(testDir + "/locator/1")
- .withHttpServicePort(0)
- .execute(), 0);
- }
- finally
- {
- Assert.Equal(gfsh2.shutdown()
- .withIncludeLocators(true)
- .execute(), 0);
- }
- }
+ .withPort(Framework.FreeTcpPort())
+ .withJmxManagerPort(Framework.FreeTcpPort())
+ .execute());
}
finally
{
- Assert.Equal(gfsh1.shutdown()
+ Assert.Equal(0, gfsh2.shutdown()
.withIncludeLocators(true)
- .execute(), 0);
+ .execute());
}
+
+ }
+ finally
+ {
+ Assert.Equal(0, gfsh1.shutdown()
+ .withIncludeLocators(true)
+ .execute());
}
}
}
diff --git a/clicache/integration-test2/GfshTest.cs b/clicache/integration-test2/GfshTest.cs
index dcf6528..819bf08 100644
--- a/clicache/integration-test2/GfshTest.cs
+++ b/clicache/integration-test2/GfshTest.cs
@@ -18,22 +18,22 @@
using System;
using System.Collections.Generic;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
[Trait("Category", "Integration")]
- public class GfshTest : IDisposable
+ public class GfshTest : TestBase
{
- public void Dispose()
+ public GfshTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
-
}
[Fact]
public void InstantiateGfshClassesTest()
{
- var gfsh = new GfshExecute();
+ var gfsh = new GfshExecute(output);
var start = gfsh.start();
Assert.NotNull(start);
@@ -53,19 +53,13 @@ namespace Apache.Geode.Client.IntegrationTests
[Fact]
public void StartLocatorStringsTest()
{
- var Gfsh = new GfshExecute();
-
- var currentDir = Environment.CurrentDirectory;
- Gfsh.Keystore = "some/path/keystore.jks";
- Gfsh.KeystorePassword = "password";
- Gfsh.Truststore = "some/path/truststore.jks";
- Gfsh.TruststorePassword = "password";
+ var Gfsh = new GfshExecute(output);
var locator = Gfsh
.start()
.locator();
var s = locator.ToString();
- Assert.True(s.Equals("start locator"));
+ Assert.Equal("start locator", s);
locator = Gfsh
.start()
@@ -79,31 +73,31 @@ namespace Apache.Geode.Client.IntegrationTests
.withLogLevel("fine")
.withMaxHeap("someHugeAmount")
.withConnect(false)
- .withUseSsl();
+ .withSslEnableComponents("locator,jmx")
+ .withSslKeyStore("some/path/keystore.jks")
+ .withSslKeyStorePassword("password1")
+ .withSslTrustStore("some/path/truststore.jks")
+ .withSslTrustStorePassword("password2");
s = locator.ToString();
- Assert.Equal(s, "start locator --name=name --dir=dir " +
- "--http-service-port=2222 --log-level=fine --max-heap=someHugeAmount " +
+ Assert.Equal("start locator --name=name --dir=dir --bind-address=address --port=420 " +
+ "--J=-Dgemfire.jmx-manager-port=1111 --http-service-port=2222 --log-level=fine --max-heap=someHugeAmount " +
"--connect=false --J=-Dgemfire.ssl-enabled-components=locator,jmx " +
- "--J=-Dgemfire.ssl-keystore=some/path/keystore.jks --J=-Dgemfire.ssl-keystore-password=password " +
- "--J=-Dgemfire.ssl-truststore=some/path/truststore.jks --J=-Dgemfire.ssl-truststore-password=password");
+ "--J=-Dgemfire.ssl-keystore=some/path/keystore.jks --J=-Dgemfire.ssl-keystore-password=password1 " +
+ "--J=-Dgemfire.ssl-truststore=some/path/truststore.jks --J=-Dgemfire.ssl-truststore-password=password2", s);
}
[Fact]
public void StartServerStringsTest()
{
- var Gfsh = new GfshExecute();
+ var Gfsh = new GfshExecute(output);
var currentDir = Environment.CurrentDirectory;
- Gfsh.Keystore = "some/path/keystore.jks";
- Gfsh.KeystorePassword = "password";
- Gfsh.Truststore = "some/path/truststore.jks";
- Gfsh.TruststorePassword = "password";
var server = Gfsh
.start()
.server();
var s = server.ToString();
- Assert.True(s.Equals("start server"));
+ Assert.Equal("start server", s);
server = Gfsh
.start()
@@ -115,119 +109,117 @@ namespace Apache.Geode.Client.IntegrationTests
.withLocators("someLocator")
.withLogLevel("debug")
.withMaxHeap("1.21gigabytes")
- .withUseSsl();
+ .withSslEnableComponents("server,locator,jmx")
+ .withSslKeyStore("some/path/keystore.jks")
+ .withSslKeyStorePassword("password1")
+ .withSslTrustStore("some/path/truststore.jks")
+ .withSslTrustStorePassword("password2");
s = server.ToString();
- Assert.Equal(s, "start server --name=server " +
- "--dir=someDir --server-port=1234 --locators=someLocator --log-level=debug " +
+ Assert.Equal("start server --name=server " +
+ "--dir=someDir --bind-address=someAddress --server-port=1234 --locators=someLocator --log-level=debug " +
"--max-heap=1.21gigabytes --J=-Dgemfire.ssl-enabled-components=server,locator,jmx " +
- "--J=-Dgemfire.ssl-keystore=some/path/keystore.jks --J=-Dgemfire.ssl-keystore-password=password " +
- "--J=-Dgemfire.ssl-truststore=some/path/truststore.jks --J=-Dgemfire.ssl-truststore-password=password");
+ "--J=-Dgemfire.ssl-keystore=some/path/keystore.jks --J=-Dgemfire.ssl-keystore-password=password1 " +
+ "--J=-Dgemfire.ssl-truststore=some/path/truststore.jks --J=-Dgemfire.ssl-truststore-password=password2", s);
}
[Fact]
public void StopLocatorStringsTest()
{
- var locator = new GfshExecute()
+ var locator = new GfshExecute(output)
.stop()
.locator();
var s = locator.ToString();
- Assert.True(s.Equals("stop locator"));
+ Assert.Equal("stop locator", s);
- locator = new GfshExecute().stop().locator()
+ locator = new GfshExecute(output).stop().locator()
.withName("name")
.withDir("dir");
s = locator.ToString();
- Assert.True(s.Equals("stop locator --name=name --dir=dir"));
+ Assert.Equal("stop locator --name=name --dir=dir", s);
}
[Fact]
public void StopServerStringsTest()
{
- var server = new GfshExecute()
+ var server = new GfshExecute(output)
.stop()
.server();
var s = server.ToString();
- Assert.True(s.Equals("stop server"));
+ Assert.Equal("stop server", s);
- server = new GfshExecute()
+ server = new GfshExecute(output)
.stop()
.server()
.withName("server")
.withDir("someDir");
s = server.ToString();
- Assert.True(s.Equals("stop server --name=server --dir=someDir"));
+ Assert.Equal("stop server --name=server --dir=someDir", s);
}
[Fact]
public void CreateRegionStringsTest()
{
- var region = new GfshExecute()
+ var region = new GfshExecute(output)
.create()
.region();
var s = region.ToString();
- Assert.True(s.Equals("create region"));
+ Assert.Equal("create region", s);
- region = new GfshExecute()
+ region = new GfshExecute(output)
.create()
.region()
.withName("region")
.withType("PARTITION");
s = region.ToString();
- Assert.True(s.Equals("create region --name=region --type=PARTITION"));
+ Assert.Equal("create region --name=region --type=PARTITION", s);
}
[Fact]
public void ShutdownStringsTest()
{
- var shutdown = new GfshExecute()
+ var shutdown = new GfshExecute(output)
.shutdown();
var s = shutdown.ToString();
- Assert.True(s.Equals("shutdown"));
+ Assert.Equal("shutdown", s);
- shutdown = new GfshExecute()
+ shutdown = new GfshExecute(output)
.shutdown()
.withIncludeLocators(true);
s = shutdown.ToString();
- Assert.True(s.Equals("shutdown --include-locators=true"));
+ Assert.Equal("shutdown --include-locators=true", s);
- shutdown = new GfshExecute()
+ shutdown = new GfshExecute(output)
.shutdown()
.withIncludeLocators(false);
s = shutdown.ToString();
- Assert.True(s.Equals("shutdown --include-locators=false"));
+ Assert.Equal("shutdown --include-locators=false", s);
}
[Fact]
public void ConfigurePdxStringsTest()
{
- var configurePdx = new GfshExecute()
+ var configurePdx = new GfshExecute(output)
.configurePdx();
var s = configurePdx.ToString();
- Assert.Equal(s, "configure pdx");
+ Assert.Equal("configure pdx", s);
- configurePdx = new GfshExecute()
+ configurePdx = new GfshExecute(output)
.configurePdx()
.withReadSerialized(true);
s = configurePdx.ToString();
- Assert.Equal(s, "configure pdx --read-serialized=true");
+ Assert.Equal( "configure pdx --read-serialized=true", s);
- configurePdx = new GfshExecute()
+ configurePdx = new GfshExecute(output)
.configurePdx()
.withReadSerialized(false);
s = configurePdx.ToString();
- Assert.Equal(s, "configure pdx --read-serialized=false");
+ Assert.Equal("configure pdx --read-serialized=false", s);
}
[Fact]
public void ConnectStringsTest()
{
- var Gfsh = new GfshExecute();
-
- var currentDir = Environment.CurrentDirectory;
- Gfsh.Keystore = "some/path/keystore.jks";
- Gfsh.KeystorePassword = "password";
- Gfsh.Truststore = "some/path/truststore.jks";
- Gfsh.TruststorePassword = "password";
+ var Gfsh = new GfshExecute(output);
var connect = Gfsh
.connect();
@@ -237,11 +229,15 @@ namespace Apache.Geode.Client.IntegrationTests
connect = Gfsh
.connect()
.withJmxManager("localhost", 1234)
- .withUseSsl();
+ .withUseSsl(true)
+ .withKeyStore("some/path/keystore.jks")
+ .withKeyStorePassword("password1")
+ .withTrustStore("some/path/truststore.jks")
+ .withTrustStorePassword("password2");
s = connect.ToString();
- Assert.Equal(s, "connect --jmx-manager=localhost[1234] --use-ssl " +
- "--key-store=some/path/keystore.jks --key-store-password=password " +
- "--trust-store=some/path/truststore.jks --trust-store-password=password");
+ Assert.Equal("connect --jmx-manager=localhost[1234] --use-ssl=true " +
+ "--key-store=some/path/keystore.jks --key-store-password=password1 " +
+ "--trust-store=some/path/truststore.jks --trust-store-password=password2", s);
}
}
}
diff --git a/clicache/integration-test2/QueryTest.cs b/clicache/integration-test2/QueryTest.cs
index 17fc292..ccb37b9 100644
--- a/clicache/integration-test2/QueryTest.cs
+++ b/clicache/integration-test2/QueryTest.cs
@@ -20,183 +20,178 @@ using System.IO;
using Xunit;
using System.Diagnostics;
using System.Threading;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
- public class QueryOrder : IPdxSerializable
- {
- private const string ORDER_ID_KEY_ = "order_id";
- private const string NAME_KEY_ = "name";
- private const string QUANTITY_KEY_ = "quantity";
- public long OrderId { get; set; }
- public string Name { get; set; }
- public short Quantity { get; set; }
- // A default constructor is required for deserialization
- public QueryOrder() { }
- public QueryOrder(int orderId, string name, short quantity)
+ public class QueryOrder : IPdxSerializable
{
- OrderId = orderId;
- Name = name;
- Quantity = quantity;
+ private const string ORDER_ID_KEY_ = "order_id";
+ private const string NAME_KEY_ = "name";
+ private const string QUANTITY_KEY_ = "quantity";
+ public long OrderId { get; set; }
+ public string Name { get; set; }
+ public short Quantity { get; set; }
+ // A default constructor is required for deserialization
+ public QueryOrder() { }
+ public QueryOrder(int orderId, string name, short quantity)
+ {
+ OrderId = orderId;
+ Name = name;
+ Quantity = quantity;
+ }
+ public override string ToString()
+ {
+ return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name, Quantity);
+ }
+ public void ToData(IPdxWriter output)
+ {
+ output.WriteLong(ORDER_ID_KEY_, OrderId);
+ output.MarkIdentityField(ORDER_ID_KEY_);
+ output.WriteString(NAME_KEY_, Name);
+ output.MarkIdentityField(NAME_KEY_);
+ output.WriteInt(QUANTITY_KEY_, Quantity);
+ output.MarkIdentityField(QUANTITY_KEY_);
+ }
+ public void FromData(IPdxReader input)
+ {
+ OrderId = input.ReadLong(ORDER_ID_KEY_);
+ Name = input.ReadString(NAME_KEY_);
+ Quantity = (short)input.ReadInt(QUANTITY_KEY_);
+ }
+ public static IPdxSerializable CreateDeserializable()
+ {
+ return new QueryOrder();
+ }
}
- public override string ToString()
- {
- return string.Format("Order: [{0}, {1}, {2}]", OrderId, Name, Quantity);
- }
- public void ToData(IPdxWriter output)
- {
- output.WriteLong(ORDER_ID_KEY_, OrderId);
- output.MarkIdentityField(ORDER_ID_KEY_);
- output.WriteString(NAME_KEY_, Name);
- output.MarkIdentityField(NAME_KEY_);
- output.WriteInt(QUANTITY_KEY_, Quantity);
- output.MarkIdentityField(QUANTITY_KEY_);
- }
- public void FromData(IPdxReader input)
- {
- OrderId = input.ReadLong(ORDER_ID_KEY_);
- Name = input.ReadString(NAME_KEY_);
- Quantity = (short)input.ReadInt(QUANTITY_KEY_);
- }
- public static IPdxSerializable CreateDeserializable()
- {
- return new QueryOrder();
- }
- }
-
- [Trait("Category", "Integration")]
- public class QueryTest : TestBase, IDisposable
- {
- private readonly Cache cache_;
- public QueryTest()
+ [Trait("Category", "Integration")]
+ public class QueryTest : TestBase
{
- var cacheFactory = new CacheFactory()
- .Set("log-level", "error");
- cache_ = cacheFactory.Create();
- }
-
- public void Dispose()
- {
- cache_.Close();
- }
-
- [Fact]
- public void PdxSerializableQueryHaveCorrectValues()
- {
- using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
- {
- Assert.Equal(cluster_.Start(), true);
- Assert.Equal(cluster_.Gfsh.create()
- .region()
- .withName("cqTestRegion")
- .withType("REPLICATE")
- .execute(), 0);
- cache_.TypeRegistry.RegisterPdxType(QueryOrder.CreateDeserializable);
- var poolFactory = cache_.GetPoolFactory()
- .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
- var pool = poolFactory
- .SetSubscriptionEnabled(true)
- .Create("pool");
-
- var regionFactory = cache_.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
-
- var region = regionFactory.Create<string, QueryOrder>("cqTestRegion");
-
- var queryService = pool.GetQueryService();
-
- Debug.WriteLine("Putting and changing Position objects in the region");
- var order1 = new QueryOrder(1, "product x", 23);
- var order2 = new QueryOrder(2, "product y", 37);
- var order3 = new QueryOrder(3, "product z", 101);
-
- region.Put("order1", order1);
-
- region.Put("order2", order2);
-
- region.Put("order3", order3);
-
- order1.Quantity = 20;
- region.Put("order1", order1);
-
- order2.Quantity = 45;
- region.Put("order2", order2);
-
- order3.Quantity = 11;
- region.Put("order3", order3);
-
- var results = region.Query<QueryOrder>("SELECT * FROM /cqTestRegion WHERE quantity > 30");
- Assert.Equal(results.Size, 1UL);
- Assert.Equal(results[0].Name, "product y");
-
- region.Clear();
- }
- }
-
- [Fact]
- public void DataSerializableQueryHaveCorrectValues()
- {
- using (var cluster_ = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
- {
- Assert.Equal(cluster_.Start(), true);
- Assert.Equal(cluster_.Gfsh.deploy()
- .withJar(Config.JavaobjectJarPath)
- .execute(), 0);
- Assert.Equal(cluster_.Gfsh.create()
- .region()
- .withName("cqTestRegion")
- .withType("REPLICATE")
- .execute(), 0);
-
- cluster_.Gfsh.executeFunction()
- .withId("InstantiateDataSerializable")
- .withMember("DataSerializableQueryHaveCorre_server_0")
- .execute();
-
- cache_.TypeRegistry.RegisterType(Position.CreateDeserializable, 22);
-
- var poolFactory = cache_.GetPoolFactory()
- .AddLocator("localhost", cluster_.Gfsh.LocatorPort);
- var pool = poolFactory
- .SetSubscriptionEnabled(true)
- .Create("pool");
-
- var regionFactory = cache_.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
-
- var region = regionFactory.Create<string, Position>("cqTestRegion");
-
- Debug.WriteLine("Putting and changing Position objects in the region");
- var order1 = new Position("GOOG", 23);
- var order2 = new Position("IBM", 37);
- var order3 = new Position("PVTL", 101);
-
- region.Put("order1", order1);
- var Value = region["order1"];
-
- region.Put("order2", order2);
-
- order1.SharesOutstanding = 55;
- region.Put("order1", order1);
-
- order2.SharesOutstanding = 77;
- region.Put("order2", order2);
-
- order2.SharesOutstanding = 11;
- region.Put("order2", order2);
+ public QueryTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
+ {
+ }
+
+ [Fact]
+ public void PdxSerializableQueryHaveCorrectValues()
+ {
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
+ {
+ Assert.True(cluster.Start());
+ Assert.Equal(0, cluster.Gfsh.create()
+ .region()
+ .withName("cqTestRegion")
+ .withType("REPLICATE")
+ .execute());
- region.Remove("order1");
+ var cache = cluster.CreateCache();
+ try
+ {
+
+ cache.TypeRegistry.RegisterPdxType(QueryOrder.CreateDeserializable);
+
+ var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default");
+
+ var region = regionFactory.Create<string, QueryOrder>("cqTestRegion");
+
+ Debug.WriteLine("Putting and changing Position objects in the region");
+ var order1 = new QueryOrder(1, "product x", 23);
+ var order2 = new QueryOrder(2, "product y", 37);
+ var order3 = new QueryOrder(3, "product z", 101);
+
+ region.Put("order1", order1);
+
+ region.Put("order2", order2);
+
+ region.Put("order3", order3);
+
+ order1.Quantity = 20;
+ region.Put("order1", order1);
+
+ order2.Quantity = 45;
+ region.Put("order2", order2);
+
+ order3.Quantity = 11;
+ region.Put("order3", order3);
+
+ var results = region.Query<QueryOrder>("SELECT * FROM /cqTestRegion WHERE quantity > 30");
+ Assert.Equal(results.Size, 1UL);
+ Assert.Equal(results[0].Name, "product y");
+
+ region.Clear();
+ }
+ finally
+ {
+ cache.Close();
+ }
+ }
+ }
+
+ [Fact]
+ public void DataSerializableQueryHaveCorrectValues()
+ {
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
+ {
+ Assert.Equal(cluster.Start(), true);
+ Assert.Equal(0, cluster.Gfsh.deploy()
+ .withJar(Config.JavaobjectJarPath)
+ .execute());
+ Assert.Equal(0, cluster.Gfsh.create()
+ .region()
+ .withName("cqTestRegion")
+ .withType("REPLICATE")
+ .execute());
+
+ Assert.Equal(0, cluster.Gfsh.executeFunction()
+ .withId("InstantiateDataSerializable")
+ .withMember("DataSerializableQueryHaveCorrectValues_server_0")
+ .execute());
+
+ var cache = cluster.CreateCache();
+ try {
+ cache.TypeRegistry.RegisterType(Position.CreateDeserializable, 22);
+
+ var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default");
+
+ var region = regionFactory.Create<string, Position>("cqTestRegion");
+
+ Debug.WriteLine("Putting and changing Position objects in the region");
+ var order1 = new Position("GOOG", 23);
+ var order2 = new Position("IBM", 37);
+ var order3 = new Position("PVTL", 101);
+
+ region.Put("order1", order1);
+ var Value = region["order1"];
+
+ region.Put("order2", order2);
+
+ order1.SharesOutstanding = 55;
+ region.Put("order1", order1);
+
+ order2.SharesOutstanding = 77;
+ region.Put("order2", order2);
+
+ order2.SharesOutstanding = 11;
+ region.Put("order2", order2);
+
+ region.Remove("order1");
- region.Put("order3", order3);
+ region.Put("order3", order3);
- var results = region.Query<Position>("SELECT * FROM /cqTestRegion WHERE sharesOutstanding > 50");
- Assert.Equal(results.Size, 1UL);
- Assert.Equal(results[0].SecId, "PVTL");
+ var results = region.Query<Position>("SELECT * FROM /cqTestRegion WHERE sharesOutstanding > 50");
+ Assert.Equal(results.Size, 1UL);
+ Assert.Equal(results[0].SecId, "PVTL");
- region.Clear();
- }
+ region.Clear();
+ }
+ finally
+ {
+ cache.Close();
+ }
+ }
+ }
}
- }
}
diff --git a/clicache/integration-test2/RegionSSLTest.cs b/clicache/integration-test2/RegionSSLTest.cs
index eb6d908..da4052f 100644
--- a/clicache/integration-test2/RegionSSLTest.cs
+++ b/clicache/integration-test2/RegionSSLTest.cs
@@ -18,6 +18,7 @@
using System;
using System.IO;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
@@ -26,13 +27,14 @@ namespace Apache.Geode.Client.IntegrationTests
{
private readonly Cache cache_;
- public RegionSSLTest()
+ public RegionSSLTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
{
var cacheFactory = new CacheFactory();
+ cacheFactory.Set("log-level", "none");
cacheFactory.Set("ssl-enabled", "true");
- cacheFactory.Set("ssl-keystore", Environment.CurrentDirectory + "\\ClientSslKeys\\client_keystore.password.pem");
+ cacheFactory.Set("ssl-keystore", Environment.CurrentDirectory + @"\ClientSslKeys\client_keystore.password.pem");
cacheFactory.Set("ssl-keystore-password", "gemstone");
- cacheFactory.Set("ssl-truststore", Environment.CurrentDirectory + "\\ClientSslKeys\\client_truststore.pem");
+ cacheFactory.Set("ssl-truststore", Environment.CurrentDirectory + @"\ClientSslKeys\client_truststore.pem");
cache_ = cacheFactory.Create();
}
@@ -45,20 +47,18 @@ namespace Apache.Geode.Client.IntegrationTests
[Fact]
public void SslPutGetTest()
{
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
cluster.UseSSL = true;
Assert.True(cluster.Start());
- Assert.Equal(cluster.Gfsh
+ Assert.Equal(0, cluster.Gfsh
.create()
.region()
.withName("testRegion1")
.withType("PARTITION")
- .execute(), 0);
+ .execute());
- cache_.GetPoolFactory()
- .AddLocator(cluster.Gfsh.LocatorBindAddress, cluster.Gfsh.LocatorPort)
- .Create("default");
+ cluster.ApplyLocators(cache_.GetPoolFactory()).Create("default");
var regionFactory = cache_.CreateRegionFactory(RegionShortcut.PROXY)
.SetPoolName("default");
diff --git a/clicache/integration-test2/RegionTest.cs b/clicache/integration-test2/RegionTest.cs
index 104bb72..0b67ca3 100644
--- a/clicache/integration-test2/RegionTest.cs
+++ b/clicache/integration-test2/RegionTest.cs
@@ -18,39 +18,42 @@
using System;
using System.IO;
using Xunit;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
[Trait("Category", "Integration")]
public class RegionTest : TestBase
{
+ public RegionTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
+ {
+ }
+
[Fact]
public void PutOnOneCacheGetOnAnotherCache()
{
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
Assert.True(cluster.Start());
- Assert.Equal(cluster.Gfsh
+ Assert.Equal(0, cluster.Gfsh
.create()
.region()
.withName("testRegion1")
.withType("PARTITION")
- .execute(), 0);
+ .execute());
- var cacheFactory = new CacheFactory();
- var cacheOne = cacheFactory.Create();
- cacheOne.GetPoolFactory()
- .AddLocator(cluster.Gfsh.LocatorBindAddress, cluster.Gfsh.LocatorPort)
- .Create("default");
+ var cacheFactory = new CacheFactory()
+ .Set("log-level", "none");
+ var cacheOne = cacheFactory.Create();
try
{
+ cluster.ApplyLocators(cacheOne.GetPoolFactory()).Create("default");
+
var cacheTwo = cacheFactory.Create();
try
{
- cacheTwo.GetPoolFactory()
- .AddLocator(cluster.Gfsh.LocatorBindAddress, cluster.Gfsh.LocatorPort)
- .Create("default");
+ cluster.ApplyLocators(cacheTwo.GetPoolFactory()).Create("default");
var regionFactory1 = cacheOne.CreateRegionFactory(RegionShortcut.PROXY)
.SetPoolName("default");
diff --git a/clicache/integration-test2/SerializationTests.cs b/clicache/integration-test2/SerializationTests.cs
index 6b5afc5..47dd405 100644
--- a/clicache/integration-test2/SerializationTests.cs
+++ b/clicache/integration-test2/SerializationTests.cs
@@ -21,6 +21,7 @@ using Xunit;
using PdxTests;
using System.Collections;
using System.Collections.Generic;
+using Xunit.Abstractions;
namespace Apache.Geode.Client.IntegrationTests
{
@@ -399,6 +400,10 @@ namespace Apache.Geode.Client.IntegrationTests
[Trait("Category", "Integration")]
public class SerializationTests : TestBase
{
+ public SerializationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
+ {
+ }
+
private void putAndCheck(IRegion<object, object> region, object key, object value)
{
region[key] = value;
@@ -410,25 +415,20 @@ namespace Apache.Geode.Client.IntegrationTests
[Fact]
public void BuiltInSerializableTypes()
{
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
Assert.True(cluster.Start());
- Assert.Equal(cluster.Gfsh.create()
+ Assert.Equal(0, cluster.Gfsh.create()
.region()
.withName("testRegion")
.withType("REPLICATE")
- .execute(), 0);
- var cacheFactory = new CacheFactory()
- .Set("log-level", "none");
- var cache = cacheFactory.Create();
-
- var poolFactory = cache.GetPoolFactory()
- .AddLocator("localhost", cluster.Gfsh.LocatorPort);
- poolFactory.Create("pool");
-
- var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
- var region = regionFactory.Create<object, object>("testRegion");
+ .execute());
+
+ var cache = cluster.CreateCache();
+
+ var region = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default")
+ .Create<object, object>("testRegion");
Assert.NotNull(region);
putAndCheck(region, "CacheableString", "foo");
@@ -482,27 +482,22 @@ namespace Apache.Geode.Client.IntegrationTests
[Fact]
public void PutGetCustomSerializableTypes()
{
- using (var cluster = new Cluster(CreateTestCaseDirectoryName(), 1, 1))
+ using (var cluster = new Cluster(output, CreateTestCaseDirectoryName(), 1, 1))
{
Assert.True(cluster.Start());
- Assert.Equal(cluster.Gfsh.create()
+ Assert.Equal(0, cluster.Gfsh.create()
.region()
.withName("testRegion")
.withType("REPLICATE")
- .execute(), 0);
- var cacheFactory = new CacheFactory()
- .Set("log-level", "none");
- var cache = cacheFactory.Create();
+ .execute());
+
+ var cache = cluster.CreateCache();
cache.TypeRegistry.RegisterType(Order.CreateDeserializable, 0x42);
- var poolFactory = cache.GetPoolFactory()
- .AddLocator("localhost", cluster.Gfsh.LocatorPort);
- poolFactory.Create("pool");
-
- var regionFactory = cache.CreateRegionFactory(RegionShortcut.PROXY)
- .SetPoolName("pool");
- var orderRegion = regionFactory.Create<int, Order>("testRegion");
+ var orderRegion = cache.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("default")
+ .Create<int, Order>("testRegion");
Assert.NotNull(orderRegion);
const int orderKey = 65;
diff --git a/clicache/integration-test2/TestBase.cs b/clicache/integration-test2/TestBase.cs
index 40338de..fe5b87e 100644
--- a/clicache/integration-test2/TestBase.cs
+++ b/clicache/integration-test2/TestBase.cs
@@ -20,13 +20,27 @@ using System.Diagnostics;
using System.IO;
using System.Reflection;
using Xunit;
+using Xunit.Abstractions;
+using Xunit.Sdk;
namespace Apache.Geode.Client.IntegrationTests
{
[Trait("Category", "Integration")]
public class TestBase
{
- private const int MaxAllowedDirectoryCharacters = 30;
+ protected ITest currentTest;
+ protected ITestOutputHelper output;
+
+ public TestBase(ITestOutputHelper testOutputHelper)
+ {
+ var helper = (TestOutputHelper)testOutputHelper;
+
+ ITest test = (ITest)helper.GetType().GetField("test", BindingFlags.NonPublic | BindingFlags.Instance)
+ .GetValue(helper);
+
+ currentTest = test;
+ output = testOutputHelper;
+ }
public void CleanTestCaseDirectory(string directory)
{
@@ -38,16 +52,7 @@ namespace Apache.Geode.Client.IntegrationTests
public string CreateTestCaseDirectoryName()
{
- var st = new StackTrace();
- var sf = st.GetFrame(1);
- var currentMethod = sf.GetMethod();
- var dirName = currentMethod.Name;
-
- if (dirName.Length > MaxAllowedDirectoryCharacters)
- {
- dirName = dirName.Substring(0, MaxAllowedDirectoryCharacters);
- }
- return dirName;
+ return currentTest.TestCase.TestMethod.Method.Name;
}
}
}
diff --git a/tests/cli/PdxClassLibrary/PdxType.cs b/tests/cli/PdxClassLibrary/PdxType.cs
index bdc86de..c55ca76 100644
--- a/tests/cli/PdxClassLibrary/PdxType.cs
+++ b/tests/cli/PdxClassLibrary/PdxType.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
using Apache.Geode.Client;
using Apache.Geode.Client.Internal;
@@ -48,13 +49,13 @@ namespace PdxTests
public override bool Equals(object obj)
{
- Console.WriteLine("in addredd equal");
+ Debug.WriteLine("in addredd equal");
if (obj == null)
return false;
Address other = obj as Address;
if (other == null)
return false;
- Console.WriteLine("in addredd equal2 " + this.ToString() + " : : " + other.ToString());
+ Debug.WriteLine("in addredd equal2 " + this.ToString() + " : : " + other.ToString());
if (_aptNumber == other._aptNumber
&& _street == other._street
&& _city == other._city)
@@ -168,7 +169,7 @@ namespace PdxTests
DateTime n = new DateTime((62135596800000/*epoch*/ + 1310447869154) * 10000, DateTimeKind.Utc);
m_dateTime = n.ToLocalTime();
- Console.WriteLine(m_dateTime.Ticks);
+ Debug.WriteLine(m_dateTime.Ticks);
m_int16Array = new short[] { 0x2332, 0x4545 };
m_uint16Array = new short[] { 0x3243, 0x3232 };
@@ -288,13 +289,13 @@ namespace PdxTests
}
public static byte[] compareByteArray(byte[] a, byte[] a2)
{
- Console.WriteLine("Compare byte array " + a.Length + " ; " + a2.Length);
+ Debug.WriteLine("Compare byte array " + a.Length + " ; " + a2.Length);
if (a.Length == a2.Length)
{
int i = 0;
while (i < a.Length)
{
- Console.WriteLine("Compare byte array " + a[i] + " : " + a2[i]);
+ Debug.WriteLine("Compare byte array " + a[i] + " : " + a2[i]);
if (a[i] != a2[i])
break;
else
@@ -366,7 +367,7 @@ namespace PdxTests
*/
public static DateTime compareData(DateTime b, DateTime b2)
{
- Console.WriteLine("date " + b.Ticks + " : " + b2.Ticks);
+ Debug.WriteLine("date " + b.Ticks + " : " + b2.Ticks);
//TODO:
// return b;
if ((b.Ticks / 10000L) == (b2.Ticks / 10000L))
@@ -869,8 +870,8 @@ namespace PdxTests
{
if (!m_address[i].Equals(addressArray[i]))
{
- Console.WriteLine(m_address[i]);
- Console.WriteLine(addressArray[i]);
+ Debug.WriteLine(m_address[i]);
+ Debug.WriteLine(addressArray[i]);
throw new Exception("Address array not mateched " + i);
}
}
diff --git a/tests/cli/PdxClassLibrary/PdxTypesReflectionTest.cs b/tests/cli/PdxClassLibrary/PdxTypesReflectionTest.cs
index e7c12c3..340c3a8 100755
--- a/tests/cli/PdxClassLibrary/PdxTypesReflectionTest.cs
+++ b/tests/cli/PdxClassLibrary/PdxTypesReflectionTest.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
using Apache.Geode.Client;
using Apache.Geode.Client.Internal;
@@ -45,13 +46,13 @@ namespace PdxTests
public override bool Equals(object obj)
{
- Console.WriteLine("in addreddR equal");
+ Debug.WriteLine("in addreddR equal");
if (obj == null)
return false;
AddressR other = obj as AddressR;
if (other == null)
return false;
- Console.WriteLine("in addreddr equal2 " + this.ToString() + " : : " + other.ToString());
+ Debug.WriteLine("in addreddr equal2 " + this.ToString() + " : : " + other.ToString());
if (_aptNumber == other._aptNumber
&& _street == other._street
&& _city == other._city)
@@ -148,7 +149,7 @@ namespace PdxTests
long ticks = 634460644691540000L;
m_dateTime = new DateTime(ticks);
- Console.WriteLine(m_dateTime.Ticks);
+ Debug.WriteLine(m_dateTime.Ticks);
m_int16Array = new short[] { 0x2332, 0x4545 };
m_uint16Array = new short[] { 0x3243, 0x3232 };
@@ -283,13 +284,13 @@ namespace PdxTests
}
byte[] compareByteArray(byte[] a, byte[] a2)
{
- Console.WriteLine("Compare byte array " + a.Length + " ; " + a2.Length);
+ Debug.WriteLine("Compare byte array " + a.Length + " ; " + a2.Length);
if (a.Length == a2.Length)
{
int i = 0;
while (i < a.Length)
{
- Console.WriteLine("Compare byte array " + a[i] + " : " + a2[i]);
+ Debug.WriteLine("Compare byte array " + a[i] + " : " + a2[i]);
if (a[i] != a2[i])
break;
else
@@ -356,7 +357,7 @@ namespace PdxTests
DateTime compareData(DateTime b, DateTime b2)
{
- Console.WriteLine("date " + b.Ticks + " : " + b2.Ticks);
+ Debug.WriteLine("date " + b.Ticks + " : " + b2.Ticks);
//TODO:
// return b;
if ((b.Ticks / 10000L) == (b2.Ticks / 10000L))