Skip to content
Snippets Groups Projects
Commit 52b99a97 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

add test

parent b791eb9a
Branches
Tags
No related merge requests found
......@@ -16,8 +16,7 @@ class MockRequestHandler : public RequestHandler {
MOCK_METHOD0(ReadyProcessRequest, bool());
MOCK_METHOD1(TearDownProcessingRequestLocked, void(bool processing_succeeded));
MOCK_METHOD2(ProcessRequestUnlocked_t, bool (const GenericRequest* request, bool* retry));
MOCK_METHOD1(ProcessRequestTimeoutUnlocked, void(GenericRequest* request))GenericRequest*
;
MOCK_METHOD1(ProcessRequestTimeoutUnlocked, void(GenericRequest* request));
uint64_t retry_counter = 0;
bool ProcessRequestUnlocked(GenericRequest* request, bool* retry) override {
retry_counter = request->GetRetryCounter();
......
......@@ -109,7 +109,7 @@ TEST_F(RequestPoolTests, TimeOut) {
EXPECT_CALL(*mock_request_handler, ReadyProcessRequest()).Times(1).WillRepeatedly(Return(true));
EXPECT_CALL(*mock_request_handler, PrepareProcessingRequestLocked()).Times(0);
EXPECT_CALL(*mock_request_handler, ProcessRequestUnlocked_t(_, _)).Times(0);
EXPECT_CALL(*mock_request_handler, ProcessRequestTimeout(_)).Times(1);
EXPECT_CALL(*mock_request_handler, ProcessRequestTimeoutUnlocked(_)).Times(1);
auto err = pool.AddRequest(std::move(request));
std::this_thread::sleep_for(std::chrono::milliseconds(10));
......
......@@ -2,6 +2,7 @@ if (UNIX)
add_subdirectory(receiver_cpu_usage)
if (BUILD_PYTHON)
add_subdirectory(consumer_python_memleak)
add_subdirectory(python_deadlock)
add_subdirectory(streamlist_python_multithread)
add_subdirectory(error-sending-data-using-callback-method)
endif()
......
set(TARGET_NAME python_deadlock_producer)
prepare_asapo()
find_package (Python3 REQUIRED)
if (UNIX)
get_target_property(PYTHON_LIBS_PRODUCER python-lib-producer BINARY_DIR)
else()
get_target_property(PYTHON_LIBS_PRODUCER asapo_producer BINARY_DIR)
endif()
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/producer_deadlock.py TEST_SCRIPT )
add_script_test("${TARGET_NAME}" "${TEST_SCRIPT} ${PYTHON_LIBS_PRODUCER} ${Python3_EXECUTABLE}" nomem)
#!/usr/bin/env bash
set -e
export PYTHONPATH=$2:${PYTHONPATH}
export Python3_EXECUTABLE=$3
$Python3_EXECUTABLE $1 $endpoint $beamtime_id $token
from __future__ import print_function
import asapo_producer
import time
import threading
lock = threading.Lock()
def callback(payload, err):
lock.acquire() # to print
if isinstance(err, asapo_producer.AsapoServerWarning):
print("successfuly sent, but with warning from server: ", payload, err)
elif err is not None:
print("could not sent: ", payload, err)
else:
print("successfuly sent: ", payload)
lock.release()
producer = asapo_producer.create_producer("google.com:8700",'processed', "beamtime", 'auto', "data_source", "token", 4, 5000)
for i in range(1, 20):
print ("sending ",i)
producer.send_file(i, local_path="./not_exist", exposed_path="./whatever",
ingest_mode=asapo_producer.INGEST_MODE_TRANSFER_METADATA_ONLY, callback=callback)
time.sleep(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment