diff --git a/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt b/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt index 08ae3908db..d4f7c0f8ec 100644 --- a/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt +++ b/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt @@ -6,7 +6,7 @@ include(ExternalProject) ExternalProject_Add(libkvsCommonLws-download GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git - GIT_TAG 178109a5dbfc5288ba5cf7fab1dc1afd5e2e182b + GIT_TAG fd562a16e41b1972df14c230b6be7a7d3f75bc6b PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bcfb871c8..1bdf9dcf5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ option(BUILD_LIBSRTP_HOST_PLATFORM "If buildng LibSRTP what is the current platf option(BUILD_LIBSRTP_DESTINATION_PLATFORM "If buildng LibSRTP what is the destination platform" OFF) option(BUILD_SAMPLE "Build available samples" ON) option(ENABLE_DATA_CHANNEL "Enable support for data channel" ON) +option(ENABLE_KVS_THREADPOOL "Enable support for KVS thread pool in signaling" ON) option(INSTRUMENTED_ALLOCATORS "Enable memory instrumentation" OFF) # Developer Flags @@ -98,6 +99,10 @@ message(STATUS "dependencies install path is ${OPEN_SRC_INSTALL_PREFIX}") add_definitions(-DKVS_CA_CERT_PATH="${CMAKE_SOURCE_DIR}/certs/cert.pem") add_definitions(-DCMAKE_DETECTED_CACERT_PATH) +if (ENABLE_KVS_THREADPOOL) + add_definitions(-DENABLE_KVS_THREADPOOL) +endif() + if(USE_OPENSSL) add_definitions(-DKVS_USE_OPENSSL) elseif(USE_MBEDTLS) diff --git a/README.md b/README.md index dfcfedd4cf..81f11f54c5 100644 --- a/README.md +++ b/README.md @@ -360,8 +360,7 @@ To build on a 32-bit Raspbian GNU/Linux 11 on 64-bit hardware, the OpenSSL libra ### Threadpool for Signaling Channel messages The threadpool is enabled by default, and starts with 3 threads that it can increase up to 5 if all 3 are actively in use. To change these values to better match the resources of your use case -please edit samples/Samples.h defines `KVS_SIGNALING_THREADPOOL_MIN` and `KVS_SIGNALING_THREADPOOL_MAX`. You can also disable the threadpool to instead create and detach each thread -to handle signaling messages by commenting out `KVS_USE_SIGNALING_CHANNEL_THREADPOOL`. +please edit samples/Samples.h defines `KVS_SIGNALING_THREADPOOL_MIN` and `KVS_SIGNALING_THREADPOOL_MAX`. You can also disable the threadpool to instead create and detach each thread to handle signaling messages by disabling the flag `-DENABLE_KVS_THREADPOOL` while building with cmake. ## Documentation All Public APIs are documented in our [Include.h](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/master/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h), we also generate a [Doxygen](https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/) each commit for easier navigation. diff --git a/samples/Samples.h b/samples/Samples.h index dedd53d65e..ba0ba9e56a 100644 --- a/samples/Samples.h +++ b/samples/Samples.h @@ -56,9 +56,6 @@ extern "C" { #define KVS_SIGNALING_THREADPOOL_MIN 3 #define KVS_SIGNALING_THREADPOOL_MAX 5 -// comment out this line to disable the feature -#define KVS_USE_SIGNALING_CHANNEL_THREADPOOL 1 - /* Uncomment the following line in order to enable IoT credentials checks in the provided samples */ // #define IOT_CORE_ENABLE_CREDENTIALS 1 diff --git a/src/source/Signaling/LwsApiCalls.c b/src/source/Signaling/LwsApiCalls.c index 18367e884d..aa9dca51db 100644 --- a/src/source/Signaling/LwsApiCalls.c +++ b/src/source/Signaling/LwsApiCalls.c @@ -2011,7 +2011,7 @@ STATUS receiveLwsMessage(PSignalingClient pSignalingClient, PCHAR pMessage, UINT DLOGW("Failed to validate the ICE server configuration received with an Offer"); } -#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL +#ifdef ENABLE_KVS_THREADPOOL CHK_STATUS(threadpoolPush(pSignalingClient->pThreadpool, receiveLwsMessageWrapper, (PVOID) pSignalingMessageWrapper)); #else // Issue the callback on a separate thread diff --git a/src/source/Signaling/Signaling.c b/src/source/Signaling/Signaling.c index c5761bf2b8..eae6bed9f7 100644 --- a/src/source/Signaling/Signaling.c +++ b/src/source/Signaling/Signaling.c @@ -37,9 +37,11 @@ STATUS createSignalingSync(PSignalingClientInfoInternal pClientInfo, PChannelInf CHK_STATUS(createValidateChannelInfo(pChannelInfo, &pSignalingClient->pChannelInfo)); CHK_STATUS(validateSignalingCallbacks(pSignalingClient, pCallbacks)); CHK_STATUS(validateSignalingClientInfo(pSignalingClient, pClientInfo)); -#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL +#ifdef ENABLE_KVS_THREADPOOL + DLOGD("Going to crate the threadpool for signaling"); CHK_STATUS(threadpoolCreate(&pSignalingClient->pThreadpool, pClientInfo->signalingClientInfo.signalingMessagesMinimumThreads, pClientInfo->signalingClientInfo.signalingMessagesMaximumThreads)); + DLOGD("Successfully created the threadpool for signaling"); #endif pSignalingClient->version = SIGNALING_CLIENT_CURRENT_VERSION; @@ -225,7 +227,7 @@ STATUS freeSignaling(PSignalingClient* ppSignalingClient) hashTableFree(pSignalingClient->diagnostics.pEndpointToClockSkewHashMap); -#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL +#ifdef ENABLE_KVS_THREADPOOL threadpoolFree(pSignalingClient->pThreadpool); #endif diff --git a/src/source/Signaling/Signaling.h b/src/source/Signaling/Signaling.h index 0355be4bac..4ba1c09cf7 100644 --- a/src/source/Signaling/Signaling.h +++ b/src/source/Signaling/Signaling.h @@ -339,7 +339,7 @@ typedef struct { UINT64 deleteTime; UINT64 connectTime; -#ifdef KVS_USE_SIGNALING_CHANNEL_THREADPOOL +#ifdef ENABLE_KVS_THREADPOOL PThreadpool pThreadpool; #endif UINT64 offerTime; diff --git a/tst/SignalingApiFunctionalityTest.cpp b/tst/SignalingApiFunctionalityTest.cpp index 3197bf15aa..6fb3d873fb 100644 --- a/tst/SignalingApiFunctionalityTest.cpp +++ b/tst/SignalingApiFunctionalityTest.cpp @@ -239,6 +239,8 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateConnectFree) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -268,6 +270,8 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateConnectFree) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, basicCreateWithRetries) @@ -289,6 +293,8 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateWithRetries) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 3; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -297,6 +303,8 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateWithRetries) EXPECT_EQ(STATUS_NULL_ARG, createSignalingClientSync(&clientInfo, NULL, &signalingClientCallbacks, (PAwsCredentialProvider) mTestCredentialProvider, &signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, mockMaster) @@ -329,6 +337,8 @@ TEST_F(SignalingApiFunctionalityTest, mockMaster) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -436,6 +446,8 @@ TEST_F(SignalingApiFunctionalityTest, mockMaster) // Free again EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); EXPECT_FALSE(IS_VALID_SIGNALING_CLIENT_HANDLE(signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, mockViewer) @@ -469,6 +481,8 @@ TEST_F(SignalingApiFunctionalityTest, mockViewer) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_VIEWER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -550,6 +564,8 @@ TEST_F(SignalingApiFunctionalityTest, mockViewer) // Free again EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); EXPECT_FALSE(IS_VALID_SIGNALING_CLIENT_HANDLE(signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) @@ -575,6 +591,8 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -767,6 +785,8 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_VIEWER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -817,6 +837,8 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceReconnectEmulation) @@ -839,6 +861,8 @@ TEST_F(SignalingApiFunctionalityTest, iceReconnectEmulation) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -902,6 +926,8 @@ TEST_F(SignalingApiFunctionalityTest, iceReconnectEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariations) @@ -927,6 +953,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1165,6 +1193,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) @@ -1190,6 +1220,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1430,6 +1462,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpiration) @@ -1455,6 +1489,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpi clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1551,6 +1587,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpi EXPECT_EQ(STATUS_SIGNALING_ICE_CONFIG_REFRESH_FAILED, errStatus); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpiration) @@ -1576,6 +1614,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpirat clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1675,6 +1715,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpirat EXPECT_EQ(STATUS_SIGNALING_ICE_CONFIG_REFRESH_FAILED, errStatus); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaultInjectionRecovered) @@ -1700,6 +1742,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -1790,6 +1834,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultInjectionRecovered) @@ -1815,6 +1861,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -1907,6 +1955,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaultInjectionNotRecovered) @@ -1932,6 +1982,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -2020,6 +2072,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultInjectionNot1669) @@ -2045,6 +2099,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -2136,6 +2192,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadAuth) @@ -2161,6 +2219,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2255,6 +2315,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth) @@ -2281,6 +2343,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2378,6 +2442,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, goAwayEmulation) @@ -2400,6 +2466,8 @@ TEST_F(SignalingApiFunctionalityTest, goAwayEmulation) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -2462,6 +2530,8 @@ TEST_F(SignalingApiFunctionalityTest, goAwayEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, unknownMessageTypeEmulation) @@ -2484,6 +2554,8 @@ TEST_F(SignalingApiFunctionalityTest, unknownMessageTypeEmulation) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; + clientInfo.signalingMessagesMinimumThreads = 3; + clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -2550,6 +2622,8 @@ TEST_F(SignalingApiFunctionalityTest, unknownMessageTypeEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) @@ -2576,6 +2650,8 @@ TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 1 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2671,6 +2747,8 @@ TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) @@ -2695,6 +2773,8 @@ TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2803,6 +2883,8 @@ TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) @@ -2827,6 +2909,8 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2935,6 +3019,8 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) EXPECT_EQ(STATUS_SUCCESS, signalingClientDeleteSync(signalingHandle)); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) @@ -2958,6 +3044,8 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -3046,6 +3134,8 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, signalingClientDisconnectSyncVariations) @@ -3090,6 +3180,8 @@ TEST_F(SignalingApiFunctionalityTest, signalingClientDisconnectSyncVariations) EXPECT_EQ(STATUS_SUCCESS, signalingClientSendMessageSync(mSignalingClientHandle, &message)); deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) @@ -3113,6 +3205,8 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.connectPreHookFn = connectPreHook; @@ -3224,6 +3318,8 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingTest) @@ -3251,6 +3347,8 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingTest) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.connectPreHookFn = connectPreHook; @@ -3327,6 +3425,8 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingTest) /* describeCount and getEndpointCount should only increase by 2 because they are cached for all channels except one and we iterate twice*/ EXPECT_TRUE(describeCount > describeCountNoCache && (describeCount - describeCountNoCache) == 2); EXPECT_TRUE(getEndpointCount > getEndpointCountNoCache && (getEndpointCount - 2*getEndpointCountNoCache) == 2); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateCache) @@ -3357,6 +3457,8 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateCache) testEntry.creationTsEpochSeconds = GETTIME() / HUNDREDS_OF_NANOS_IN_A_SECOND; /* update first cache entry*/ EXPECT_EQ(STATUS_SUCCESS, signalingCacheSaveToFile(&testEntry, DEFAULT_CACHE_FILE_PATH)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateMultiChannelCache) @@ -3428,6 +3530,8 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateMultiChannelCache) MEMFREE(fileBuffer); FREMOVE(DEFAULT_CACHE_FILE_PATH); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateFullMultiChannelCache) @@ -3481,6 +3585,8 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateFullMultiChannelCache) EXPECT_EQ(0, STRCMP(testEntry.channelName, testChannel)); FREMOVE(DEFAULT_CACHE_FILE_PATH); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer) @@ -3506,6 +3612,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -3667,6 +3775,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_SlowClockSkew) @@ -3692,6 +3802,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_SlowClockSkew) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); @@ -3856,6 +3968,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_SlowClockSkew) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } @@ -3882,6 +3996,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); @@ -4046,6 +4162,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew_VerifyOffsetRemovedWhenClockFixed) @@ -4074,6 +4192,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew_Veri clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; + clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; + clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); @@ -4263,6 +4383,8 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew_Veri deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } diff --git a/tst/SignalingApiTest.cpp b/tst/SignalingApiTest.cpp index 29652b8544..affcc3b5b1 100644 --- a/tst/SignalingApiTest.cpp +++ b/tst/SignalingApiTest.cpp @@ -38,6 +38,8 @@ TEST_F(SignalingApiTest, createValidateChannelInfo) // Test default agent postfix EXPECT_PRED_FORMAT2(testing::IsSubstring, agentString, rChannelInfo->pUserAgent); freeChannelInfo(&rChannelInfo); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingSendMessageSync) @@ -81,6 +83,8 @@ TEST_F(SignalingApiTest, signalingSendMessageSync) EXPECT_EQ(expectedStatus, signalingClientSendMessageSync(mSignalingClientHandle, &signalingMessage)); deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingSendMessageSyncFileCredsProvider) @@ -138,6 +142,8 @@ TEST_F(SignalingApiTest, signalingSendMessageSyncFileCredsProvider) deinitializeSignalingClient(); EXPECT_EQ(STATUS_SUCCESS, freeFileCredentialProvider(&pAwsCredentialProvider)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientConnectSync) @@ -154,6 +160,8 @@ TEST_F(SignalingApiTest, signalingClientConnectSync) EXPECT_EQ(expectedStatus, signalingClientConnectSync(mSignalingClientHandle)); deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientDeleteSync) @@ -184,6 +192,8 @@ TEST_F(SignalingApiTest, signalingClientDeleteSync) EXPECT_EQ(expectedStatus, signalingClientSendMessageSync(mSignalingClientHandle, &signalingMessage)); deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientGetIceConfigInfoCount) @@ -204,6 +214,8 @@ TEST_F(SignalingApiTest, signalingClientGetIceConfigInfoCount) } deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientGetIceConfigInfo) @@ -240,6 +252,8 @@ TEST_F(SignalingApiTest, signalingClientGetIceConfigInfo) } deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientGetCurrentState) @@ -259,6 +273,8 @@ TEST_F(SignalingApiTest, signalingClientGetCurrentState) EXPECT_EQ(expectedState, state); deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientGetStateString) @@ -270,11 +286,15 @@ TEST_F(SignalingApiTest, signalingClientGetStateString) EXPECT_EQ(STATUS_SUCCESS, signalingClientGetStateString((SIGNALING_CLIENT_STATE) i, &pStateStr)); DLOGV("Iterating states \"%s\"", pStateStr); } + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientDisconnectSync) { EXPECT_NE(STATUS_SUCCESS, signalingClientDisconnectSync(INVALID_SIGNALING_CLIENT_HANDLE_VALUE)); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientGetMetrics) @@ -365,6 +385,8 @@ TEST_F(SignalingApiTest, signalingClientGetMetrics) EXPECT_NE(0, metrics.signalingClientStats.dpApiCallLatency); deinitializeSignalingClient(); + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiTest, signalingClientCreateWithClientInfoVariations) @@ -498,6 +520,8 @@ TEST_F(SignalingApiTest, signalingClientCreateWithClientInfoVariations) deinitializeSignalingClient(); mClientInfo.cacheFilePath = NULL; + //wait for threads of threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } } // namespace webrtcclient diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index f4abf4532e..f165bf869b 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -95,6 +95,8 @@ class WebRtcClientTestBase : public ::testing::Test { mClientInfo.signalingRetryStrategyCallbacks.freeRetryStrategyFn = freeRetryStrategyFn; mClientInfo.signalingRetryStrategyCallbacks.executeRetryStrategyFn = executeRetryStrategyFn; mClientInfo.signalingClientCreationMaxRetryAttempts = 0; + mClientInfo.signalingMessagesMinimumThreads = 3; + mClientInfo.signalingMessagesMaximumThreads = 5; MEMSET(&mChannelInfo, 0x00, SIZEOF(mChannelInfo)); mChannelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -110,6 +112,7 @@ class WebRtcClientTestBase : public ::testing::Test { mChannelInfo.reconnect = TRUE; mChannelInfo.pCertPath = mCaCertPath; mChannelInfo.messageTtl = TEST_SIGNALING_MESSAGE_TTL; + if ((mChannelInfo.pRegion = getenv(DEFAULT_REGION_ENV_VAR)) == NULL) { mChannelInfo.pRegion = (PCHAR) TEST_DEFAULT_REGION; } diff --git a/tst/suppressions/TSAN.supp b/tst/suppressions/TSAN.supp index 0c1179bfbd..636d016122 100644 --- a/tst/suppressions/TSAN.supp +++ b/tst/suppressions/TSAN.supp @@ -176,4 +176,4 @@ deadlock:com::amazonaws::kinesis::video::webrtcclient::DtlsFunctionalityTest::cr # instead of flagging each individual instance of the test. deadlock:lwsListenerHandler deadlock:connectSignalingChannelLws -race:lwsListenerHandler \ No newline at end of file +race:lwsListenerHandler