当前位置: 首页>>代码示例>>C++>>正文


C++ testing::DoAll方法代码示例

本文整理汇总了C++中testing::DoAll方法的典型用法代码示例。如果您正苦于以下问题:C++ testing::DoAll方法的具体用法?C++ testing::DoAll怎么用?C++ testing::DoAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在testing的用法示例。


在下文中一共展示了testing::DoAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: detector

// This test verifies that an authentication request that comes from
// the same instance of the framework (e.g., ZK blip) before
// 'Master::_registerFramework()' from an earlier attempt, causes the
// master to successfully register the framework.
TEST_F(MasterAuthorizationTest, DuplicateRegistration)
{
  MockAuthorizer authorizer;
  Try<PID<Master> > master = StartMaster(&authorizer);
  ASSERT_SOME(master);

  // Create a detector for the scheduler driver because we want the
  // spurious leading master change to be known by the scheduler
  // driver only.
  StandaloneMasterDetector detector(master.get());
  MockScheduler sched;
  TestingMesosSchedulerDriver driver(&sched, &detector);

  Future<Nothing> registered;
  EXPECT_CALL(sched, registered(&driver, _, _))
    .WillOnce(FutureSatisfy(&registered));

  // Return pending futures from authorizer.
  Future<Nothing> future1;
  Promise<bool> promise1;
  Future<Nothing> future2;
  Promise<bool> promise2;
  EXPECT_CALL(authorizer, authorize(An<const mesos::ACL::ReceiveOffers&>()))
    .WillOnce(DoAll(FutureSatisfy(&future1),
                    Return(promise1.future())))
    .WillOnce(DoAll(FutureSatisfy(&future2),
                    Return(promise2.future())));

  driver.start();

  // Wait until first authorization attempt is in progress.
  AWAIT_READY(future1);

  // Simulate a spurious leading master change at the scheduler.
  detector.appoint(master.get());

  // Wait until second authorization attempt is in progress.
  AWAIT_READY(future2);

  // Now complete the first authorization attempt.
  promise1.set(true);

  // First registration request should succeed because the
  // framework PID did not change.
  AWAIT_READY(registered);

  Future<FrameworkRegisteredMessage> frameworkRegisteredMessage =
    FUTURE_PROTOBUF(FrameworkRegisteredMessage(), _, _);

  // Now complete the second authorization attempt.
  promise2.set(true);

  // Master should acknowledge the second registration attempt too.
  AWAIT_READY(frameworkRegisteredMessage);

  driver.stop();
  driver.join();

  Shutdown();
}
开发者ID:Bbarrett,项目名称:mesos,代码行数:64,代码来源:master_authorization_tests.cpp

示例2: driver

TEST(ResourceOffersTest, TaskUsesNoResources)
{
  ASSERT_TRUE(GTEST_IS_THREADSAFE);

  PID<Master> master = local::launch(1, 2, 1 * Gigabyte, false);

  MockScheduler sched;
  MesosSchedulerDriver driver(&sched, "", DEFAULT_EXECUTOR_INFO, master);

  vector<Offer> offers;

  trigger resourceOffersCall;

  EXPECT_CALL(sched, registered(&driver, _))
    .Times(1);

  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(DoAll(SaveArg<1>(&offers),
                    Trigger(&resourceOffersCall)))
    .WillRepeatedly(Return());

  driver.start();

  WAIT_UNTIL(resourceOffersCall);

  EXPECT_NE(0, offers.size());

  TaskDescription task;
  task.set_name("");
  task.mutable_task_id()->set_value("1");
  task.mutable_slave_id()->MergeFrom(offers[0].slave_id());

  vector<TaskDescription> tasks;
  tasks.push_back(task);

  TaskStatus status;

  trigger statusUpdateCall;

  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(DoAll(SaveArg<1>(&status),
                    Trigger(&statusUpdateCall)));

  driver.launchTasks(offers[0].id(), tasks);

  WAIT_UNTIL(statusUpdateCall);

  EXPECT_EQ(task.task_id(), status.task_id());
  EXPECT_EQ(TASK_LOST, status.state());
  EXPECT_TRUE(status.has_message());
  EXPECT_EQ("Task uses no resources", status.message());

  driver.stop();
  driver.join();

  local::shutdown();
}
开发者ID:samwhitlock,项目名称:mesos-monitoring,代码行数:57,代码来源:resource_offers_tests.cpp

