Skip to content

Commit

Permalink
Adds the 1.9.5 fluent-bit rock
Browse files Browse the repository at this point in the history
The -DFLB_TRACE=Off cmake flag is set in v1.9.5, and the
-DFLB_CHUNK_TRACE=On is set in v2.1.6.

Updated the sanity tests to also test v1.9.5 image.

Updated integration test to pick the v2.1.6 image.
  • Loading branch information
claudiubelu committed Jul 22, 2024
1 parent 6e9c648 commit a80dc7f
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 31 deletions.
119 changes: 119 additions & 0 deletions 1.9.5/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: fluent-bit
summary: ROCK for the fluent-bit Project.
description: This ROCK is a drop in replacement for the fluent/fluent-bit image.
version: "1.9.5"
license: Apache-2.0

base: bare
build-base: [email protected]
platforms:
amd64:
arm64:

environment:
RELEASE_VERSION: 1.9.5

entrypoint-service: fluent-bit
services:
fluent-bit:
override: replace
summary: "fluent-bit service"
startup: enabled
command: "/fluent-bit/bin/fluent-bit [ -c /fluent-bit/etc/fluent-bit.conf ]"
on-failure: shutdown

parts:
# https://github.com/fluent/fluent-bit/blob/v1.9.5/dockerfiles/Dockerfile
fluent-bit:
source: https://github.com/fluent/fluent-bit
source-type: git
plugin: cmake
source-tag: v${CRAFT_PROJECT_VERSION}
stage-packages:
- ca-certificates
- libsasl2-2
- pkg-config
- libpq5
- libsystemd0
- zlib1g
- libatomic1
- libgcrypt20
- libzstd1
- liblz4-1
- libgssapi-krb5-2
- libgpg-error0
- libkrb5-3
- libk5crypto3
- libcom-err2
- libkrb5support0
- libgnutls30
- libkeyutils1
- libp11-kit0
- libidn2-0
- libunistring2
- libtasn1-6
- libnettle8
- libhogweed6
- libgmp10
- libffi7
- liblzma5
- libyaml-0-2
build-packages:
- build-essential
- curl
- ca-certificates
- cmake
- git
- make
- tar
- libssl-dev
- libsasl2-dev
- pkg-config
- libsystemd-dev
- zlib1g-dev
- libpq-dev
- postgresql-server-dev-all
- flex
- bison
- libyaml-dev
- wget
cmake-parameters:
- -DFLB_TRACE=Off
- -DFLB_RELEASE=On
- -DFLB_JEMALLOC=On
- -DFLB_TLS=On
- -DFLB_SHARED_LIB=Off
- -DFLB_EXAMPLES=Off
- -DFLB_HTTP_SERVER=On
- -DFLB_IN_EXEC=Off
- -DFLB_IN_SYSTEMD=On
- -DFLB_OUT_KAFKA=On
- -DFLB_OUT_PGSQL=On
- -DFLB_NIGHTLY_BUILD=""
- -DFLB_LOG_NO_CONTROL_CHARS=On
override-build: |
craftctl default
make -j "$(getconf _NPROCESSORS_ONLN)"
mkdir -p ${CRAFT_PART_INSTALL}/fluent-bit/bin/ ${CRAFT_PART_INSTALL}/fluent-bit/etc/ ${CRAFT_PART_INSTALL}/fluent-bit/log/ ${CRAFT_PART_INSTALL}/etc/ssl
install bin/fluent-bit ${CRAFT_PART_INSTALL}/fluent-bit/bin/
# Configuration files
cp ${CRAFT_PART_SRC}/conf/fluent-bit.conf \
${CRAFT_PART_SRC}/conf/parsers.conf \
${CRAFT_PART_SRC}/conf/parsers_ambassador.conf \
${CRAFT_PART_SRC}/conf/parsers_java.conf \
${CRAFT_PART_SRC}/conf/parsers_extra.conf \
${CRAFT_PART_SRC}/conf/parsers_openstack.conf \
${CRAFT_PART_SRC}/conf/parsers_cinder.conf \
${CRAFT_PART_SRC}/conf/plugins.conf \
${CRAFT_PART_INSTALL}/fluent-bit/etc/
# Generate schema and include as part of the container image
${CRAFT_PART_INSTALL}/fluent-bit/bin/fluent-bit -J > ${CRAFT_PART_INSTALL}/fluent-bit/etc/schema.json
ln -rs ${CRAFT_PART_INSTALL}/fluent-bit/bin/fluent-bit ${CRAFT_PART_INSTALL}/bin/fluent-bit
# Get missing packages
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
dpkg -x ./libssl1.1_1.1.0g-2ubuntu4_amd64.deb ${CRAFT_PART_INSTALL}/
wget http://security.ubuntu.com/ubuntu/pool/main/o/openldap/libldap-2.4-2_2.4.49+dfsg-2ubuntu1.10_amd64.deb
dpkg -x ./libldap-2.4-2_2.4.49+dfsg-2ubuntu1.10_amd64.deb ${CRAFT_PART_INSTALL}/
File renamed without changes.
38 changes: 14 additions & 24 deletions tests/integration/test_fluent_bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,31 @@

