fluent-bit icon indicating copy to clipboard operation
fluent-bit copied to clipboard

in_http: add test code and close server_fd on exit

Open nokute78 opened this issue 2 years ago • 3 comments

This patch is to

  • Add test code for in_http
  • Close server_fd on exit handler that the test code detects

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
  • [X] Debug log output from testing the change
  • [X] 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] Attached local packaging test output showing all targets (including any new ones) build.

Documentation

  • [N/A] Documentation required for this feature

Backporting

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

Debug log/Valgrind output

$ valgrind --leak-check=full bin/flb-rt-in_http 
==37824== Memcheck, a memory error detector
==37824== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==37824== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==37824== Command: bin/flb-rt-in_http
==37824== 
Test http...                                    ==37824== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test successful_response_code_200...            ==37824== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test successful_response_code_204...            ==37824== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
SUCCESS: All unit tests have passed.
==37824== 
==37824== HEAP SUMMARY:
==37824==     in use at exit: 0 bytes in 0 blocks
==37824==   total heap usage: 5,355 allocs, 5,355 frees, 3,506,160 bytes allocated
==37824== 
==37824== All heap blocks were freed -- no leaks are possible
==37824== 
==37824== For lists of detected and suppressed errors, rerun with: -s
==37824== 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 avatar Jul 16 '22 02:07 nokute78

I rebased master and CI passed.

nokute78 avatar Jul 23 '22 23:07 nokute78

Add test for tag_key.

$ valgrind --leak-check=full bin/flb-rt-in_http 
==53084== Memcheck, a memory error detector
==53084== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==53084== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==53084== Command: bin/flb-rt-in_http
==53084== 
Test http...                                    ==53084== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test successful_response_code_200...            ==53084== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test successful_response_code_204...            ==53084== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
Test tag_key...                                 ==53084== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
SUCCESS: All unit tests have passed.
==53084== 
==53084== HEAP SUMMARY:
==53084==     in use at exit: 0 bytes in 0 blocks
==53084==   total heap usage: 7,138 allocs, 7,138 frees, 4,666,166 bytes allocated
==53084== 
==53084== All heap blocks were freed -- no leaks are possible
==53084== 
==53084== For lists of detected and suppressed errors, rerun with: -s
==53084== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

nokute78 avatar Jul 30 '22 23:07 nokute78

@edsiper @niedbalski Ping. I'm waiting to merge to create a new patch for #5386

nokute78 avatar Aug 05 '22 22:08 nokute78