示例#1
0
TEST_P(Registrar_BENCHMARK_Test, performance)
{
  Registrar registrar(flags, state);
  AWAIT_READY(registrar.recover(master));

  vector<SlaveInfo> infos;

  Attributes attributes = Attributes::parse("foo:bar;baz:quux");
  Resources resources =
    Resources::parse("cpus(*):1.0;mem(*):512;disk(*):2048").get();

  size_t slaveCount = GetParam();

  // Create slaves.
  for (size_t i = 0; i < slaveCount; ++i) {
    // Simulate real slave information.
    SlaveInfo info;
    info.set_hostname("localhost");
    info.mutable_id()->set_value(
        std::string("201310101658-2280333834-5050-48574-") + stringify(i));
    info.mutable_resources()->MergeFrom(resources);
    info.mutable_attributes()->MergeFrom(attributes);
    infos.push_back(info);
  }

  // Admit slaves.
  Stopwatch watch;
  watch.start();
  Future<bool> result;
  foreach (const SlaveInfo& info, infos) {
    result = registrar.apply(Owned<Operation>(new AdmitSlave(info)));
  }
示例#2
0
TEST_F(RegistrarTest, recover)
{
  Registrar registrar(state);

  SlaveInfo slave;
  slave.set_hostname("localhost");
  SlaveID id;
  id.set_value("1");
  slave.mutable_id()->CopyFrom(id);

  // Operations preceding recovery will fail.
  AWAIT_EXPECT_FAILED(registrar.admit(slave));
  AWAIT_EXPECT_FAILED(registrar.readmit(slave));
  AWAIT_EXPECT_FAILED(registrar.remove(slave));

  MasterInfo info;
  info.set_id("foobar");
  info.set_ip(0);
  info.set_port(5050);
  info.set_pid("0:5050");

  Future<Registry> registry = registrar.recover(info);

  // Before waiting for the recovery to complete, invoke some
  // operations to ensure they do not fail.
  Future<bool> admit = registrar.admit(slave);
  Future<bool> readmit = registrar.readmit(slave);
  Future<bool> remove = registrar.remove(slave);

  AWAIT_READY(registry);
  EXPECT_EQ(info, registry.get().master().info());

  AWAIT_EQ(true, admit);
  AWAIT_EQ(true, readmit);
  AWAIT_EQ(true, remove);
}