Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "windows-x64",
"configurePreset": "windows-x64",
"output": {
"outputOnFailure": true
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
}
]
}
5 changes: 5 additions & 0 deletions scaler/io/ymq/message_connection_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ void MessageConnectionTCP::onCreated()
if (lastError == ERROR_IO_PENDING) {
return;
}

unrecoverableError({
Error::ErrorCode::CoreBug,
"Originated from",
Expand Down Expand Up @@ -352,6 +353,10 @@ void MessageConnectionTCP::onRead()
}

#ifdef _WIN32
// TODO: This need rewrite to better logic
if (!_connFd) {
return;
}
const bool ok = ReadFile((HANDLE)(SOCKET)_connFd, nullptr, 0, nullptr, this->_eventManager.get());
if (ok) {
onRead();
Expand Down
22 changes: 11 additions & 11 deletions scaler/io/ymq/timed_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ class TimedQueue {
}
}

Identifier push(Timestamp timestamp, Callback cb)
Configuration::ExecutionCancellationIdentifier push(Timestamp timestamp, Configuration::TimedQueueCallback cb)
{
auto ts = convertToLARGE_INTEGER(timestamp);
if (pq.empty() || timestamp < std::get<0>(pq.top())) {
if (pq.empty() || timestamp < pq.top().timestamp) {
SetWaitableTimer(
_timerFd,
(LARGE_INTEGER*)&ts,
Expand All @@ -218,16 +218,16 @@ class TimedQueue {
return _currentId++;
}

void cancelExecution(Identifier id) { _cancelledFunctions.insert(id); }
void cancelExecution(Configuration::ExecutionCancellationIdentifier id) { _cancelledFunctions.insert(id); }

std::vector<Callback> dequeue()
std::vector<Configuration::TimedQueueCallback> dequeue()
{
std::vector<Callback> callbacks;
std::vector<Configuration::TimedQueueCallback> callbacks;

Timestamp now;
while (pq.size()) {
if (std::get<0>(pq.top()) < now) {
auto [ts, cb, id] = std::move(const_cast<PriorityQueue::reference>(pq.top()));
if (pq.top().timestamp < now) {
auto [ts, cb, id] = std::move(const_cast<std::priority_queue<TimedCallback>::reference>(pq.top()));
pq.pop();
auto cancelled = _cancelledFunctions.find(id);
if (cancelled != _cancelledFunctions.end()) {
Expand All @@ -240,7 +240,7 @@ class TimedQueue {
}

if (!pq.empty()) {
auto nextTs = std::get<0>(pq.top());
auto nextTs = pq.top().timestamp;
auto ts = convertToLARGE_INTEGER(nextTs);
SetWaitableTimer(
_timerFd,
Expand All @@ -258,9 +258,9 @@ class TimedQueue {

private:
HANDLE _timerFd;
Identifier _currentId;
PriorityQueue pq;
std::set<Identifier> _cancelledFunctions;
Configuration::ExecutionCancellationIdentifier _currentId;
std::priority_queue<TimedCallback> pq;
std::set<Configuration::ExecutionCancellationIdentifier> _cancelledFunctions;
};

#endif // _WIN32
Expand Down
25 changes: 15 additions & 10 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,29 @@ function(add_test_executable test_name source_file)

target_include_directories(${test_name} PRIVATE ${CMAKE_BINARY_DIR})

target_link_libraries(${test_name} PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,-Bstatic>
object_storage_server_objs
target_link_libraries(${test_name} PRIVATE
$<$<NOT:$<PLATFORM_ID:Windows>>:object_storage_server_objs>
ymq_objs
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,-Bdynamic>
CapnProto::capnp
CapnProto::kj
GTest::gtest_main
Python3::Python
)

add_test(NAME ${test_name} COMMAND ${test_name})

# Post build: We need to copy if dll is not present, otherwise the test program won't find gtest.dll
# See https://stackoverflow.com/questions/69978314/cmake-with-gtest-on-windows-build-starts-test-but-shared-libs-cannot-be-found
if (WIN32)
add_custom_command(TARGET ${test_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:${test_name}>
$<TARGET_FILE_DIR:${test_name}>
COMMAND_EXPAND_LISTS
)
endif()
endfunction()

if(LINUX OR APPLE)
# Add the directory for the C++ tests.
add_subdirectory(cpp)
# Add the directory for the C++ tests.
add_subdirectory(cpp)

# Add the new directory for io tests.
add_subdirectory(io/ymq)
endif()
7 changes: 5 additions & 2 deletions tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# this fetches Google Test, so it must be included first.
add_subdirectory(object_storage)
add_subdirectory(ymq)
if(LINUX OR APPLE)
add_subdirectory(object_storage)
endif()

add_subdirectory(ymq)
2 changes: 2 additions & 0 deletions tests/cpp/ymq/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
add_test_executable(test_ymq test_ymq.cpp)

add_test_executable(test_ymq_logging test_ymq_logging.cpp)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

#include "scaler/io/ymq/logging.h"

#ifdef max
#undef max
#endif

// Test fixture for direct unit testing of the log() function's formatting
class LoggingUnitTest: public ::testing::Test {
protected:
Expand Down
1 change: 0 additions & 1 deletion tests/io/ymq/CMakeLists.txt

This file was deleted.

Loading