Skip to content

Commit

Permalink
Run Python integration tests as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mszabo-wikia committed Jul 29, 2024
1 parent 8132030 commit f5ee055
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mcrouter/lib/network/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(NOT BUILD_TESTS)
endif()

add_executable(mcrouter_mock_mc_server MockMc.cpp MockMcServer.cpp)
set_property(TARGET mcrouter_mock_mc_server PROPERTY OUTPUT_NAME mock_mc_server)

target_link_libraries(
mcrouter_mock_mc_server
Expand Down Expand Up @@ -51,6 +52,7 @@ target_link_libraries(
FBThrift::thrift-core)

add_executable(mcrouter_mock_mc_server_dual MockMc.cpp MockMcServerDual.cpp)
set_property(TARGET mcrouter_mock_mc_server_dual PROPERTY OUTPUT_NAME mock_mc_server_dual)

target_link_libraries(
mcrouter_mock_mc_server_dual
Expand Down
23 changes: 23 additions & 0 deletions mcrouter/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,27 @@
# This source code is licensed under the MIT license found in the LICENSE file
# in the root directory of this source tree.

if(BUILD_TESTS)
find_package(Python3 COMPONENTS Interpreter)

# Python integration tests need to run from the build directory so that they
# can access mcrouter binaries, so copy them and their fixtures over.
file(GLOB mcrouter_integration_test_files CONFIGURE_DEPENDS "*.json" "*.py")
foreach(TEST_FILE ${mcrouter_integration_test_files})
configure_file(${TEST_FILE} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
endforeach()

configure_file(mcrouter_config.py ${CMAKE_CURRENT_BINARY_DIR}/config.py
COPYONLY)

file(GLOB mcrouter_integration_test_cases CONFIGURE_DEPENDS "test_*.py")
foreach(TEST_CASE ${mcrouter_integration_test_cases})
get_filename_component(test_name ${TEST_CASE} NAME_WE)
add_test(
NAME "integration_${test_name}"
COMMAND ${Python3_EXECUTABLE} -B -m unittest -q mcrouter.test.${test_name}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endforeach()
endif()

add_subdirectory(cpp_unit_tests)
3 changes: 1 addition & 2 deletions mcrouter/test/MCProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import tempfile
import time

from carbon.carbon_result.thrift_types import Result
from mcrouter.test.config import McrouterGlobals


Expand Down Expand Up @@ -256,7 +255,7 @@ def ensure_connected(self):
while True:
try:
res = self.thrift_client.mcVersion()
if res == Result.OK:
if res == carbon.carbon_result.thrift_types.Result.OK:
return
except Exception as e:
print("Error on sending mcVersion in Thrift: {}".format(e))
Expand Down
1 change: 1 addition & 0 deletions mcrouter/test/mcrouter_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def binPath(name):
"mcrouter": "./mcrouter/mcrouter",
"mcpiper": "./mcrouter/tools/mcpiper/mcpiper",
"mockmc": "./mcrouter/lib/network/test/mock_mc_server",
"mockmcdual": "./mcrouter/lib/network/test/mock_mc_server_dual",
"prodmc": "./mcrouter/lib/network/test/mock_mc_server",
}
return bins[name]
Expand Down

0 comments on commit f5ee055

Please sign in to comment.