Skip to content

Commit f3556ec

Browse files
committed
tests: runtime: Add a test case for not found error case of cloudwatch_logs
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 8351ae7 commit f3556ec

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

tests/runtime/out_cloudwatch.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "../../plugins/out_cloudwatch_logs/cloudwatch_api.h"
1010

1111
#define ERROR_ALREADY_EXISTS "{\"__type\":\"ResourceAlreadyExistsException\"}"
12+
#define CLOUDWATCH_ERROR_NOT_FOUND "{\"__type\":\"ResourceNotFoundException\"}"
1213
/* not a real error code, but tests that the code can respond to any error */
1314
#define ERROR_UNKNOWN "{\"__type\":\"UNKNOWN\"}"
1415

@@ -284,6 +285,44 @@ void flb_test_cloudwatch_error_put_log_events(void)
284285
flb_destroy(ctx);
285286
}
286287

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+
287326
void flb_test_cloudwatch_put_retention_policy_success(void)
288327
{
289328
int ret;
@@ -548,6 +587,7 @@ TEST_LIST = {
548587
{"create_group_error", flb_test_cloudwatch_error_create_group },
549588
{"create_stream_error", flb_test_cloudwatch_error_create_stream },
550589
{"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 },
551591
{"put_retention_policy_success", flb_test_cloudwatch_put_retention_policy_success },
552592
{"already_exists_create_group_put_retention_policy", flb_test_cloudwatch_already_exists_create_group_put_retention_policy },
553593
{"error_put_retention_policy", flb_test_cloudwatch_error_put_retention_policy },

0 commit comments

Comments
 (0)