You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by mm...@apache.org on 2020/08/04 22:00:37 UTC
[geode-native] 04/06: Add updated SNI test: - use new SniConfigPath
variable
This is an automated email from the ASF dual-hosted git repository.
mmartell pushed a commit to branch GEODE-8398-sni-support-dotnet
in repository https://gitbox.apache.org/repos/asf/geode-native.git
commit dcd14c0d57611885e3db5d76506950664c117075
Author: Mike Martell <mm...@pivotal.io>
AuthorDate: Tue Aug 4 14:58:16 2020 -0700
Add updated SNI test:
- use new SniConfigPath variable
---
clicache/integration-test2/CMakeLists.txt | 1 +
clicache/integration-test2/Config.cs.in | 5 ++
clicache/integration-test2/SNITests.cs | 137 ++++++++++++++++++++++++++++++
3 files changed, 143 insertions(+)
diff --git a/clicache/integration-test2/CMakeLists.txt b/clicache/integration-test2/CMakeLists.txt
index a6c31d4..fc23361 100644
--- a/clicache/integration-test2/CMakeLists.txt
+++ b/clicache/integration-test2/CMakeLists.txt
@@ -48,6 +48,7 @@ add_library( ${PROJECT_NAME} SHARED
packages.config
AutoSerializationTests.cs
SerializationTests.cs
+ SNITests.cs
)
set_source_files_properties(
diff --git a/clicache/integration-test2/Config.cs.in b/clicache/integration-test2/Config.cs.in
index 9ec3f65..4111ec2 100644
--- a/clicache/integration-test2/Config.cs.in
+++ b/clicache/integration-test2/Config.cs.in
@@ -38,4 +38,9 @@ public class Config
{
get { return @"@CMAKE_CURRENT_SOURCE_DIR@/../../ssl_keys/client_keys"; }
}
+
+ public static string SniConfigPath
+ {
+ get { return @"@CMAKE_CURRENT_SOURCE_DIR@/../../sni-test-config"; }
+ }
}
diff --git a/clicache/integration-test2/SNITests.cs b/clicache/integration-test2/SNITests.cs
new file mode 100644
index 0000000..3e96ce5
--- /dev/null
+++ b/clicache/integration-test2/SNITests.cs
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using Xunit;
+using PdxTests;
+using System.Collections;
+using System.Collections.Generic;
+using Xunit.Abstractions;
+
+namespace Apache.Geode.Client.IntegrationTests
+{
+ [Trait("Category", "Integration")]
+ public class SNITests : TestBase, IDisposable
+ {
+ string currentWorkingDirectory;
+ Process dockerProcess;
+ private readonly Cache cache_;
+
+ public SNITests(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
+ {
+ currentWorkingDirectory = Directory.GetCurrentDirectory();
+ var clientTruststore = Config.SslClientKeyPath + @"/truststore_sni.pem";
+
+
+
+ var cacheFactory = new CacheFactory();
+ cacheFactory.Set("log-level", "none");
+ cacheFactory.Set("log-file", "c:/temp/SNITest-csharp.log");
+ cacheFactory.Set("ssl-enabled", "true");
+ cacheFactory.Set("ssl-truststore", clientTruststore);
+
+ cache_ = cacheFactory.Create();
+
+ var pd = "--project-directory " + Config.SniConfigPath + " up -d";
+ var dc = Process.Start(@"C:\Program Files\docker\docker\resources\bin\docker-compose.exe", "-f " + Config.SniConfigPath + "/docker-compose.yml" + " up -d");
+ dc.WaitForExit();
+
+ var d = Process.Start(@"C:\Program Files\docker\docker\resources\bin\docker.exe", "exec -t geode gfsh run --file=/geode/scripts/geode-starter.gfsh");
+ d.WaitForExit();
+ }
+
+ public void Dispose()
+ {
+
+ var dockerComposeProc = Process.Start(@"C:\Program Files\docker\docker\resources\bin\docker-compose.exe", "stop");
+ dockerComposeProc.WaitForExit();
+
+ var dockerProc = Process.Start(@"C:\Program Files\docker\docker\resources\bin\docker.exe", "container prune -f");
+ dockerProc.WaitForExit();
+
+ }
+
+ private string RunDockerCommand(string dockerCommand)
+ {
+ ProcessStartInfo startInfo = new ProcessStartInfo();
+ startInfo.RedirectStandardOutput = true;
+ startInfo.UseShellExecute = false;
+ startInfo.FileName = @"C:\Program Files\Docker\Docker\resources\bin\docker.exe";
+ startInfo.Arguments = dockerCommand;
+ dockerProcess = Process.Start(startInfo);
+ String rVal = dockerProcess.StandardOutput.ReadToEnd();
+ dockerProcess.WaitForExit();
+ return rVal;
+ }
+
+ private int ParseProxyPort(string proxyString)
+ {
+ int colonPosition = proxyString.IndexOf(":");
+ string portNumberString = proxyString.Substring(colonPosition + 1);
+ return Int32.Parse(portNumberString);
+ }
+
+ [Fact]
+ public void ConnectViaProxyTest()
+ {
+ var portString = RunDockerCommand("port haproxy");
+ var portNumber = ParseProxyPort(portString);
+
+ cache_.GetPoolManager()
+ .CreateFactory()
+ .SetSniProxy("localhost", portNumber)
+ .AddLocator("locator-maeve", 10334)
+ .Create("pool");
+
+ var region = cache_.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool")
+ .Create<string, string>("jellyfish");
+
+ region.Put("1", "one");
+ var value = region.Get("1");
+
+ Assert.Equal("one", value);
+ cache_.Close();
+ }
+
+ [Fact]
+ public void ConnectionFailsTest()
+ {
+ cache_.GetPoolManager()
+ .CreateFactory()
+ .AddLocator("localhost", 10334)
+ .Create("pool");
+
+ var region = cache_.CreateRegionFactory(RegionShortcut.PROXY)
+ .SetPoolName("pool")
+ .Create<string, string>("region");
+
+ Assert.Throws<NotConnectedException>(() => region.Put("1", "one"));
+ }
+
+ [Fact]
+ public void DoNothingTest()
+ {
+ cache_.GetPoolManager()
+ .CreateFactory()
+ .AddLocator("localhost", 10334)
+ .Create("pool");
+ }
+ }
+}
\ No newline at end of file