|
9 | 9 | #include "../../plugins/out_cloudwatch_logs/cloudwatch_api.h" |
10 | 10 |
|
11 | 11 | #define ERROR_ALREADY_EXISTS "{\"__type\":\"ResourceAlreadyExistsException\"}" |
| 12 | +#define CLOUDWATCH_ERROR_NOT_FOUND "{\"__type\":\"ResourceNotFoundException\"}" |
12 | 13 | /* not a real error code, but tests that the code can respond to any error */ |
13 | 14 | #define ERROR_UNKNOWN "{\"__type\":\"UNKNOWN\"}" |
14 | 15 |
|
@@ -284,6 +285,44 @@ void flb_test_cloudwatch_error_put_log_events(void) |
284 | 285 | flb_destroy(ctx); |
285 | 286 | } |
286 | 287 |
|
| 288 | +void flb_test_cloudwatch_error_put_log_events_not_found(void) |
| 289 | +{ |
| 290 | + int ret; |
| 291 | + flb_ctx_t *ctx; |
| 292 | + int in_ffd; |
| 293 | + int out_ffd; |
| 294 | + |
| 295 | + /* ResourceNotFoundException must follow the normal output retry path. */ |
| 296 | + setenv("FLB_CLOUDWATCH_PLUGIN_UNDER_TEST", "true", 1); |
| 297 | + setenv("TEST_PUT_LOG_EVENTS_ERROR", CLOUDWATCH_ERROR_NOT_FOUND, 1); |
| 298 | + |
| 299 | + ctx = flb_create(); |
| 300 | + |
| 301 | + in_ffd = flb_input(ctx, (char *) "lib", NULL); |
| 302 | + TEST_CHECK(in_ffd >= 0); |
| 303 | + flb_input_set(ctx, in_ffd, "tag", "test", NULL); |
| 304 | + |
| 305 | + out_ffd = flb_output(ctx, (char *) "cloudwatch_logs", NULL); |
| 306 | + TEST_CHECK(out_ffd >= 0); |
| 307 | + flb_output_set(ctx, out_ffd, "match", "test", NULL); |
| 308 | + flb_output_set(ctx, out_ffd, "region", "us-west-2", NULL); |
| 309 | + flb_output_set(ctx, out_ffd, "log_group_name", "fluent", NULL); |
| 310 | + flb_output_set(ctx, out_ffd, "log_stream_prefix", "from-fluent-", NULL); |
| 311 | + flb_output_set(ctx, out_ffd, "auto_create_group", "On", NULL); |
| 312 | + flb_output_set(ctx, out_ffd, "net.keepalive", "Off", NULL); |
| 313 | + flb_output_set(ctx, out_ffd, "Retry_Limit", "1", NULL); |
| 314 | + |
| 315 | + ret = flb_start(ctx); |
| 316 | + TEST_CHECK(ret == 0); |
| 317 | + |
| 318 | + flb_lib_push(ctx, in_ffd, (char *) JSON_TD, (int) sizeof(JSON_TD) - 1); |
| 319 | + |
| 320 | + sleep(2); |
| 321 | + flb_stop(ctx); |
| 322 | + flb_destroy(ctx); |
| 323 | + unsetenv("TEST_PUT_LOG_EVENTS_ERROR"); |
| 324 | +} |
| 325 | + |
287 | 326 | void flb_test_cloudwatch_put_retention_policy_success(void) |
288 | 327 | { |
289 | 328 | int ret; |
@@ -548,6 +587,7 @@ TEST_LIST = { |
548 | 587 | {"create_group_error", flb_test_cloudwatch_error_create_group }, |
549 | 588 | {"create_stream_error", flb_test_cloudwatch_error_create_stream }, |
550 | 589 | {"put_log_events_error", flb_test_cloudwatch_error_put_log_events }, |
| 590 | + {"put_log_events_not_found", flb_test_cloudwatch_error_put_log_events_not_found }, |
551 | 591 | {"put_retention_policy_success", flb_test_cloudwatch_put_retention_policy_success }, |
552 | 592 | {"already_exists_create_group_put_retention_policy", flb_test_cloudwatch_already_exists_create_group_put_retention_policy }, |
553 | 593 | {"error_put_retention_policy", flb_test_cloudwatch_error_put_retention_policy }, |
|
0 commit comments