Repository: mesos Updated Branches: refs/heads/master 6bd625748 -> 01f6f7b31
Implemented the ERROR Event handler in the scheduler driver. Review: https://reviews.apache.org/r/35752 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0e745fe2 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0e745fe2 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0e745fe2 Branch: refs/heads/master Commit: 0e745fe2b1a3c70fb3d23682c8fdb3acc553efbe Parents: d52da5d Author: Benjamin Mahler <[email protected]> Authored: Mon Jun 22 16:17:19 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Thu Jul 16 16:11:43 2015 -0700 ---------------------------------------------------------------------- src/Makefile.am | 1 + src/sched/sched.cpp | 2 +- src/tests/scheduler_event_call_tests.cpp | 94 +++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/0e745fe2/src/Makefile.am ---------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index e5b5d36..e2cbd15 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1517,6 +1517,7 @@ mesos_tests_SOURCES = \ tests/resource_offers_tests.cpp \ tests/resources_tests.cpp \ tests/scheduler_tests.cpp \ + tests/scheduler_event_call_tests.cpp \ tests/script.cpp \ tests/slave_recovery_tests.cpp \ tests/slave_tests.cpp \ http://git-wip-us.apache.org/repos/asf/mesos/blob/0e745fe2/src/sched/sched.cpp ---------------------------------------------------------------------- diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp index cd80f29..3dc8a58 100644 --- a/src/sched/sched.cpp +++ b/src/sched/sched.cpp @@ -507,7 +507,7 @@ protected: break; } - drop(event, "Unimplemented"); + error(event.error().message()); break; } http://git-wip-us.apache.org/repos/asf/mesos/blob/0e745fe2/src/tests/scheduler_event_call_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/scheduler_event_call_tests.cpp b/src/tests/scheduler_event_call_tests.cpp new file mode 100644 index 0000000..d352fb4 --- /dev/null +++ b/src/tests/scheduler_event_call_tests.cpp @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <gmock/gmock.h> + +#include <mesos/scheduler.hpp> + +#include <process/future.hpp> +#include <process/gmock.hpp> +#include <process/gtest.hpp> +#include <process/message.hpp> +#include <process/pid.hpp> + +#include <stout/nothing.hpp> +#include <stout/try.hpp> + +#include "master/master.hpp" + +#include "tests/containerizer.hpp" +#include "tests/mesos.hpp" + +using mesos::internal::master::Master; + +using mesos::scheduler::Event; + +using process::Future; +using process::Message; +using process::PID; +using process::UPID; + +using testing::_; +using testing::Eq; + +namespace mesos { +namespace internal { +namespace tests { + + +// These tests intercept master messages and manually +// post Event messages to the driver. +class SchedulerDriverEventTest : public MesosTest {}; + + +// Ensures that the driver can handle the ERROR event. +TEST_F(SchedulerDriverEventTest, Error) +{ + Try<PID<Master>> master = StartMaster(); + ASSERT_SOME(master); + + MockScheduler sched; + MesosSchedulerDriver driver( + &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL); + + EXPECT_CALL(sched, registered(&driver, _, _)); + + Future<Message> frameworkRegisteredMessage = + FUTURE_MESSAGE(Eq(FrameworkRegisteredMessage().GetTypeName()), _, _); + + driver.start(); + + AWAIT_READY(frameworkRegisteredMessage); + UPID frameworkPid = frameworkRegisteredMessage.get().to; + + Event event; + event.set_type(Event::ERROR); + event.mutable_error()->set_message("error message"); + + Future<Nothing> error; + EXPECT_CALL(sched, error(&driver, event.error().message())) + .WillOnce(FutureSatisfy(&error)); + + process::post(master.get(), frameworkPid, event); + + AWAIT_READY(error); +} + +} // namespace tests { +} // namespace internal { +} // namespace mesos {
