Пример #1
0
TEST(ObRootServer2LogTest, start_switch)
{
  ObRootServer2 master;
  ObRootWorkerForTest master_worker;
  ASSERT_TRUE(master.init("./root_server.conf", 100, &master_worker));
  ObRootServerTester master_wrapper(&master);
  master_wrapper.stop_thread();

  ObRootServer2 slave;
  ObRootWorkerForTest slave_worker;
  ASSERT_TRUE(slave.init("./root_server.conf", 100, &slave_worker));
  ObRootServerTester slave_wrapper(&slave);
  slave_wrapper.stop_thread();

  master_wrapper.set_master(true);
  master_wrapper.stop_thread();
  slave_wrapper.stop_thread();
  slave_wrapper.set_master(false);

  TBSYS_LOG(DEBUG, "Server status: %d", master_wrapper.get_server_status());
  bool ret = master.start_switch();
  TBSYS_LOG(DEBUG, "Server status: %d", master_wrapper.get_server_status());
  ASSERT_TRUE(ret);
  TBSYS_LOG(DEBUG, "master start switch done");

  int64_t ts = master.get_time_stamp_changing();

  ObRootLogWorker log_worker = slave_wrapper.get_log_worker();
  log_worker.do_start_report(ts, true);
  log_worker.do_start_switch(ts);
  TBSYS_LOG(DEBUG, "slave start switch done");

  int64_t slave_ts = slave.get_time_stamp_changing();

  ASSERT_EQ(ts, slave_ts);
  ASSERT_EQ(master_wrapper.get_server_status(), slave_wrapper.get_server_status());
}
Пример #2
0
TEST(ObRootServer2LogTest, cs_schema_changed)
{
  int32_t port = 1001;
  ObServer server(ObServer::IPV4, "10.10.10.1", port);
  int64_t ts = 12345;

  ObRootServer2 root;
  ObRootWorkerForTest worker;
  ASSERT_TRUE(root.init("./root_server.conf", 100, &worker));
  ObRootServerTester wrapper(&root);
  wrapper.stop_thread();

  wrapper.get_log_worker().do_cs_regist(server, ts);
  ObChunkServerManager& slave_server_manager = wrapper.get_server_manager();
  ObChunkServerManager::iterator it = slave_server_manager.find_by_ip(server);
  ASSERT_TRUE(it != slave_server_manager.end());

  it->status_ = ObServerStatus::STATUS_REPORTING;

  wrapper.get_log_worker().do_cs_merge_over(it->server_, root.get_time_stamp_changing());
  ASSERT_EQ(ObServerStatus::STATUS_REPORTED, it->status_);

}