Project: mesos
Issue MESOS-3418: Factor out V1 API test helper functions
We currently have some helper functionality for V1 API tests. This is copied in a few test files. Factor this out into a common place once the API is stabilized. {code} // Helper class for using EXPECT_CALL since the Mesos scheduler API // is callback based. class Callbacks { public: MOCK_METHOD0(connected, void(void)); MOCK_METHOD0(disconnected, void(void)); MOCK_METHOD1(received, void(const std::queue&)); }; {code} {code} // Enqueues all received events into a libprocess queue. // TODO(jmlvanre): Factor this common code out of tests into V1 // helper. ACTION_P(Enqueue, queue) { std::queue events = arg0; while (!events.empty()) { // Note that we currently drop HEARTBEATs because most of these tests // are not designed to deal with heartbeats. // TODO(vinod): Implement DROP_HTTP_CALLS that can filter heartbeats. if (events.front().type() == Event::HEARTBEAT) { VLOG(1) << "Ignoring HEARTBEAT event"; } else { queue->put(events.front()); } events.pop(); } } {code} We can also update the helpers in {{/tests/mesos.hpp}} to support the V1 API. This would let us get ride of lines like: {code} v1::TaskInfo taskInfo = evolve(createTask(devolve(offer), "", DEFAULT_EXECUTOR_ID)); {code} In favor of: {code} v1::TaskInfo taskInfo = createTask(offer, "", DEFAULT_EXECUTOR_ID); {code}
Story points: 2