MCPcopy Create free account
hub / github.com/apache/brpc / TestAuthenticationParallel

Method TestAuthenticationParallel

test/brpc_channel_unittest.cpp:1873–1911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1871 }
1872
1873 void TestAuthenticationParallel(bool single_server,
1874 bool async, bool short_connection) {
1875 std::cout << " *** single=" << single_server
1876 << " async=" << async
1877 << " short=" << short_connection << std::endl;
1878
1879 ASSERT_EQ(0, StartAccept(_ep));
1880 MyAuthenticator auth;
1881
1882 const int NCHANS = 5;
1883 brpc::Channel subchans[NCHANS];
1884 brpc::ParallelChannel channel;
1885 for (int i = 0; i < NCHANS; ++i) {
1886 SetUpChannel(&subchans[i], single_server, short_connection, &auth);
1887 ASSERT_EQ(0, channel.AddChannel(
1888 &subchans[i], brpc::DOESNT_OWN_CHANNEL,
1889 NULL, NULL));
1890 }
1891
1892 const int NUM = 10;
1893 pthread_t tids[NUM];
1894 for (int i = 0; i < NUM; ++i) {
1895 google::protobuf::Closure* thrd_func =
1896 brpc::NewCallback(
1897 this, &ChannelTest::RPCThread, (brpc::ChannelBase*)&channel, async);
1898 EXPECT_EQ(0, pthread_create(&tids[i], NULL,
1899 RunClosure, thrd_func));
1900 }
1901 for (int i = 0; i < NUM; ++i) {
1902 pthread_join(tids[i], NULL);
1903 }
1904
1905 if (short_connection) {
1906 EXPECT_EQ(NUM * NCHANS, auth.count.load());
1907 } else {
1908 EXPECT_EQ(1, auth.count.load());
1909 }
1910 StopAndJoin();
1911 }
1912
1913 void TestAuthenticationSelective(bool single_server,
1914 bool async, bool short_connection) {

Callers

nothing calls this directly

Calls 3

NewCallbackFunction · 0.85
AddChannelMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected