| 205 | }; |
| 206 | |
| 207 | virtual void Notify(google::protobuf::RpcController* cntl_base, |
| 208 | const test::NotifyRequest* request, |
| 209 | test::NotifyResponse* response, |
| 210 | google::protobuf::Closure* done) { |
| 211 | brpc::ClosureGuard done_guard(done); |
| 212 | const std::string& message = request->message(); |
| 213 | LOG(INFO) << message; |
| 214 | if (message == "ResetCaseSet") { |
| 215 | _server.Stop(0); |
| 216 | _server.Join(); |
| 217 | _echo_service->StopTestCase(); |
| 218 | |
| 219 | LoadCaseSet(FLAGS_case_file); |
| 220 | _case_index = 0; |
| 221 | response->set_message("CaseSetReset"); |
| 222 | } else if (message == "StartCase") { |
| 223 | CHECK(!_server.IsRunning()) << "Continuous StartCase"; |
| 224 | const test::TestCase& test_case = _case_set.test_case(_case_index++); |
| 225 | _echo_service->SetTestCase(test_case); |
| 226 | brpc::ServerOptions options; |
| 227 | options.max_concurrency = FLAGS_server_max_concurrency; |
| 228 | _server.MaxConcurrencyOf("test.EchoService.Echo") = test_case.max_concurrency(); |
| 229 | |
| 230 | _server.Start(FLAGS_echo_port, &options); |
| 231 | _echo_service->StartTestCase(); |
| 232 | response->set_message("CaseStarted"); |
| 233 | } else if (message == "StopCase") { |
| 234 | CHECK(_server.IsRunning()) << "Continuous StopCase"; |
| 235 | _server.Stop(0); |
| 236 | _server.Join(); |
| 237 | |
| 238 | _echo_service->StopTestCase(); |
| 239 | response->set_message("CaseStopped"); |
| 240 | } else { |
| 241 | LOG(FATAL) << "Invalid message:" << message; |
| 242 | response->set_message("Invalid Cntl Message"); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | private: |
| 247 | void LoadCaseSet(const std::string& file_path) { |
no test coverage detected