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/11/25 22:05:57 UTC

[geode-native] branch develop updated: GEODE-7447: Fix test breakage on Windows (#552)

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 e3087f2  GEODE-7447: Fix test breakage on Windows (#552)
e3087f2 is described below

commit e3087f2da67787d1611ca7f334e32b6b0a1ae669
Author: Blake Bender <bb...@pivotal.io>
AuthorDate: Mon Nov 25 14:05:46 2019 -0800

    GEODE-7447: Fix test breakage on Windows (#552)
    
    * std::chrono for things like system time on Windows return a
    non-standard ratio corresponding to 'ticks' (100ns units)
    * This unit was blowing up our string conversion code, which defaulted
    to nullptr for string value of unrecognized units
    * Just stop logging std::chrono values in EntryExpiryHandler
    * Fix formatting
    * Add duration test for "unknown units" case
---
 cppcache/include/geode/internal/chrono/duration.hpp |  2 +-
 cppcache/src/EntryExpiryHandler.cpp                 | 20 +++++++-------------
 cppcache/test/util/chrono/durationTest.cpp          |  3 +++
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/cppcache/include/geode/internal/chrono/duration.hpp b/cppcache/include/geode/internal/chrono/duration.hpp
index 519d48b..ac9eedb 100644
--- a/cppcache/include/geode/internal/chrono/duration.hpp
+++ b/cppcache/include/geode/internal/chrono/duration.hpp
@@ -35,7 +35,7 @@ namespace duration {
 
 template <class Period>
 struct _suffix {
-  static constexpr char const* value = nullptr;
+  static constexpr char const* value = "<<unknown units>>";
 };
 template <>
 struct _suffix<std::ratio<3600>> {
diff --git a/cppcache/src/EntryExpiryHandler.cpp b/cppcache/src/EntryExpiryHandler.cpp
index 8c1334c..e29f2a5 100644
--- a/cppcache/src/EntryExpiryHandler.cpp
+++ b/cppcache/src/EntryExpiryHandler.cpp
@@ -56,25 +56,19 @@ int EntryExpiryHandler::handle_timeout(const ACE_Time_Value& current_time,
     }
 
     auto elapsed = curr_time - lastTimeForExp;
-    LOGDEBUG(
-        "Entered entry expiry task handler for key [%s] of region [%s]: "
-        "%s,%s,%s,%s",
-        Utils::nullSafeToString(key).c_str(),
-        m_regionPtr->getFullPath().c_str(),
-        to_string(curr_time.time_since_epoch()).c_str(),
-        to_string(lastTimeForExp.time_since_epoch()).c_str(),
-        to_string(m_duration).c_str(), to_string(elapsed).c_str());
+
+    LOGDEBUG("Entered entry expiry task handler for key [%s] of region [%s]",
+             Utils::nullSafeToString(key).c_str(),
+             m_regionPtr->getFullPath().c_str());
     if (elapsed >= m_duration) {
       DoTheExpirationAction(key);
     } else {
       // reset the task after
       // (lastAccessTime + entryExpiryDuration - curr_time) in seconds
       auto remaining = m_duration - elapsed;
-      auto remainingStr = to_string(remaining);
-      LOGDEBUG(
-          "Resetting expiry task %s secs later for key [%s] of region [%s]",
-          remainingStr.c_str(), Utils::nullSafeToString(key).c_str(),
-          m_regionPtr->getFullPath().c_str());
+      LOGDEBUG("Resetting expiry task for key [%s] of region [%s]",
+               Utils::nullSafeToString(key).c_str(),
+               m_regionPtr->getFullPath().c_str());
       m_regionPtr->getCacheImpl()->getExpiryTaskManager().resetTask(
           expProps.getExpiryTaskId(), remaining);
       return 0;
diff --git a/cppcache/test/util/chrono/durationTest.cpp b/cppcache/test/util/chrono/durationTest.cpp
index b436bf7..80e766e 100644
--- a/cppcache/test/util/chrono/durationTest.cpp
+++ b/cppcache/test/util/chrono/durationTest.cpp
@@ -47,6 +47,9 @@ TEST(util_chrono_durationTest, to_string) {
   EXPECT_EQ("42ns", to_string(std::chrono::nanoseconds(42)));
   EXPECT_EQ("0ns", to_string(std::chrono::nanoseconds(0)));
   EXPECT_EQ("-42ns", to_string(std::chrono::nanoseconds(-42)));
+
+  EXPECT_EQ("100<<unknown units>>",
+            to_string(std::chrono::duration<int, std::ratio<1, 100000>>(100)));
 }
 
 TEST(util_chrono_durationTest, from_string) {