summaryrefslogtreecommitdiff
path: root/src/components/policy
diff options
context:
space:
mode:
authorAlexander Kutsan (GitHub) <akutsan@luxoft.com>2017-01-13 16:29:20 +0200
committerGitHub <noreply@github.com>2017-01-13 16:29:20 +0200
commit787736fe317125e77d9a422c86169c17e1d3a678 (patch)
tree9b78babcc1e0ab3eafa281dba8d93429d1c9eb28 /src/components/policy
parentc5e69c4f3bb3fab43bf5d9d2303a39858b60e7fc (diff)
parent81d6f8e743b734d6f1957d29b4c193f9bebd531a (diff)
downloadsdl_core-787736fe317125e77d9a422c86169c17e1d3a678.tar.gz
Merge pull request #1169 from LuxoftAKutsan/fix/timeout_in_seconds_fix
Use secconds against ms in RPCs
Diffstat (limited to 'src/components/policy')
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h2
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc6
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_test.cc2
-rw-r--r--src/components/policy/policy_external/test/update_status_manager_test.cc1
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager.h2
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h4
-rw-r--r--src/components/policy/policy_regular/include/policy/status.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/update_status_manager.h2
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc8
-rw-r--r--src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h2
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc4
12 files changed, 18 insertions, 18 deletions
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index db0fd6f122..505c9f71ce 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -77,7 +77,7 @@ class PolicyManagerImpl : public PolicyManager {
virtual std::string GetPolicyTableStatus() const;
virtual void ResetRetrySequence();
virtual int NextRetryTimeout();
- virtual int TimeoutExchange();
+ virtual uint32_t TimeoutExchangeMSec();
virtual const std::vector<int> RetrySequenceDelaysSeconds();
virtual void OnExceededTimeout();
virtual std::string GetLockScreenIconUrl() const OVERRIDE;
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index 64dcadf1ab..737fbf16f8 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -236,7 +236,7 @@ void PolicyManagerImpl::RequestPTUpdate() {
BinaryMessage update(message_string.begin(), message_string.end());
listener_->OnSnapshotCreated(
- update, RetrySequenceDelaysSeconds(), TimeoutExchange());
+ update, RetrySequenceDelaysSeconds(), TimeoutExchangeMSec());
} else {
LOG4CXX_ERROR(logger_, "Invalid Policy table snapshot - PTUpdate failed");
}
@@ -1059,7 +1059,7 @@ void PolicyManagerImpl::ResetRetrySequence() {
update_status_manager_.OnResetRetrySequence();
}
-int PolicyManagerImpl::TimeoutExchange() {
+uint32_t PolicyManagerImpl::TimeoutExchangeMSec() {
return retry_sequence_timeout_;
}
@@ -1073,7 +1073,7 @@ void PolicyManagerImpl::OnExceededTimeout() {
}
void PolicyManagerImpl::OnUpdateStarted() {
- int update_timeout = TimeoutExchange();
+ uint32_t update_timeout = TimeoutExchangeMSec();
LOG4CXX_DEBUG(logger_,
"Update timeout will be set to (milisec): " << update_timeout);
update_status_manager_.OnUpdateSentOut(update_timeout);
diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
index af7923918d..bc9f5ac8e6 100644
--- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc
@@ -223,7 +223,7 @@ TEST_F(PolicyManagerImplTest2, TimeOutExchange) {
// Arrange
CreateLocalPT(preloadet_pt_filename_);
// Check value taken from PT
- EXPECT_EQ(70000, manager_->TimeoutExchange());
+ EXPECT_EQ(70000u, manager_->TimeoutExchangeMSec());
}
TEST_F(PolicyManagerImplTest,
diff --git a/src/components/policy/policy_external/test/update_status_manager_test.cc b/src/components/policy/policy_external/test/update_status_manager_test.cc
index cb8cc98410..5546984ff4 100644
--- a/src/components/policy/policy_external/test/update_status_manager_test.cc
+++ b/src/components/policy/policy_external/test/update_status_manager_test.cc
@@ -148,6 +148,7 @@ TEST_F(UpdateStatusManagerTest,
// Arrange
EXPECT_CALL(listener_, OnUpdateStatusChanged(update_needed_status_));
manager_->ScheduleUpdate();
+ status_ = manager_->GetLastUpdateStatus();
EXPECT_EQ(StatusUpdateRequired, status_);
EXPECT_CALL(listener_, OnUpdateStatusChanged(updating_status_));
manager_->OnUpdateSentOut(k_timeout_);
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index c3fa6f1e34..47d8e69551 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -114,7 +114,7 @@ class CacheManager : public CacheManagerInterface {
/**
* @brief Returns timeout to wait for a response of PT update
- * @return value in seconds
+ * @return value in msec
*/
virtual int TimeoutResponse();
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager.h b/src/components/policy/policy_regular/include/policy/policy_manager.h
index 87db06acdb..1f726d308e 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager.h
@@ -159,7 +159,7 @@ class PolicyManager : public usage_statistics::StatisticsManager {
* Gets timeout to wait until receive response
* @return timeout in seconds
*/
- virtual int TimeoutExchange() = 0;
+ virtual uint32_t TimeoutExchangeMSec() = 0;
/**
* @brief List of timeouts in seconds between retries
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index e77158c157..31e4ab454c 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -84,7 +84,7 @@ class PolicyManagerImpl : public PolicyManager {
virtual std::string GetPolicyTableStatus() const;
virtual void ResetRetrySequence();
virtual uint32_t NextRetryTimeout();
- virtual int TimeoutExchange();
+ virtual uint32_t TimeoutExchangeMSec();
virtual const std::vector<int> RetrySequenceDelaysSeconds();
virtual void OnExceededTimeout();
virtual void OnUpdateStarted();
@@ -313,7 +313,7 @@ class PolicyManagerImpl : public PolicyManager {
std::map<std::string, AppPermissions> app_permissions_diff_;
/**
- * Timeout to wait response with UpdatePT
+ * Timeout to wait response with UpdatePT (msec)
*/
uint32_t retry_sequence_timeout_;
diff --git a/src/components/policy/policy_regular/include/policy/status.h b/src/components/policy/policy_regular/include/policy/status.h
index e5f464d10a..1d9ae97f8e 100644
--- a/src/components/policy/policy_regular/include/policy/status.h
+++ b/src/components/policy/policy_regular/include/policy/status.h
@@ -55,7 +55,6 @@ enum UpdateEvent {
kOnResetRetrySequence
};
-
const std::string kUpToDate = "UP_TO_DATE";
const std::string kUpdateNeeded = "UPDATE_NEEDED";
const std::string kUpdating = "UPDATING";
diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h
index c6c94cd420..ccd55e040a 100644
--- a/src/components/policy/policy_regular/include/policy/update_status_manager.h
+++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h
@@ -83,7 +83,7 @@ class UpdateStatusManager : public UpdateStatusManagerInterface {
/**
* @brief Update status hanlder for PTS sending out
- * @param update_timeout Timeout for waiting of incoming PTU
+ * @param update_timeout Timeout for waiting of incoming PTU (msec)
*/
void OnUpdateSentOut(uint32_t update_timeout);
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index ef678dd852..ac82c9ebcb 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -58,7 +58,7 @@ void DeleteManager(policy::PolicyManager* pm) {
}
namespace {
-const uint32_t kDefaultRetryTimeoutInSec = 60u;
+const uint32_t kDefaultRetryTimeoutInMSec = 60u * date_time::DateTime::MILLISECONDS_IN_SECOND;
} // namespace
namespace policy {
@@ -69,7 +69,7 @@ PolicyManagerImpl::PolicyManagerImpl()
: PolicyManager()
, listener_(NULL)
, cache_(new CacheManager)
- , retry_sequence_timeout_(kDefaultRetryTimeoutInSec)
+ , retry_sequence_timeout_(kDefaultRetryTimeoutInMSec)
, retry_sequence_index_(0)
, timer_retry_sequence_("Retry sequence timer",
new timer::TimerTaskImpl<PolicyManagerImpl>(
@@ -796,7 +796,7 @@ void PolicyManagerImpl::ResetRetrySequence() {
update_status_manager_.OnResetRetrySequence();
}
-int PolicyManagerImpl::TimeoutExchange() {
+uint32_t PolicyManagerImpl::TimeoutExchangeMSec() {
return retry_sequence_timeout_;
}
@@ -810,7 +810,7 @@ void PolicyManagerImpl::OnExceededTimeout() {
}
void PolicyManagerImpl::OnUpdateStarted() {
- int update_timeout = TimeoutExchange();
+ uint32_t update_timeout = TimeoutExchangeMSec();
LOG4CXX_DEBUG(logger_,
"Update timeout will be set to (milisec): " << update_timeout);
update_status_manager_.OnUpdateSentOut(update_timeout);
diff --git a/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h b/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h
index ea931d1637..b63bdf2d19 100644
--- a/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h
+++ b/src/components/policy/policy_regular/test/include/policy/mock_policy_manager.h
@@ -78,7 +78,7 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD0(ForcePTExchange, std::string());
MOCK_METHOD0(ResetRetrySequence, void());
MOCK_METHOD0(NextRetryTimeout, int());
- MOCK_METHOD0(TimeoutExchange, int());
+ MOCK_METHOD0(TimeoutExchangeMSec, uint32_t());
MOCK_METHOD0(RetrySequenceDelaysSeconds, const std::vector<int>());
MOCK_METHOD0(OnExceededTimeout, void());
MOCK_METHOD0(OnUpdateStarted, void());
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index 2b6da8e5fd..2f241fa069 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -881,7 +881,7 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) {
for (uint32_t retry_number = 0u; retry_number < size; ++retry_number) {
waiting_timeout += seconds_between_retries[retry_number].asInt();
- waiting_timeout += manager->TimeoutExchange();
+ waiting_timeout += manager->TimeoutExchangeMSec();
// it's in miliseconds
EXPECT_EQ(waiting_timeout * date_time::DateTime::MILLISECONDS_IN_SECOND,
@@ -894,7 +894,7 @@ TEST_F(PolicyManagerImplTest2, TimeOutExchange) {
// Arrange
CreateLocalPT("sdl_preloaded_pt.json");
// Check value taken from PT
- EXPECT_EQ(70000, manager->TimeoutExchange());
+ EXPECT_EQ(70000u, manager->TimeoutExchangeMSec());
}
TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) {