Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: internal: log_event_encoder: Add test code #7584

Closed
wants to merge 11 commits into from

Conversation

nokute78
Copy link
Collaborator

This patch is to add test code for log_event_encoder.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Debug/Valgrind output

$ valgrind --leak-check=full bin/flb-it-log_event_encoder 
==117306== Memcheck, a memory error detector
==117306== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==117306== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==117306== Command: bin/flb-it-log_event_encoder
==117306== 
Test basic_format_fluent_bit_v2...              [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
Test basic_format_fluent_bit_v1...              [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
Test basic_metadata_format_fluent_bit_v2...     [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
Test create_destroy...                          [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
Test create_unsupported_format...               [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
Test init_destroy...                            [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
Test init_unsupported_format...                 [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
Test emit_raw_record...                         [ OK ]
==117306== Warning: invalid file descriptor -1 in syscall close()
SUCCESS: All unit tests have passed.
==117306== 
==117306== HEAP SUMMARY:
==117306==     in use at exit: 0 bytes in 0 blocks
==117306==   total heap usage: 6,745 allocs, 6,745 frees, 861,245 bytes allocated
==117306== 
==117306== All heap blocks were freed -- no leaks are possible
==117306== 
==117306== For lists of detected and suppressed errors, rerun with: -s
==117306== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@nokute78 nokute78 temporarily deployed to pr June 18, 2023 01:42 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr June 18, 2023 01:42 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr June 18, 2023 01:43 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr June 18, 2023 02:05 — with GitHub Actions Inactive
@edsiper
Copy link
Member

edsiper commented Jul 3, 2023

@nokute78 there is something wrong in the windows test:

      Start 32: flb-it-log_event_encoder
32/40 Test #32: flb-it-log_event_encoder .........***Failed    0.44 sec
Test basic_format_fluent_bit_v2...              [ FAILED ]
  Unhandled SEH exception... failed
    Exception code:    0xc0000005
    Exception address: 0x00007FF7E1C2B0A0
Test basic_format_fluent_bit_v1...              [ FAILED ]
  log_event_encoder.c:471: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test basic_metadata_format_fluent_bit_v2...     [ FAILED ]
  log_event_encoder.c:541: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test create_destroy...                          [ OK ]
Test create_unsupported_format...               [ OK ]
Test init_destroy...                            [ OK ]
Test init_unsupported_format...                 [ OK ]
Test emit_raw_record...                         [ OK ]
  Access violation.
FAILED: 3 of 8 unit tests have failed.
      Start 33: flb-it-processor
33/40 Test #33: flb-it-processor .................   Passed    0.03 sec
      Start 34: flb-it-config_format
34/40 Test #34: flb-it-config_format .............   Passed    0.02 sec
      Start 35: flb-it-config_format_fluentbit
35/40 Test #35: flb-it-config_format_fluentbit ...   Passed    0.11 sec
      Start 36: flb-it-stream_processor
36/40 Test #36: flb-it-stream_processor ..........   Passed   17.86 sec
      Start 37: flb-it-record_accessor
37/40 Test #37: flb-it-record_accessor ...........   Passed    0.32 sec
      Start 38: flb-it-metrics
38/40 Test #38: flb-it-metrics ...................   Passed    0.02 sec
      Start 39: flb-it-aws_compress
39/40 Test #39: flb-it-aws_compress ..............   Passed    0.12 sec
      Start 40: flb-it-lua
40/40 Test #40: flb-it-lua .......................   Passed    0.11 sec
98% tests passed, 1 tests failed out of 40
Label Time Summary:
internal    =  50.94 sec*proc (40 tests)
Total Test time (real) =  51.23 sec
The following tests FAILED:
	 32 - flb-it-log_event_encoder (Failed)
Errors while running CTest

@nokute78
Copy link
Collaborator Author

nokute78 commented Jul 3, 2023

Hmm, flb_log_event_encoder_append_body_values may cause error.
I don't know why...

@nokute78
Copy link
Collaborator Author

nokute78 commented Jul 7, 2023

Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78 nokute78 temporarily deployed to pr July 9, 2023 00:50 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 9, 2023 00:50 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 9, 2023 00:50 — with GitHub Actions Inactive
@nokute78
Copy link
Collaborator Author

nokute78 commented Jul 9, 2023

I added a commit 6473941 to add debug logs.
This commit should be removed before merging.

@nokute78 nokute78 temporarily deployed to pr July 9, 2023 01:17 — with GitHub Actions Inactive
@nokute78
Copy link
Collaborator Author

nokute78 commented Jul 9, 2023

https://ci.appveyor.com/project/fluent/fluent-bit-2e87g/builds/47500501/job/y3xh6k0tpa4qhgaf#L4020
It pointed msgpack_pack_str_body was failed.

msgpack_sbuffer_write may return realloc error.

  1. msgpack_pack_str_body -> msgpack_pack_append_buffer source
  2. msgpack_pack_append_buffer -> callback(msgpack_sbuffer_write) source
  3. msgpack_sbuffer_write returns -1 when realloc fails. source
31/40 Test #31: flb-it-log .......................   Passed   20.24 sec
      Start 32: flb-it-log_event_encoder
32/40 Test #32: flb-it-log_event_encoder .........***Failed    0.14 sec
Test basic_format_fluent_bit_v2...              [2023/07/09 01:03:36] [error] result=-1 str=key1 len=4
[ FAILED ]
  log_event_encoder.c:407: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test basic_format_fluent_bit_v1...              [2023/07/09 01:03:36] [error] result=-1 str=key1 len=4
[ FAILED ]
  log_event_encoder.c:471: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test basic_metadata_format_fluent_bit_v2...     [2023/07/09 01:03:36] [error] result=-1 str=key1 len=4
[ FAILED ]
  log_event_encoder.c:541: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test create_destroy...                          [ OK ]
Test create_unsupported_format...               [ OK ]
Test init_destroy...                            [ OK ]

Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78 nokute78 temporarily deployed to pr July 9, 2023 01:47 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 9, 2023 01:47 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 9, 2023 01:47 — with GitHub Actions Inactive
@nokute78
Copy link
Collaborator Author

nokute78 commented Jul 9, 2023

I added flb_errno.
919ef76

It reported "Not enough space" .

32/40 Test #32: flb-it-log_event_encoder .........***Failed    0.18 sec
Test basic_format_fluent_bit_v2...              [2023/07/09 02:00:47] [error] [C:\projects\fluent-bit-2e87g\src\flb_log_event_encoder_primitives.c:85 errno=12] Not enough space
[2023/07/09 02:00:47] [error] result=-1 str=key1 len=4
[ FAILED ]
  log_event_encoder.c:407: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test basic_format_fluent_bit_v1...              [2023/07/09 02:00:47] [error] [C:\projects\fluent-bit-2e87g\src\flb_log_event_encoder_primitives.c:85 errno=12] Not enough space
[2023/07/09 02:00:47] [error] result=-1 str=key1 len=4
[ FAILED ]
  log_event_encoder.c:471: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test basic_metadata_format_fluent_bit_v2...     [2023/07/09 02:00:47] [error] [C:\projects\fluent-bit-2e87g\src\flb_log_event_encoder_primitives.c:85 errno=12] Not enough space
[2023/07/09 02:00:47] [error] result=-1 str=key1 len=4
[ FAILED ]
  log_event_encoder.c:541: Check ret == FLB_EVENT_ENCODER_SUCCESS... failed
    flb_log_event_encoder_append_body_values failed. ret=Serializatoin failure
Test create_destroy...                          [ OK ]

@nokute78 nokute78 temporarily deployed to pr July 9, 2023 02:10 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 14, 2023 23:37 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 14, 2023 23:37 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 14, 2023 23:37 — with GitHub Actions Inactive
@nokute78 nokute78 force-pushed the test_log_event_encoder branch from c95f003 to df82307 Compare July 17, 2023 06:14
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 06:15 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 06:15 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 06:15 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 06:37 — with GitHub Actions Inactive
a
Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78 nokute78 force-pushed the test_log_event_encoder branch from df82307 to 6d25013 Compare July 17, 2023 08:58
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 08:58 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 08:58 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 08:58 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 09:23 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 09:31 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 09:31 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 09:31 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 09:56 — with GitHub Actions Inactive
@nokute78 nokute78 force-pushed the test_log_event_encoder branch from 9a471f1 to af64114 Compare July 17, 2023 11:31
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 11:32 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 11:32 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 11:32 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 17, 2023 11:56 — with GitHub Actions Inactive
a
Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78 nokute78 force-pushed the test_log_event_encoder branch from af64114 to 0658943 Compare July 22, 2023 22:42
@nokute78 nokute78 temporarily deployed to pr July 22, 2023 22:43 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 22, 2023 22:43 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 22, 2023 22:43 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr July 22, 2023 23:08 — with GitHub Actions Inactive
@nokute78
Copy link
Collaborator Author

I tested on Windows.
'int' type is converted int64_t in va_list and it caused error.

I tried to push a refactored PR #7736

@nokute78
Copy link
Collaborator Author

Note:
https://learn.microsoft.com/en-us/cpp/cpp/functions-with-variable-argument-lists-cpp?view=msvc-170

When arguments of type char are passed as variable arguments, they are converted to type int.
 Similarly, when arguments of type float are passed as variable arguments, they are converted to type double.
 Arguments of other types are subject to the usual integral and floating-point promotions.
 See [Standard Conversions](https://learn.microsoft.com/en-us/cpp/cpp/standard-conversions?view=msvc-170) for more information.

@nokute78 nokute78 closed this Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants