1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

SRS5: DVR: Support blackbox test based on hooks. v5.0.132 (#3365)

PICK e655948e96
This commit is contained in:
Winlin 2023-01-07 20:36:59 +08:00 committed by winlin
parent 3c6ade8721
commit f06a2d61f7
31 changed files with 4704 additions and 3925 deletions

View file

@ -68,6 +68,16 @@ const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER;
#define SRS_OVERWRITE_BY_ENV_MILLISECONDS(key) if (!srs_getenv(key).empty()) return (srs_utime_t)(::atoi(srs_getenv(key).c_str()) * SRS_UTIME_MILLISECONDS)
#define SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atof(srs_getenv(key).c_str()) * SRS_UTIME_SECONDS)
#define SRS_OVERWRITE_BY_ENV_FLOAT_MILLISECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atof(srs_getenv(key).c_str()) * SRS_UTIME_MILLISECONDS)
#define SRS_OVERWRITE_BY_ENV_DIRECTIVE(key) { \
static SrsConfDirective* dir = NULL; \
if (!dir && !srs_getenv(key).empty()) { \
string v = srs_getenv(key); \
dir = new SrsConfDirective(); \
dir->name = key; \
dir->args.push_back(v); \
} \
if (dir) return dir; \
}
/**
* dumps the ingest/transcode-engine in @param dir to amf0 object @param engine.
@ -5359,6 +5369,8 @@ SrsConfDirective* SrsConfig::get_vhost_http_hooks(string vhost)
bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
{
SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.http_hooks.enabled"); // SRS_VHOST_HTTP_HOOKS_ENABLED
static bool DEFAULT = false;
SrsConfDirective* conf = get_vhost(vhost);
@ -5371,6 +5383,8 @@ bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
bool SrsConfig::get_vhost_http_hooks_enabled(SrsConfDirective* vhost)
{
SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.http_hooks.enabled"); // SRS_VHOST_HTTP_HOOKS_ENABLED
static bool DEFAULT = false;
SrsConfDirective* conf = vhost->get("http_hooks");
@ -5388,6 +5402,8 @@ bool SrsConfig::get_vhost_http_hooks_enabled(SrsConfDirective* vhost)
SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_connect"); // SRS_VHOST_HTTP_HOOKS_ON_CONNECT
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5398,6 +5414,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_close"); // SRS_VHOST_HTTP_HOOKS_ON_CLOSE
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5408,6 +5426,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_publish"); // SRS_VHOST_HTTP_HOOKS_ON_PUBLISH
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5418,6 +5438,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_unpublish"); // SRS_VHOST_HTTP_HOOKS_ON_UNPUBLISH
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5428,6 +5450,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_play"); // SRS_VHOST_HTTP_HOOKS_ON_PLAY
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5438,6 +5462,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_stop"); // SRS_VHOST_HTTP_HOOKS_ON_STOP
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5448,6 +5474,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_dvr(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_dvr"); // SRS_VHOST_HTTP_HOOKS_ON_DVR
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5458,6 +5486,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_dvr(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_hls(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_hls"); // SRS_VHOST_HTTP_HOOKS_ON_HLS
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;
@ -5468,6 +5498,8 @@ SrsConfDirective* SrsConfig::get_vhost_on_hls(string vhost)
SrsConfDirective* SrsConfig::get_vhost_on_hls_notify(string vhost)
{
SRS_OVERWRITE_BY_ENV_DIRECTIVE("srs.vhost.http_hooks.on_hls_notify"); // SRS_VHOST_HTTP_HOOKS_ON_HLS_NOTIFY
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
if (!conf) {
return NULL;

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 0
#define VERSION_REVISION 131
#define VERSION_REVISION 132
#endif

View file

@ -3937,8 +3937,6 @@ VOID TEST(ConfigMainTest, SrtServerTlpktDrop)
VOID TEST(ConfigEnvTest, CheckEnvValuesGlobal)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4035,8 +4033,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesGlobal)
VOID TEST(ConfigEnvTest, CheckEnvValuesthreads)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4047,8 +4043,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesthreads)
VOID TEST(ConfigEnvTest, CheckEnvValuesRtmp)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4082,8 +4076,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesRtmp)
VOID TEST(ConfigEnvTest, CheckEnvValuesHttpApi)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4126,8 +4118,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHttpApi)
VOID TEST(ConfigEnvTest, CheckEnvValuesHttpServer)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4163,8 +4153,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHttpServer)
VOID TEST(ConfigEnvTest, CheckEnvValuesSrtServer)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4220,8 +4208,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesSrtServer)
VOID TEST(ConfigEnvTest, CheckEnvValuesVhostSrt)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4235,8 +4221,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesVhostSrt)
VOID TEST(ConfigEnvTest, CheckEnvValuesRtcServer)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4303,8 +4287,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesRtcServer)
VOID TEST(ConfigEnvTest, CheckEnvValuesVhostRtc)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4362,8 +4344,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesVhostRtc)
VOID TEST(ConfigEnvTest, CheckEnvValuesVhostPlay)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4433,8 +4413,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesVhostPlay)
VOID TEST(ConfigEnvTest, CheckEnvValuesVhostPublish)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4460,8 +4438,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesVhostPublish)
VOID TEST(ConfigEnvTest, CheckEnvValuesCircuitBreaker)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4490,8 +4466,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesCircuitBreaker)
VOID TEST(ConfigEnvTest, CheckEnvValuesTencentcloudCls)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4539,8 +4513,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesTencentcloudCls)
VOID TEST(ConfigEnvTest, CheckEnvValuesTencentcloudApm)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4566,8 +4538,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesTencentcloudApm)
VOID TEST(ConfigEnvTest, CheckEnvValuesExporter)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4587,8 +4557,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesExporter)
VOID TEST(ConfigEnvTest, CheckEnvValuesHeartbeat)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4611,8 +4579,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHeartbeat)
VOID TEST(ConfigEnvTest, CheckEnvValuesScope)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4646,8 +4612,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesScope)
VOID TEST(ConfigEnvTest, CheckEnvValuesHttpStatic)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4664,8 +4628,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHttpStatic)
VOID TEST(ConfigEnvTest, CheckEnvValuesHttpRemux)
{
srs_error_t err;
MockSrsConfig conf;
if (true) {
@ -4722,8 +4684,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHttpRemux)
VOID TEST(ConfigEnvTest, CheckEnvValuesDash)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4776,8 +4736,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHds)
VOID TEST(ConfigEnvTest, CheckEnvValuesDvr)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4806,8 +4764,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesDvr)
VOID TEST(ConfigEnvTest, CheckEnvValuesHls)
{
srs_error_t err;
if (true) {
MockSrsConfig conf;
@ -4886,4 +4842,71 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHls)
SrsSetEnvConfig(hls_dts_directly, "SRS_VHOST_HLS_HLS_DTS_DIRECTLY", "off");
EXPECT_FALSE(conf.get_vhost_hls_dts_directly("__defaultVhost__"));
}
}
}
VOID TEST(ConfigEnvTest, CheckEnvValuesHooks)
{
MockSrsConfig conf;
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ENABLED", "on");
EXPECT_TRUE(conf.get_vhost_http_hooks_enabled("__defaultVhost__"));
}
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ON_PUBLISH", "http://server/api/publish");
SrsConfDirective* dir = conf.get_vhost_on_publish("__defaultVhost__");
ASSERT_TRUE(dir != NULL);
ASSERT_TRUE((int)dir->args.size() == 1);
ASSERT_STREQ("http://server/api/publish", dir->arg0().c_str());
}
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ON_UNPUBLISH", "http://server/api/unpublish");
SrsConfDirective* dir = conf.get_vhost_on_unpublish("__defaultVhost__");
ASSERT_TRUE(dir != NULL);
ASSERT_TRUE((int)dir->args.size() == 1);
ASSERT_STREQ("http://server/api/unpublish", dir->arg0().c_str());
}
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ON_PLAY", "http://server/api/play");
SrsConfDirective* dir = conf.get_vhost_on_play("__defaultVhost__");
ASSERT_TRUE(dir != NULL);
ASSERT_TRUE((int)dir->args.size() == 1);
ASSERT_STREQ("http://server/api/play", dir->arg0().c_str());
}
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ON_STOP", "http://server/api/stop");
SrsConfDirective* dir = conf.get_vhost_on_stop("__defaultVhost__");
ASSERT_TRUE(dir != NULL);
ASSERT_TRUE((int)dir->args.size() == 1);
ASSERT_STREQ("http://server/api/stop", dir->arg0().c_str());
}
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ON_DVR", "http://server/api/dvr");
SrsConfDirective* dir = conf.get_vhost_on_dvr("__defaultVhost__");
ASSERT_TRUE(dir != NULL);
ASSERT_TRUE((int)dir->args.size() == 1);
ASSERT_STREQ("http://server/api/dvr", dir->arg0().c_str());
}
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ON_HLS", "http://server/api/hls");
SrsConfDirective* dir = conf.get_vhost_on_hls("__defaultVhost__");
ASSERT_TRUE(dir != NULL);
ASSERT_TRUE((int)dir->args.size() == 1);
ASSERT_STREQ("http://server/api/hls", dir->arg0().c_str());
}
if (true) {
SrsSetEnvConfig(hooks, "SRS_VHOST_HTTP_HOOKS_ON_HLS_NOTIFY", "http://server/api/hls_notify");
SrsConfDirective* dir = conf.get_vhost_on_hls_notify("__defaultVhost__");
ASSERT_TRUE(dir != NULL);
ASSERT_TRUE((int)dir->args.size() == 1);
ASSERT_STREQ("http://server/api/hls_notify", dir->arg0().c_str());
}
}