Closed ahmedyarub closed 3 years ago
The test passes but it used to wait for 60 seconds before ending. Now it wait for 3 seconds only to speedup unit tests. How can we end the unit test after the response is sent?
The test passes but it used to wait for 60 seconds before ending. Now it wait for 3 seconds only to speedup unit tests.
create_response
should not be called after a call to upgrade
.
Without a response the unit test would fail So what do you suggest to do in this case?
Without a response the unit test would fail
Which unit-test?
TEST_CASE( "connection state for WS" , "[connection_state][ws]" )
This one
This test passes successfully: https://travis-ci.com/Stiffstream/restinio/jobs/229166913#L1917
This test passes successfully: https://travis-ci.com/Stiffstream/restinio/jobs/229166913#L1917
On Windows it fails with the following log if I don't add the req->create_response() part: `D:\cpp\restinio\dev\test\handle_requests\connection_state\main.cpp:338: Failure: REQUIRE_NOTHROW(response = do_request( request_str )) with expansion: response = do_request( request_str )
D:\cpp\restinio\dev\test\handle_requests\connection_state\main.cpp:338: Failure: unexpected exception [2019-09-06 12:23:56.999] TRACE: starting server on 127.0.0.1:8085 [2019-09-06 12:23:57.001] INFO: init accept #0 [2019-09-06 12:23:57.001] INFO: server started on 127.0.0.1:8085 [2019-09-06 12:23:57.002] TRACE: accept connection from 127.0.0.1:52130 on socket #0 [2019-09-06 12:23:57.003] TRACE: [connection:1] start connection with 127.0.0.1:52130 [2019-09-06 12:23:57.003] TRACE: [connection:1] start waiting for request [2019-09-06 12:23:57.003] TRACE: [connection:1] continue reading request [2019-09-06 12:23:57.003] TRACE: [connection:1] received 204 bytes [2019-09-06 12:23:57.003] TRACE: [connection:1] upgrade request received: GET /chat; Upgrade: 'websocket'; [2019-09-06 12:23:57.003] INFO: [connection:1] handle upgrade request (#0): GET /chat [2019-09-06 12:23:57.003] TRACE: [connection:1] move socket to [ws_connection:1] [2019-09-06 12:23:57.004] TRACE: [ws_connection:1] start connection with 127.0.0.1:52130 [2019-09-06 12:23:57.004] TRACE: [ws_connection:1] start next write group, size: 1 [2019-09-06 12:23:57.004] TRACE: [ws_connection:1] sending data with buf count: 1, total size: 129 [2019-09-06 12:23:57.004] TRACE: [ws_connection:1] start reading header [2019-09-06 12:23:57.004] TRACE: [ws_connection:1] continue reading message [2019-09-06 12:23:57.004] TRACE: [ws_connection:1] kill [2019-09-06 12:23:57.004] TRACE: [ws_connection:1] close socket [2019-09-06 12:23:57.004] TRACE: [connection:1] destructor called [2019-09-06 12:23:57.005] ERROR: [ws_connection:1] reading message header error: The I/O operation has been aborted because of either a thread exit or an application request. [2019-09-06 12:23:57.005] ERROR: [ws_connection:1] unable to write: The I/O operation has been aborted because of either a thread exit or an application request. [2019-09-06 12:23:57.005] TRACE: [ws_connection:1] destructor called [2019-09-06 12:23:57.005] TRACE: closing server on 127.0.0.1:8085 [2019-09-06 12:23:57.005] INFO: server closed on 127.0.0.1:8085 Process finished with exit code 1 `
I built it with the following CMake flags: -DCMAKE_INSTALL_PREFIX="c:/Program Files/Restinio" -DRESTINIO_FIND_DEPS=ON -DCMAKE_TOOLCHAIN_FILE="D:/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_CXX_FLAGS_DEBUG="/MDd /Zi /Ob0 /Od /RTC1 /bigobj /D_WIN32_WINDOWS /D_WINSOCK_DEPRECATED_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS"
Looks like there are some errors with clang compilation. I'll be making more tests within the next few days.
On Windows it fails
I think the reason is elsewhere. create_response
must not be called after passing a request to upgrade
.
I regularly check builds under Windows, but in Release mode only. In Release builds this unit-test doesn't fail. I can suppose that there is some problem with timing in Debug builds where some actions can take much more time than in Release mode.
On Windows it fails
I think the reason is elsewhere.
create_response
must not be called after passing a request toupgrade
.I regularly check builds under Windows, but in Release mode only. In Release builds this unit-test doesn't fail. I can suppose that there is some problem with timing in Debug builds where some actions can take much more time than in Release mode.
AppVeyor has Windows builds. I'll create a script within the next few days to automate testing on Windows. I'm testing with Release builds but we might be having different configurations. Automating the builds would probably help in this regards.
This should provide better code quality and may be even better performance. I've made some small adjustments to unit tests.