示例3: get

TEST(HTTPConnectionTest, ClosingRequest)
{
  Http http;

  http::URL url = http::URL(
      "http",
      http.process->self().address.ip,
      http.process->self().address.port,
      http.process->self().id + "/get");

  Future<http::Connection> connect = http::connect(url);
  AWAIT_READY(connect);

  http::Connection connection = connect.get();

  // Issue two pipelined requests, the second will not have
  // 'keepAlive' set. This prevents further requests and leads
  // to a disconnection upon receiving the second response.
  Promise<http::Response> promise1, promise2;
  Future<http::Request> get1, get2;

  EXPECT_CALL(*http.process, get(_))
    .WillOnce(DoAll(FutureArg<0>(&get1),
                    Return(promise1.future())))
    .WillOnce(DoAll(FutureArg<0>(&get2),
                    Return(promise2.future())));

  http::Request request1, request2;

  request1.method = "GET";
  request2.method = "GET";

  request1.url = url;
  request2.url = url;

  request1.keepAlive = true;
  request2.keepAlive = false;

  Future<http::Response> response1 = connection.send(request1);
  Future<http::Response> response2 = connection.send(request2);

  // After a closing request, sends should fail.
  AWAIT_FAILED(connection.send(request1));

  // Complete the responses.
  promise1.set(http::OK("body"));
  promise2.set(http::OK("body"));

  AWAIT_READY(response1);
  AWAIT_READY(response2);

  AWAIT_READY(connection.disconnected());
}
开发者ID:haosdent,项目名称:mesos,代码行数:53,代码来源:http_tests.cpp

示例4: SetUp

  virtual void SetUp() {
    const std::string kArbitraryLocalCredentialUsername = "ufrag";
    const std::string kArbitraryLocalCredentialPassword = "upass";
    const std::string kArbitraryConnectionId = "a_connection_id";
    const std::string kArbitraryTransportName = "video";
    const std::string kArbitraryDataPacket = "test";

    libnice = new MockLibNice;
    libnice_pointer.reset(libnice);
    nice_listener = std::make_shared<MockLibNiceConnectionListener>();
    ice_config = new erizo::IceConfig();
    ufrag = strdup(kArbitraryLocalCredentialUsername.c_str());
    pass = strdup(kArbitraryLocalCredentialPassword.c_str());
    test_packet = strdup(kArbitraryDataPacket.c_str());

    ice_config->media_type = erizo::VIDEO_TYPE;
    ice_config->transport_name = kArbitraryTransportName;
    ice_config->ice_components = 1;
    ice_config->connection_id = kArbitraryConnectionId;

    EXPECT_CALL(*libnice, NiceAgentNew(_)).Times(1);
    EXPECT_CALL(*libnice, NiceAgentAddStream(_, _)).Times(1).WillOnce(Return(1));
    EXPECT_CALL(*libnice, NiceAgentGetLocalCredentials(_, _, _, _)).Times(1).
      WillOnce(DoAll(SetArgPointee<2>(ufrag), SetArgPointee<3>(pass), Return(true)));
    EXPECT_CALL(*libnice, NiceAgentAttachRecv(_, _, _, _, _, _)).Times(1).WillOnce(Return(true));
    EXPECT_CALL(*libnice, NiceAgentGatherCandidates(_, _)).Times(1).WillOnce(Return(true));
    EXPECT_CALL(*libnice, NiceAgentSetRemoteCredentials(_, _, _, _)).Times(0);
    EXPECT_CALL(*libnice, NiceAgentSetPortRange(_, _, _, _, _)).Times(0);
    EXPECT_CALL(*libnice, NiceAgentSetRelayInfo(_, _, _, _, _, _, _)).Times(0);

    nice_connection = new erizo::LibNiceConnection(libnice_pointer,
        *ice_config);
    nice_connection->setIceListener(nice_listener);
    nice_connection->start();
  }
开发者ID:mccob,项目名称:licode,代码行数:35,代码来源:LibNiceConnectionTest.cpp

示例5: nice

TEST_F(LibNiceConnectionStartTest, start_Configures_Libnice_With_Port_Range) {
  const std::string kArbitraryLocalCredentialUsername = "ufrag";
  const std::string kArbitraryLocalCredentialPassword = "upass";
  const std::string kArbitraryConnectionId = "a_connection_id";
  const std::string kArbitraryTransportName = "video";

  const unsigned int kArbitraryMinPort = 1240;
  const unsigned int kArbitraryMaxPort = 2504;

  char *ufrag = strdup(kArbitraryLocalCredentialUsername.c_str());
  char *pass = strdup(kArbitraryLocalCredentialPassword.c_str());

  ice_config->min_port = kArbitraryMinPort;
  ice_config->max_port = kArbitraryMaxPort;
  ice_config->transport_name = kArbitraryTransportName;
  ice_config->media_type = erizo::VIDEO_TYPE;
  ice_config->connection_id = kArbitraryConnectionId;
  ice_config->ice_components = 1;

  EXPECT_CALL(*libnice, NiceAgentNew(_)).Times(1);
  EXPECT_CALL(*libnice, NiceAgentAddStream(_, _)).Times(1);
  EXPECT_CALL(*libnice, NiceAgentGetLocalCredentials(_, _, _, _)).Times(1).
    WillOnce(DoAll(SetArgPointee<2>(ufrag), SetArgPointee<3>(pass), Return(true)));
  EXPECT_CALL(*libnice, NiceAgentAttachRecv(_, _, _, _, _, _)).Times(1).WillOnce(Return(true));
  EXPECT_CALL(*libnice, NiceAgentGatherCandidates(_, _)).Times(1).WillOnce(Return(true));
  EXPECT_CALL(*libnice, NiceAgentSetRemoteCredentials(_, _, _, _)).Times(0);
  EXPECT_CALL(*libnice, NiceAgentSetPortRange(_, _, _, kArbitraryMinPort, kArbitraryMaxPort)).Times(1);
  EXPECT_CALL(*libnice, NiceAgentSetRelayInfo(_, _, _, _, _, _, _)).Times(0);

  erizo::LibNiceConnection nice(libnice_pointer,
      *ice_config);
  nice.setIceListener(nice_listener);
  nice.start();
}
开发者ID:mccob,项目名称:licode,代码行数:34,代码来源:LibNiceConnectionTest.cpp

示例6: state

TEST_P(RegistrarTest, storeTimeout)
{
  Clock::pause();

  MockStorage storage;
  State state(&storage);

  Registrar registrar(flags, &state);

  EXPECT_CALL(storage, get(_))
    .WillOnce(Return(None()));

  Future<Nothing> set;
  EXPECT_CALL(storage, set(_, _))
    .WillOnce(DoAll(FutureSatisfy(&set),
                    Return(Future<bool>())));

  Future<Registry> recover = registrar.recover(master);

  AWAIT_READY(set);

  Clock::advance(flags.registry_store_timeout);

  AWAIT_FAILED(recover);

  Clock::resume();

  // Ensure the registrar fails subsequent operations.
  AWAIT_FAILED(registrar.apply(Owned<Operation>(new AdmitSlave(slave))));
}
开发者ID:Bbarrett,项目名称:mesos,代码行数:30,代码来源:registrar_tests.cpp

示例7: GetDFUState

void USBHost::GetDFUState(Outcome outcome, uint8_t *state) {
  Mock::VerifyAndClearExpectations(m_usb_mock);

  if (outcome == OUTCOME_OK) {
    EXPECT_CALL(*m_usb_mock,
                ControlSend(m_usb_handle, _, sizeof(uint8_t)))
        .WillOnce(DoAll(
              WithArgs<1, 2>(CopyDataTo(state, sizeof(uint8_t))),
              Return(USB_DEVICE_CONTROL_TRANSFER_RESULT_SUCCESS)));
  } else {
    EXPECT_CALL(*m_usb_mock,
                ControlStatus(m_usb_handle, USB_DEVICE_CONTROL_STATUS_ERROR))
      .WillOnce(Return(USB_DEVICE_CONTROL_TRANSFER_RESULT_SUCCESS));
  }

  USB_SETUP_PACKET packet;
  packet.bmRequestType = 0xa1;
  packet.bRequest = DFU_GETSTATE;
  packet.wValue = 0;
  packet.wIndex = INTERFACE;
  packet.wLength = 1;

  SetupRequest(&packet, sizeof(packet));
  Mock::VerifyAndClearExpectations(m_usb_mock);
}
开发者ID:nitrokart,项目名称:ja-rule,代码行数:25,代码来源:BootloaderTestHelper.cpp

示例8: m

TEST(FaultToleranceTest, SlaveLost)
{
  ASSERT_TRUE(GTEST_IS_THREADSAFE);

  SimpleAllocator a;
  Master m(&a);
  PID<Master> master = process::spawn(&m);

  ProcessBasedIsolationModule isolationModule;

  Resources resources = Resources::parse("cpus:2;mem:1024");

  Slave s(resources, true, &isolationModule);
  PID<Slave> slave = process::spawn(&s);

  BasicMasterDetector detector(master, slave, true);

  MockScheduler sched;
  MesosSchedulerDriver driver(&sched, DEFAULT_FRAMEWORK_INFO, master);

  vector<Offer> offers;

  trigger resourceOffersCall;

  EXPECT_CALL(sched, registered(&driver, _, _))
    .Times(1);

  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(DoAll(SaveArg<1>(&offers),
                    Trigger(&resourceOffersCall)))
    .WillRepeatedly(Return());

  driver.start();

  WAIT_UNTIL(resourceOffersCall);

  EXPECT_EQ(1, offers.size());

  trigger offerRescindedCall, slaveLostCall;

  EXPECT_CALL(sched, offerRescinded(&driver, offers[0].id()))
    .WillOnce(Trigger(&offerRescindedCall));

  EXPECT_CALL(sched, slaveLost(&driver, offers[0].slave_id()))
    .WillOnce(Trigger(&slaveLostCall));

  process::terminate(slave);

  WAIT_UNTIL(offerRescindedCall);
  WAIT_UNTIL(slaveLostCall);

  driver.stop();
  driver.join();

  process::wait(slave);

  process::terminate(master);
  process::wait(master);
}
开发者ID:adegtiar,项目名称:sceem,代码行数:59,代码来源:fault_tolerance_tests.cpp

示例9: registered

TEST(ResourceOffersTest, ResourcesGetReofferedWhenUnused)
{
  ASSERT_TRUE(GTEST_IS_THREADSAFE);

  PID<Master> master = local::launch(1, 2, 1 * Gigabyte, false);

  MockScheduler sched1;
  MesosSchedulerDriver driver1(&sched1, "", DEFAULT_EXECUTOR_INFO, master);

  vector<Offer> offers;

  trigger sched1ResourceOfferCall;

  EXPECT_CALL(sched1, registered(&driver1, _))
    .Times(1);

  EXPECT_CALL(sched1, resourceOffers(&driver1, _))
    .WillOnce(DoAll(SaveArg<1>(&offers),
                    Trigger(&sched1ResourceOfferCall)))
    .WillRepeatedly(Return());

  driver1.start();

  WAIT_UNTIL(sched1ResourceOfferCall);

  EXPECT_NE(0, offers.size());

  vector<TaskDescription> tasks; // Use nothing!

  driver1.launchTasks(offers[0].id(), tasks);

  driver1.stop();
  driver1.join();

  MockScheduler sched2;
  MesosSchedulerDriver driver2(&sched2, "", DEFAULT_EXECUTOR_INFO, master);

  trigger sched2ResourceOfferCall;

  EXPECT_CALL(sched2, registered(&driver2, _))
    .Times(1);

  EXPECT_CALL(sched2, resourceOffers(&driver2, _))
    .WillOnce(Trigger(&sched2ResourceOfferCall))
    .WillRepeatedly(Return());

  EXPECT_CALL(sched2, offerRescinded(&driver2, _))
    .Times(AtMost(1));

  driver2.start();

  WAIT_UNTIL(sched2ResourceOfferCall);

  driver2.stop();
  driver2.join();

  local::shutdown();
}
开发者ID:samwhitlock,项目名称:mesos-monitoring,代码行数:58,代码来源:resource_offers_tests.cpp

示例10: body

TEST(HTTPTest, Endpoints)
{
  Http http;

  // First hit '/body' (using explicit sockets and HTTP/1.0).
  Try<Socket> create = Socket::create();
  ASSERT_SOME(create);

  Socket socket = create.get();

  AWAIT_READY(socket.connect(http.process->self().address));

  std::ostringstream out;
  out << "GET /" << http.process->self().id << "/body"
      << " HTTP/1.0\r\n"
      << "Connection: Keep-Alive\r\n"
      << "\r\n";

  const string data = out.str();

  EXPECT_CALL(*http.process, body(_))
    .WillOnce(Return(http::OK()));

  AWAIT_READY(socket.send(data));

  string response = "HTTP/1.1 200 OK";

  AWAIT_EXPECT_EQ(response, socket.recv(response.size()));

  // Now hit '/pipe' (by using http::get).
  http::Pipe pipe;
  http::OK ok;
  ok.type = http::Response::PIPE;
  ok.reader = pipe.reader();

  Future<Nothing> request;
  EXPECT_CALL(*http.process, pipe(_))
    .WillOnce(DoAll(FutureSatisfy(&request),
                    Return(ok)));

  Future<http::Response> future = http::get(http.process->self(), "pipe");

  AWAIT_READY(request);

  // Write the response.
  http::Pipe::Writer writer = pipe.writer();
  EXPECT_TRUE(writer.write("Hello World\n"));
  EXPECT_TRUE(writer.close());

  AWAIT_READY(future);
  EXPECT_EQ(http::Status::OK, future->code);
  EXPECT_EQ(http::Status::string(http::Status::OK), future->status);

  EXPECT_SOME_EQ("chunked", future->headers.get("Transfer-Encoding"));
  EXPECT_EQ("Hello World\n", future->body);
}
开发者ID:haosdent,项目名称:mesos,代码行数:56,代码来源:http_tests.cpp

示例11: driver

TEST(FaultToleranceTest, FrameworkReregister)
{
  ASSERT_TRUE(GTEST_IS_THREADSAFE);

  MockFilter filter;
  process::filter(&filter);

  EXPECT_MESSAGE(filter, _, _, _)
    .WillRepeatedly(Return(false));

  PID<Master> master = local::launch(1, 2, 1 * Gigabyte, false);

  MockScheduler sched;
  MesosSchedulerDriver driver(&sched, DEFAULT_FRAMEWORK_INFO, master);

  trigger schedRegisteredCall, schedReregisteredCall;

  EXPECT_CALL(sched, registered(&driver, _, _))
    .WillOnce(Trigger(&schedRegisteredCall));

  EXPECT_CALL(sched, reregistered(&driver, _))
    .WillOnce(Trigger(&schedReregisteredCall));

  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillRepeatedly(Return());

  EXPECT_CALL(sched, offerRescinded(&driver, _))
    .Times(AtMost(1));

  process::Message message;

  EXPECT_MESSAGE(filter, Eq(FrameworkRegisteredMessage().GetTypeName()), _, _)
    .WillOnce(DoAll(SaveArgField<0>(&process::MessageEvent::message, &message),
                    Return(false)));

  driver.start();

  WAIT_UNTIL(schedRegisteredCall); // Ensures registered message is received.

  // Simulate a spurious newMasterDetected event (e.g., due to ZooKeeper
  // expiration) at the scheduler.
  NewMasterDetectedMessage newMasterDetectedMsg;
  newMasterDetectedMsg.set_pid(master);

  process::post(message.to, newMasterDetectedMsg);

  WAIT_UNTIL(schedReregisteredCall);

  driver.stop();
  driver.join();

  local::shutdown();

  process::filter(NULL);
}
开发者ID:adegtiar,项目名称:sceem,代码行数:55,代码来源:fault_tolerance_tests.cpp

