Esempio n. 1
0
TEST(ObRootServer2LogTest, do_server_down)
{
  int32_t port = 1001;
  ObServer server(ObServer::IPV4, "10.10.10.1", port);
  int32_t status = 1;
  int64_t ts = 123456;

  ObRootServer2 master;
  ObRootWorkerForTest master_worker;
  ASSERT_TRUE(master.init("./root_server.conf", 100, &master_worker));

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

  ObRootServerTester wrapper(&slave);
  wrapper.stop_thread();
  int ret = master.regist_server(server, false, status, ts);
  ASSERT_EQ(OB_SUCCESS, ret);

  ObRootLogWorker log_worker = wrapper.get_log_worker();
  log_worker.do_cs_regist(server, ts); // up server

  ObChunkServerManager& server_manager = wrapper.get_server_manager();
  ObChunkServerManager::iterator it = server_manager.find_by_ip(server);
  ASSERT_TRUE(it != server_manager.end());
  ASSERT_NE(ObServerStatus::STATUS_DEAD, it->status_);

  log_worker.do_server_down(server, ts); // down server
  it = server_manager.find_by_ip(server);
  ASSERT_TRUE(it != server_manager.end());
  ASSERT_EQ(ObServerStatus::STATUS_DEAD, it->status_);
}
Esempio n. 2
0
TEST(ObRootServer2LogTest, do_load_report)
{
  int32_t port = 1001;
  ObServer server(ObServer::IPV4, "10.10.10.1", port);
  int32_t status = 1;
  int64_t ts = 123456;

  int64_t cap = 12345;
  int64_t used = 1234;

  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();

  int ret = master.regist_server(server, false, status, ts);
  ASSERT_EQ(OB_SUCCESS, ret);
  ret = master.update_capacity_info(server, cap, used);
  ASSERT_EQ(OB_SUCCESS, ret);

  ObRootLogWorker log_worker = slave_wrapper.get_log_worker();
  log_worker.do_cs_regist(server, ts);
  log_worker.do_cs_load_report(server, cap, used);

  ObChunkServerManager& master_server_manager = master_wrapper.get_server_manager();
  ObChunkServerManager::iterator it = master_server_manager.find_by_ip(server);
  ASSERT_TRUE(it != master_server_manager.end());

  int64_t master_cap = it->disk_info_.get_capacity();
  int32_t master_used = it->disk_info_.get_used();

  ObChunkServerManager& slave_server_manager = slave_wrapper.get_server_manager();
  it = slave_server_manager.find_by_ip(server);
  ASSERT_TRUE(it != slave_server_manager.end());

  int64_t slave_cap = it->disk_info_.get_capacity();
  int32_t slave_used = it->disk_info_.get_used();

  ASSERT_EQ(cap, master_cap);
  ASSERT_EQ(used, master_used);
  ASSERT_EQ(master_cap, slave_cap);
  ASSERT_EQ(master_used, slave_used);
}
Esempio n. 3
0
TEST(ObRootServer2LogTest, do_cs_regist)
{
  int32_t port = 1001;
  ObServer server(ObServer::IPV4, "10.10.10.1", port);
  int32_t status = 1;
  int64_t ts = 123456;

  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();

  int ret = master.regist_server(server, false, status, ts);
  ASSERT_EQ(OB_SUCCESS, ret);

  ObRootLogWorker log_worker = slave_wrapper.get_log_worker();
  log_worker.do_cs_regist(server, ts);

  ObChunkServerManager& master_server_manager = master_wrapper.get_server_manager();
  ObChunkServerManager::iterator it = master_server_manager.find_by_ip(server);
  ASSERT_TRUE(it != master_server_manager.end());

  int64_t master_hb = it->last_hb_time_;
  int32_t master_port = it->port_cs_;

  ObChunkServerManager& slave_server_manager = slave_wrapper.get_server_manager();
  it = slave_server_manager.find_by_ip(server);
  ASSERT_TRUE(it != slave_server_manager.end());

  int64_t slave_hb = it->last_hb_time_;
  int32_t slave_port = it->port_cs_;

  ASSERT_EQ(ts, master_hb);
  ASSERT_EQ(port, master_port);
  ASSERT_EQ(master_hb, slave_hb);
  ASSERT_EQ(master_port, slave_port);
}
Esempio n. 4
0
void MigrateTestEnv::setup()
{
  // 1. init
  ObRootServer2* rs = worker_.get_root_server();
  ASSERT_TRUE(rs->init("./root_server.conf", 100, &worker_));

  rs->start_threads();
  sleep(1);
  
  // 2. cs register
  int status;
  ASSERT_EQ(OB_SUCCESS, rs->regist_server(cs1_, false, status));
  ASSERT_EQ(OB_SUCCESS, rs->regist_server(cs2_, false, status));

  // 3. cs1 report tablets replicas
  ObTabletReportInfoList report_list1;
  ObTabletReportInfoList report_list2;
  ObTabletReportInfo report_info;
  ObTabletLocation location;
  location.tablet_version_ = tablet_version_;
  info1_.range_.table_id_ = 10001;
  info1_.range_.border_flag_.set_inclusive_end();
  info1_.range_.border_flag_.unset_inclusive_start();
  info1_.range_.border_flag_.set_min_value();
  info1_.range_.border_flag_.unset_max_value();

  info1_.range_.start_key_.assign_buffer(buf1[0], 30);
  info1_.range_.end_key_.assign_buffer(buf2[0], 30);
  info1_.range_.start_key_.write("aa1", 3);
  info1_.range_.end_key_.write("ba1", 3);

  location.chunkserver_ = cs1_;

  report_info.tablet_info_ = info1_;
  report_info.tablet_location_ = location;
  report_list1.add_tablet(report_info);

  info1_.range_.border_flag_.unset_min_value();
  info1_.range_.border_flag_.set_max_value();
  info1_.range_.start_key_.assign_buffer(buf1[1], 30);
  info1_.range_.end_key_.assign_buffer(buf2[1], 30);
  info1_.range_.start_key_.write("ba1", 3);
  info1_.range_.end_key_.write("ca1", 3);

  report_info.tablet_info_ = info1_;
  report_info.tablet_location_ = location;
  report_list1.add_tablet(report_info);

  int64_t now = tbsys::CTimeUtil::getTime();
  ASSERT_EQ(OB_SUCCESS, rs->report_tablets(cs1_, report_list1, now));
  ASSERT_EQ(OB_SUCCESS, rs->report_tablets(cs2_, report_list2, now));

  // wait init finish
  sleep(5);
}
Esempio n. 5
0
TEST(ObRootServer2LogTest, begin_balance)
{
  ObRootServer2 server;
  ObRootWorkerForTest worker;
  ASSERT_TRUE(server.init("./root_server.conf", 100, &worker));
  ObRootServerTester wrapper(&server);
  wrapper.stop_thread();

  ASSERT_NE(ObRootServer2::STATUS_BALANCING, wrapper.get_server_status());

  wrapper.get_log_worker().do_begin_balance();
  ASSERT_EQ(ObRootServer2::STATUS_BALANCING, wrapper.get_server_status());
}
Esempio n. 6
0
TEST(ObRootServer2LogTest, us_unload_done)
{
  ObRootServer2 server;
  ObRootWorkerForTest worker;
  ASSERT_TRUE(server.init("./root_server.conf", 100, &worker));
  ObRootServerTester wrapper(&server);
  wrapper.stop_thread();

  ObServerStatus* us = wrapper.get_update_server();
  us->status_ = ObServerStatus::STATUS_REPORTED;
  
  wrapper.get_log_worker().do_us_unload_done(us->server_);
  ASSERT_EQ(ObServerStatus::STATUS_SERVING, us->status_);
}
Esempio n. 7
0
TEST(ObRootServer2LogTest, us_schema_changed)
{
  ObRootServer2 server;
  ObRootWorkerForTest worker;
  ASSERT_TRUE(server.init("./root_server.conf", 100, &worker));
  ObRootServerTester wrapper(&server);
  wrapper.stop_thread();

  ObServerStatus* us = wrapper.get_update_server();
  us->status_ = ObServerStatus::STATUS_REPORTING;
  
  wrapper.get_log_worker().do_us_mem_frozen(us->server_, 0);
  ASSERT_EQ(ObServerStatus::STATUS_REPORTED, us->status_);
}
Esempio n. 8
0
//TEST(ObRootServer2LogTest, start_report)
//{
//  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();
//
//  TBSYS_LOG(DEBUG, "Server status: %d", master_wrapper.get_server_status());
//  bool ret = master.start_report(true);
//  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);
//  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());
//}
//
TEST(ObRootServer2LogTest, create_table_done)
{
  ObRootServer2 server;
  ObRootWorkerForTest worker;
  ASSERT_TRUE(server.init("./root_server.conf", 100, &worker));
  ObRootServerTester wrapper(&server);
  wrapper.stop_thread();

  ASSERT_FALSE(wrapper.get_create_table_done());

  wrapper.get_log_worker().do_create_table_done();

  ASSERT_TRUE(wrapper.get_create_table_done());
}
Esempio n. 9
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());
}
Esempio n. 10
0
TEST(ObRootServer2LogTest, cs_schema_changing)
{
  int32_t port = 1001;
  ObServer server(ObServer::IPV4, "10.10.10.1", port);
  int64_t ts = 123456;

  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_SERVING;

  wrapper.get_log_worker().do_cs_start_merging(it->server_);
  ASSERT_EQ(ObServerStatus::STATUS_REPORTING, it->status_);
}