Skip to content

Commit 6d9d47c

Browse files
jdelapladisa6302kateyanuragniyatim23hassanctech
authored
Release 1 3 0 (#274)
* Update readme to include instruction for offline mode * Update PIC to latest. PIC changes includes adding a utility for exponential backoff retries. (#241) Update PIC to latest. PIC changes includes adding a utility for exponential backoff retries. PIC changes - awslabs/amazon-kinesis-video-streams-pic@e4b4666 * updated cmake verison from 2.8 to 3.6.3 (#240) Co-authored-by: Hassan Sahibzada <[email protected]> * Update README and travis.yml to acknowledge develop (#236) * Update README and travis.yml to acknowledge develop * Mentions of the develop branch in the README are now a codeblock Co-authored-by: Hassan Sahibzada <[email protected]> * Sample support for KVS events * Update PIC git_tag, move event fragment generation to first frame * Update git_tag to top of develop * Replace generic STATUS_IOT_FAILED status with more detailed status codes and logging * Fix unit tests and retriable errors section * Update producer tests to use PIC state machine retry logic * remove debug log * update pic hash * Update readme to specify using cmake flags with clang and not gcc (#265) * Update PIC commit * Updating PIC hash * update git has to include new service call results for auto clock skew correction (#266) * Including log fix from PIC * Pull in retry count (#268) * Update PIC to current master (release 1.3.0 PIC) * Update put counts * specify osx image directly instead of relying on default * export CPATH for newer mac OS to resolve build issues * suppress warnings * use catalina -- tested locally, until we can work out big sur issues in travis * test with debug logging failed tests only since we cannot repro locally * Adding debug logs around postReadCallback() * sleep more accurately taking into account time taken within other API calls * increse test execution time to make sure we can receive an ack * increase exec time in other tests as well * lower log level and extra log statements and reinstate all tests running for mac os Co-authored-by: Divya Sampath Kumar <[email protected]> Co-authored-by: Anurag Katey <[email protected]> Co-authored-by: Niyati Maheshwari <[email protected]> Co-authored-by: Hassan Sahibzada <[email protected]> Co-authored-by: Anurag Katey <[email protected]>
1 parent 6a7aab4 commit 6d9d47c

22 files changed

+118
-35
lines changed

Diff for: .travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ matrix:
4646
# MacOS Builds
4747
- name: "OSX GCC"
4848
os: osx
49+
osx_image: xcode12
4950
compiler: gcc
51+
env: CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
5052
before_script:
5153
- mkdir build && cd build && cmake .. -DBUILD_TEST=TRUE
5254
script:
@@ -56,7 +58,9 @@ matrix:
5658

5759
- name: "OSX Clang"
5860
os: osx
61+
osx_image: xcode12
5962
compiler: clang
63+
env: CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
6064
before_script:
6165
- mkdir build && cd build && cmake .. -DBUILD_TEST=TRUE -DCOMPILER_WARNINGS=TRUE
6266
script:

Diff for: CMake/Dependencies/libcurl-CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(libcurl-download NONE)
44

Diff for: CMake/Dependencies/libgtest-CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(libgtest-download NONE)
44

Diff for: CMake/Dependencies/libjsmn-CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(libjsmn-download NONE)
44

Diff for: CMake/Dependencies/libjsmn-add-cmakelists.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ index 0000000..f4a1d44
44
--- /dev/null
55
+++ b/CMakeLists.txt
66
@@ -0,0 +1,11 @@
7-
+cmake_minimum_required(VERSION 2.8)
7+
+cmake_minimum_required(VERSION 3.6.3)
88
+project(jsmn C)
99
+
1010
+

Diff for: CMake/Dependencies/libkvspic-CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(libkvspic-download NONE)
44

@@ -7,7 +7,7 @@ include(ExternalProject)
77
# clone repo only
88
ExternalProject_Add(libkvspic-download
99
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-pic.git
10-
GIT_TAG e189514da70c02f430c8069aec9ea11943b74d8c
10+
GIT_TAG 04fdbdffa929f7390b946493ce8a995fb09c0ceb
1111
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-src"
1212
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-build"
1313
CMAKE_ARGS

Diff for: CMake/Dependencies/libmbedtls-CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(libmbedtls-download NONE)
44

Diff for: CMake/Dependencies/libopenssl-CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(libopenssl-download NONE)
44

@@ -12,9 +12,9 @@ else()
1212
endif()
1313

1414
if (DEFINED BUILD_OPENSSL_PLATFORM AND NOT BUILD_OPENSSL_PLATFORM STREQUAL OFF)
15-
SET(CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build/src/project_libopenssl/Configure ${OPENSSL_EXTRA} --prefix=${OPEN_SRC_INSTALL_PREFIX} --openssldir=${OPEN_SRC_INSTALL_PREFIX} ${BUILD_OPENSSL_PLATFORM})
15+
SET(CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build/src/project_libopenssl/Configure ${OPENSSL_EXTRA} --prefix=${OPEN_SRC_INSTALL_PREFIX} --openssldir=${OPEN_SRC_INSTALL_PREFIX} ${BUILD_OPENSSL_PLATFORM} -Wno-nullability-completeness -Wno-expansion-to-defined)
1616
else()
17-
SET(CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build/src/project_libopenssl/config ${OPENSSL_EXTRA} --prefix=${OPEN_SRC_INSTALL_PREFIX} --openssldir=${OPEN_SRC_INSTALL_PREFIX})
17+
SET(CONFIGURE_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build/src/project_libopenssl/config ${OPENSSL_EXTRA} --prefix=${OPEN_SRC_INSTALL_PREFIX} --openssldir=${OPEN_SRC_INSTALL_PREFIX} -Wno-nullability-completeness -Wno-expansion-to-defined)
1818
endif()
1919
endif()
2020

Diff for: CMake/Dependencies/libwebsockets-CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(libwebsocket-download NONE)
44

Diff for: CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
33
include(Utilities)
44
project(KinesisVideoProducerC LANGUAGES C)

Diff for: README.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ You can pass the following options to `cmake ..`.
5858
* `-DUNDEFINED_BEHAVIOR_SANITIZER` Build with UndefinedBehaviorSanitizer
5959
* `-DALIGNED_MEMORY_MODEL` Build for aligned memory model only devices. Default is OFF.
6060

61+
62+
DMEMORY_SANITIZER, DTHREAD_SANITIZER etc. flags works only with clang compiler
63+
and not with gcc compiler. For using clang (on Ubuntu), do the following -
64+
```
65+
sudo apt-get install clang
66+
export CC=/usr/bin/clang
67+
export CXX=/usr/bin/clang++
68+
cmake .. -DMEMORY_SANITIZER=TRUE
69+
```
70+
6171
### Build
6272
To build the library run make in the build directory you executed CMake.
6373

@@ -78,10 +88,12 @@ The last three arguments are optional. By default,
7888
* `audio-codec` is `aac`
7989

8090
If you want to use the sample for `PCM_ALAW/G.711` frames, run
81-
`./kvsAudioVideoStreamingSample <channel-name> <streaming_duration> <sample_location> alaw`
91+
`./kvsAudioVideoStreamingSample <channel-name> <streaming_duration> <sample_location> alaw 0`
8292

8393
This will stream the video/audio files from the `samples/h264SampleFrames` and `samples/aacSampleFrames` or `samples/alawSampleFrames` (as per the choice of audio codec in the last argument) respectively.
8494

95+
If you want to enable KVS events in fragment metadata, change the 5th parameter from 0 -> 1. This feature is found only in the audio/video sample, but can be written into the video only sample as well.
96+
8597
For video only, run `./kvsVideoOnlyStreamingSample <channel-name>`
8698

8799
This will stream the video files from the `samples/h264SampleFrames`.
@@ -97,9 +109,17 @@ export AWS_ACCESS_KEY_ID=<YourAWSAccessKey>
97109
Now you can execute the unit tests from the `build` directory as follows:
98110
`./tst/producer_test`
99111

100-
## Development
112+
### Offline mode
113+
The samples run in near real time mode by default. In order to set up offline mode, the following APIs can be used in the samples instead of the realtime variant:
114+
115+
For video only: `createOfflineVideoStreamInfoProviderWithCodecs()`
116+
For video and audio: `createOfflineAudioVideoStreamInfoProviderWithCodecs()`
117+
118+
The 2 APIs are available in [this](https://github.com/awslabs/amazon-kinesis-video-streams-producer-c/blob/412aab82c99a72f9dbde975f5fea81ffdc844ae5/src/include/com/amazonaws/kinesis/video/cproducer/Include.h) header file.
101119

102-
The repository is using `develop` branch as the aggregation and all of the feature development is done in appropriate feature branches. The PRs (Pull Requests) are cut on a feature branch and once approved with all the checks passed they can be merged by a click of a button on the PR tool. The master branch should always be build-able and all the tests should be passing. We are welcoming any contribution to the code base. The master branch contains our most recent release cycle from develop.
120+
121+
## Development
122+
The repository is using `develop` branch as the aggregation and all of the feature development is done in appropriate feature branches. The PRs (Pull Requests) are cut on a feature branch and once approved with all the checks passed they can be merged by a click of a button on the PR tool. The master branch should always be build-able and all the tests should be passing. We are welcoming any contribution to the code base. The master branch contains our most recent release cycle from `develop`.
103123

104124
### Release
105125
The repository is under active development and even with incremental unit test coverage where some of the tests are actually full integration tests, we require more rigorous internal testing in order to 'cut' release versions. The release is cut against a particular commit that gets approved. The general philosophy is to cut a release when a set of commits contribute to a self-containing feature or when we add major internal functionality improvements.

Diff for: samples/KvsAudioVideoStreamingSample.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define FILE_LOGGING_BUFFER_SIZE (100 * 1024)
2323
#define MAX_NUMBER_OF_LOG_FILES 5
2424

25+
UINT8 gEventsEnabled = 0;
26+
2527
typedef struct {
2628
PBYTE buffer;
2729
UINT32 size;
@@ -69,6 +71,10 @@ PVOID putVideoFrameRoutine(PVOID args)
6971
startUpLatency = (DOUBLE)(GETTIME() - data->startTime) / (DOUBLE) HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
7072
DLOGD("Start up latency: %lf ms", startUpLatency);
7173
data->firstFrame = FALSE;
74+
if(gEventsEnabled) {
75+
//generate an image and notification event at the start of the video stream.
76+
putKinesisVideoEventMetadata(data->streamHandle, STREAM_EVENT_TYPE_NOTIFICATION | STREAM_EVENT_TYPE_IMAGE_GENERATION, NULL);
77+
}
7278
}
7379

7480
ATOMIC_STORE_BOOL(&data->firstVideoFramePut, TRUE);
@@ -182,7 +188,12 @@ INT32 main(INT32 argc, CHAR* argv[])
182188

183189
STRNCPY(audioCodec, AUDIO_CODEC_NAME_AAC, STRLEN(AUDIO_CODEC_NAME_AAC)); //aac audio by default
184190

185-
if (argc == 5) {
191+
if (argc == 6) {
192+
if (STRCMP(argv[5], "1")){
193+
gEventsEnabled = 1;
194+
}
195+
}
196+
if (argc >= 5) {
186197
if (!STRCMP(argv[4], AUDIO_CODEC_NAME_ALAW)){
187198
STRNCPY(audioCodec, AUDIO_CODEC_NAME_ALAW, STRLEN(AUDIO_CODEC_NAME_ALAW));
188199
}

Diff for: src/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project(KinesisVideoProducerC LANGUAGES C)
44

Diff for: src/include/com/amazonaws/kinesis/video/common/Include.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,19 @@ extern "C" {
5050
#define STATUS_FILE_CREDENTIAL_PROVIDER_OPEN_FILE_FAILED STATUS_COMMON_PRODUCER_BASE + 0x00000022
5151
#define STATUS_FILE_CREDENTIAL_PROVIDER_INVALID_FILE_LENGTH STATUS_COMMON_PRODUCER_BASE + 0x00000023
5252
#define STATUS_FILE_CREDENTIAL_PROVIDER_INVALID_FILE_FORMAT STATUS_COMMON_PRODUCER_BASE + 0x00000024
53+
#define STATUS_CURL_PERFORM_FAILED STATUS_COMMON_PRODUCER_BASE + 0x00000025
54+
#define STATUS_IOT_INVALID_RESPONSE_LENGTH STATUS_COMMON_PRODUCER_BASE + 0x00000026
55+
#define STATUS_IOT_NULL_AWS_CREDS STATUS_COMMON_PRODUCER_BASE + 0x00000027
56+
#define STATUS_IOT_INVALID_URI_LEN STATUS_COMMON_PRODUCER_BASE + 0x00000028
5357
/*!@} */
5458

5559
/**
5660
* Macro for checking whether the status code should be retried by the continuous retry logic
5761
*/
5862
#define IS_RETRIABLE_COMMON_LIB_ERROR(error) \
5963
((error) == STATUS_INVALID_API_CALL_RETURN_JSON || (error) == STATUS_CURL_INIT_FAILED || (error) == STATUS_CURL_LIBRARY_INIT_FAILED || \
60-
(error) == STATUS_HMAC_GENERATION_ERROR || (error) == STATUS_IOT_FAILED || (error) == STATUS_IOT_EXPIRATION_OCCURS_IN_PAST || \
64+
(error) == STATUS_HMAC_GENERATION_ERROR || (error) == STATUS_CURL_PERFORM_FAILED || (error) == STATUS_IOT_INVALID_RESPONSE_LENGTH || \
65+
(error) == STATUS_IOT_NULL_AWS_CREDS || (error) == STATUS_IOT_INVALID_URI_LEN || (error) == STATUS_IOT_EXPIRATION_OCCURS_IN_PAST || \
6166
(error) == STATUS_IOT_EXPIRATION_PARSING_FAILED || (error) == STATUS_IOT_CREATE_LWS_CONTEXT_FAILED || \
6267
(error) == STATUS_FILE_CREDENTIAL_PROVIDER_OPEN_FILE_FAILED || (error) == STATUS_FILE_CREDENTIAL_PROVIDER_INVALID_FILE_LENGTH || \
6368
(error) == STATUS_FILE_CREDENTIAL_PROVIDER_INVALID_FILE_FORMAT)

Diff for: src/source/Common/Curl/CurlCall.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ STATUS blockingCurlCall(PRequestInfo pRequestInfo, PCallInfo pCallInfo)
7676

7777
if (res != CURLE_OK) {
7878
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
79-
DLOGE("Curl perform failed for url %s with result %s : %s ", url, curl_easy_strerror(res), errorBuffer);
80-
CHK(FALSE, STATUS_IOT_FAILED);
79+
CHK_ERR(FALSE, STATUS_CURL_PERFORM_FAILED, "Curl perform failed for url %s with result %s : %s ", url, curl_easy_strerror(res), errorBuffer);
8180
}
8281

8382
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpStatusCode);
84-
CHK_ERR(httpStatusCode == HTTP_STATUS_CODE_OK, STATUS_IOT_FAILED, "Curl call response failed with http status %lu", httpStatusCode);
83+
CHK_ERR(httpStatusCode == HTTP_STATUS_CODE_OK, STATUS_CURL_PERFORM_FAILED, "Curl call response failed with http status %lu", httpStatusCode);
8584

8685
CleanUp:
8786

Diff for: src/source/Common/IotCredentialProvider.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ STATUS parseIotResponse(PIotCredentialProvider pIotCredentialProvider, PCallInfo
130130
CHK(pIotCredentialProvider != NULL && pCallInfo != NULL, STATUS_NULL_ARG);
131131

132132
resultLen = pCallInfo->responseDataLen;
133+
CHK_ERR(resultLen > 0, STATUS_IOT_INVALID_RESPONSE_LENGTH, "IoT response has a length of 0");
133134
pResponseStr = pCallInfo->responseData;
134-
CHK(resultLen > 0, STATUS_IOT_FAILED);
135135

136136
jsmn_init(&parser);
137137
tokenCount = jsmn_parse(&parser, pResponseStr, resultLen, tokens, SIZEOF(tokens) / SIZEOF(jsmntok_t));
@@ -165,7 +165,7 @@ STATUS parseIotResponse(PIotCredentialProvider pIotCredentialProvider, PCallInfo
165165
}
166166
}
167167

168-
CHK(accessKeyId != NULL && secretKey != NULL && sessionToken != NULL, STATUS_IOT_FAILED);
168+
CHK(accessKeyId != NULL && secretKey != NULL && sessionToken != NULL, STATUS_IOT_NULL_AWS_CREDS);
169169

170170
currentTime = pIotCredentialProvider->getCurrentTimeFn(pIotCredentialProvider->customData);
171171
CHK_STATUS(convertTimestampToEpoch(expirationTimestampStr, currentTime / HUNDREDS_OF_NANOS_IN_A_SECOND, &expiration));
@@ -211,7 +211,7 @@ STATUS iotCurlHandler(PIotCredentialProvider pIotCredentialProvider)
211211

212212
formatLen = SNPRINTF(serviceUrl, MAX_URI_CHAR_LEN, "%s%s%s%c%s%s", CONTROL_PLANE_URI_PREFIX, pIotCredentialProvider->iotGetCredentialEndpoint,
213213
ROLE_ALIASES_PATH, '/', pIotCredentialProvider->roleAlias, CREDENTIAL_SERVICE);
214-
CHK(formatLen > 0 && formatLen < MAX_URI_CHAR_LEN, STATUS_IOT_FAILED);
214+
CHK(formatLen > 0 && formatLen < MAX_URI_CHAR_LEN, STATUS_IOT_INVALID_URI_LEN);
215215

216216
// Form a new request info based on the params
217217
CHK_STATUS(createRequestInfo(serviceUrl, NULL, DEFAULT_AWS_REGION, pIotCredentialProvider->caCertPath, pIotCredentialProvider->certPath,

Diff for: tst/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.6.3)
22

33
project (producerTest)
44

Diff for: tst/CallbacksProviderPublicApiTest.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ TEST_F(CallbacksProviderPublicApiTest, createDefaultCallbacksProviderWithIotCert
8181
NULL,
8282
&pClientCallbacks));
8383

84-
EXPECT_EQ(STATUS_IOT_FAILED, createDefaultCallbacksProviderWithIotCertificate(
84+
EXPECT_EQ(STATUS_CURL_PERFORM_FAILED, createDefaultCallbacksProviderWithIotCertificate(
8585
TEST_IOT_ENDPOINT,
8686
TEST_IOT_CERT_PATH,
8787
TEST_IOT_ROLE_ALIAS,
@@ -153,7 +153,7 @@ TEST_F(CallbacksProviderPublicApiTest, createDefaultCallbacksProviderWithIotCert
153153
NULL,
154154
&pClientCallbacks));
155155

156-
EXPECT_EQ(STATUS_IOT_FAILED, createDefaultCallbacksProviderWithIotCertificate(
156+
EXPECT_EQ(STATUS_CURL_PERFORM_FAILED, createDefaultCallbacksProviderWithIotCertificate(
157157
TEST_IOT_ENDPOINT,
158158
TEST_IOT_CERT_PATH,
159159
TEST_IOT_CERT_PRIVATE_KEY_PATH,

Diff for: tst/ProducerClientBasicTest.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ PVOID ProducerClientTestBase::basicProducerRoutine(STREAM_HANDLE streamHandle, S
347347

348348
UINT32 index = 0, persistentMetadataIndex = 0;
349349
UINT64 timestamp = GETTIME();
350+
UINT64 diffTime;
350351
Frame frame;
351352
std::string persistentMetadataName;
352353
TID tid = GETTID();
@@ -449,7 +450,10 @@ EXPECT_TRUE(kinesis_video_stream->putFrame(eofr));
449450

450451
// Sleep a while for non-offline modes
451452
if (streamingType != STREAMING_TYPE_OFFLINE) {
452-
THREAD_SLEEP(TEST_FRAME_DURATION);
453+
diffTime = GETTIME()-timestamp;
454+
if (diffTime < TEST_FRAME_DURATION) {
455+
THREAD_SLEEP(TEST_FRAME_DURATION-diffTime);
456+
}
453457
}
454458
}
455459

@@ -516,7 +520,7 @@ TEST_F(ProducerClientBasicTest, create_produce_stream)
516520
#endif
517521

518522
// Wait for some time to produce
519-
THREAD_SLEEP(TEST_EXECUTION_DURATION);
523+
THREAD_SLEEP(2*TEST_EXECUTION_DURATION);
520524

521525
// Indicate the cancel for the threads
522526
mStopProducer = TRUE;
@@ -571,7 +575,7 @@ TEST_F(ProducerClientBasicTest, create_produce_stream_parallel)
571575
}
572576

573577
// Wait for some time to produce
574-
THREAD_SLEEP(TEST_EXECUTION_DURATION);
578+
THREAD_SLEEP(2*TEST_EXECUTION_DURATION);
575579

576580
// Indicate the cancel for the threads
577581
mStopProducer = TRUE;
@@ -617,7 +621,7 @@ TEST_F(ProducerClientBasicTest, create_produce_client_parallel)
617621
}
618622

619623
// Wait for some time to produce
620-
THREAD_SLEEP(TEST_EXECUTION_DURATION);
624+
THREAD_SLEEP(2*TEST_EXECUTION_DURATION);
621625

622626
// Indicate the cancel for the threads
623627
mStopProducer = TRUE;
@@ -675,13 +679,13 @@ TEST_F(ProducerClientBasicTest, cachingEndpointProvider_Returns_EndpointFromCach
675679
EXPECT_TRUE(mProducerStopped) << "Producer thread failed to stop cleanly";
676680

677681
// Expect the number of calls
678-
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mPutStreamFnCount);
679-
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mGetStreamingEndpointFnCount);
682+
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mPutStreamFnCount);
683+
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mGetStreamingEndpointFnCount);
680684
EXPECT_EQ(0, mCurlCreateStreamCount);
681685
EXPECT_EQ(0, mCurlDescribeStreamCount);
682686
EXPECT_EQ(0, mCurlTagResourceCount);
683687
EXPECT_EQ(1 * TEST_STREAM_COUNT, mCurlGetDataEndpointCount);
684-
EXPECT_EQ((ITERATION_COUNT + 1) * TEST_STREAM_COUNT, mCurlPutMediaCount);
688+
EXPECT_EQ((ITERATION_COUNT + 2) * TEST_STREAM_COUNT, mCurlPutMediaCount);
685689

686690
// We will block for some time due to an incorrect implementation of the awaiting code
687691
// NOTE: The proper implementation should use synchronization primitives to await for the

Diff for: tst/ProducerContinuousRetryTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ TEST_F(ProducerContinuousRetryTest, recover_on_retriable_common_lib_error) {
268268

269269
// Inject a fault
270270
pAuth = (PRotatingStaticAuthCallbacks) mAuthCallbacks;
271-
pAuth->retStatus = STATUS_IOT_FAILED;
271+
pAuth->retStatus = STATUS_CURL_PERFORM_FAILED;
272272
pAuth->failCount = 0;
273273
pAuth->recoverCount = 3; // 1 for main token, 1 for the security token for the first session
274274
// and only then should fail for the last token.

Diff for: tst/ProducerTestFixture.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ ProducerClientTestBase::ProducerClientTestBase() :
278278
mDeviceInfo.clientInfo.loggerLogLevel = this->loggerLogLevel;
279279
mDeviceInfo.clientInfo.logMetric = TRUE;
280280

281+
mDeviceInfo.clientInfo.kvsRetryStrategyCallbacks.createRetryStrategyFn = createRetryStrategyFn;
282+
mDeviceInfo.clientInfo.kvsRetryStrategyCallbacks.getCurrentRetryAttemptNumberFn = getCurrentRetryAttemptNumberFn;
283+
mDeviceInfo.clientInfo.kvsRetryStrategyCallbacks.freeRetryStrategyFn = freeRetryStrategyFn;
284+
mDeviceInfo.clientInfo.kvsRetryStrategyCallbacks.executeRetryStrategyFn = executeRetryStrategyFn;
285+
281286
mDefaultRegion[0] = '\0';
282287
mStreamingRotationPeriod = TEST_STREAMING_TOKEN_DURATION;
283288

@@ -837,6 +842,35 @@ VOID ProducerClientTestBase::printFrameInfo(PFrame pFrame)
837842
pFrame->presentationTs);
838843
}
839844

845+
STATUS ProducerClientTestBase::createRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy) {
846+
STATUS retStatus = STATUS_SUCCESS;
847+
PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState = NULL;
848+
849+
CHK_STATUS(exponentialBackoffRetryStrategyCreate(pKvsRetryStrategy));
850+
CHK(pKvsRetryStrategy->retryStrategyType == KVS_RETRY_STRATEGY_EXPONENTIAL_BACKOFF_WAIT, STATUS_INTERNAL_ERROR);
851+
852+
pExponentialBackoffRetryStrategyState = TO_EXPONENTIAL_BACKOFF_STATE(pKvsRetryStrategy->pRetryStrategy);
853+
854+
// Overwrite retry config to avoid slow long running tests
855+
pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.retryFactorTime = HUNDREDS_OF_NANOS_IN_A_MILLISECOND * 5;
856+
pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.maxRetryWaitTime = HUNDREDS_OF_NANOS_IN_A_MILLISECOND * 75;
857+
858+
CleanUp:
859+
return retStatus;
860+
}
861+
862+
STATUS ProducerClientTestBase::getCurrentRetryAttemptNumberFn(PKvsRetryStrategy pKvsRetryStrategy, PUINT32 pRetryCount) {
863+
return getExponentialBackoffRetryCount(pKvsRetryStrategy, pRetryCount);
864+
}
865+
866+
STATUS ProducerClientTestBase::freeRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy) {
867+
return exponentialBackoffRetryStrategyFree(pKvsRetryStrategy);
868+
}
869+
870+
STATUS ProducerClientTestBase::executeRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy, PUINT64 retryWaitTime) {
871+
return getExponentialBackoffRetryStrategyWaitTime(pKvsRetryStrategy, retryWaitTime);
872+
}
873+
840874
} // namespace video
841875
} // namespace kinesis
842876
} // namespace amazonaws

0 commit comments

Comments
 (0)