from k8s_test_harness import harness
from k8s_test_harness.util import exec_util
from k8s_test_harness.util import env_util, k8s_util


pytest_plugins = ["k8s_test_harness.plugin"]

LOG = logging.getLogger(__name__)


def test_integration_fluent_bit(module_instance: harness.Instance):
image_name_env_variable = "ROCK_FLUENT_BIT"
fluent_bit_rock = env_util.get_build_meta_info_for_rock_version(
"fluent-bit", "2.1.6", "amd64"
)

image_uri = os.getenv(image_name_env_variable)
assert image_uri is not None, f"{image_name_env_variable} is not set"
image_split = image_uri.split(":")
images = [
k8s_util.HelmImage(fluent_bit_rock.image)
]

helm_command = [
"k8s",
"helm",
"install",
helm_command = k8s_util.get_helm_install_command(
"fluent-bit",
"--repo",
"https://fluent.github.io/helm-charts",
"fluent-bit",
"--namespace",
"fluent-bit",
"--create-namespace",
"--version",
"0.34.2", # chart version with 2.1.6 app
"--set",
"installCRDs=true",
"--set",
f"image.repository={image_split[0]}",
"--set",
f"image.tag={image_split[1]}",
"--set",
"securityContext.runAsUser=584792",
]
namespace="fluent-bit",
repository="https://fluent.github.io/helm-charts",
chart_version="0.34.2", # chart version with 2.1.6 app
images=images,
)

module_instance.exec(helm_command)

Expand Down
18 changes: 11 additions & 7 deletions tests/sanity/test_rock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
# Copyright 2024 Canonical, Ltd.
#

import os
import subprocess

from k8s_test_harness.util import env_util
import pytest

def test_sanity():
image_variable = "ROCK_FLUENT_BIT"
entrypoint = "fluent-bit"
image = os.getenv(image_variable)
assert image is not None, f"${image_variable} is not set"

@pytest.mark.parametrize("image_version", ("2.1.6", "1.9.5"))
def test_sanity(image_version):
rock = env_util.get_build_meta_info_for_rock_version(
"fluent-bit", image_version, "amd64"
)
image = rock.image

entrypoint = "fluent-bit"
docker_run = subprocess.run(
["docker", "run", "--rm", "--entrypoint", entrypoint, image, "--version"],
capture_output=True,
check=True,
text=True,
)
assert "Fluent Bit v2.1.6" in docker_run.stdout
assert f"Fluent Bit v{image_version}" in docker_run.stdout
2 changes: 2 additions & 0 deletions tests/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ commands =
pass_env =
TEST_*
ROCK_*
BUILT_ROCKS_METADATA

[testenv:integration]
description = Run integration tests
Expand All @@ -62,6 +63,7 @@ commands =
pass_env =
TEST_*
ROCK_*
BUILT_ROCKS_METADATA

[flake8]
max-line-length = 120
Expand Down

0 comments on commit a80dc7f

Please sign in to comment.