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/03 13:06:37 UTC

[GitHub] [geode-native] mmartell opened a new pull request #610: GEODE-8214: Add new ServerDisconnect test

mmartell opened a new pull request #610:
URL: https://github.com/apache/geode-native/pull/610


   This test was designed to assist with debugging of issues discovered with boost::asio.


----------------------------------------------------------------
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



[GitHub] [geode-native] mmartell commented on a change in pull request #610: GEODE-8214: Add new ServerDisconnect test

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #610:
URL: https://github.com/apache/geode-native/pull/610#discussion_r434747492



##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/CacheListener.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::CacheableInt16;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::CacheListener;
+using apache::geode::client::NotConnectedException;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+static bool isDisconnected = false;
+
+class RegionDisconnectedListener : public CacheListener {
+  void afterRegionDisconnected(Region&) override { isDisconnected = true; }
+};
+
+Cache createTestCache() {
+  CacheFactory cacheFactory;
+  return cacheFactory.set("log-level", "none")
+      .set("statistic-sampling-enabled", "false")
+      .create();
+}
+
+TEST(ServerDisconnect, WithRegionDisconnectedListener) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("region")
+      .withType("PARTITION")
+      .execute();
+
+  {
+    auto cache = createTestCache();
+
+    auto poolFactory =
+        cache.getPoolManager().createFactory().setSubscriptionEnabled(true);
+
+    cluster.applyLocators(poolFactory);
+
+    auto pool = poolFactory.create("pool");
+    auto regionFactory =
+        cache.createRegionFactory(RegionShortcut::CACHING_PROXY);
+
+    auto regionDisconnectedListener =
+        std::make_shared<RegionDisconnectedListener>();
+    auto region = regionFactory.setPoolName("pool")
+                      .setCacheListener(regionDisconnectedListener)
+                      .create("region");
+
+    region->put("one", std::make_shared<CacheableInt16>(1));
+
+    std::vector<Server>& servers = cluster.getServers();
+    servers[0].stop();
+
+    try {
+      region->put("two", std::make_shared<CacheableInt16>(2));
+    } catch (const NotConnectedException&) {
+    }
+
+    ASSERT_EQ(isDisconnected, true);

Review comment:
       Great suggestion. Will look at mocks for future tests.




----------------------------------------------------------------
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



[GitHub] [geode-native] mmartell commented on a change in pull request #610: GEODE-8214: Add new ServerDisconnect test

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #610:
URL: https://github.com/apache/geode-native/pull/610#discussion_r434703971



##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/CacheListener.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::CacheableInt16;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::CacheListener;
+using apache::geode::client::NotConnectedException;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+static bool isDisconnected = false;
+
+class RegionDisconnectedListener : public CacheListener {
+  void afterRegionDisconnected(Region&) override { isDisconnected = true; }
+};
+
+Cache createTestCache() {
+  CacheFactory cacheFactory;
+  return cacheFactory.set("log-level", "none")
+      .set("statistic-sampling-enabled", "false")
+      .create();
+}
+
+TEST(ServerDisconnect, WithRegionDisconnectedListener) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("region")
+      .withType("PARTITION")
+      .execute();
+
+  {

Review comment:
       Good catch!




----------------------------------------------------------------
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



[GitHub] [geode-native] mmartell commented on pull request #610: GEODE-8214: Add new ServerDisconnect test

Posted by GitBox <gi...@apache.org>.
mmartell commented on pull request #610:
URL: https://github.com/apache/geode-native/pull/610#issuecomment-638199356


   Note: This test passes on develop, but fails on feature/asio branch.


----------------------------------------------------------------
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



[GitHub] [geode-native] pivotal-jbarrett commented on a change in pull request #610: GEODE-8214: Add new ServerDisconnect test

Posted by GitBox <gi...@apache.org>.
pivotal-jbarrett commented on a change in pull request #610:
URL: https://github.com/apache/geode-native/pull/610#discussion_r434589754



##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>

Review comment:
       I don’t see any direct uses of any of these includes. If they aren’t used please remove.

##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/CacheListener.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::CacheableInt16;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::CacheListener;
+using apache::geode::client::NotConnectedException;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+static bool isDisconnected = false;
+
+class RegionDisconnectedListener : public CacheListener {
+  void afterRegionDisconnected(Region&) override { isDisconnected = true; }
+};
+
+Cache createTestCache() {
+  CacheFactory cacheFactory;
+  return cacheFactory.set("log-level", "none")
+      .set("statistic-sampling-enabled", "false")
+      .create();
+}
+
+TEST(ServerDisconnect, WithRegionDisconnectedListener) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("region")
+      .withType("PARTITION")
+      .execute();
+
+  {
+    auto cache = createTestCache();
+
+    auto poolFactory =
+        cache.getPoolManager().createFactory().setSubscriptionEnabled(true);
+
+    cluster.applyLocators(poolFactory);
+
+    auto pool = poolFactory.create("pool");
+    auto regionFactory =
+        cache.createRegionFactory(RegionShortcut::CACHING_PROXY);
+
+    auto regionDisconnectedListener =
+        std::make_shared<RegionDisconnectedListener>();
+    auto region = regionFactory.setPoolName("pool")
+                      .setCacheListener(regionDisconnectedListener)
+                      .create("region");
+
+    region->put("one", std::make_shared<CacheableInt16>(1));
+
+    std::vector<Server>& servers = cluster.getServers();

Review comment:
       const auto&

##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/CacheListener.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::CacheableInt16;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::CacheListener;
+using apache::geode::client::NotConnectedException;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+static bool isDisconnected = false;
+
+class RegionDisconnectedListener : public CacheListener {
+  void afterRegionDisconnected(Region&) override { isDisconnected = true; }
+};
+
+Cache createTestCache() {
+  CacheFactory cacheFactory;
+  return cacheFactory.set("log-level", "none")
+      .set("statistic-sampling-enabled", "false")
+      .create();
+}
+
+TEST(ServerDisconnect, WithRegionDisconnectedListener) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("region")
+      .withType("PARTITION")
+      .execute();
+
+  {

Review comment:
       What’s the purpose of this inner block? I don’t see any code outside this block.

##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/CacheListener.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::CacheableInt16;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::CacheListener;
+using apache::geode::client::NotConnectedException;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+static bool isDisconnected = false;
+
+class RegionDisconnectedListener : public CacheListener {
+  void afterRegionDisconnected(Region&) override { isDisconnected = true; }
+};
+
+Cache createTestCache() {
+  CacheFactory cacheFactory;
+  return cacheFactory.set("log-level", "none")
+      .set("statistic-sampling-enabled", "false")
+      .create();
+}
+
+TEST(ServerDisconnect, WithRegionDisconnectedListener) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("region")
+      .withType("PARTITION")
+      .execute();
+
+  {
+    auto cache = createTestCache();
+
+    auto poolFactory =
+        cache.getPoolManager().createFactory().setSubscriptionEnabled(true);
+
+    cluster.applyLocators(poolFactory);
+
+    auto pool = poolFactory.create("pool");
+    auto regionFactory =
+        cache.createRegionFactory(RegionShortcut::CACHING_PROXY);
+
+    auto regionDisconnectedListener =
+        std::make_shared<RegionDisconnectedListener>();
+    auto region = regionFactory.setPoolName("pool")
+                      .setCacheListener(regionDisconnectedListener)
+                      .create("region");
+
+    region->put("one", std::make_shared<CacheableInt16>(1));
+
+    std::vector<Server>& servers = cluster.getServers();
+    servers[0].stop();
+
+    try {
+      region->put("two", std::make_shared<CacheableInt16>(2));
+    } catch (const NotConnectedException&) {
+    }
+
+    ASSERT_EQ(isDisconnected, true);

Review comment:
       You might want to look at gmock as an alternative approach. You could create a mock listener and assert that the event method was invoked.




----------------------------------------------------------------
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



[GitHub] [geode-native] mmartell merged pull request #610: GEODE-8214: Add new ServerDisconnect test

Posted by GitBox <gi...@apache.org>.
mmartell merged pull request #610:
URL: https://github.com/apache/geode-native/pull/610


   


----------------------------------------------------------------
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



[GitHub] [geode-native] mmartell commented on a change in pull request #610: GEODE-8214: Add new ServerDisconnect test

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #610:
URL: https://github.com/apache/geode-native/pull/610#discussion_r434710484



##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>

Review comment:
       Good catch!




----------------------------------------------------------------
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



[GitHub] [geode-native] mmartell commented on a change in pull request #610: GEODE-8214: Add new ServerDisconnect test

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #610:
URL: https://github.com/apache/geode-native/pull/610#discussion_r434709404



##########
File path: cppcache/integration/test/ServerDisconnectWithListener.cpp
##########
@@ -0,0 +1,101 @@
+/* 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 <chrono>
+#include <exception>
+#include <iostream>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheFactory.hpp>
+#include <geode/CacheListener.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/RegionFactory.hpp>
+#include <geode/RegionShortcut.hpp>
+
+#include "framework/Cluster.h"
+#include "framework/Framework.h"
+#include "framework/Gfsh.h"
+
+namespace {
+
+using apache::geode::client::Cache;
+using apache::geode::client::CacheableInt16;
+using apache::geode::client::CacheFactory;
+using apache::geode::client::CacheListener;
+using apache::geode::client::NotConnectedException;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+static bool isDisconnected = false;
+
+class RegionDisconnectedListener : public CacheListener {
+  void afterRegionDisconnected(Region&) override { isDisconnected = true; }
+};
+
+Cache createTestCache() {
+  CacheFactory cacheFactory;
+  return cacheFactory.set("log-level", "none")
+      .set("statistic-sampling-enabled", "false")
+      .create();
+}
+
+TEST(ServerDisconnect, WithRegionDisconnectedListener) {
+  Cluster cluster{LocatorCount{1}, ServerCount{1}};
+
+  cluster.start();
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("region")
+      .withType("PARTITION")
+      .execute();
+
+  {
+    auto cache = createTestCache();
+
+    auto poolFactory =
+        cache.getPoolManager().createFactory().setSubscriptionEnabled(true);
+
+    cluster.applyLocators(poolFactory);
+
+    auto pool = poolFactory.create("pool");
+    auto regionFactory =
+        cache.createRegionFactory(RegionShortcut::CACHING_PROXY);
+
+    auto regionDisconnectedListener =
+        std::make_shared<RegionDisconnectedListener>();
+    auto region = regionFactory.setPoolName("pool")
+                      .setCacheListener(regionDisconnectedListener)
+                      .create("region");
+
+    region->put("one", std::make_shared<CacheableInt16>(1));
+
+    std::vector<Server>& servers = cluster.getServers();

Review comment:
       Can't use const here (since Server::stop not a const member function). But I like the switch to auto&.




----------------------------------------------------------------
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