Classes | Macros | Functions | Variables
kinesis_video_streamer_test.cpp File Reference
#include <aws_ros1_common/sdk_utils/logging/aws_ros_logger.h>
#include <gtest/gtest.h>
#include <kinesis_manager/kinesis_stream_manager.h>
#include <kinesis_manager/stream_definition_provider.h>
#include <kinesis_video_msgs/KinesisVideoFrame.h>
#include <kinesis_video_streamer/ros_stream_subscription_installer.h>
#include <kinesis_video_streamer/streamer.h>
#include <kinesis_video_streamer/subscriber_callbacks.h>
#include <ros/callback_queue.h>
#include <ros/ros.h>
#include <rosgraph_msgs/Log.h>
#include <queue>
#include "kinesis_video_streamer_test_utils.h"
Include dependency graph for kinesis_video_streamer_test.cpp:

Go to the source code of this file.

Classes

class  KinesisVideoStreamerE2ETest
 
class  KinesisVideoStreamerTestBase
 

Macros

#define ROS_POSTCALLBACK_ASSERT_TRUE(expr)
 Some tests rely on ROS callback processing which may take time. To avoid unnecessary waits we define a helper macro with the following logic: If the assertion would fail, call available callbacks first. If the assertion would still fail, call available callbacks with a "small" timeout (0.1s). If the assertion would still fail, call available callbacks with a "large" timeout (5s). finally, ASSERT_TRUE. This avoids unnecessary waits and ensures sufficient processing time if needed. More...
 

Functions

void ImageTransportTestCallback (const KinesisStreamManagerInterface &stream_manager, std::string stream_name, const sensor_msgs::ImageConstPtr &image)
 
 INSTANTIATE_TEST_CASE_P (End2EndTest, KinesisVideoStreamerE2ETest,::testing::ValuesIn(callback_tuples))
 
void KinesisVideoFrameTransportTestCallback (KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg)
 
int main (int argc, char **argv)
 
void RekognitionEnabledKinesisVideoFrameTransportTestCallback (KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg, const ros::Publisher &publisher)
 
void rosout_logger_callback (const rosgraph_msgs::Log &published_log)
 
 TEST (StreamerGlobalSuite, rosParameterConstruction)
 
 TEST_F (KinesisVideoStreamerTestBase, sanity)
 
 TEST_F (KinesisVideoStreamerTestBase, invalidCallbackShouldReturnFalse)
 
 TEST_F (KinesisVideoStreamerTestBase, codecPrivateDataFailure)
 
 TEST_F (KinesisVideoStreamerTestBase, invalidStreamDefinition)
 
 TEST_F (KinesisVideoStreamerTestBase, streamInitializationFailures)
 
 TEST_P (KinesisVideoStreamerE2ETest, E2ETest)
 

Variables

vector< tuple< Aws::Kinesis::KinesisVideoFrameTransportCallbackFn, Aws::Kinesis::ImageTransportCallbackFn, Aws::Kinesis::RekognitionEnabledKinesisVideoFrameTransportCallbackFn > > callback_tuples
 
constexpr double kMultipleCallbacksWaitTime = 5
 
queue< rosgraph_msgs::Log > * kRosoutQueue = nullptr
 
constexpr double kSingleCallbackWaitTime = 0.1
 
TestDatakTestData = nullptr
 

Macro Definition Documentation

#define ROS_POSTCALLBACK_ASSERT_TRUE (   expr)
Value:
if (!(expr)) { \
ros::getGlobalCallbackQueue()->callAvailable(); \
if (!(expr)) { \
ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(kSingleCallbackWaitTime)); \
if (!(expr)) { \
ros::getGlobalCallbackQueue()->callAvailable( \
} \
} \
} \
ASSERT_TRUE(expr)
constexpr double kSingleCallbackWaitTime
constexpr double kMultipleCallbacksWaitTime

Some tests rely on ROS callback processing which may take time. To avoid unnecessary waits we define a helper macro with the following logic: If the assertion would fail, call available callbacks first. If the assertion would still fail, call available callbacks with a "small" timeout (0.1s). If the assertion would still fail, call available callbacks with a "large" timeout (5s). finally, ASSERT_TRUE. This avoids unnecessary waits and ensures sufficient processing time if needed.

Definition at line 42 of file kinesis_video_streamer_test.cpp.

