Skip to content

Conversation

@ryanohnemus
Copy link
Contributor

Adds an initial CI test folder with a single test to check if the kubernetes filter plugin is enhancing records with k8s pod labels.

We can add kubernetes_namespace label checks after fluent/fluent-bit#8279 has merged.

NOTE: Since the fluentbit container does not have tar available, I wasn't able to just use a file output with a kubectl cp and instead just use another output plugin (elasticsearch) to be able to fetch and check the results easily. (Obviously this will look very similar to the elasticsearch-basic ci/bats test).

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
@patrick-stephens
Copy link
Collaborator

patrick-stephens commented Jan 11, 2024

NOTE: Since the fluentbit container does not have tar available, I wasn't able to just use a file output with a kubectl cp and instead just use another output plugin (elasticsearch) to be able to fetch and check the results easily. (Obviously this will look very similar to the elasticsearch-basic ci/bats test).

Yeah I think that's fair enough, I was thinking it potentially could be done with stdout and then checking the output of the pods or another output like Loki, etc. (we could also use a PV for file access) but this is fine and works.

Just need to check why it did not run the integration tests in this case. We may need to run them for the specific branch but I was hoping it would trigger on PR to confirm the test actually passes before we merge.

Potentially we could consider using the debug container but I think integration tests really should be on the production deployment. It may mean some extra hoops to jump through but ensures no delta in the production container.

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
@ryanohnemus
Copy link
Contributor Author

@patrick-stephens I like your idea of using stdout plugin much better than my original version. I just pushed a new update and removed the elasticsearch output dependency.

This version works by creating fluentbit that will read container logs that are in the $TEST_NAMESPACE. Since I'm running fluentbit as a deployment, any test container I create needs to be on the same k8s node for fluentbit to see it's logs. I use the fluent-bit container's nodeName after it's deployment to specify that as a nodeSelector when I run a hello world app (just a base alpine image that prints hello world every 2 seconds). That hello world app is being assigned a custom label this_is_a_test_label=true and after all that is deployed and running, I look for it specifically.

Let me know your thoughts!

Copy link
Collaborator

@patrick-stephens patrick-stephens left a comment

Choose a reason for hiding this comment

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

Some minor niggles but otherwise looks good to me.

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
@ryanohnemus
Copy link
Contributor Author

@patrick-stephens - ok i just pushed the latest version.

bats-detik version was updated, it looked like some of the other libs had higher versions but i only updated the one i needed to fix that try bug. I believe I addressed your other comments or responded to them, please take another look, hopefully it's looking much cleaner now.

@ryanohnemus
Copy link
Contributor Author

@patrick-stephens just pushed another diff, please take a look when you get a chance!

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
Copy link
Collaborator

@patrick-stephens patrick-stephens left a comment

Choose a reason for hiding this comment

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

I think this is fine, I'd like to verify it runs successfully though - I'm not sure why the PR is not running it but we can potentially explicitly run the workflow for a branch or if you can confirm it is ok manually?

@patrick-stephens
Copy link
Collaborator

@ryanohnemus does this pass locally for you btw?

@ryanohnemus
Copy link
Contributor Author

@patrick-stephens

./run-tests.sh tests/kubernetes-plugins/basic.bats   
+++ dirname /Users/ryan/repos/fluent-bit-ci/tools/install-bats.sh
++ cd /Users/ryan/repos/fluent-bit-ci/tools
++ pwd
+ SCRIPT_DIR=/Users/ryan/repos/fluent-bit-ci/tools
+ BATS_ROOT=/Users/ryan/repos/fluent-bit-ci/tools/bats
+ BATS_FILE_ROOT=/Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-file
+ BATS_SUPPORT_ROOT=/Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-support
+ BATS_ASSERT_ROOT=/Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-assert
+ BATS_DETIK_ROOT=/Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-detik
+ rm -rf /Users/ryan/repos/fluent-bit-ci/tools/bats
+ mkdir -p /Users/ryan/repos/fluent-bit-ci/tools/bats/lib
+ BATS_ASSERT_VERSION=2.0.0
+ BATS_SUPPORT_VERSION=0.3.0
+ BATS_FILE_VERSION=0.3.0
+ BATS_DETIK_VERSION=1.2.1
++ mktemp -d
+ DOWNLOAD_TEMP_DIR=/var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR
+ pushd /var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR
/var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR ~/repos/fluent-bit-ci
+ curl -LO https://github.com/bats-core/bats-assert/archive/refs/tags/v2.0.0.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 21631    0 21631    0     0  42141      0 --:--:-- --:--:-- --:--:-- 42141
+ unzip -q v2.0.0.zip
+ mv -f /var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR/bats-assert-2.0.0 /Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-assert
+ rm -f v2.0.0.zip
+ curl -LO https://github.com/bats-core/bats-support/archive/refs/tags/v0.3.0.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 18035  100 18035    0     0  27533      0 --:--:-- --:--:-- --:--:-- 27533
+ unzip -q v0.3.0.zip
+ mv -f /var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR/bats-support-0.3.0 /Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-support
+ rm -f v0.3.0.zip
+ curl -LO https://github.com/bats-core/bats-file/archive/refs/tags/v0.3.0.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 47242    0 47242    0     0  73563      0 --:--:-- --:--:-- --:--:--  474k
+ unzip -q v0.3.0.zip
+ mv -f /var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR/bats-file-0.3.0 /Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-file
+ rm -f v0.3.0.zip
+ curl -LO https://github.com/bats-core/bats-detik/archive/refs/tags/v1.2.1.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  154k    0  154k    0     0   304k      0 --:--:-- --:--:-- --:--:--  304k
+ unzip -q v1.2.1.zip
+ mv -f /var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR/bats-detik-1.2.1/lib /Users/ryan/repos/fluent-bit-ci/tools/bats/lib/bats-detik
+ rm -f v1.2.1.zip
+ popd
~/repos/fluent-bit-ci
+ rm -rf /var/folders/m3/_vmlrw313xddy2ynj_g9b7680000gn/T/tmp.A5D8LenhmR


========================
Starting tests.
========================

Fluentbit repository: ghcr.io/fluent/fluent-bit - tag: latest


1..1
ok 1 test fluent-bit reads k8s labels in 118000ms


========================
All tests passed!
========================

@patrick-stephens patrick-stephens merged commit 4ae1006 into fluent:main Jan 12, 2024
@patrick-stephens
Copy link
Collaborator

Can you rebase and push a new commit to your original PR so it can trigger the new tests?

@ryanohnemus
Copy link
Contributor Author

@patrick-stephens - ok i created a new draft pr #122 over here, but i still don't see it automatically kicking off a run?

@patrick-stephens
Copy link
Collaborator

Sorry I meant to your Fluent Bit PR - the namespace label support there.

@ryanohnemus ryanohnemus deleted the k8s_filter_ci branch January 28, 2024 20:14
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.

2 participants