You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/06/12 17:20:53 UTC

[GitHub] [geode-native] moleske commented on a change in pull request #616: GEODE-8128: Add SNI tests using new test framework

moleske commented on a change in pull request #616:
URL: https://github.com/apache/geode-native/pull/616#discussion_r439542991



##########
File path: cppcache/integration/test/SNITest.cpp
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+#include <cstdlib>
+#include <fstream>

Review comment:
       This doesn't seem used

##########
File path: cppcache/integration/framework/Cluster.h
##########
@@ -171,60 +171,77 @@ class Cluster {
               const std::string truststorePassword);
 
   bool useSsl();
-  bool requireSslAuthentication();
-  std::string keystore();
-  std::string truststore();
-  std::string keystorePassword();
-  std::string truststorePassword();
 
-  Gfsh &getGfsh();
+  void usePropertiesFile(const std::string propertiesFile);
+  void useSecurityPropertiesFile(const std::string securityPropertiesFile);
+  void useHostNameForClients(const std::string hostNameForClients);
+  bool usePropertiesFile();
+  bool useSecurityPropertiesFile();
+  bool useHostNameForClients();
+bool requireSslAuthentication();

Review comment:
       Something I think happened with your auto formatter, or at least the indentation seems to have gotten out of whack

##########
File path: cppcache/integration/test/SNITest.cpp
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+
+namespace ssltest {
+
+using apache::geode::client::AuthenticationRequiredException;
+using apache::geode::client::CacheableString;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::Exception;
+using apache::geode::client::RegionShortcut;
+
+class SNITest : public ::testing::Test {
+ protected:
+  // You can remove any or all of the following functions if their bodies would
+  // be empty.
+
+  SNITest() {
+    // You can do set-up work for each test here.
+    certificatePassword = std::string("apachegeode");
+    currentWorkingDirectory = boost::filesystem::current_path();
+  }
+
+  ~SNITest() override = default;
+  // You can do clean-up work that doesn't throw exceptions here.
+
+  // If the constructor and destructor are not enough for setting up
+  // and cleaning up each test, you can define the following methods:
+  void SetUp() override {
+    // Code here will be called immediately after the constructor (right
+    // before each test).
+#if defined(_WINDOWS)

Review comment:
       In config.h it says we have `_WIN32` already defined.  Should we use that one like was used in #608 ?

##########
File path: cppcache/integration/test/SNITest.cpp
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+
+namespace ssltest {
+
+using apache::geode::client::AuthenticationRequiredException;
+using apache::geode::client::CacheableString;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::Exception;
+using apache::geode::client::RegionShortcut;
+
+class SNITest : public ::testing::Test {
+ protected:
+  // You can remove any or all of the following functions if their bodies would

Review comment:
       This looks like generated comments.  I'm assuming this and the others in this file aren't necessary?

##########
File path: cppcache/integration/test/SNITest.cpp
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+
+namespace ssltest {
+
+using apache::geode::client::AuthenticationRequiredException;
+using apache::geode::client::CacheableString;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::Exception;
+using apache::geode::client::RegionShortcut;
+
+class SNITest : public ::testing::Test {
+ protected:
+  // You can remove any or all of the following functions if their bodies would
+  // be empty.
+
+  SNITest() {
+    // You can do set-up work for each test here.
+    certificatePassword = std::string("apachegeode");
+    currentWorkingDirectory = boost::filesystem::current_path();
+  }
+
+  ~SNITest() override = default;
+  // You can do clean-up work that doesn't throw exceptions here.
+
+  // If the constructor and destructor are not enough for setting up
+  // and cleaning up each test, you can define the following methods:
+  void SetUp() override {
+    // Code here will be called immediately after the constructor (right
+    // before each test).
+#if defined(_WINDOWS)
+    std::string sniDir(currentWorkingDirectory.string());
+    sniDir += "/../sni-test-config";
+    SetCurrentDirectory(sniDir.c_str());
+#else
+    chdir("./sni-test-config");
+#endif
+
+    std::system("docker-compose up -d");
+
+    std::system(
+        "docker exec -t geode gfsh run "
+        "--file=/geode/scripts/geode-starter.gfsh");
+  }
+
+  void TearDown() override {
+    // Code here will be called immediately after each test (right
+    // before the destructor).
+    std::system("docker-compose stop");
+  }
+
+  std::string makeItSo(const char* command) {
+    std::string commandOutput;
+#if defined(_WINDOWS)
+    std::unique_ptr<FILE, decltype(&_pclose)> pipe(_popen(command, "r"),
+                                                   _pclose);
+#else
+    std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(command, "r"), pclose);
+#endif
+    std::array<char, 128> charBuff;
+    if (!pipe) {
+      throw std::runtime_error("Failed on the POPEN");
+    }
+    while (fgets(charBuff.data(), charBuff.size(), pipe.get()) != nullptr) {
+      commandOutput += charBuff.data();
+    }
+    return commandOutput;
+  }
+
+  int parseProxyPort(std::string proxyString) {
+    // 15443/tcp -> 0.0.0.0:32787
+    std::size_t colonPosition = proxyString.find(":");
+    std::string portNumberString = proxyString.substr((colonPosition + 1));
+    return stoi(portNumberString);
+  }
+
+  // Class members declared here can be used by all tests in the test suite
+  // for Ssl.
+  Cluster cluster = Cluster{LocatorCount{1}, ServerCount{1}};
+  std::string certificatePassword;

Review comment:
       This is assigned, but doesn't seem like it is actually used in the file

##########
File path: cppcache/integration/test/sni-test-config/docker-compose.yml
##########
@@ -0,0 +1,43 @@
+#
+# 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.
+#
+version: '3'
+services:
+  geode:
+    container_name: 'geode'
+    image: 'apachegeode/geode'
+    expose:
+      - '10334'
+      - '40404'
+    entrypoint: 'sh'
+    command: ["-c", "while true; do sleep 600; done"]

Review comment:
       Was it intended to use the `forever` script here?  I can't find where that script was intended to be used, but this has the same line.  Otherwise it seems the `forever` script could be removed

##########
File path: cppcache/integration/test/sni-test-config/scripts/geode-starter-2.gfsh
##########
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+start locator --name=locator-maeve --hostname-for-clients=locator-maeve --properties-file=/geode/config/gemfire.properties --security-properties-file=/geode/config/gfsecurity.properties --J=-Dgemfire.ssl-keystore=/geode/config/locator-maeve-keystore.jks

Review comment:
       `geode-starter-2` is not a very informative name when comparing to `geode-starter`.  I'm wondering if something indicating the difference between the two, such `geode-start-one-server` and `geode-start-two-servers` would be useful




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org