Function Documentation

void ImageTransportTestCallback ( const KinesisStreamManagerInterface stream_manager,
std::string  stream_name,
const sensor_msgs::ImageConstPtr &  image 
)

Definition at line 208 of file kinesis_video_streamer_test.cpp.

INSTANTIATE_TEST_CASE_P ( End2EndTest  ,
KinesisVideoStreamerE2ETest  ,
::testing::ValuesIn(callback_tuples  
)

Perform an end to end test using both the mocked and real callbacks. The mocked callbacks execution is used to check that N published messages result in N invocations of the callback, while execution with the real callbacks checks that N published messages result in N calls to the PutFrame API.

void KinesisVideoFrameTransportTestCallback ( KinesisStreamManagerInterface stream_manager,
std::string  stream_name,
const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &  frame_msg 
)

Definition at line 201 of file kinesis_video_streamer_test.cpp.

int main ( int  argc,
char **  argv 
)

Definition at line 413 of file kinesis_video_streamer_test.cpp.

void RekognitionEnabledKinesisVideoFrameTransportTestCallback ( KinesisStreamManagerInterface stream_manager,
std::string  stream_name,
const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &  frame_msg,
const ros::Publisher publisher 
)

Definition at line 214 of file kinesis_video_streamer_test.cpp.

void rosout_logger_callback ( const rosgraph_msgs::Log &  published_log)

Definition at line 408 of file kinesis_video_streamer_test.cpp.

TEST ( StreamerGlobalSuite  ,
rosParameterConstruction   
)

Definition at line 391 of file kinesis_video_streamer_test.cpp.

TEST_F ( KinesisVideoStreamerTestBase  ,
sanity   
)

Tests success scenario.

Definition at line 97 of file kinesis_video_streamer_test.cpp.

TEST_F ( KinesisVideoStreamerTestBase  ,
invalidCallbackShouldReturnFalse   
)

Definition at line 113 of file kinesis_video_streamer_test.cpp.

TEST_F ( KinesisVideoStreamerTestBase  ,
codecPrivateDataFailure   
)

Codec private data loading failure

Definition at line 122 of file kinesis_video_streamer_test.cpp.

TEST_F ( KinesisVideoStreamerTestBase  ,
invalidStreamDefinition   
)

Invalid stream definitions

Definition at line 138 of file kinesis_video_streamer_test.cpp.

TEST_F ( KinesisVideoStreamerTestBase  ,
streamInitializationFailures   
)

InitializeVideoStream failure

Subscription failure

Definition at line 153 of file kinesis_video_streamer_test.cpp.

TEST_P ( KinesisVideoStreamerE2ETest  ,
E2ETest   
)

Definition at line 371 of file kinesis_video_streamer_test.cpp.

Variable Documentation

Initial value:
= {
void ImageTransportTestCallback(const KinesisStreamManagerInterface &stream_manager, std::string stream_name, const sensor_msgs::ImageConstPtr &image)
void RekognitionEnabledKinesisVideoFrameTransportCallback(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg, const ros::Publisher &publisher)
void KinesisVideoFrameTransportCallback(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg)
void ImageTransportCallback(const KinesisStreamManagerInterface &stream_manager, std::string stream_name, const sensor_msgs::ImageConstPtr &image)
void RekognitionEnabledKinesisVideoFrameTransportTestCallback(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg, const ros::Publisher &publisher)
void KinesisVideoFrameTransportTestCallback(KinesisStreamManagerInterface &stream_manager, std::string stream_name, const kinesis_video_msgs::KinesisVideoFrame::ConstPtr &frame_msg)

Definition at line 376 of file kinesis_video_streamer_test.cpp.

constexpr double kMultipleCallbacksWaitTime = 5

Definition at line 33 of file kinesis_video_streamer_test.cpp.

queue<rosgraph_msgs::Log>* kRosoutQueue = nullptr

Definition at line 59 of file kinesis_video_streamer_test.cpp.

constexpr double kSingleCallbackWaitTime = 0.1

Definition at line 32 of file kinesis_video_streamer_test.cpp.

TestData* kTestData = nullptr

Definition at line 60 of file kinesis_video_streamer_test.cpp.



kinesis_video_streamer
Author(s): AWS RoboMaker
autogenerated on Fri Mar 5 2021 03:29:15