示例12: spawn

// Like the 'remote' test but uses http::connect.
TEST(ProcessTest, Http1)
{
  ASSERT_TRUE(GTEST_IS_THREADSAFE);

  RemoteProcess process;
  spawn(process);

  http::URL url = http::URL(
      "http",
      process.self().address.ip,
      process.self().address.port,
      process.self().id + "/handler");

  Future<http::Connection> connect = http::connect(url);
  AWAIT_READY(connect);

  http::Connection connection = connect.get();

  Future<UPID> pid;
  Future<string> body;
  EXPECT_CALL(process, handler(_, _))
    .WillOnce(DoAll(FutureArg<0>(&pid),
                    FutureArg<1>(&body)));

  http::Request request;
  request.method = "POST";
  request.url = url;
  request.headers["User-Agent"] = "libprocess/";
  request.body = "hello world";

  // Send the libprocess request. Note that we will not
  // receive a 202 due to the use of the `User-Agent`
  // header, therefore we need to explicitly disconnect!
  Future<http::Response> response = connection.send(request);

  AWAIT_READY(body);
  ASSERT_EQ("hello world", body.get());

  AWAIT_READY(pid);
  ASSERT_EQ(UPID(), pid.get());

  EXPECT_TRUE(response.isPending());

  AWAIT_READY(connection.disconnect());

  terminate(process);
  wait(process);
}
开发者ID:LinxiaHu,项目名称:mesos,代码行数:49,代码来源:process_tests.cpp

示例13: strdup

TEST_F(LibNiceConnectionTest, getSelectedPair_Calls_Libnice_And_Returns_Pair) {
  const std::string kArbitraryRemoteIp = "192.168.1.2";
  const int kArbitraryRemotePort = 4242;
  const std::string kArbitraryLocalIp = "192.168.1.1";
  const int kArbitraryLocalPort = 2222;
  const int kArbitraryPriority = 1;

  const std::string kArbitraryLocalUsername = "localuser";
  const std::string kArbitraryLocalPassword = "localpass";
  const std::string kArbitraryRemoteUsername = "remoteuser";
  const std::string kArbitraryRemotePassword = "remotepass";


  NiceCandidate* local_candidate = nice_candidate_new(NICE_CANDIDATE_TYPE_HOST);
  local_candidate->username = strdup(kArbitraryLocalUsername.c_str());
  local_candidate->password = strdup(kArbitraryLocalPassword.c_str());
  local_candidate->stream_id = (guint) 1;
  local_candidate->component_id = 1;
  local_candidate->priority = kArbitraryPriority;
  local_candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
  nice_address_set_from_string(&local_candidate->addr, kArbitraryLocalIp.c_str());
  nice_address_set_from_string(&local_candidate->base_addr, kArbitraryLocalIp.c_str());
  nice_address_set_port(&local_candidate->addr, kArbitraryLocalPort);
  nice_address_set_port(&local_candidate->base_addr, kArbitraryLocalPort);

  NiceCandidate* remote_candidate = nice_candidate_new(NICE_CANDIDATE_TYPE_HOST);
  remote_candidate->username = strdup(kArbitraryRemoteUsername.c_str());
  remote_candidate->password = strdup(kArbitraryRemotePassword.c_str());
  remote_candidate->stream_id = (guint) 1;
  remote_candidate->component_id = 1;
  remote_candidate->priority = kArbitraryPriority;
  remote_candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
  nice_address_set_from_string(&remote_candidate->addr, kArbitraryRemoteIp.c_str());
  nice_address_set_port(&remote_candidate->addr, kArbitraryRemotePort);
  nice_address_set_from_string(&remote_candidate->base_addr, kArbitraryRemoteIp.c_str());
  nice_address_set_port(&remote_candidate->base_addr, kArbitraryRemotePort);

  EXPECT_CALL(*libnice, NiceAgentGetSelectedPair(_, _, _, _, _)).Times(1).WillOnce(
    DoAll(SetArgPointee<3>(local_candidate), SetArgPointee<4>(remote_candidate), Return(true)));

  erizo::CandidatePair candidate_pair = nice_connection->getSelectedPair();
  EXPECT_EQ(candidate_pair.erizoCandidateIp, kArbitraryLocalIp);
  EXPECT_EQ(candidate_pair.erizoCandidatePort, kArbitraryLocalPort);
  EXPECT_EQ(candidate_pair.clientCandidateIp, kArbitraryRemoteIp);
  EXPECT_EQ(candidate_pair.clientCandidatePort, kArbitraryRemotePort);
}
开发者ID:mccob,项目名称:licode,代码行数:46,代码来源:LibNiceConnectionTest.cpp

