You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2018/11/29 18:31:38 UTC
[mesos] 14/14: Used `OperationID` instead of `string` in test
helpers.
This is an automated email from the ASF dual-hosted git repository.
chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit bf4e8b392b3fa58ffdbf5f14ce3f0ba7a1674a0c
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Thu Nov 15 01:27:39 2018 -0800
Used `OperationID` instead of `string` in test helpers.
This change makes the helper more consistent with other helpers, and is
more future-proof to changes in `OperationID`.
Review: https://reviews.apache.org/r/69366
---
src/tests/master_slave_reconciliation_tests.cpp | 2 +-
src/tests/master_tests.cpp | 2 +-
src/tests/mesos.hpp | 40 +++++++++++++---------
src/tests/operation_reconciliation_tests.cpp | 4 +--
.../storage_local_resource_provider_tests.cpp | 16 +++++----
5 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/src/tests/master_slave_reconciliation_tests.cpp b/src/tests/master_slave_reconciliation_tests.cpp
index 064b4d4..de6e382 100644
--- a/src/tests/master_slave_reconciliation_tests.cpp
+++ b/src/tests/master_slave_reconciliation_tests.cpp
@@ -577,7 +577,7 @@ TEST_F(
operationId.set_value("operation");
mesos.send(v1::createCallAccept(
- frameworkId, offer, {v1::RESERVE(reserved, operationId.value())}));
+ frameworkId, offer, {v1::RESERVE(reserved, operationId)}));
AWAIT_READY(applyOperationMessage);
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index 561c382..ef2c001 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -9286,7 +9286,7 @@ TEST_F(MasterTest, DropOperationWithIDAffectingDefaultResources)
operationId.set_value("operation");
mesos.send(v1::createCallAccept(
- frameworkId, offer, {v1::RESERVE(reserved, operationId.value())}));
+ frameworkId, offer, {v1::RESERVE(reserved, operationId)}));
// Wait for the framework to receive the OPERATION_ERROR update.
AWAIT_READY(operationErrorUpdate);
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 9850821..c08e7e6 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -1310,17 +1310,17 @@ inline TDomainInfo createDomainInfo(
// Helpers for creating operations.
-template <typename TResources, typename TOffer>
+template <typename TResources, typename TOperationID, typename TOffer>
inline typename TOffer::Operation RESERVE(
const TResources& resources,
- const Option<std::string> operationId = None())
+ const Option<TOperationID>& operationId = None())
{
typename TOffer::Operation operation;
operation.set_type(TOffer::Operation::RESERVE);
operation.mutable_reserve()->mutable_resources()->CopyFrom(resources);
if (operationId.isSome()) {
- operation.mutable_id()->set_value(operationId.get());
+ operation.mutable_id()->CopyFrom(operationId.get());
}
return operation;
@@ -1410,12 +1410,16 @@ inline typename TOffer::Operation LAUNCH_GROUP(
}
-template <typename TResource, typename TTargetType, typename TOffer>
+template <
+ typename TResource,
+ typename TTargetType,
+ typename TOperationID,
+ typename TOffer>
inline typename TOffer::Operation CREATE_DISK(
const TResource& source,
const TTargetType& targetType,
const Option<std::string>& targetProfile = None(),
- const Option<std::string>& operationId = None())
+ const Option<TOperationID>& operationId = None())
{
typename TOffer::Operation operation;
operation.set_type(TOffer::Operation::CREATE_DISK);
@@ -1427,7 +1431,7 @@ inline typename TOffer::Operation CREATE_DISK(
}
if (operationId.isSome()) {
- operation.mutable_id()->set_value(operationId.get());
+ operation.mutable_id()->CopyFrom(operationId.get());
}
return operation;
@@ -1747,7 +1751,8 @@ inline DomainInfo createDomainInfo(Args&&... args)
template <typename... Args>
inline Offer::Operation RESERVE(Args&&... args)
{
- return common::RESERVE<Resources, Offer>(std::forward<Args>(args)...);
+ return common::RESERVE<Resources, OperationID, Offer>(
+ std::forward<Args>(args)...);
}
@@ -1804,9 +1809,9 @@ inline Offer::Operation LAUNCH_GROUP(Args&&... args)
template <typename... Args>
inline Offer::Operation CREATE_DISK(Args&&... args)
{
- return common::CREATE_DISK<Resource,
- Resource::DiskInfo::Source::Type,
- Offer>(std::forward<Args>(args)...);
+ return common::
+ CREATE_DISK<Resource, Resource::DiskInfo::Source::Type, OperationID, Offer>(
+ std::forward<Args>(args)...);
}
@@ -2041,8 +2046,10 @@ inline hashmap<std::string, double> convertToHashmap(Args&&... args)
template <typename... Args>
inline mesos::v1::Offer::Operation RESERVE(Args&&... args)
{
- return common::RESERVE<mesos::v1::Resources, mesos::v1::Offer>(
- std::forward<Args>(args)...);
+ return common::RESERVE<
+ mesos::v1::Resources,
+ mesos::v1::OperationID,
+ mesos::v1::Offer>(std::forward<Args>(args)...);
}
@@ -2107,10 +2114,11 @@ inline mesos::v1::Offer::Operation LAUNCH_GROUP(Args&&... args)
template <typename... Args>
inline mesos::v1::Offer::Operation CREATE_DISK(Args&&... args)
{
- return common::CREATE_DISK<mesos::v1::Resource,
- mesos::v1::Resource::DiskInfo::Source::Type,
- mesos::v1::Offer>(
- std::forward<Args>(args)...);
+ return common::CREATE_DISK<
+ mesos::v1::Resource,
+ mesos::v1::Resource::DiskInfo::Source::Type,
+ mesos::v1::OperationID,
+ mesos::v1::Offer>(std::forward<Args>(args)...);
}
diff --git a/src/tests/operation_reconciliation_tests.cpp b/src/tests/operation_reconciliation_tests.cpp
index 8afac9a..a5e81a1 100644
--- a/src/tests/operation_reconciliation_tests.cpp
+++ b/src/tests/operation_reconciliation_tests.cpp
@@ -179,7 +179,7 @@ TEST_P(OperationReconciliationTest, PendingOperation)
mesos.send(createCallAccept(
frameworkId,
offer,
- {RESERVE(reservedResources, operationId.value())}));
+ {RESERVE(reservedResources, operationId)}));
AWAIT_READY(applyOperationMessage);
@@ -795,7 +795,7 @@ TEST_P(OperationReconciliationTest, AgentPendingOperationAfterMasterFailover)
source.get(),
Resource::DiskInfo::Source::MOUNT,
None(),
- operationId.value())}));
+ operationId)}));
AWAIT_READY(applyOperation);
diff --git a/src/tests/storage_local_resource_provider_tests.cpp b/src/tests/storage_local_resource_provider_tests.cpp
index 8c88c14..422a152 100644
--- a/src/tests/storage_local_resource_provider_tests.cpp
+++ b/src/tests/storage_local_resource_provider_tests.cpp
@@ -4204,7 +4204,9 @@ TEST_F(StorageLocalResourceProviderTest, RetryOperationStatusUpdateToScheduler)
.WillOnce(FutureArg<1>(&retriedUpdate));
// Create a volume.
- const string operationId = "operation";
+ v1::OperationID operationId;
+ operationId.set_value("operation");
+
mesos.send(v1::createCallAccept(
frameworkId,
offer,
@@ -4216,7 +4218,7 @@ TEST_F(StorageLocalResourceProviderTest, RetryOperationStatusUpdateToScheduler)
AWAIT_READY(update);
- ASSERT_EQ(operationId, update->status().operation_id().value());
+ ASSERT_EQ(operationId, update->status().operation_id());
ASSERT_EQ(
mesos::v1::OperationState::OPERATION_FINISHED, update->status().state());
ASSERT_TRUE(update->status().has_uuid());
@@ -4230,7 +4232,7 @@ TEST_F(StorageLocalResourceProviderTest, RetryOperationStatusUpdateToScheduler)
// should resend it after the status update retry interval minimum.
AWAIT_READY(retriedUpdate);
- ASSERT_EQ(operationId, retriedUpdate->status().operation_id().value());
+ ASSERT_EQ(operationId, retriedUpdate->status().operation_id());
ASSERT_EQ(
mesos::v1::OperationState::OPERATION_FINISHED,
retriedUpdate->status().state());
@@ -4397,10 +4399,10 @@ TEST_F(
frameworkId,
offer,
{v1::CREATE_DISK(
- source.get(),
- v1::Resource::DiskInfo::Source::MOUNT,
- None(),
- operationId.value())}));
+ source.get(),
+ v1::Resource::DiskInfo::Source::MOUNT,
+ None(),
+ operationId)}));
AWAIT_READY(update);