gaussianrecurrence commented on code in PR #974:
URL: https://github.com/apache/geode-native/pull/974#discussion_r902718227


##########
cppcache/test/TcrConnectionTest.cpp:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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 <CacheImpl.hpp>
+#include <TcrConnection.hpp>
+#include <TcrConnectionManager.hpp>
+
+#include <gtest/gtest.h>
+
+namespace {
+
+using apache::geode::client::CacheImpl;
+using apache::geode::client::TcrConnection;
+using apache::geode::client::TcrConnectionManager;
+
+class TcrConnectionTest : public TcrConnection {
+ public:
+  explicit TcrConnectionTest(const TcrConnectionManager& manager)
+      : TcrConnection(manager) {}
+
+  int getExpiryTimeVariancePercentage() {
+    return expiryTimeVariancePercentage_;
+  }
+};
+
+TEST(TcrConnectionTest,
+     getExpiryTimeVariancePercentageReturnsRandomBetweenMinusNineAndNine) {
+  CacheImpl* cache = nullptr;
+
+  // Create several connections at the same time
+  const int connections = 100;
+  std::unique_ptr<TcrConnectionTest> tcrConnections[connections];
+  for (int i = 0; i < connections; i++) {
+    tcrConnections[i] =
+        std::unique_ptr<TcrConnectionTest>(new TcrConnectionTest(
+            static_cast<const TcrConnectionManager>(nullptr)));
+  }
+

Review Comment:
   This is a suggestion for a change to this case or maybe for another case, 
but given the goal of this change is to ensure the variance is evenly 
distributed along the connections created within a close period of time, I'd 
suggest instead of comparing with the first value, I'd rather sample the 
distribution and check no bucket in the sample has more than x times (i.e 
double) the expected amount.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to