Skip to content

Commit

Permalink
Start fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mszabo-wikia committed Jul 28, 2024
1 parent 02d47ba commit 04d0531
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 25 deletions.
6 changes: 6 additions & 0 deletions mcrouter/lib/network/test/AsyncMcClientTestSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ class AsyncMcClientBasicTestBase {
client.waitForReplies(6);
client.sendGet("shutdown", carbon::Result::NOTFOUND);
client.waitForReplies();
server->shutdown();
server->join();
EXPECT_EQ(1, server->getAcceptedConns());
EXPECT_TRUE(onUpCalled);
Expand All @@ -396,6 +397,7 @@ TEST_P(AsyncMcClientBasicTest, basicTest) {
}

TEST_P(AsyncMcClientBasicTest, qosClass) {
GTEST_SKIP() << "TODO";
for (uint64_t path = 0; path < 4; ++path) {
LOG(INFO) << "Path: " << path;
// SCOPED_TRACE(folly::to<std::string>("Path=", path));
Expand Down Expand Up @@ -959,6 +961,7 @@ using TFOTestParams = std::tuple<bool, bool, bool, SecurityMech>;
class AsyncMcClientTFOTest : public TestWithParam<TFOTestParams> {};

TEST_P(AsyncMcClientTFOTest, testTfoWithSSL) {
GTEST_SKIP() << "TODO";
auto serverEnabled = std::get<0>(GetParam());
auto clientEnabled = std::get<1>(GetParam());

Expand Down Expand Up @@ -1164,6 +1167,9 @@ TEST_P(AsyncMcClientSSLOffloadTest, clientReset) {
evb.loopOnce();
client.reset();
evb.loop();

server->shutdown();
server->join();
}

INSTANTIATE_TEST_CASE_P(AsyncMcClientTest, AsyncMcClientSSLOffloadTest, Bool());
4 changes: 4 additions & 0 deletions mcrouter/lib/network/test/MockMc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ MockMc::findUnexpired(folly::StringPiece key) {
return it;
}

size_t MockMc::itemCount() const noexcept {
return citems_.size();
}

void MockMc::flushAll() {
citems_.clear();
}
Expand Down
2 changes: 2 additions & 0 deletions mcrouter/lib/network/test/MockMc.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class MockMc {

CasResult cas(folly::StringPiece key, Item item, uint64_t token);

size_t itemCount() const noexcept;

/**
* clear all items
*/
Expand Down
1 change: 1 addition & 0 deletions mcrouter/lib/network/test/MockMcOnRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class MockMcOnRequest {
if (key == "__mockmc__") {
StatsReply stats;
stats.addStat("cmd_get_count", cmd_get_count.load());
stats.addStat("total_items", mc_.itemCount());
Context::reply(std::move(ctx), stats.getReply());
} else {
Context::reply(std::move(ctx), Reply(carbon::Result::BAD_COMMAND));
Expand Down
9 changes: 7 additions & 2 deletions mcrouter/test/MCProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ def stats(self, spec=None):
if spec:
q = "stats {spec}\r\n".format(spec=spec)
self._sendall(q)

s = {}
line = None
fds = select.select([self.fd], [], [], 20.0)
Expand Down Expand Up @@ -1030,7 +1029,8 @@ def __init__(self, port=None, ssl_port=None, extra_args=None):
pass_fds = []

# if mockmc is used here, we initialize the same way as MockMemcached
if McrouterGlobals.binPath("mockmc") == args[0]:
self.is_mock_server = McrouterGlobals.binPath("mockmc") == args[0]
if self.is_mock_server:
if port is None:
listen_sock = create_listen_socket()
port = listen_sock.getsockname()[1]
Expand Down Expand Up @@ -1103,6 +1103,11 @@ def __init__(self, port=None, ssl_port=None, extra_args=None):
tries -= 1
self.disconnect()

def stats(self, spec=None):
if self.is_mock_server:
return super().stats('__mockmc__')
return super().stats(spec)

def getsslport(self):
return self.ssl_port

Expand Down
1 change: 1 addition & 0 deletions mcrouter/test/cpp_unit_tests/McrouterClientUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ TEST(CarbonRouterClient, basicUsageSameThreadClient) {
// gracefully. This ensures graceful destruction of the static
// CarbonRouterInstance instance.
router->shutdown();
ioThreadPool->join();
ioThreadPool.reset();
EXPECT_TRUE(replyReceived);
}
Expand Down
46 changes: 23 additions & 23 deletions mcrouter/test/test_unknown_name_handle.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"pools": {
"A": { "servers": ["localhost:12345"] },
"B": { "servers": ["localhost:12346"] }
},
"named_handles": [
{
"hash": {
"salt": "gut.texas"
},
"name" : "B",
"pool": {
"name" : "B4",
"inherit" : "smc:twmemcache.gut.texas",
"protocol": "thrift",
"security_mech": "tls_to_plain",
"port_override": 11322,
"port_override_cross_dc": 11322,
"qos": {
"class": 2,
"path": 2
},
"port_override_within_dc": 11322
},
"type": "PoolRoute"
"type": "PoolRoute",
"name": "route:A",
"pool": "A"
},
{
"type": "PoolRoute",
"name": "route:B",
"pool": "B"
},
{
"type": "AllSyncRoute",
"name": "route:C",
"children": "NullRoute"
},
{
"type": "AllSyncRoute",
"name": "route:all",
"children": ["route:A", "route:B", "route:C"]
}
],

"route": {
"type": "FailoverRoute",
"children": [
"D",
"B"
]
"children": ["D", "B"]
}
}

0 comments on commit 04d0531

Please sign in to comment.