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

Netobserv 390: fix kafka transformer #237

Merged
merged 6 commits into from
Jun 24, 2022

Conversation

OlivierCazade
Copy link
Contributor

Multiple small changes in this PR:

  • Fix timer in kafka ingester which was causing the FLP transformer to stop processing flows under too much traffic
  • Add batch limit in kafka ingester
  • Fix concurrent map access that could cause some crash when loglevel was set to debug
  • Expose Kafka commit interval and default to 500ms for performances

Copy link

@mariomac mariomac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add unit tests or integration tests, if possible

Copy link

@mariomac mariomac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a test that actually verifies the current additions. Something like:

  • Abstract current kafka listener behind an injectable interface to provide mocks/fakes.

Test 1:

  • Set a very high batch read timeout (e.g. 1h)
  • Send mocked kafka messages with a total size lower than batchMaxLength
  • Verify that messages aren't forwarded by the output channel
  • Send messages until the total size is higher than batchMaxLength
  • Verify that messages are forwarded by the output channel

Test 2:

  • Set a very high batchMaxlength
  • set a reasonably low batch timeout: e.g. 100 ms
  • Send few mocked kafka messages (size < batchMatLength), making sure they are received before these 100ms. If we can't, increase the timeout e.g. to 200ms or ideally, also allow injecting a ticker that can be triggered on demand.
  • Verify that the kafka messages are sent after the timeout

@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2022

Codecov Report

Merging #237 (30d60a2) into main (4b7265e) will increase coverage by 0.10%.
The diff coverage is 84.84%.

@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
+ Coverage   61.22%   61.32%   +0.10%     
==========================================
  Files          67       67              
  Lines        3863     3886      +23     
==========================================
+ Hits         2365     2383      +18     
- Misses       1348     1352       +4     
- Partials      150      151       +1     
Flag Coverage Δ
unittests 61.32% <84.84%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/pipeline/ingest/ingest_kafka.go 80.15% <84.84%> (-0.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b7265e...30d60a2. Read the comment docs.

@KalmanMeth
Copy link
Collaborator

Abstract current kafka listener behind an injectable interface to provide mocks/fakes.
Test 1: Set a very high batch read timeout (e.g. 1h)
Test 2: Set a very high batchMaxlength

Such tests could be added to test/e2e/kafka/kafka_test.go or the existing tests could be adjusted to include these.

@OlivierCazade
Copy link
Contributor Author

I added the suggested tests.

@OlivierCazade OlivierCazade merged commit 16d9c36 into netobserv:main Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants