| 41 | static ObjectPool* perm_objects; |
| 42 | |
| 43 | TEST(StatestoreTest, SmokeTest) { |
| 44 | // All allocations done by 'new' to avoid problems shutting down Thrift servers |
| 45 | // gracefully. |
| 46 | MetricGroup* metrics = perm_objects->Add(new MetricGroup("statestore")); |
| 47 | Statestore* statestore = perm_objects->Add(new Statestore(metrics)); |
| 48 | // Thrift will internally pick an ephemeral port if we pass in 0 as the port. |
| 49 | int statestore_port = 0; |
| 50 | ASSERT_OK(statestore->Init(statestore_port)); |
| 51 | |
| 52 | MetricGroup* metrics_2 = perm_objects->Add(new MetricGroup("statestore_2")); |
| 53 | // Port already in use |
| 54 | Statestore* statestore_wont_start = perm_objects->Add(new Statestore(metrics_2)); |
| 55 | ASSERT_FALSE(statestore_wont_start->Init(statestore->port()).ok()); |
| 56 | statestore_wont_start->ShutdownForTesting(); |
| 57 | |
| 58 | StatestoreSubscriber* sub_will_start = perm_objects->Add( |
| 59 | new StatestoreSubscriber("sub1", MakeNetworkAddress("localhost", 0), |
| 60 | MakeNetworkAddress("localhost", statestore->port()), MakeNetworkAddress("", 0), |
| 61 | new MetricGroup(""), TStatestoreSubscriberType::COORDINATOR_EXECUTOR)); |
| 62 | ASSERT_OK(sub_will_start->Start()); |
| 63 | |
| 64 | // Confirm that a subscriber trying to use an in-use port will fail to start. |
| 65 | StatestoreSubscriber* sub_will_not_start = perm_objects->Add(new StatestoreSubscriber( |
| 66 | "sub3", MakeNetworkAddress("localhost", sub_will_start->heartbeat_port()), |
| 67 | MakeNetworkAddress("localhost", statestore->port()), MakeNetworkAddress("", 0), |
| 68 | new MetricGroup(""), TStatestoreSubscriberType::COORDINATOR_EXECUTOR)); |
| 69 | ASSERT_FALSE(sub_will_not_start->Start().ok()); |
| 70 | |
| 71 | statestore->ShutdownForTesting(); |
| 72 | } |
| 73 | |
| 74 | // Runs an SSL smoke test with provided parameters. |
| 75 | void SslSmokeTestHelper(const string& server_ca_certificate, |
nothing calls this directly
no test coverage detected