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 29, 2024
1 parent f5ee055 commit a290cd6
Show file tree
Hide file tree
Showing 8 changed files with 46 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 @@ -1143,6 +1143,9 @@ TEST_P(AsyncMcClientSSLOffloadTest, closeNow) {
EXPECT_FALSE(upCalled);
EXPECT_TRUE(downReason.has_value());
EXPECT_EQ(*downReason, ConnectionDownReason::ABORTED);

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

TEST_P(AsyncMcClientSSLOffloadTest, clientReset) {
Expand All @@ -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
2 changes: 2 additions & 0 deletions mcrouter/lib/network/test/TestClientServerUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void TestServerOnRequest::onRequest(
processReply(std::move(ctx), Reply(carbon::Result::NOTFOUND));
} else if (req.key_ref()->fullKey() == "shutdown") {
shutdownLock_.post();
// TODO
std::this_thread::sleep_for(std::chrono::milliseconds(100));
processReply(std::move(ctx), Reply(carbon::Result::NOTFOUND));
flushQueue();
} else if (req.key_ref()->fullKey() == "busy") {
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 a290cd6

Please sign in to comment.