TEST(PointwiseTest, WorksForLhsNativeArray) { const int lhs[] = { 1, 2, 3 }; ::std::vector<int> rhs; rhs.push_back(2); rhs.push_back(4); rhs.push_back(6); EXPECT_THAT(lhs, Pointwise(Lt(), rhs)); EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs))); EXPECT_THAT(lhs, Each(Lt(0))); }
TEST_F(LibNiceConnectionTest, queuePacket_QueuedPackets_Can_Be_getPacket_When_Ready) { erizo::packetPtr packet; EXPECT_CALL(*nice_listener, updateIceState(erizo::IceState::READY , _)).Times(1); nice_connection->updateIceState(erizo::IceState::READY); EXPECT_CALL(*nice_listener, onPacketReceived(_)).WillOnce(SaveArg<0>(&packet)); nice_connection->onData(0, test_packet, sizeof(test_packet)); ASSERT_THAT(packet.get(), Not(Eq(nullptr))); EXPECT_EQ(static_cast<unsigned int>(packet->length), sizeof(test_packet)); EXPECT_EQ(0, strcmp(test_packet, packet->data)); }
TEST_F(Documents, RemoveAllValidIfExceptionIsThrown) { ClangBackEnd::FileContainer fileContainer(filePath, projectPartId); documents.create({fileContainer}); ASSERT_THROW(documents.remove({ClangBackEnd::FileContainer(Utf8StringLiteral("dontextist.pro"), projectPartId), fileContainer}), ClangBackEnd::DocumentDoesNotExistException); ASSERT_THAT(documents.documents(), Not(Contains(Document(filePath, projects.project(projectPartId), Utf8StringVector(), documents)))); }
// This test checks that a failover scheduler gets the // retried status update. TEST_F(FaultToleranceTest, SchedulerFailoverStatusUpdate) { Clock::pause(); Try<PID<Master> > master = StartMaster(); ASSERT_SOME(master); MockExecutor exec(DEFAULT_EXECUTOR_ID); Try<PID<Slave> > slave = StartSlave(&exec); ASSERT_SOME(slave); // Launch the first (i.e., failing) scheduler. MockScheduler sched1; MesosSchedulerDriver driver1(&sched1, DEFAULT_FRAMEWORK_INFO, master.get()); FrameworkID frameworkId; EXPECT_CALL(sched1, registered(&driver1, _, _)) .WillOnce(SaveArg<1>(&frameworkId)); Future<vector<Offer> > offers; EXPECT_CALL(sched1, resourceOffers(&driver1, _)) .WillOnce(FutureArg<1>(&offers)) .WillRepeatedly(Return()); driver1.start(); AWAIT_READY(offers); EXPECT_NE(0u, offers.get().size()); // Launch a task. TaskInfo task; task.set_name(""); task.mutable_task_id()->set_value("1"); task.mutable_slave_id()->MergeFrom(offers.get()[0].slave_id()); task.mutable_resources()->MergeFrom(offers.get()[0].resources()); task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO); vector<TaskInfo> tasks; tasks.push_back(task); EXPECT_CALL(exec, registered(_, _, _, _)) .Times(1); EXPECT_CALL(exec, launchTask(_, _)) .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING)); // Drop the first status update message // between master and the scheduler. Future<StatusUpdateMessage> statusUpdateMessage = DROP_PROTOBUF(StatusUpdateMessage(), _, Not(AnyOf(Eq(master.get()), Eq(slave.get())))); driver1.launchTasks(offers.get()[0].id(), tasks); AWAIT_READY(statusUpdateMessage); // Now launch the second (i.e., failover) scheduler using the // framework id recorded from the first scheduler and wait until it // registers. MockScheduler sched2; FrameworkInfo framework2; // Bug in gcc 4.1.*, must assign on next line. framework2 = DEFAULT_FRAMEWORK_INFO; framework2.mutable_id()->MergeFrom(frameworkId); MesosSchedulerDriver driver2(&sched2, framework2, master.get()); Future<Nothing> registered2; EXPECT_CALL(sched2, registered(&driver2, frameworkId, _)) .WillOnce(FutureSatisfy(®istered2)); // Scheduler1 should get an error due to failover. EXPECT_CALL(sched1, error(&driver1, "Framework failed over")); driver2.start(); AWAIT_READY(registered2); // Now advance time enough for the reliable timeout // to kick in and another status update is sent. Future<Nothing> statusUpdate; EXPECT_CALL(sched2, statusUpdate(&driver2, _)) .WillOnce(FutureSatisfy(&statusUpdate)); Clock::advance(STATUS_UPDATE_RETRY_INTERVAL); AWAIT_READY(statusUpdate); EXPECT_CALL(exec, shutdown(_)) .Times(AtMost(1)); driver1.stop(); driver2.stop(); driver1.join(); driver2.join(); Shutdown(); Clock::resume(); }
TEST(FaultToleranceTest, SchedulerFailoverStatusUpdate) { ASSERT_TRUE(GTEST_IS_THREADSAFE); Clock::pause(); MockFilter filter; process::filter(&filter); EXPECT_MESSAGE(filter, _, _, _) .WillRepeatedly(Return(false)); SimpleAllocator a; Master m(&a); PID<Master> master = process::spawn(&m); MockExecutor exec; trigger shutdownCall; EXPECT_CALL(exec, registered(_, _, _, _)) .Times(1); EXPECT_CALL(exec, launchTask(_, _)) .WillOnce(SendStatusUpdate(TASK_RUNNING)); EXPECT_CALL(exec, shutdown(_)) .WillOnce(Trigger(&shutdownCall)); map<ExecutorID, Executor*> execs; execs[DEFAULT_EXECUTOR_ID] = &exec; TestingIsolationModule isolationModule(execs); Resources resources = Resources::parse("cpus:2;mem:1024"); Slave s(resources, true, &isolationModule); PID<Slave> slave = process::spawn(&s); BasicMasterDetector detector(master, slave, true); // Launch the first (i.e., failing) scheduler and wait until the // first status update message is sent to it (drop the message). MockScheduler sched1; MesosSchedulerDriver driver1(&sched1, DEFAULT_FRAMEWORK_INFO, master); FrameworkID frameworkId; vector<Offer> offers; trigger resourceOffersCall, statusUpdateMsg; EXPECT_CALL(sched1, registered(&driver1, _, _)) .WillOnce(SaveArg<1>(&frameworkId)); EXPECT_CALL(sched1, resourceOffers(&driver1, _)) .WillOnce(DoAll(SaveArg<1>(&offers), Trigger(&resourceOffersCall))) .WillRepeatedly(Return()); EXPECT_CALL(sched1, statusUpdate(&driver1, _)) .Times(0); EXPECT_CALL(sched1, error(&driver1, "Framework failed over")) .Times(1); EXPECT_MESSAGE(filter, Eq(StatusUpdateMessage().GetTypeName()), _, Not(AnyOf(Eq(master), Eq(slave)))) .WillOnce(DoAll(Trigger(&statusUpdateMsg), Return(true))) .RetiresOnSaturation(); driver1.start(); WAIT_UNTIL(resourceOffersCall); EXPECT_NE(0, offers.size()); TaskInfo task; task.set_name(""); task.mutable_task_id()->set_value("1"); task.mutable_slave_id()->MergeFrom(offers[0].slave_id()); task.mutable_resources()->MergeFrom(offers[0].resources()); task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO); vector<TaskInfo> tasks; tasks.push_back(task); driver1.launchTasks(offers[0].id(), tasks); WAIT_UNTIL(statusUpdateMsg); // Now launch the second (i.e., failover) scheduler using the // framework id recorded from the first scheduler and wait until it // registers, at which point advance time enough for the reliable // timeout to kick in and another status update message is sent. MockScheduler sched2; FrameworkInfo framework2; // Bug in gcc 4.1.*, must assign on next line. framework2 = DEFAULT_FRAMEWORK_INFO; framework2.mutable_id()->MergeFrom(frameworkId); MesosSchedulerDriver driver2(&sched2, framework2, master); trigger registeredCall, statusUpdateCall; EXPECT_CALL(sched2, registered(&driver2, frameworkId, _)) .WillOnce(Trigger(®isteredCall)); EXPECT_CALL(sched2, statusUpdate(&driver2, _)) .WillOnce(Trigger(&statusUpdateCall)); driver2.start(); WAIT_UNTIL(registeredCall); Clock::advance(STATUS_UPDATE_RETRY_INTERVAL_SECONDS); WAIT_UNTIL(statusUpdateCall); driver1.stop(); driver2.stop(); driver1.join(); driver2.join(); WAIT_UNTIL(shutdownCall); // Ensures MockExecutor can be deallocated. process::terminate(slave); process::wait(slave); process::terminate(master); process::wait(master); process::filter(NULL); Clock::resume(); }