Skip to content

Commit

Permalink
sanity: Uses k8s_test_harness utils
Browse files Browse the repository at this point in the history
The k8s_test_harness contains commonly used util functions. This
will simplify the tests.
  • Loading branch information
claudiubelu committed Jul 22, 2024
1 parent 962a13c commit c59b39c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
25 changes: 3 additions & 22 deletions tests/integration/test_fluent_bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
# Copyright 2024 Canonical, Ltd.
#
import logging
import os

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__)
Expand All @@ -19,33 +16,17 @@ def test_integration_fluent_bit(module_instance: harness.Instance):
"fluent-bit", "2.1.6", "amd64"
)

images = [
k8s_util.HelmImage(fluent_bit_rock.image)
]
images = [k8s_util.HelmImage(fluent_bit_rock.image)]

helm_command = k8s_util.get_helm_install_command(
"fluent-bit",
"fluent-bit",
namespace="fluent-bit",
repository="https://fluent.github.io/helm-charts",
chart_version="0.34.2", # chart version with 2.1.6 app
chart_version="0.34.2", # chart version with 2.1.6 app
images=images,
)

module_instance.exec(helm_command)

exec_util.stubbornly(retries=5, delay_s=5).on(module_instance).exec(
[
"k8s",
"kubectl",
"wait",
"--for=condition=ready",
"pod",
"-l",
"app.kubernetes.io/name=fluent-bit",
"--namespace",
"fluent-bit",
"--timeout",
"180s",
]
)
k8s_util.wait_for_daemonset(module_instance, "fluent-bit", "fluent-bit")
13 changes: 3 additions & 10 deletions tests/sanity/test_rock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# Copyright 2024 Canonical, Ltd.
#

import subprocess

from k8s_test_harness.util import env_util
import pytest
from k8s_test_harness.util import docker_util, env_util


@pytest.mark.parametrize("image_version", ("2.1.6", "1.9.5"))
Expand All @@ -16,10 +14,5 @@ def test_sanity(image_version):
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 f"Fluent Bit v{image_version}" in docker_run.stdout
process = docker_util.run_in_docker(image, [entrypoint, "--version"])
assert f"Fluent Bit v{image_version}" in process.stdout

0 comments on commit c59b39c

Please sign in to comment.