You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2019/01/11 18:33:47 UTC
[geode-native] branch develop updated: GEODE-6249: port attributes
mutator test (#431)
This is an automated email from the ASF dual-hosted git repository.
bbender 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 adf1df6 GEODE-6249: port attributes mutator test (#431)
adf1df6 is described below
commit adf1df6de1a924f05c76a5955fd0e26d604b41f2
Author: Blake Bender <ek...@hotmail.com>
AuthorDate: Fri Jan 11 10:33:42 2019 -0800
GEODE-6249: port attributes mutator test (#431)
- Add AttributesMutator test to new framework, duplicating/updating old code
- Rename AttributesMutator test, since it doesn't actually test AttributesMutator
- GEODE-6249: Delete old AttributesMutator test
Co-authored-by: Michael Oleske <mo...@pivotal.io>
---
cppcache/integration-test/CMakeLists.txt | 1 -
.../integration-test/testAttributesMutator.cpp | 89 ----------------------
cppcache/integration/test/CMakeLists.txt | 10 +--
cppcache/integration/test/ExpirationTest.cpp | 84 ++++++++++++++++++++
4 files changed, 89 insertions(+), 95 deletions(-)
diff --git a/cppcache/integration-test/CMakeLists.txt b/cppcache/integration-test/CMakeLists.txt
index 94d1f62..0daaeb9 100644
--- a/cppcache/integration-test/CMakeLists.txt
+++ b/cppcache/integration-test/CMakeLists.txt
@@ -172,7 +172,6 @@ set_property(TEST testRegionAttributesFactory PROPERTY LABELS STABLE QUICK)
set_property(TEST testXmlCacheCreationWithOverFlow PROPERTY LABELS STABLE QUICK)
set_property(TEST testThinClientRemoveAllLocal PROPERTY LABELS STABLE QUICK)
set_property(TEST testDunit PROPERTY LABELS STABLE QUICK)
-set_property(TEST testAttributesMutator PROPERTY LABELS STABLE QUICK)
set_property(TEST testSpinLock PROPERTY LABELS STABLE QUICK)
set_property(TEST testSubRegions PROPERTY LABELS STABLE QUICK)
set_property(TEST testThinClientSSLAuthFail PROPERTY LABELS STABLE QUICK)
diff --git a/cppcache/integration-test/testAttributesMutator.cpp b/cppcache/integration-test/testAttributesMutator.cpp
deleted file mode 100644
index ec6fd26..0000000
--- a/cppcache/integration-test/testAttributesMutator.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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 <geode/CacheFactory.hpp>
-#include <geode/Region.hpp>
-#include <geode/RegionAttributesFactory.hpp>
-
-#include "CacheImpl.hpp"
-#include "CacheRegionHelper.hpp"
-
-#include "fw_dunit.hpp"
-
-using apache::geode::client::Cache;
-using apache::geode::client::CacheableInt32;
-using apache::geode::client::CacheFactory;
-using apache::geode::client::CacheRegionHelper;
-using apache::geode::client::ExpirationAction;
-using apache::geode::client::Region;
-using apache::geode::client::RegionAttributesFactory;
-
-class TestData {
- public:
- std::shared_ptr<Region> m_region;
- std::shared_ptr<Cache> m_cache;
-
-} Test;
-
-#define A s1p1
-
-/* setup recipient */
-DUNIT_TASK(A, Init)
- {
- auto cacheFactory = CacheFactory();
- Test.m_cache = std::make_shared<Cache>(cacheFactory.create());
-
- RegionAttributesFactory regionAttributesFactory;
- regionAttributesFactory.setEntryTimeToLive(
- ExpirationAction::LOCAL_INVALIDATE, std::chrono::seconds(5));
- auto regionAttributes = regionAttributesFactory.create();
-
- auto &&cacheImpl = CacheRegionHelper::getCacheImpl(Test.m_cache.get());
- cacheImpl->createRegion("Local_ETTL_LI", regionAttributes, Test.m_region);
- }
-ENDTASK
-
-DUNIT_TASK(A, CreateAndVerifyExpiry)
- {
- auto value = CacheableInt32::create(1);
- LOGDEBUG("### About to put of :one:1: ###");
- Test.m_region->put("one", value);
- LOGDEBUG("### Finished put of :one:1: ###");
-
- // countdown begins... it is ttl so access should not play into it..
- SLEEP(3000); // sleep for a second, expect value to still be there.
- auto res =
- std::dynamic_pointer_cast<CacheableInt32>(Test.m_region->get("one"));
- ASSERT(res->value() == 1, "Expected to find value 1.");
- fflush(stdout);
- SLEEP(5000); // sleep for 5 more seconds, expect value to be invalid.
- fflush(stdout);
- res = nullptr;
- ASSERT(Test.m_region->containsValueForKey("one") == false,
- "should not contain value.");
- }
-ENDTASK
-
-/* Test value sizes up to 1meg */
-DUNIT_TASK(A, Close)
- {
- Test.m_region->destroyRegion();
- Test.m_cache->close();
- Test.m_cache = nullptr;
- Test.m_region = nullptr;
- }
-ENDTASK
diff --git a/cppcache/integration/test/CMakeLists.txt b/cppcache/integration/test/CMakeLists.txt
index 0580a0a..f38a5b0 100644
--- a/cppcache/integration/test/CMakeLists.txt
+++ b/cppcache/integration/test/CMakeLists.txt
@@ -15,15 +15,15 @@
add_executable(cpp-integration-test
ChunkedHeaderTest.cpp
+ DataSerializableTest.cpp
+ EnableChunkHandlerThreadTest.cpp
ExampleTest.cpp
- RegionPutGetAllTest.cpp
+ ExpirationTest.cpp
+ FunctionExecutionTest.cpp
PdxInstanceTest.cpp
+ RegionPutGetAllTest.cpp
RegisterKeysTest.cpp
StructTest.cpp
- EnableChunkHandlerThreadTest.cpp
- DataSerializableTest.cpp
- FunctionExecutionTest.cpp
- StructTest.cpp
)
target_compile_definitions(cpp-integration-test
diff --git a/cppcache/integration/test/ExpirationTest.cpp b/cppcache/integration/test/ExpirationTest.cpp
new file mode 100644
index 0000000..fddf72d
--- /dev/null
+++ b/cppcache/integration/test/ExpirationTest.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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 <future>
+#include <iostream>
+#include <random>
+#include <thread>
+
+#include <gtest/gtest.h>
+
+#include <geode/Cache.hpp>
+#include <geode/CacheableBuiltins.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::CacheableInt32;
+using apache::geode::client::CacheableString;
+using apache::geode::client::ExpirationAction;
+using apache::geode::client::Pool;
+using apache::geode::client::Region;
+using apache::geode::client::RegionShortcut;
+
+using std::chrono::minutes;
+
+const int TEST_TTL_ENTRY_TIMEOUT = 5;
+
+Cache createCache() {
+ using apache::geode::client::CacheFactory;
+
+ auto cache = CacheFactory()
+ .set("log-level", "none")
+ .set("statistic-sampling-enabled", "false")
+ .create();
+
+ return cache;
+}
+
+std::shared_ptr<Region> setupRegion(Cache& cache) {
+ auto region = cache.createRegionFactory(RegionShortcut::LOCAL)
+ .setEntryTimeToLive(ExpirationAction::LOCAL_INVALIDATE,
+ std::chrono::seconds(5))
+ .create("region");
+
+ return region;
+}
+
+TEST(ExpirationTest, verifyExpiration) {
+ auto cache = createCache();
+ auto region = setupRegion(cache);
+
+ region->put(1, "one");
+ std::this_thread::sleep_for(std::chrono::seconds(3));
+ ASSERT_TRUE(region->containsValueForKey(1));
+ auto result = std::dynamic_pointer_cast<CacheableString>(region->get(1));
+ ASSERT_NE(result, nullptr);
+ ASSERT_EQ(result->value(), "one");
+
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+ ASSERT_FALSE(region->containsValueForKey(1));
+}
+
+} // namespace