示例14: GetParam

// Tests that an agent endpoint handler forms
// correct queries against the authorizer.
TEST_P(SlaveEndpointTest, AuthorizedRequest)
{
  const string endpoint = GetParam();

  StandaloneMasterDetector detector;

  MockAuthorizer mockAuthorizer;

  Future<Nothing> recover = FUTURE_DISPATCH(_, &Slave::__recover);

  Try<Owned<cluster::Slave>> agent = StartSlave(&detector, &mockAuthorizer);
  ASSERT_SOME(agent);

  AWAIT_READY(recover);

  // Ensure that the slave has finished recovery.
  Clock::pause();
  Clock::settle();
  Clock::resume();

  Future<authorization::Request> request;
  EXPECT_CALL(mockAuthorizer, authorized(_))
    .WillOnce(DoAll(FutureArg<0>(&request),
                    Return(true)));

  Future<Response> response = http::get(
      agent.get()->pid,
      endpoint,
      None(),
      createBasicAuthHeaders(DEFAULT_CREDENTIAL));

  AWAIT_READY(request);

  const string principal = DEFAULT_CREDENTIAL.principal();
  EXPECT_EQ(principal, request->subject().value());

  // TODO(bbannier): Once agent endpoint handlers use more than just
  // `GET_ENDPOINT_WITH_PATH` we should factor out the request method
  // and expected authorization action and parameterize
  // `SlaveEndpointTest` on that as well in addition to the endpoint.
  EXPECT_EQ(authorization::GET_ENDPOINT_WITH_PATH, request->action());

  EXPECT_EQ("/" + endpoint, request->object().value());

  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
}
开发者ID:mpark,项目名称:mesos,代码行数:48,代码来源:slave_authorization_tests.cpp

示例15: driver

// This test ensures that a framework that is removed while
// authorization for registration is in progress is properly handled.
TEST_F(MasterAuthorizationTest, FrameworkRemovedBeforeRegistration)
{
  MockAuthorizer authorizer;
  Try<PID<Master> > master = StartMaster(&authorizer);
  ASSERT_SOME(master);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);

  // Return a pending future from authorizer.
  Future<Nothing> future;
  Promise<bool> promise;
  EXPECT_CALL(authorizer, authorize(An<const mesos::ACL::ReceiveOffers&>()))
    .WillOnce(DoAll(FutureSatisfy(&future),
                    Return(promise.future())));

  driver.start();

  // Wait until authorization is in progress.
  AWAIT_READY(future);

  // Stop the framework.
  // At this point the framework is disconnected but the master does
  // not take any action because the framework is not in its map yet.
  driver.stop();
  driver.join();

  // Settle the clock here to ensure master handles the framework
  // 'exited' event.
  Clock::pause();
  Clock::settle();
  Clock::resume();

  Future<Nothing> frameworkRemoved =
    FUTURE_DISPATCH(_, &AllocatorProcess::frameworkRemoved);

  // Now complete authorization.
  promise.set(true);

  // When the master tries to link to a non-existent framework PID
  // it should realize the framework is gone and remove it.
  AWAIT_READY(frameworkRemoved);

  Shutdown();
}
开发者ID:Bbarrett,项目名称:mesos,代码行数:48,代码来源:master_authorization_tests.cpp


注:本文中的testing::DoAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。