You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/10/20 20:01:31 UTC
[5/5] mesos git commit: Split mesos test helpers into 'internal' and
'v1' namespaces.
Split mesos test helpers into 'internal' and 'v1' namespaces.
Review: https://reviews.apache.org/r/52976
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e9da9b3b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e9da9b3b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e9da9b3b
Branch: refs/heads/master
Commit: e9da9b3bc41aa81c25d36901e52ff1e941fa09e6
Parents: 2373819
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Mon Oct 17 23:15:21 2016 -0700
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Oct 20 12:33:30 2016 -0700
----------------------------------------------------------------------
src/tests/api_tests.cpp | 15 +-
src/tests/containerizer.cpp | 8 +-
src/tests/containerizer.hpp | 6 +-
src/tests/default_executor_tests.cpp | 16 +-
src/tests/executor_http_api_tests.cpp | 8 +-
src/tests/fault_tolerance_tests.cpp | 8 +-
src/tests/http_fault_tolerance_tests.cpp | 86 +-
src/tests/master_contender_detector_tests.cpp | 33 +-
src/tests/master_maintenance_tests.cpp | 20 +-
src/tests/master_tests.cpp | 12 +-
src/tests/mesos.hpp | 978 +++++++++++++++++----
src/tests/scheduler_http_api_tests.cpp | 28 +-
src/tests/scheduler_tests.cpp | 152 ++--
src/tests/slave_recovery_tests.cpp | 4 +-
src/tests/slave_tests.cpp | 40 +-
15 files changed, 1010 insertions(+), 404 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index e42b62e..f87130d 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -811,8 +811,7 @@ TEST_P(MasterAPITest, ListFiles)
ASSERT_TRUE(v1Response.get().IsInitialized());
ASSERT_EQ(v1::master::Response::LIST_FILES, v1Response.get().type());
ASSERT_EQ(3, v1Response.get().list_files().file_infos().size());
- ASSERT_EQ(evolve(file),
- v1Response.get().list_files().file_infos(2));
+ ASSERT_EQ(evolve(file), v1Response.get().list_files().file_infos(2));
}
@@ -1469,8 +1468,8 @@ TEST_P(MasterAPITest, Subscribe)
Try<Owned<cluster::Master>> master = this->StartMaster();
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -1483,7 +1482,7 @@ TEST_P(MasterAPITest, Subscribe)
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected));
- scheduler::TestV1Mesos mesos(master.get()->pid, contentType, scheduler);
+ scheduler::v1::TestMesos mesos(master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -1503,7 +1502,7 @@ TEST_P(MasterAPITest, Subscribe)
call.set_type(v1::scheduler::Call::SUBSCRIBE);
v1::scheduler::Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
mesos.send(call);
}
@@ -1571,12 +1570,12 @@ TEST_P(MasterAPITest, Subscribe)
.WillOnce(FutureSatisfy(&update));
EXPECT_CALL(*executor, connected(_))
- .WillOnce(executor::SendSubscribe(frameworkId, evolve(executorId)));
+ .WillOnce(v1::executor::SendSubscribe(frameworkId, evolve(executorId)));
EXPECT_CALL(*executor, subscribed(_, _));
EXPECT_CALL(*executor, launch(_, _))
- .WillOnce(executor::SendUpdateFromTask(
+ .WillOnce(v1::executor::SendUpdateFromTask(
frameworkId, evolve(executorId), v1::TASK_RUNNING));
EXPECT_CALL(*executor, acknowledged(_, _));
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer.cpp b/src/tests/containerizer.cpp
index 27c29b4..69b93c7 100644
--- a/src/tests/containerizer.cpp
+++ b/src/tests/containerizer.cpp
@@ -42,7 +42,7 @@ namespace tests {
TestContainerizer::TestContainerizer(
const ExecutorID& executorId,
- const shared_ptr<MockV1HTTPExecutor>& executor)
+ const shared_ptr<v1::MockHTTPExecutor>& executor)
{
executors[executorId] = Owned<ExecutorData>(new ExecutorData());
executors.at(executorId)->v1ExecutorMock = executor;
@@ -177,9 +177,9 @@ Future<bool> TestContainerizer::_launch(
new MesosExecutorDriver(executorData->executor));
executorData->driver->start();
} else {
- shared_ptr<MockV1HTTPExecutor> executor = executorData->v1ExecutorMock;
- executorData->v1Library = Owned<executor::TestV1Mesos>(
- new executor::TestV1Mesos(ContentType::PROTOBUF, executor));
+ shared_ptr<v1::MockHTTPExecutor> executor = executorData->v1ExecutorMock;
+ executorData->v1Library = Owned<v1::executor::TestMesos>(
+ new v1::executor::TestMesos(ContentType::PROTOBUF, executor));
}
os::unsetenv("MESOS_LOCAL");
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer.hpp b/src/tests/containerizer.hpp
index 940c414..d418ece 100644
--- a/src/tests/containerizer.hpp
+++ b/src/tests/containerizer.hpp
@@ -61,7 +61,7 @@ public:
// unique across FrameworkIDs, which is not the case.
TestContainerizer(
const ExecutorID& executorId,
- const std::shared_ptr<MockV1HTTPExecutor>& executor);
+ const std::shared_ptr<v1::MockHTTPExecutor>& executor);
TestContainerizer(const hashmap<ExecutorID, Executor*>& executors);
@@ -176,8 +176,8 @@ private:
// HTTP executors. Note that `mesos::v1::executor::Mesos`
// requires that we provide it a shared pointer to the executor.
- std::shared_ptr<MockV1HTTPExecutor> v1ExecutorMock;
- process::Owned<executor::TestV1Mesos> v1Library;
+ std::shared_ptr<v1::MockHTTPExecutor> v1ExecutorMock;
+ process::Owned<v1::executor::TestMesos> v1Library;
};
// TODO(bmahler): The test containerizer currently assumes that
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/default_executor_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/default_executor_tests.cpp b/src/tests/default_executor_tests.cpp
index 92e6b9f..70779e8 100644
--- a/src/tests/default_executor_tests.cpp
+++ b/src/tests/default_executor_tests.cpp
@@ -75,7 +75,7 @@ TEST_P(DefaultExecutorTest, ROOT_TaskRunning)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Resources resources =
Resources::parse("cpus:0.1;mem:32;disk:32").get();
@@ -101,7 +101,7 @@ TEST_P(DefaultExecutorTest, ROOT_TaskRunning)
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected));
- scheduler::TestV1Mesos mesos(
+ scheduler::v1::TestMesos mesos(
master.get()->pid, ContentType::PROTOBUF, scheduler);
AWAIT_READY(connected);
@@ -215,7 +215,7 @@ TEST_P(DefaultExecutorTest, ROOT_KillTask)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Resources resources =
Resources::parse("cpus:0.1;mem:32;disk:32").get();
@@ -241,7 +241,7 @@ TEST_P(DefaultExecutorTest, ROOT_KillTask)
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected));
- scheduler::TestV1Mesos mesos(
+ scheduler::v1::TestMesos mesos(
master.get()->pid, ContentType::PROTOBUF, scheduler);
AWAIT_READY(connected);
@@ -399,7 +399,7 @@ TEST_F(DefaultExecutorTest, KillTaskGroupOnTaskFailure)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Resources resources =
Resources::parse("cpus:0.1;mem:32;disk:32").get();
@@ -424,7 +424,7 @@ TEST_F(DefaultExecutorTest, KillTaskGroupOnTaskFailure)
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected));
- scheduler::TestV1Mesos mesos(
+ scheduler::v1::TestMesos mesos(
master.get()->pid, ContentType::PROTOBUF, scheduler);
AWAIT_READY(connected);
@@ -572,7 +572,7 @@ TEST_P(DefaultExecutorTest, ROOT_TaskUsesExecutor)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Resources resources =
Resources::parse("cpus:0.1;mem:32;disk:32").get();
@@ -598,7 +598,7 @@ TEST_P(DefaultExecutorTest, ROOT_TaskUsesExecutor)
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected));
- scheduler::TestV1Mesos mesos(
+ scheduler::v1::TestMesos mesos(
master.get()->pid, ContentType::PROTOBUF, scheduler);
AWAIT_READY(connected);
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/executor_http_api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/executor_http_api_tests.cpp b/src/tests/executor_http_api_tests.cpp
index a9f1a7b..872caf6 100644
--- a/src/tests/executor_http_api_tests.cpp
+++ b/src/tests/executor_http_api_tests.cpp
@@ -331,7 +331,7 @@ TEST_P(ExecutorHttpApiTest, DefaultAccept)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -408,7 +408,7 @@ TEST_P(ExecutorHttpApiTest, NoAcceptHeader)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -729,8 +729,8 @@ TEST_F(ExecutorHttpApiTest, SubscribeBeforeContainerizerRecovery)
// since the agent hasn't finished recovering the containerizer.
Call call;
- call.mutable_framework_id()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO.id());
- call.mutable_executor_id()->CopyFrom(DEFAULT_V1_EXECUTOR_ID);
+ call.mutable_framework_id()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO.id());
+ call.mutable_executor_id()->CopyFrom(v1::DEFAULT_EXECUTOR_ID);
call.set_type(Call::SUBSCRIBE);
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/fault_tolerance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/fault_tolerance_tests.cpp b/src/tests/fault_tolerance_tests.cpp
index 95ac98c..1a8888d 100644
--- a/src/tests/fault_tolerance_tests.cpp
+++ b/src/tests/fault_tolerance_tests.cpp
@@ -65,6 +65,8 @@ using namespace mesos::internal::protobuf;
using mesos::internal::master::Master;
+using mesos::internal::scheduler::DEFAULT_REGISTRATION_BACKOFF_FACTOR;
+
using mesos::internal::slave::Slave;
using mesos::master::detector::MasterDetector;
@@ -716,7 +718,7 @@ TEST_F(FaultToleranceTest, SchedulerFailoverRetriedReregistration)
AWAIT_READY(reregistrationMessage);
// Trigger the re-registration retry instantly to avoid blocking the test.
- Clock::advance(internal::scheduler::DEFAULT_REGISTRATION_BACKOFF_FACTOR);
+ Clock::advance(DEFAULT_REGISTRATION_BACKOFF_FACTOR);
AWAIT_READY(sched2Registered);
@@ -770,7 +772,7 @@ TEST_F(FaultToleranceTest, FrameworkReliableRegistration)
// Trigger the re-registration retry instantly to avoid blocking the test.
Clock::pause();
- Clock::advance(internal::scheduler::DEFAULT_REGISTRATION_BACKOFF_FACTOR);
+ Clock::advance(DEFAULT_REGISTRATION_BACKOFF_FACTOR);
AWAIT_READY(registered); // Ensures registered message is received.
@@ -1706,7 +1708,7 @@ TEST_F(FaultToleranceTest, SlaveReliableRegistration)
// Trigger the registration retry instantly to avoid blocking the test.
Clock::pause();
- Clock::advance(internal::slave::DEFAULT_REGISTRATION_BACKOFF_FACTOR);
+ Clock::advance(DEFAULT_REGISTRATION_BACKOFF_FACTOR);
AWAIT_READY(resourceOffers);
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/http_fault_tolerance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/http_fault_tolerance_tests.cpp b/src/tests/http_fault_tolerance_tests.cpp
index 57ef562..d625ffc 100644
--- a/src/tests/http_fault_tolerance_tests.cpp
+++ b/src/tests/http_fault_tolerance_tests.cpp
@@ -89,7 +89,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterFailoverTimeout)
master::Flags flags = CreateMasterFlags();
flags.authenticate_frameworks = false;
- v1::FrameworkInfo frameworkInfo = DEFAULT_V1_FRAMEWORK_INFO;
+ v1::FrameworkInfo frameworkInfo = v1::DEFAULT_FRAMEWORK_INFO;
frameworkInfo.set_failover_timeout(Weeks(2).secs());
Try<Owned<cluster::Master>> master = StartMaster(flags);
@@ -105,13 +105,13 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterFailoverTimeout)
// Launch the first (i.e., failing) scheduler and wait until it receives
// a `SUBSCRIBED` event to launch the second (i.e., failover) scheduler.
{
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected));
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -161,14 +161,14 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterFailoverTimeout)
// Now launch the second (i.e., failover) scheduler using the
// framework id recorded from the first scheduler.
{
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected))
.WillRepeatedly(Return()); // Ignore future invocations.
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -188,7 +188,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterFailoverTimeout)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
subscribe->mutable_framework_info()->mutable_id()->CopyFrom(frameworkId);
schedulerLibrary.send(call);
@@ -216,14 +216,14 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterTeardown)
// Launch the first (i.e., failing) scheduler and wait until it receives
// a `SUBSCRIBED` event to launch the second (i.e., failover) scheduler.
{
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected))
.WillRepeatedly(Return()); // Ignore future invocations.
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -240,7 +240,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterTeardown)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
schedulerLibrary.send(call);
}
@@ -280,14 +280,14 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterTeardown)
// Now launch the second (i.e., failover) scheduler using the
// framework id recorded from the first scheduler.
{
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected))
.WillRepeatedly(Return()); // Ignore future invocations.
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -307,7 +307,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerSubscribeAfterTeardown)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
subscribe->mutable_framework_info()->mutable_id()->CopyFrom(frameworkId);
schedulerLibrary.send(call);
@@ -328,8 +328,8 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverStatusUpdate)
Try<Owned<cluster::Master>> master = StartMaster(flags);
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -346,7 +346,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverStatusUpdate)
ContentType contentType = ContentType::PROTOBUF;
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -367,7 +367,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverStatusUpdate)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
schedulerLibrary.send(call);
}
@@ -380,12 +380,12 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverStatusUpdate)
EXPECT_NE(0, offers->offers().size());
EXPECT_CALL(*executor, connected(_))
- .WillOnce(executor::SendSubscribe(frameworkId, evolve(executorId)));
+ .WillOnce(v1::executor::SendSubscribe(frameworkId, evolve(executorId)));
EXPECT_CALL(*executor, subscribed(_, _));
EXPECT_CALL(*executor, launch(_, _))
- .WillOnce(executor::SendUpdateFromTask(
+ .WillOnce(v1::executor::SendUpdateFromTask(
frameworkId, evolve(executorId), v1::TASK_RUNNING));
Future<Nothing> acknowledged;
@@ -427,14 +427,14 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverStatusUpdate)
// Failover the scheduler without acknowledging the status update.
- auto scheduler2 = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler2 = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected2;
EXPECT_CALL(*scheduler2, connected(_))
.WillOnce(FutureSatisfy(&connected2));
// Failover to another scheduler instance.
- scheduler::TestV1Mesos schedulerLibrary2(
+ scheduler::v1::TestMesos schedulerLibrary2(
master.get()->pid, contentType, scheduler2);
AWAIT_READY(connected2);
@@ -467,7 +467,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverStatusUpdate)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
subscribe->mutable_framework_info()->mutable_id()->CopyFrom(frameworkId);
schedulerLibrary2.send(call);
@@ -505,8 +505,8 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverExecutorToFrameworkMessage)
Try<Owned<cluster::Master>> master = StartMaster(flags);
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -523,7 +523,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverExecutorToFrameworkMessage)
ContentType contentType = ContentType::PROTOBUF;
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -544,7 +544,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverExecutorToFrameworkMessage)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
schedulerLibrary.send(call);
}
@@ -557,7 +557,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverExecutorToFrameworkMessage)
EXPECT_NE(0, offers->offers().size());
EXPECT_CALL(*executor, connected(_))
- .WillOnce(executor::SendSubscribe(frameworkId, evolve(executorId)));
+ .WillOnce(v1::executor::SendSubscribe(frameworkId, evolve(executorId)));
v1::executor::Mesos* executorLib;
EXPECT_CALL(*executor, subscribed(_, _))
@@ -589,14 +589,14 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverExecutorToFrameworkMessage)
AWAIT_READY(launch);
- auto scheduler2 = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler2 = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected2;
EXPECT_CALL(*scheduler2, connected(_))
.WillOnce(FutureSatisfy(&connected2));
// Failover to another scheduler instance.
- scheduler::TestV1Mesos schedulerLibrary2(
+ scheduler::v1::TestMesos schedulerLibrary2(
master.get()->pid, contentType, scheduler2);
AWAIT_READY(connected2);
@@ -623,7 +623,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverExecutorToFrameworkMessage)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
subscribe->mutable_framework_info()->mutable_id()->CopyFrom(frameworkId);
schedulerLibrary2.send(call);
@@ -673,8 +673,8 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverFrameworkToExecutorMessage)
Try<Owned<cluster::Master>> master = StartMaster(flags);
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -691,7 +691,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverFrameworkToExecutorMessage)
ContentType contentType = ContentType::PROTOBUF;
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -712,7 +712,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverFrameworkToExecutorMessage)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
schedulerLibrary.send(call);
}
@@ -725,7 +725,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverFrameworkToExecutorMessage)
EXPECT_NE(0, offers->offers().size());
EXPECT_CALL(*executor, connected(_))
- .WillOnce(executor::SendSubscribe(frameworkId, evolve(executorId)));
+ .WillOnce(v1::executor::SendSubscribe(frameworkId, evolve(executorId)));
EXPECT_CALL(*executor, subscribed(_, _));
@@ -755,14 +755,14 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverFrameworkToExecutorMessage)
AWAIT_READY(launch);
- auto scheduler2 = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler2 = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected2;
EXPECT_CALL(*scheduler2, connected(_))
.WillOnce(FutureSatisfy(&connected2));
// Failover to another scheduler instance.
- scheduler::TestV1Mesos schedulerLibrary2(
+ scheduler::v1::TestMesos schedulerLibrary2(
master.get()->pid, contentType, scheduler2);
AWAIT_READY(connected2);
@@ -789,7 +789,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverFrameworkToExecutorMessage)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
subscribe->mutable_framework_info()->mutable_id()->CopyFrom(frameworkId);
schedulerLibrary2.send(call);
@@ -812,7 +812,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerFailoverFrameworkToExecutorMessage)
Call::Message* message = call.mutable_message();
message->mutable_agent_id()->CopyFrom(offer.agent_id());
- message->mutable_executor_id()->CopyFrom(DEFAULT_V1_EXECUTOR_ID);
+ message->mutable_executor_id()->CopyFrom(v1::DEFAULT_EXECUTOR_ID);
message->set_data("hello world");
schedulerLibrary2.send(call);
@@ -838,8 +838,8 @@ TEST_F(HttpFaultToleranceTest, SchedulerExit)
Try<Owned<cluster::Master>> master = StartMaster(flags);
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -856,7 +856,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerExit)
ContentType contentType = ContentType::PROTOBUF;
- scheduler::TestV1Mesos schedulerLibrary(
+ scheduler::v1::TestMesos schedulerLibrary(
master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -877,7 +877,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerExit)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
schedulerLibrary.send(call);
}
@@ -890,7 +890,7 @@ TEST_F(HttpFaultToleranceTest, SchedulerExit)
EXPECT_NE(0, offers->offers().size());
EXPECT_CALL(*executor, connected(_))
- .WillOnce(executor::SendSubscribe(frameworkId, evolve(executorId)));
+ .WillOnce(v1::executor::SendSubscribe(frameworkId, evolve(executorId)));
EXPECT_CALL(*executor, subscribed(_, _));
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/master_contender_detector_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_contender_detector_tests.cpp b/src/tests/master_contender_detector_tests.cpp
index 2a7d713..d41caea 100644
--- a/src/tests/master_contender_detector_tests.cpp
+++ b/src/tests/master_contender_detector_tests.cpp
@@ -63,6 +63,8 @@ using mesos::internal::master::Master;
using mesos::internal::slave::Slave;
+using mesos::internal::protobuf::createMasterInfo;
+
using mesos::master::contender::MASTER_CONTENDER_ZK_SESSION_TIMEOUT;
using mesos::master::contender::MasterContender;
using mesos::master::contender::StandaloneMasterContender;
@@ -91,7 +93,6 @@ namespace mesos {
namespace internal {
namespace tests {
-
class MasterContenderDetectorTest : public MesosTest {};
@@ -146,7 +147,7 @@ TEST(BasicMasterContenderDetectorTest, Contender)
Owned<MasterContender> contender(new StandaloneMasterContender());
- contender->initialize(internal::protobuf::createMasterInfo(master));
+ contender->initialize(createMasterInfo(master));
Future<Future<Nothing>> contended = contender->contend();
AWAIT_READY(contended);
@@ -235,7 +236,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, MasterContender)
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo master = internal::protobuf::createMasterInfo(pid);
+ MasterInfo master = createMasterInfo(pid);
contender.initialize(master);
Future<Future<Nothing>> contended = contender.contend();
@@ -294,7 +295,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, ContenderPendingElection)
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo master = internal::protobuf::createMasterInfo(pid);
+ MasterInfo master = createMasterInfo(pid);
contender.initialize(master);
@@ -351,7 +352,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, MasterContenders)
pid1.address.ip = net::IP(10000000);
pid1.address.port = 10000;
- MasterInfo master1 = internal::protobuf::createMasterInfo(pid1);
+ MasterInfo master1 = createMasterInfo(pid1);
contender1->initialize(master1);
@@ -370,7 +371,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, MasterContenders)
pid2.address.ip = net::IP(10000001);
pid2.address.port = 10001;
- MasterInfo master2 = internal::protobuf::createMasterInfo(pid2);
+ MasterInfo master2 = createMasterInfo(pid2);
contender2.initialize(master2);
@@ -410,7 +411,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, NonRetryableFrrors)
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo master = internal::protobuf::createMasterInfo(pid);
+ MasterInfo master = createMasterInfo(pid);
// group2's password is wrong and operations on it will fail.
Owned<zookeeper::Group> group2(new Group(
@@ -475,7 +476,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, ContenderDetectorShutdownNetwork)
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo master = internal::protobuf::createMasterInfo(pid);
+ MasterInfo master = createMasterInfo(pid);
contender.initialize(master);
@@ -552,7 +553,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, MasterDetectorTimedoutSession)
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo leader = internal::protobuf::createMasterInfo(pid);
+ MasterInfo leader = createMasterInfo(pid);
leaderContender.initialize(leader);
@@ -574,7 +575,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, MasterDetectorTimedoutSession)
pid2.address.ip = net::IP(10000001);
pid2.address.port = 10001;
- MasterInfo follower = internal::protobuf::createMasterInfo(pid2);
+ MasterInfo follower = createMasterInfo(pid2);
followerContender.initialize(follower);
@@ -664,7 +665,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest,
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo leader = internal::protobuf::createMasterInfo(pid);
+ MasterInfo leader = createMasterInfo(pid);
// Create the group instance so we can expire its session.
Owned<zookeeper::Group> group(
@@ -694,7 +695,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest,
pid2.address.ip = net::IP(10000001);
pid2.address.port = 10001;
- MasterInfo follower = internal::protobuf::createMasterInfo(pid2);
+ MasterInfo follower = createMasterInfo(pid2);
ZooKeeperMasterDetector followerDetector(url.get());
ZooKeeperMasterContender followerContender(url.get());
@@ -742,7 +743,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, MasterDetectorExpireSlaveZKSession)
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo master = internal::protobuf::createMasterInfo(pid);
+ MasterInfo master = createMasterInfo(pid);
ZooKeeperMasterContender masterContender(url.get());
masterContender.initialize(master);
@@ -804,7 +805,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest,
pid.address.ip = net::IP(10000000);
pid.address.port = 10000;
- MasterInfo leader = internal::protobuf::createMasterInfo(pid);
+ MasterInfo leader = createMasterInfo(pid);
leaderContender.initialize(leader);
@@ -825,7 +826,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest,
pid2.address.ip = net::IP(10000001);
pid2.address.port = 10001;
- MasterInfo follower = internal::protobuf::createMasterInfo(pid2);
+ MasterInfo follower = createMasterInfo(pid2);
followerContender.initialize(follower);
@@ -882,7 +883,7 @@ TEST_F(ZooKeeperMasterContenderDetectorTest, MasterDetectorUsesJson)
pid.address.ip = net::IP::parse("10.10.1.22", AF_INET).get();
pid.address.port = 8080;
- MasterInfo leader = internal::protobuf::createMasterInfo(pid);
+ MasterInfo leader = createMasterInfo(pid);
JSON::Object masterInfo = JSON::protobuf(leader);
// Simulate a leading master.
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/master_maintenance_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_maintenance_tests.cpp b/src/tests/master_maintenance_tests.cpp
index 6917272..f46cb50 100644
--- a/src/tests/master_maintenance_tests.cpp
+++ b/src/tests/master_maintenance_tests.cpp
@@ -99,7 +99,7 @@ namespace tests {
JSON::Array createMachineList(std::initializer_list<MachineID> _ids)
{
RepeatedPtrField<MachineID> ids =
- internal::protobuf::maintenance::createMachineList(_ids);
+ mesos::internal::protobuf::maintenance::createMachineList(_ids);
return JSON::protobuf(ids);
}
@@ -353,14 +353,14 @@ TEST_F(MasterMaintenanceTest, PendingUnavailabilityTest)
Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), &containerizer);
ASSERT_SOME(slave);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected))
.WillRepeatedly(Return()); // Ignore future invocations.
- scheduler::TestV1Mesos mesos(
+ scheduler::v1::TestMesos mesos(
master.get()->pid, ContentType::PROTOBUF, scheduler);
AWAIT_READY(connected);
@@ -381,7 +381,7 @@ TEST_F(MasterMaintenanceTest, PendingUnavailabilityTest)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
mesos.send(call);
}
@@ -1101,14 +1101,14 @@ TEST_F(MasterMaintenanceTest, InverseOffers)
ASSERT_EQ(0, statuses.get().draining_machines(0).statuses().size());
// Now start a framework.
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected))
.WillRepeatedly(Return()); // Ignore future invocations.
- scheduler::TestV1Mesos mesos(
+ scheduler::v1::TestMesos mesos(
master.get()->pid, ContentType::PROTOBUF, scheduler);
AWAIT_READY(connected);
@@ -1133,7 +1133,7 @@ TEST_F(MasterMaintenanceTest, InverseOffers)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
mesos.send(call);
}
@@ -1435,14 +1435,14 @@ TEST_F(MasterMaintenanceTest, InverseOffersFilters)
AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
// Now start a framework.
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
Future<Nothing> connected;
EXPECT_CALL(*scheduler, connected(_))
.WillOnce(FutureSatisfy(&connected))
.WillRepeatedly(Return()); // Ignore future invocations.
- scheduler::TestV1Mesos mesos(
+ scheduler::v1::TestMesos mesos(
master.get()->pid, ContentType::PROTOBUF, scheduler);
AWAIT_READY(connected);
@@ -1471,7 +1471,7 @@ TEST_F(MasterMaintenanceTest, InverseOffersFilters)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
mesos.send(call);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/master_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp
index b31502f..033fae3 100644
--- a/src/tests/master_tests.cpp
+++ b/src/tests/master_tests.cpp
@@ -4994,8 +4994,8 @@ TEST_F(MasterTest, RecoverResourcesOrphanedTask)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- auto scheduler = std::make_shared<MockV1HTTPScheduler>();
- auto executor = std::make_shared<MockV1HTTPExecutor>();
+ auto scheduler = std::make_shared<v1::MockHTTPScheduler>();
+ auto executor = std::make_shared<v1::MockHTTPExecutor>();
ExecutorID executorId = DEFAULT_EXECUTOR_ID;
TestContainerizer containerizer(executorId, executor);
@@ -5011,7 +5011,7 @@ TEST_F(MasterTest, RecoverResourcesOrphanedTask)
ContentType contentType = ContentType::PROTOBUF;
- scheduler::TestV1Mesos mesos(master.get()->pid, contentType, scheduler);
+ scheduler::v1::TestMesos mesos(master.get()->pid, contentType, scheduler);
AWAIT_READY(connected);
@@ -5031,7 +5031,7 @@ TEST_F(MasterTest, RecoverResourcesOrphanedTask)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
mesos.send(call);
}
@@ -5046,13 +5046,13 @@ TEST_F(MasterTest, RecoverResourcesOrphanedTask)
v1::executor::Mesos* execMesos = nullptr;
EXPECT_CALL(*executor, connected(_))
- .WillOnce(executor::SendSubscribe(frameworkId, evolve(executorId)));
+ .WillOnce(v1::executor::SendSubscribe(frameworkId, evolve(executorId)));
EXPECT_CALL(*executor, subscribed(_, _))
.WillOnce(SaveArg<0>(&execMesos));
EXPECT_CALL(*executor, launch(_, _))
- .WillOnce(executor::SendUpdateFromTask(
+ .WillOnce(v1::executor::SendUpdateFromTask(
frameworkId, evolve(executorId), v1::TASK_RUNNING));
Future<Nothing> acknowledged;
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index a9af6e1..08bfedb 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -27,6 +27,7 @@
#include <mesos/scheduler.hpp>
#include <mesos/v1/executor.hpp>
+#include <mesos/v1/resources.hpp>
#include <mesos/v1/scheduler.hpp>
#include <mesos/v1/executor/executor.hpp>
@@ -65,6 +66,8 @@
#include "master/master.hpp"
+#include "sched/constants.hpp"
+
#include "slave/constants.hpp"
#include "slave/slave.hpp"
@@ -330,135 +333,238 @@ protected:
#endif // MESOS_HAS_JAVA
+namespace v1 {
-// Macros to get/create (default) ExecutorInfos and FrameworkInfos.
-#define DEFAULT_EXECUTOR_INFO \
- ({ ExecutorInfo executor; \
- executor.mutable_executor_id()->set_value("default"); \
- executor.mutable_command()->set_value("exit 1"); \
- executor; })
+// Alias existing `mesos::v1` namespaces so that we can easily write
+// `v1::` in tests.
+//
+// TODO(jmlvanre): Remove these aliases once we clean up the `tests`
+// namespace hierarchy.
+namespace agent = mesos::v1::agent;
+namespace maintenance = mesos::v1::maintenance;
+namespace master = mesos::v1::master;
+namespace quota = mesos::v1::quota;
+namespace scheduler = mesos::v1::scheduler;
+
+using mesos::v1::TASK_STAGING;
+using mesos::v1::TASK_STARTING;
+using mesos::v1::TASK_RUNNING;
+using mesos::v1::TASK_KILLING;
+using mesos::v1::TASK_FINISHED;
+using mesos::v1::TASK_FAILED;
+using mesos::v1::TASK_KILLED;
+using mesos::v1::TASK_ERROR;
+using mesos::v1::TASK_LOST;
+using mesos::v1::TASK_DROPPED;
+using mesos::v1::TASK_UNREACHABLE;
+using mesos::v1::TASK_GONE;
+using mesos::v1::TASK_GONE_BY_OPERATOR;
+using mesos::v1::TASK_UNKNOWN;
+
+using mesos::v1::AgentID;
+using mesos::v1::ContainerID;
+using mesos::v1::ExecutorID;
+using mesos::v1::ExecutorInfo;
+using mesos::v1::Filters;
+using mesos::v1::FrameworkID;
+using mesos::v1::FrameworkInfo;
+using mesos::v1::InverseOffer;
+using mesos::v1::MachineID;
+using mesos::v1::Metric;
+using mesos::v1::Offer;
+using mesos::v1::Resource;
+using mesos::v1::Resources;
+using mesos::v1::TaskID;
+using mesos::v1::TaskInfo;
+using mesos::v1::TaskGroupInfo;
+using mesos::v1::TaskState;
+using mesos::v1::TaskStatus;
+using mesos::v1::WeightInfo;
+
+} // namespace v1 {
+
+namespace common {
+template <typename TExecutorInfo>
+struct DefaultExecutorInfo
+{
+ static TExecutorInfo create()
+ {
+ TExecutorInfo executor;
+ executor.mutable_executor_id()->set_value("default");
+ executor.mutable_command()->set_value("exit 1");
+ return executor;
+ }
+};
-#define DEFAULT_V1_EXECUTOR_INFO \
- ({ v1::ExecutorInfo executor; \
- executor.mutable_executor_id()->set_value("default"); \
- executor.mutable_command()->set_value("exit 1"); \
- executor; })
+template <typename TCredential>
+struct DefaultCredential
+{
+ static TCredential create()
+ {
+ TCredential credential;
+ credential.set_principal("test-principal");
+ credential.set_secret("test-secret");
+ return credential;
+ }
+};
-#define DEFAULT_CREDENTIAL \
- ({ Credential credential; \
- credential.set_principal("test-principal"); \
- credential.set_secret("test-secret"); \
- credential; })
+// TODO(jmlvanre): consider factoring this out.
+template <typename TCredential>
+struct DefaultCredential2
+{
+ static TCredential create()
+ {
+ TCredential credential;
+ credential.set_principal("test-principal-2");
+ credential.set_secret("test-secret-2");
+ return credential;
+ }
+};
-#define DEFAULT_CREDENTIAL_2 \
- ({ Credential credential; \
- credential.set_principal("test-principal-2"); \
- credential.set_secret("test-secret-2"); \
- credential; })
+template <typename TFrameworkInfo, typename TCredential>
+struct DefaultFrameworkInfo
+{
+ static TFrameworkInfo create()
+ {
+ TFrameworkInfo framework;
+ framework.set_name("default");
+ framework.set_user(os::user().get());
+ framework.set_principal(
+ DefaultCredential<TCredential>::create().principal());
+ return framework;
+ }
+};
-#define DEFAULT_V1_CREDENTIAL \
- ({ v1::Credential credential; \
- credential.set_principal("test-principal"); \
- credential.set_secret("test-secret"); \
- credential; })
+template <typename TExecutorInfo, typename TExecutorID>
+struct DefaultExecutorID
+{
+ static TExecutorID create()
+ {
+ return DefaultExecutorInfo<TExecutorInfo>::create().executor_id();
+ }
+};
-#define DEFAULT_FRAMEWORK_INFO \
- ({ FrameworkInfo framework; \
- framework.set_name("default"); \
- framework.set_user(os::user().get()); \
- framework.set_principal(DEFAULT_CREDENTIAL.principal()); \
- framework; })
+} // namespace common {
+// TODO(jmlvanre): Remove `inline` once we have adjusted all tests to
+// distinguish between `internal` and `v1`.
+inline namespace internal {
+using DefaultExecutorInfo = common::DefaultExecutorInfo<ExecutorInfo>;
+using DefaultCredential = common::DefaultCredential<Credential>;
+using DefaultCredential2 = common::DefaultCredential2<Credential>;
+using DefaultFrameworkInfo =
+ common::DefaultFrameworkInfo<FrameworkInfo, Credential>;
+using DefaultExecutorID = common::DefaultExecutorID<ExecutorInfo, ExecutorID>;
+} // namespace internal {
-#define DEFAULT_V1_FRAMEWORK_INFO \
- ({ v1::FrameworkInfo framework; \
- framework.set_name("default"); \
- framework.set_user(os::user().get()); \
- framework.set_principal(DEFAULT_CREDENTIAL.principal()); \
- framework; })
+namespace v1 {
+using DefaultExecutorInfo =
+ common::DefaultExecutorInfo<mesos::v1::ExecutorInfo>;
+using DefaultCredential = common::DefaultCredential<mesos::v1::Credential>;
+using DefaultCredential2 = common::DefaultCredential2<mesos::v1::Credential>;
+using DefaultFrameworkInfo =
+ common::DefaultFrameworkInfo<mesos::v1::FrameworkInfo, mesos::v1::Credential>;
+using DefaultExecutorID =
+ common::DefaultExecutorID<mesos::v1::ExecutorInfo, mesos::v1::ExecutorID>;
+} // namespace v1 {
-#define DEFAULT_EXECUTOR_ID \
- DEFAULT_EXECUTOR_INFO.executor_id()
+// Macros to get/create (default) ExecutorInfos and FrameworkInfos.
+#define DEFAULT_EXECUTOR_INFO DefaultExecutorInfo::create()
-#define DEFAULT_V1_EXECUTOR_ID \
- DEFAULT_V1_EXECUTOR_INFO.executor_id()
+#define DEFAULT_CREDENTIAL DefaultCredential::create()
+#define DEFAULT_CREDENTIAL_2 DefaultCredential2::create()
-inline mesos::Environment createEnvironment(
- const hashmap<std::string, std::string>& map)
-{
- mesos::Environment environment;
- foreachpair (const std::string& key, const std::string& value, map) {
- mesos::Environment::Variable* variable = environment.add_variables();
- variable->set_name(key);
- variable->set_value(value);
- }
- return environment;
-}
+
+#define DEFAULT_FRAMEWORK_INFO DefaultFrameworkInfo::create()
-inline ExecutorInfo createExecutorInfo(
+#define DEFAULT_EXECUTOR_ID DefaultExecutorID::create()
+
+
+// We factor out all common behavior and templatize it so that we can
+// can call it from both `v1::` and `internal::`.
+namespace common {
+template <typename TExecutorInfo, typename TResources, typename TCommandInfo>
+inline TExecutorInfo createExecutorInfo(
const std::string& executorId,
- const std::string& command,
+ const TCommandInfo& command,
const Option<std::string>& resources = None())
{
- ExecutorInfo executor;
+ TExecutorInfo executor;
executor.mutable_executor_id()->set_value(executorId);
- executor.mutable_command()->set_value(command);
+ executor.mutable_command()->CopyFrom(command);
if (resources.isSome()) {
executor.mutable_resources()->CopyFrom(
- Resources::parse(resources.get()).get());
+ TResources::parse(resources.get()).get());
}
return executor;
}
-inline ExecutorInfo createExecutorInfo(
+template <typename TExecutorInfo, typename TResources>
+inline TExecutorInfo createExecutorInfo(
const std::string& executorId,
- const CommandInfo& command,
+ const std::string& command,
const Option<std::string>& resources = None())
{
- ExecutorInfo executor;
+ TExecutorInfo executor;
executor.mutable_executor_id()->set_value(executorId);
- executor.mutable_command()->CopyFrom(command);
+ executor.mutable_command()->set_value(command);
if (resources.isSome()) {
executor.mutable_resources()->CopyFrom(
- Resources::parse(resources.get()).get());
+ TResources::parse(resources.get()).get());
}
return executor;
}
-inline CommandInfo createCommandInfo(const std::string& command)
+template <typename TExecutorInfo, typename TResources>
+inline TExecutorInfo createExecutorInfo(
+ const std::string& executorId,
+ const char* command,
+ const Option<std::string>& resources = None())
+{
+ return createExecutorInfo<TExecutorInfo, TResources>(
+ executorId,
+ std::string(command),
+ resources);
+}
+
+
+template <typename TCommandInfo>
+inline TCommandInfo createCommandInfo(const std::string& command)
{
- CommandInfo commandInfo;
+ TCommandInfo commandInfo;
commandInfo.set_value(command);
return commandInfo;
}
-inline Image createDockerImage(const std::string& imageName)
+template <typename TImage>
+inline TImage createDockerImage(const std::string& imageName)
{
- Image image;
- image.set_type(Image::DOCKER);
+ TImage image;
+ image.set_type(TImage::DOCKER);
image.mutable_docker()->set_name(imageName);
return image;
}
-inline Volume createVolumeFromHostPath(
+template <typename TVolume>
+inline TVolume createVolumeFromHostPath(
const std::string& containerPath,
const std::string& hostPath,
- const Volume::Mode& mode)
+ const typename TVolume::Mode& mode)
{
- Volume volume;
+ TVolume volume;
volume.set_container_path(containerPath);
volume.set_host_path(hostPath);
volume.set_mode(mode);
@@ -466,32 +572,34 @@ inline Volume createVolumeFromHostPath(
}
-inline Volume createVolumeFromDockerImage(
+template <typename TVolume, typename TImage>
+inline TVolume createVolumeFromDockerImage(
const std::string& containerPath,
const std::string& imageName,
- const Volume::Mode& mode)
+ const typename TVolume::Mode& mode)
{
- Volume volume;
+ TVolume volume;
volume.set_container_path(containerPath);
volume.set_mode(mode);
- volume.mutable_image()->CopyFrom(createDockerImage(imageName));
+ volume.mutable_image()->CopyFrom(createDockerImage<TImage>(imageName));
return volume;
}
-inline ContainerInfo createContainerInfo(
+template <typename TContainerInfo, typename TVolume, typename TImage>
+inline TContainerInfo createContainerInfo(
const Option<std::string> imageName = None(),
- const vector<Volume>& volumes = {})
+ const vector<TVolume>& volumes = {})
{
- ContainerInfo info;
- info.set_type(ContainerInfo::MESOS);
+ TContainerInfo info;
+ info.set_type(TContainerInfo::MESOS);
if (imageName.isSome()) {
- Image* image = info.mutable_mesos()->mutable_image();
- image->CopyFrom(createDockerImage(imageName.get()));
+ TImage* image = info.mutable_mesos()->mutable_image();
+ image->CopyFrom(createDockerImage<TImage>(imageName.get()));
}
- foreach (const Volume& volume, volumes) {
+ foreach (const TVolume& volume, volumes) {
info.add_volumes()->CopyFrom(volume);
}
@@ -499,23 +607,43 @@ inline ContainerInfo createContainerInfo(
}
+inline void setAgentID(TaskInfo* task, const SlaveID& slaveId)
+{
+ task->mutable_slave_id()->CopyFrom(slaveId);
+}
+inline void setAgentID(
+ mesos::v1::TaskInfo* task,
+ const mesos::v1::AgentID& agentId)
+{
+ task->mutable_agent_id()->CopyFrom(agentId);
+}
+
+
// TODO(bmahler): Refactor this to make the distinction between
// command tasks and executor tasks clearer.
-inline TaskInfo createTask(
- const SlaveID& slaveId,
- const Resources& resources,
- const CommandInfo& command,
- const Option<mesos::ExecutorID>& executorId = None(),
+template <
+ typename TTaskInfo,
+ typename TExecutorID,
+ typename TSlaveID,
+ typename TResources,
+ typename TExecutorInfo,
+ typename TCommandInfo,
+ typename TOffer>
+inline TTaskInfo createTask(
+ const TSlaveID& slaveId,
+ const TResources& resources,
+ const TCommandInfo& command,
+ const Option<TExecutorID>& executorId = None(),
const std::string& name = "test-task",
const std::string& id = UUID::random().toString())
{
- TaskInfo task;
+ TTaskInfo task;
task.set_name(name);
task.mutable_task_id()->set_value(id);
- task.mutable_slave_id()->CopyFrom(slaveId);
+ setAgentID(&task, slaveId);
task.mutable_resources()->CopyFrom(resources);
if (executorId.isSome()) {
- ExecutorInfo executor;
+ TExecutorInfo executor;
executor.mutable_executor_id()->CopyFrom(executorId.get());
executor.mutable_command()->CopyFrom(command);
task.mutable_executor()->CopyFrom(executor);
@@ -527,46 +655,77 @@ inline TaskInfo createTask(
}
-inline TaskInfo createTask(
- const SlaveID& slaveId,
- const Resources& resources,
+template <
+ typename TTaskInfo,
+ typename TExecutorID,
+ typename TSlaveID,
+ typename TResources,
+ typename TExecutorInfo,
+ typename TCommandInfo,
+ typename TOffer>
+inline TTaskInfo createTask(
+ const TSlaveID& slaveId,
+ const TResources& resources,
const std::string& command,
- const Option<mesos::ExecutorID>& executorId = None(),
+ const Option<TExecutorID>& executorId = None(),
const std::string& name = "test-task",
const std::string& id = UUID::random().toString())
{
- return createTask(
- slaveId,
- resources,
- createCommandInfo(command),
- executorId,
- name,
- id);
+ return createTask<
+ TTaskInfo,
+ TExecutorID,
+ TSlaveID,
+ TResources,
+ TExecutorInfo,
+ TCommandInfo,
+ TOffer>(
+ slaveId,
+ resources,
+ createCommandInfo<TCommandInfo>(command),
+ executorId,
+ name,
+ id);
}
-inline TaskInfo createTask(
- const Offer& offer,
+template <
+ typename TTaskInfo,
+ typename TExecutorID,
+ typename TSlaveID,
+ typename TResources,
+ typename TExecutorInfo,
+ typename TCommandInfo,
+ typename TOffer>
+inline TTaskInfo createTask(
+ const TOffer& offer,
const std::string& command,
- const Option<mesos::ExecutorID>& executorId = None(),
+ const Option<TExecutorID>& executorId = None(),
const std::string& name = "test-task",
const std::string& id = UUID::random().toString())
{
- return createTask(
- offer.slave_id(),
- offer.resources(),
- command,
- executorId,
- name,
- id);
+ return createTask<
+ TTaskInfo,
+ TExecutorID,
+ TSlaveID,
+ TResources,
+ TExecutorInfo,
+ TCommandInfo,
+ TOffer>(
+ offer.slave_id(),
+ offer.resources(),
+ command,
+ executorId,
+ name,
+ id);
}
-inline Resource::ReservationInfo createReservationInfo(
+template <typename TResource, typename TLabels>
+inline typename TResource::ReservationInfo createReservationInfo(
const Option<std::string>& principal = None(),
- const Option<Labels>& labels = None())
+ const Option<TLabels>& labels = None())
{
- Resource::ReservationInfo info;
+ typename TResource::ReservationInfo info;
if (principal.isSome()) {
info.set_principal(principal.get());
@@ -580,13 +739,14 @@ inline Resource::ReservationInfo createReservationInfo(
}
-inline Resource createReservedResource(
+template <typename TResource, typename TResources>
+inline TResource createReservedResource(
const std::string& name,
const std::string& value,
const std::string& role,
- const Option<Resource::ReservationInfo>& reservation)
+ const Option<typename TResource::ReservationInfo>& reservation)
{
- Resource resource = Resources::parse(name, value, role).get();
+ TResource resource = TResources::parse(name, value, role).get();
if (reservation.isSome()) {
resource.mutable_reservation()->CopyFrom(reservation.get());
@@ -599,15 +759,16 @@ inline Resource createReservedResource(
// NOTE: We only set the volume in DiskInfo if 'containerPath' is set.
// If volume mode is not specified, Volume::RW will be used (assuming
// 'containerPath' is set).
-inline Resource::DiskInfo createDiskInfo(
+template <typename TResource, typename TVolume>
+inline typename TResource::DiskInfo createDiskInfo(
const Option<std::string>& persistenceId,
const Option<std::string>& containerPath,
- const Option<Volume::Mode>& mode = None(),
+ const Option<typename TVolume::Mode>& mode = None(),
const Option<std::string>& hostPath = None(),
- const Option<Resource::DiskInfo::Source>& source = None(),
+ const Option<typename TResource::DiskInfo::Source>& source = None(),
const Option<std::string>& principal = None())
{
- Resource::DiskInfo info;
+ typename TResource::DiskInfo info;
if (persistenceId.isSome()) {
info.mutable_persistence()->set_id(persistenceId.get());
@@ -618,9 +779,9 @@ inline Resource::DiskInfo createDiskInfo(
}
if (containerPath.isSome()) {
- Volume volume;
+ TVolume volume;
volume.set_container_path(containerPath.get());
- volume.set_mode(mode.isSome() ? mode.get() : Volume::RW);
+ volume.set_mode(mode.isSome() ? mode.get() : TVolume::RW);
if (hostPath.isSome()) {
volume.set_host_path(hostPath.get());
@@ -638,11 +799,13 @@ inline Resource::DiskInfo createDiskInfo(
// Helper for creating a disk source with type `PATH`.
-inline Resource::DiskInfo::Source createDiskSourcePath(const std::string& root)
+template <typename TResource>
+inline typename TResource::DiskInfo::Source createDiskSourcePath(
+ const std::string& root)
{
- Resource::DiskInfo::Source source;
+ typename TResource::DiskInfo::Source source;
- source.set_type(Resource::DiskInfo::Source::PATH);
+ source.set_type(TResource::DiskInfo::Source::PATH);
source.mutable_path()->set_root(root);
return source;
@@ -650,11 +813,13 @@ inline Resource::DiskInfo::Source createDiskSourcePath(const std::string& root)
// Helper for creating a disk source with type `MOUNT`.
-inline Resource::DiskInfo::Source createDiskSourceMount(const std::string& root)
+template <typename TResource>
+inline typename TResource::DiskInfo::Source createDiskSourceMount(
+ const std::string& root)
{
- Resource::DiskInfo::Source source;
+ typename TResource::DiskInfo::Source source;
- source.set_type(Resource::DiskInfo::Source::MOUNT);
+ source.set_type(TResource::DiskInfo::Source::MOUNT);
source.mutable_mount()->set_root(root);
return source;
@@ -662,19 +827,25 @@ inline Resource::DiskInfo::Source createDiskSourceMount(const std::string& root)
// Helper for creating a disk resource.
-inline Resource createDiskResource(
+template <typename TResource, typename TVolume>
+inline TResource createDiskResource(
const std::string& value,
const std::string& role,
const Option<std::string>& persistenceID,
const Option<std::string>& containerPath,
- const Option<Resource::DiskInfo::Source>& source = None(),
+ const Option<typename TResource::DiskInfo::Source>& source = None(),
bool isShared = false)
{
- Resource resource = Resources::parse("disk", value, role).get();
+ TResource resource = Resources::parse("disk", value, role).get();
if (persistenceID.isSome() || containerPath.isSome() || source.isSome()) {
resource.mutable_disk()->CopyFrom(
- createDiskInfo(persistenceID, containerPath, None(), None(), source));
+ createDiskInfo<TResource, TVolume>(
+ persistenceID,
+ containerPath,
+ None(),
+ None(),
+ source));
if (isShared) {
resource.mutable_shared();
@@ -687,23 +858,24 @@ inline Resource createDiskResource(
// Note that `reservationPrincipal` should be specified if and only if
// the volume uses dynamically reserved resources.
-inline Resource createPersistentVolume(
+template <typename TResource, typename TVolume>
+inline TResource createPersistentVolume(
const Bytes& size,
const std::string& role,
const std::string& persistenceId,
const std::string& containerPath,
const Option<std::string>& reservationPrincipal = None(),
- const Option<Resource::DiskInfo::Source>& source = None(),
+ const Option<typename TResource::DiskInfo::Source>& source = None(),
const Option<std::string>& creatorPrincipal = None(),
bool isShared = false)
{
- Resource volume = Resources::parse(
+ TResource volume = Resources::parse(
"disk",
stringify(size.megabytes()),
role).get();
volume.mutable_disk()->CopyFrom(
- createDiskInfo(
+ createDiskInfo<TResource, TVolume>(
persistenceId,
containerPath,
None(),
@@ -725,21 +897,22 @@ inline Resource createPersistentVolume(
// Note that `reservationPrincipal` should be specified if and only if
// the volume uses dynamically reserved resources.
-inline Resource createPersistentVolume(
- Resource volume,
+template <typename TResource, typename TVolume>
+inline TResource createPersistentVolume(
+ TResource volume,
const std::string& persistenceId,
const std::string& containerPath,
const Option<std::string>& reservationPrincipal = None(),
const Option<std::string>& creatorPrincipal = None(),
bool isShared = false)
{
- Option<Resource::DiskInfo::Source> source = None();
+ Option<typename TResource::DiskInfo::Source> source = None();
if (volume.has_disk() && volume.disk().has_source()) {
source = volume.disk().source();
}
volume.mutable_disk()->CopyFrom(
- createDiskInfo(
+ createDiskInfo<TResource, TVolume>(
persistenceId,
containerPath,
None(),
@@ -759,8 +932,9 @@ inline Resource createPersistentVolume(
}
+template <typename TCredential>
inline process::http::Headers createBasicAuthHeaders(
- const Credential& credential)
+ const TCredential& credential)
{
return process::http::Headers{{
"Authorization",
@@ -771,16 +945,17 @@ inline process::http::Headers createBasicAuthHeaders(
// Create WeightInfos from the specified weights flag.
-inline google::protobuf::RepeatedPtrField<WeightInfo> createWeightInfos(
+template <typename TWeightInfo>
+inline google::protobuf::RepeatedPtrField<TWeightInfo> createWeightInfos(
const std::string& weightsFlag)
{
- google::protobuf::RepeatedPtrField<WeightInfo> infos;
+ google::protobuf::RepeatedPtrField<TWeightInfo> infos;
std::vector<std::string> tokens = strings::tokenize(weightsFlag, ",");
foreach (const std::string& token, tokens) {
std::vector<std::string> pair = strings::tokenize(token, "=");
EXPECT_EQ(2u, pair.size());
double weight = atof(pair[1].c_str());
- WeightInfo weightInfo;
+ TWeightInfo weightInfo;
weightInfo.set_role(pair[0]);
weightInfo.set_weight(weight);
infos.Add()->CopyFrom(weightInfo);
@@ -791,12 +966,13 @@ inline google::protobuf::RepeatedPtrField<WeightInfo> createWeightInfos(
// Convert WeightInfos protobuf to weights hashmap.
+template <typename TWeightInfo>
inline hashmap<std::string, double> convertToHashmap(
- const google::protobuf::RepeatedPtrField<WeightInfo> weightInfos)
+ const google::protobuf::RepeatedPtrField<TWeightInfo> weightInfos)
{
hashmap<std::string, double> weights;
- foreach (const WeightInfo& weightInfo, weightInfos) {
+ foreach (const TWeightInfo& weightInfo, weightInfos) {
weights[weightInfo.role()] = weightInfo.weight();
}
@@ -805,48 +981,53 @@ inline hashmap<std::string, double> convertToHashmap(
// Helpers for creating offer operations.
-inline Offer::Operation RESERVE(const Resources& resources)
+template <typename TResources, typename TOffer>
+inline typename TOffer::Operation RESERVE(const TResources& resources)
{
- Offer::Operation operation;
- operation.set_type(Offer::Operation::RESERVE);
+ typename TOffer::Operation operation;
+ operation.set_type(TOffer::Operation::RESERVE);
operation.mutable_reserve()->mutable_resources()->CopyFrom(resources);
return operation;
}
-inline Offer::Operation UNRESERVE(const Resources& resources)
+template <typename TResources, typename TOffer>
+inline typename TOffer::Operation UNRESERVE(const TResources& resources)
{
- Offer::Operation operation;
- operation.set_type(Offer::Operation::UNRESERVE);
+ typename TOffer::Operation operation;
+ operation.set_type(TOffer::Operation::UNRESERVE);
operation.mutable_unreserve()->mutable_resources()->CopyFrom(resources);
return operation;
}
-inline Offer::Operation CREATE(const Resources& volumes)
+template <typename TResources, typename TOffer>
+inline typename TOffer::Operation CREATE(const TResources& volumes)
{
- Offer::Operation operation;
- operation.set_type(Offer::Operation::CREATE);
+ typename TOffer::Operation operation;
+ operation.set_type(TOffer::Operation::CREATE);
operation.mutable_create()->mutable_volumes()->CopyFrom(volumes);
return operation;
}
-inline Offer::Operation DESTROY(const Resources& volumes)
+template <typename TResources, typename TOffer>
+inline typename TOffer::Operation DESTROY(const TResources& volumes)
{
- Offer::Operation operation;
- operation.set_type(Offer::Operation::DESTROY);
+ typename TOffer::Operation operation;
+ operation.set_type(TOffer::Operation::DESTROY);
operation.mutable_destroy()->mutable_volumes()->CopyFrom(volumes);
return operation;
}
-inline Offer::Operation LAUNCH(const std::vector<TaskInfo>& tasks)
+template <typename TOffer, typename TTaskInfo>
+inline typename TOffer::Operation LAUNCH(const std::vector<TTaskInfo>& tasks)
{
- Offer::Operation operation;
- operation.set_type(Offer::Operation::LAUNCH);
+ typename TOffer::Operation operation;
+ operation.set_type(TOffer::Operation::LAUNCH);
- foreach (const TaskInfo& task, tasks) {
+ foreach (const TTaskInfo& task, tasks) {
operation.mutable_launch()->add_task_infos()->CopyFrom(task);
}
@@ -854,15 +1035,415 @@ inline Offer::Operation LAUNCH(const std::vector<TaskInfo>& tasks)
}
-inline Parameters parameterize(const ACLs& acls)
+template <typename TParameters, typename TParameter>
+inline TParameters parameterize(const ACLs& acls)
{
- Parameters parameters;
- Parameter* parameter = parameters.add_parameter();
+ TParameters parameters;
+ TParameter* parameter = parameters.add_parameter();
parameter->set_key("acls");
parameter->set_value(std::string(jsonify(JSON::Protobuf(acls))));
return parameters;
}
+} // namespace common {
+
+
+// TODO(jmlvanre): Remove `inline` once we have adjusted all tests to
+// distinguish between `internal` and `v1`.
+inline namespace internal {
+template <typename... Args>
+inline ExecutorInfo createExecutorInfo(Args&&... args)
+{
+ return common::createExecutorInfo<ExecutorInfo, Resources>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline CommandInfo createCommandInfo(Args&&... args)
+{
+ return common::createCommandInfo<CommandInfo>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Image createDockerImage(Args&&... args)
+{
+ return common::createDockerImage<Image>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Volume createVolumeFromHostPath(Args&&... args)
+{
+ return common::createVolumeFromHostPath<Volume>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Volume createVolumeFromDockerImage(Args&&... args)
+{
+ return common::createVolumeFromDockerImage<Volume, Image>(
+ std::forward<Args>(args)...);
+}
+
+
+// We specify the argument to allow brace initialized construction.
+inline ContainerInfo createContainerInfo(
+ const Option<std::string> imageName = None(),
+ const vector<Volume>& volumes = {})
+{
+ return common::createContainerInfo<ContainerInfo, Volume, Image>(
+ imageName,
+ volumes);
+}
+
+
+template <typename... Args>
+inline TaskInfo createTask(Args&&... args)
+{
+ return common::createTask<
+ TaskInfo,
+ ExecutorID,
+ SlaveID,
+ Resources,
+ ExecutorInfo,
+ CommandInfo,
+ Offer>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Resource::ReservationInfo createReservationInfo(Args&&... args)
+{
+ return common::createReservationInfo<Resource, Labels>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Resource createReservedResource(Args&&... args)
+{
+ return common::createReservedResource<Resource, Resources>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Resource::DiskInfo createDiskInfo(Args&&... args)
+{
+ return common::createDiskInfo<Resource, Volume>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Resource::DiskInfo::Source createDiskSourcePath(Args&&... args)
+{
+ return common::createDiskSourcePath<Resource>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Resource::DiskInfo::Source createDiskSourceMount(Args&&... args)
+{
+ return common::createDiskSourceMount<Resource>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Resource createDiskResource(Args&&... args)
+{
+ return common::createDiskResource<Resource, Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Resource createPersistentVolume(Args&&... args)
+{
+ return common::createPersistentVolume<Resource, Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline process::http::Headers createBasicAuthHeaders(Args&&... args)
+{
+ return common::createBasicAuthHeaders<Credential>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline google::protobuf::RepeatedPtrField<WeightInfo> createWeightInfos(
+ Args&&... args)
+{
+ return common::createWeightInfos<WeightInfo>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline hashmap<std::string, double> convertToHashmap(Args&&... args)
+{
+ return common::convertToHashmap<WeightInfo>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Offer::Operation RESERVE(Args&&... args)
+{
+ return common::RESERVE<Resources, Offer>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Offer::Operation UNRESERVE(Args&&... args)
+{
+ return common::UNRESERVE<Resources, Offer>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Offer::Operation CREATE(Args&&... args)
+{
+ return common::CREATE<Resources, Offer>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline Offer::Operation DESTROY(Args&&... args)
+{
+ return common::DESTROY<Resources, Offer>(std::forward<Args>(args)...);
+}
+
+
+// We specify the argument to allow brace initialized construction.
+inline Offer::Operation LAUNCH(const std::vector<TaskInfo>& tasks)
+{
+ return common::LAUNCH<Offer, TaskInfo>(tasks);
+}
+
+
+template <typename... Args>
+inline Parameters parameterize(Args&&... args)
+{
+ return common::parameterize<Parameters, Parameter>(
+ std::forward<Args>(args)...);
+}
+} // namespace internal {
+
+
+namespace v1 {
+template <typename... Args>
+inline mesos::v1::ExecutorInfo createExecutorInfo(Args&&... args)
+{
+ return common::createExecutorInfo<
+ mesos::v1::ExecutorInfo,
+ mesos::v1::Resources>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::CommandInfo createCommandInfo(Args&&... args)
+{
+ return common::createCommandInfo<mesos::v1::CommandInfo>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Image createDockerImage(Args&&... args)
+{
+ return common::createDockerImage<mesos::v1::Image>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Volume createVolumeFromHostPath(Args&&... args)
+{
+ return common::createVolumeFromHostPath<mesos::v1::Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Volume createVolumeFromDockerImage(Args&&... args)
+{
+ return common::createVolumeFromDockerImage<
+ mesos::v1::Volume, mesos::v1::Image>(std::forward<Args>(args)...);
+}
+
+
+// We specify the argument to allow brace initialized construction.
+inline mesos::v1::ContainerInfo createContainerInfo(
+ const Option<std::string> imageName = None(),
+ const vector<mesos::v1::Volume>& volumes = {})
+{
+ return common::createContainerInfo<
+ mesos::v1::ContainerInfo, mesos::v1::Volume, mesos::v1::Image>(
+ imageName, volumes);
+}
+
+
+template <typename... Args>
+inline mesos::v1::TaskInfo createTask(Args&&... args)
+{
+ return common::createTask<
+ mesos::v1::TaskInfo,
+ mesos::v1::ExecutorID,
+ mesos::v1::AgentID,
+ mesos::v1::Resources,
+ mesos::v1::ExecutorInfo,
+ mesos::v1::CommandInfo,
+ mesos::v1::Offer>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Resource::ReservationInfo createReservationInfo(
+ Args&&... args)
+{
+ return common::createReservationInfo<mesos::v1::Resource, mesos::v1::Labels>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Resource createReservedResource(Args&&... args)
+{
+ return common::createReservedResource<
+ mesos::v1::Resource, mesos::v1::Resources>(std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Resource::DiskInfo createDiskInfo(Args&&... args)
+{
+ return common::createDiskInfo<mesos::v1::Resource, mesos::v1::Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Resource::DiskInfo::Source createDiskSourcePath(
+ Args&&... args)
+{
+ return common::createDiskSourcePath<mesos::v1::Resource>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Resource::DiskInfo::Source createDiskSourceMount(
+ Args&&... args)
+{
+ return common::createDiskSourceMount<mesos::v1::Resource>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Resource createDiskResource(Args&&... args)
+{
+ return common::createDiskResource<mesos::v1::Resource, mesos::v1::Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Resource createPersistentVolume(Args&&... args)
+{
+ return common::createPersistentVolume<mesos::v1::Resource, mesos::v1::Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline process::http::Headers createBasicAuthHeaders(Args&&... args)
+{
+ return common::createBasicAuthHeaders<mesos::v1::Credential>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline google::protobuf::RepeatedPtrField<
+ mesos::v1::WeightInfo> createWeightInfos(Args&&... args)
+{
+ return common::createWeightInfos<mesos::v1::WeightInfo>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline hashmap<std::string, double> convertToHashmap(Args&&... args)
+{
+ return common::convertToHashmap<mesos::v1::WeightInfo>(
+ std::forward<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)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Offer::Operation UNRESERVE(Args&&... args)
+{
+ return common::UNRESERVE<mesos::v1::Resources, mesos::v1::Offer>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Offer::Operation CREATE(Args&&... args)
+{
+ return common::CREATE<mesos::v1::Resources, mesos::v1::Offer>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Offer::Operation DESTROY(Args&&... args)
+{
+ return common::DESTROY<mesos::v1::Resources, mesos::v1::Offer>(
+ std::forward<Args>(args)...);
+}
+
+
+// We specify the argument to allow brace initialized construction.
+inline mesos::v1::Offer::Operation LAUNCH(
+ const std::vector<mesos::v1::TaskInfo>& tasks)
+{
+ return common::LAUNCH<mesos::v1::Offer, mesos::v1::TaskInfo>(tasks);
+}
+
+
+template <typename... Args>
+inline mesos::v1::Parameters parameterize(Args&&... args)
+{
+ return common::parameterize<mesos::v1::Parameters, mesos::v1::Parameter>(
+ std::forward<Args>(args)...);
+}
+} // namespace v1 {
+
+
+inline mesos::Environment createEnvironment(
+ const hashmap<std::string, std::string>& map)
+{
+ mesos::Environment environment;
+ foreachpair (const std::string& key, const std::string& value, map) {
+ mesos::Environment::Variable* variable = environment.add_variables();
+ variable->set_name(key);
+ variable->set_value(value);
+ }
+ return environment;
+}
// Definition of a mock Scheduler to be used in tests with gmock.
@@ -1010,10 +1591,10 @@ public:
mesos::master::detector::MasterDetector* _detector)
: MesosSchedulerDriver(
scheduler,
- DEFAULT_FRAMEWORK_INFO,
+ internal::DEFAULT_FRAMEWORK_INFO,
"",
true,
- DEFAULT_CREDENTIAL)
+ internal::DEFAULT_CREDENTIAL)
{
// No-op destructor as _detector lives on the stack.
detector =
@@ -1031,7 +1612,7 @@ public:
framework,
"",
implicitAcknowledgements,
- DEFAULT_CREDENTIAL)
+ internal::DEFAULT_CREDENTIAL)
{
// No-op destructor as _detector lives on the stack.
detector =
@@ -1150,7 +1731,7 @@ public:
lambda::bind(&TestMesos<Mesos, Event>::events,
this,
lambda::_1),
- DEFAULT_V1_CREDENTIAL,
+ v1::DEFAULT_CREDENTIAL,
detector),
scheduler(_scheduler) {}
@@ -1190,17 +1771,24 @@ private:
std::shared_ptr<MockHTTPScheduler<Mesos, Event>> scheduler;
};
+namespace v1 {
-using TestV1Mesos =
+using TestMesos =
TestMesos<mesos::v1::scheduler::Mesos, mesos::v1::scheduler::Event>;
+} // namespace v1 {
+
} // namespace scheduler {
-using MockV1HTTPScheduler =
- scheduler::MockHTTPScheduler<
+namespace v1 {
+
+using MockHTTPScheduler =
+ tests::scheduler::MockHTTPScheduler<
mesos::v1::scheduler::Mesos, mesos::v1::scheduler::Event>;
+} // namespace v1 {
+
namespace executor {
@@ -1299,19 +1887,32 @@ private:
std::shared_ptr<MockHTTPExecutor<Mesos, Event>> executor;
};
+} // namespace executor {
+
+
+namespace v1 {
+namespace executor {
+
+// Alias existing `mesos::v1::executor` classes so that we can easily
+// write `v1::executor::` in tests.
+using Call = mesos::v1::executor::Call;
+using Event = mesos::v1::executor::Event;
+using Mesos = mesos::v1::executor::Mesos;
-using TestV1Mesos =
- TestMesos<mesos::v1::executor::Mesos, mesos::v1::executor::Event>;
+using TestMesos =
+ ::mesos::internal::tests::executor::TestMesos<
+ mesos::v1::executor::Mesos,
+ mesos::v1::executor::Event>;
// TODO(anand): Move these actions to the `v1::executor` namespace.
ACTION_P2(SendSubscribe, frameworkId, executorId)
{
- v1::executor::Call call;
+ mesos::v1::executor::Call call;
call.mutable_framework_id()->CopyFrom(frameworkId);
call.mutable_executor_id()->CopyFrom(executorId);
- call.set_type(v1::executor::Call::SUBSCRIBE);
+ call.set_type(mesos::v1::executor::Call::SUBSCRIBE);
call.mutable_subscribe();
@@ -1321,18 +1922,18 @@ ACTION_P2(SendSubscribe, frameworkId, executorId)
ACTION_P3(SendUpdateFromTask, frameworkId, executorId, state)
{
- v1::TaskStatus status;
+ mesos::v1::TaskStatus status;
status.mutable_task_id()->CopyFrom(arg1.task().task_id());
status.mutable_executor_id()->CopyFrom(executorId);
status.set_state(state);
- status.set_source(v1::TaskStatus::SOURCE_EXECUTOR);
+ status.set_source(mesos::v1::TaskStatus::SOURCE_EXECUTOR);
status.set_uuid(UUID::random().toBytes());
- v1::executor::Call call;
+ mesos::v1::executor::Call call;
call.mutable_framework_id()->CopyFrom(frameworkId);
call.mutable_executor_id()->CopyFrom(executorId);
- call.set_type(v1::executor::Call::UPDATE);
+ call.set_type(mesos::v1::executor::Call::UPDATE);
call.mutable_update()->mutable_status()->CopyFrom(status);
@@ -1342,18 +1943,18 @@ ACTION_P3(SendUpdateFromTask, frameworkId, executorId, state)
ACTION_P3(SendUpdateFromTaskID, frameworkId, executorId, state)
{
- v1::TaskStatus status;
+ mesos::v1::TaskStatus status;
status.mutable_task_id()->CopyFrom(arg1.task_id());
status.mutable_executor_id()->CopyFrom(executorId);
status.set_state(state);
- status.set_source(v1::TaskStatus::SOURCE_EXECUTOR);
+ status.set_source(mesos::v1::TaskStatus::SOURCE_EXECUTOR);
status.set_uuid(UUID::random().toBytes());
- v1::executor::Call call;
+ mesos::v1::executor::Call call;
call.mutable_framework_id()->CopyFrom(frameworkId);
call.mutable_executor_id()->CopyFrom(executorId);
- call.set_type(v1::executor::Call::UPDATE);
+ call.set_type(mesos::v1::executor::Call::UPDATE);
call.mutable_update()->mutable_status()->CopyFrom(status);
@@ -1363,11 +1964,14 @@ ACTION_P3(SendUpdateFromTaskID, frameworkId, executorId, state)
} // namespace executor {
-using MockV1HTTPExecutor =
- executor::MockHTTPExecutor<
+using MockHTTPExecutor =
+ tests::executor::MockHTTPExecutor<
mesos::v1::executor::Mesos, mesos::v1::executor::Event>;
+} // namespace v1 {
+
+
// Definition of a mock FetcherProcess to be used in tests with gmock.
class MockFetcherProcess : public slave::FetcherProcess
{
http://git-wip-us.apache.org/repos/asf/mesos/blob/e9da9b3b/src/tests/scheduler_http_api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_http_api_tests.cpp b/src/tests/scheduler_http_api_tests.cpp
index 6390f2e..083cc3e 100644
--- a/src/tests/scheduler_http_api_tests.cpp
+++ b/src/tests/scheduler_http_api_tests.cpp
@@ -228,7 +228,7 @@ TEST_P(SchedulerHttpApiTest, UnsupportedContentMediaType)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
const string unknownMediaType = "application/unknown-media-type";
@@ -255,7 +255,7 @@ TEST_P(SchedulerHttpApiTest, Subscribe)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
// Retrieve the parameter passed as content type to this test.
const string contentType = GetParam();
@@ -322,7 +322,7 @@ TEST_P(SchedulerHttpApiTest, RejectFrameworkWithInvalidRole)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- v1::FrameworkInfo framework = DEFAULT_V1_FRAMEWORK_INFO;
+ v1::FrameworkInfo framework = v1::DEFAULT_FRAMEWORK_INFO;
// Set invalid role.
framework.set_role("/test/test1");
subscribe->mutable_framework_info()->CopyFrom(framework);
@@ -372,7 +372,7 @@ TEST_P(SchedulerHttpApiTest, SubscribeWithStreamId)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
// Retrieve the parameter passed as content type to this test.
const string contentType = GetParam();
@@ -403,7 +403,7 @@ TEST_P(SchedulerHttpApiTest, SubscribedOnRetry)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
// Retrieve the parameter passed as content type to this test.
const string contentType = GetParam();
@@ -485,7 +485,7 @@ TEST_P(SchedulerHttpApiTest, UpdatePidToHttpScheduler)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- v1::FrameworkInfo frameworkInfo = DEFAULT_V1_FRAMEWORK_INFO;
+ v1::FrameworkInfo frameworkInfo = v1::DEFAULT_FRAMEWORK_INFO;
frameworkInfo.set_failover_timeout(Weeks(2).secs());
MockScheduler sched;
@@ -572,7 +572,7 @@ TEST_P(SchedulerHttpApiTest, UpdateHttpToPidScheduler)
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
- v1::FrameworkInfo frameworkInfo = DEFAULT_V1_FRAMEWORK_INFO;
+ v1::FrameworkInfo frameworkInfo = v1::DEFAULT_FRAMEWORK_INFO;
Call call;
call.set_type(Call::SUBSCRIBE);
@@ -655,7 +655,7 @@ TEST_P(SchedulerHttpApiTest, NotAcceptable)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
Future<Response> response = process::http::streaming::post(
master.get()->pid,
@@ -685,7 +685,7 @@ TEST_P(SchedulerHttpApiTest, NoAcceptHeader)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
Future<Response> response = process::http::streaming::post(
master.get()->pid,
@@ -712,7 +712,7 @@ TEST_P(SchedulerHttpApiTest, DefaultAccept)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
// Retrieve the parameter passed as content type to this test.
const string contentType = GetParam();
@@ -765,7 +765,7 @@ TEST_P(SchedulerHttpApiTest, TeardownWithoutStreamId)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
Future<Response> response = process::http::streaming::post(
master.get()->pid,
@@ -838,7 +838,7 @@ TEST_P(SchedulerHttpApiTest, TeardownWrongStreamId)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
Future<Response> response = process::http::streaming::post(
master.get()->pid,
@@ -879,7 +879,7 @@ TEST_P(SchedulerHttpApiTest, TeardownWrongStreamId)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
// Set the framework ID in the subscribe call.
call.mutable_framework_id()->CopyFrom(frameworkId);
@@ -957,7 +957,7 @@ TEST_P(SchedulerHttpApiTest, MalformedUUID)
call.set_type(Call::SUBSCRIBE);
Call::Subscribe* subscribe = call.mutable_subscribe();
- subscribe->mutable_framework_info()->CopyFrom(DEFAULT_V1_FRAMEWORK_INFO);
+ subscribe->mutable_framework_info()->CopyFrom(v1::DEFAULT_FRAMEWORK_INFO);
Future<Response> response = process::http::streaming::post(
master.get()->pid,