|
19 | 19 |
|
20 | 20 | #include "flb_tests_internal.h" |
21 | 21 |
|
22 | | -#define FLB_YAML FLB_TESTS_DATA_PATH "/data/reload/yaml/processor.yaml" |
23 | | -#define FLB_CLASSIC FLB_TESTS_DATA_PATH "/data/reload/fluent-bit.conf" |
| 22 | +#define FLB_YAML FLB_TESTS_DATA_PATH "/data/reload/yaml/processor.yaml" |
| 23 | +#define FLB_YAML_MISSING_INCLUDE FLB_TESTS_DATA_PATH "/data/reload/yaml/missing_include.yaml" |
| 24 | +#define FLB_CLASSIC FLB_TESTS_DATA_PATH "/data/reload/fluent-bit.conf" |
24 | 25 |
|
25 | 26 | void test_reconstruct_cf() |
26 | 27 | { |
@@ -247,6 +248,60 @@ void test_reload_yaml() |
247 | 248 | flb_destroy(ctx); |
248 | 249 | } |
249 | 250 |
|
| 251 | +/* data/reload/yaml/missing_include.yaml */ |
| 252 | +void test_reload_yaml_missing_include() |
| 253 | +{ |
| 254 | + struct flb_cf *cf = NULL; |
| 255 | + struct flb_cf *cf_opts; |
| 256 | + struct flb_cf_section *section; |
| 257 | + struct cfl_variant *ret; |
| 258 | + flb_ctx_t *ctx; |
| 259 | + int status; |
| 260 | + |
| 261 | + cf_opts = flb_cf_create(); |
| 262 | + TEST_CHECK(cf_opts != NULL); |
| 263 | + |
| 264 | + section = flb_cf_section_create(cf_opts, "INPUT", 5); |
| 265 | + TEST_CHECK(section != NULL); |
| 266 | + |
| 267 | + ret = flb_cf_section_property_add(cf_opts, section->properties, "name", 0, "dummy", 0); |
| 268 | + TEST_CHECK(ret != NULL); |
| 269 | + |
| 270 | + ctx = flb_create(); |
| 271 | + if (!TEST_CHECK(ctx != NULL)) { |
| 272 | + TEST_MSG("flb_create failed"); |
| 273 | + exit(EXIT_FAILURE); |
| 274 | + } |
| 275 | + |
| 276 | + cf = ctx->config->cf_main; |
| 277 | + |
| 278 | + status = flb_reload_reconstruct_cf(cf_opts, cf); |
| 279 | + TEST_CHECK(status == 0); |
| 280 | + |
| 281 | + cf = flb_cf_create_from_file(cf, FLB_YAML); |
| 282 | + TEST_CHECK(cf != NULL); |
| 283 | + |
| 284 | + ctx->config->conf_path_file = flb_sds_create(FLB_YAML); |
| 285 | + ctx->config->enable_hot_reload = FLB_TRUE; |
| 286 | + |
| 287 | + status = flb_config_load_config_format(ctx->config, cf); |
| 288 | + TEST_CHECK(status == 0); |
| 289 | + |
| 290 | + status = flb_start(ctx); |
| 291 | + TEST_CHECK(status == 0); |
| 292 | + |
| 293 | + flb_sds_destroy(ctx->config->conf_path_file); |
| 294 | + ctx->config->conf_path_file = flb_sds_create(FLB_YAML_MISSING_INCLUDE); |
| 295 | + |
| 296 | + status = flb_reload(ctx, cf_opts); |
| 297 | + TEST_CHECK(status == FLB_RELOAD_HALTED); |
| 298 | + |
| 299 | + flb_cf_destroy(cf_opts); |
| 300 | + |
| 301 | + flb_stop(ctx); |
| 302 | + flb_destroy(ctx); |
| 303 | +} |
| 304 | + |
250 | 305 | /* Test hot reload watchdog timeout functionality */ |
251 | 306 | #ifndef FLB_SYSTEM_WINDOWS |
252 | 307 | void test_reload_watchdog_timeout() |
@@ -394,6 +449,7 @@ TEST_LIST = { |
394 | 449 | { "reconstruct_cf" , test_reconstruct_cf}, |
395 | 450 | { "reload" , test_reload}, |
396 | 451 | { "reload_yaml" , test_reload_yaml}, |
| 452 | + { "reload_yaml_missing_include", test_reload_yaml_missing_include}, |
397 | 453 | { "reload_watchdog_timeout", test_reload_watchdog_timeout}, |
398 | 454 | { 0 } |
399 | 455 | }; |
0 commit comments