MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / SetUp

Method SetUp

src/apiserver/api_server_test.cc:36–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 return instance;
35 }
36 virtual void SetUp() {
37 std::cout << "Environment SetUp!" << std::endl;
38 ::hybridse::vm::Engine::InitializeGlobalLLVM();
39 FLAGS_zk_session_timeout = 100000;
40
41 mc.reset(new sdk::MiniCluster(6181));
42 ASSERT_TRUE(mc->SetUp()) << "Fail to set up mini cluster";
43
44 queue_svc.reset(new APIServerImpl);
45 sdk::ClusterOptions cluster_options;
46 cluster_options.zk_cluster = mc->GetZkCluster();
47 cluster_options.zk_path = mc->GetZkPath();
48 ASSERT_TRUE(queue_svc->Init(cluster_options));
49
50 // Http server set up
51 ASSERT_TRUE(server.AddService(queue_svc.get(), brpc::SERVER_DOESNT_OWN_SERVICE, "/* => Process") == 0)
52 << "Fail to add queue_svc";
53
54 // Start the server.
55 int api_server_port = 8010;
56 brpc::ServerOptions server_options;
57 // options.idle_timeout_sec = FLAGS_idle_timeout_s;
58 ASSERT_TRUE(server.Start(api_server_port, &server_options) == 0) << "Fail to start HttpServer";
59
60 sdk::SQLRouterOptions sql_opt;
61 sql_opt.session_timeout = 30000;
62 sql_opt.zk_cluster = mc->GetZkCluster();
63 sql_opt.zk_path = mc->GetZkPath();
64 // sql_opt.enable_debug = true;
65 cluster_remote = sdk::NewClusterSQLRouter(sql_opt);
66 hybridse::sdk::Status status;
67 ASSERT_TRUE(cluster_remote != nullptr);
68
69 db = "api_server_test";
70 cluster_remote->DropDB(db, &status);
71 cluster_remote->CreateDB(db, &status);
72 std::vector<std::string> dbs;
73 ASSERT_TRUE(cluster_remote->ShowDB(&dbs, &status));
74 ASSERT_TRUE(std::find(dbs.begin(), dbs.end(), db) != dbs.end());
75
76 brpc::ChannelOptions options;
77 options.protocol = "http";
78 options.timeout_ms = 2000 /*milliseconds*/;
79 options.max_retry = 3;
80 ASSERT_TRUE(http_channel.Init("http://127.0.0.1:", api_server_port, &options) == 0)
81 << "Fail to initialize http channel";
82 }
83
84 virtual void TearDown() {
85 std::cout << "Environment TearDown!" << std::endl;

Callers

nothing calls this directly

Calls 10

NewClusterSQLRouterFunction · 0.85
resetMethod · 0.80
GetZkClusterMethod · 0.80
GetZkPathMethod · 0.80
DropDBMethod · 0.80
ShowDBMethod · 0.80
InitMethod · 0.45
getMethod · 0.45
StartMethod · 0.45
CreateDBMethod · 0.45

Tested by

no test coverage detected