Skip to content

Commit

Permalink
Perf test improvements
Browse files Browse the repository at this point in the history
* collect inspection reports even if the job succeeds
  * the k8s-dqlite logs can help us understand if the expected
    code paths were reached or if there's excessive logging
* multiple kube-burner iterations
  * helps us determine if an error is transient or if dqlite was
    compromised
  * longer test duration, covering periodic jobs such as compaction
  • Loading branch information
petrutlucian94 committed Feb 14, 2025
1 parent cceeb47 commit b7cb056
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/performance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
TEST_INSPECTION_REPORTS_DIR: ${{ github.workspace }}/inspection-reports
TEST_METRICS_DIR: ${{ github.workspace }}/test/performance/results/head
TEST_RUN_NAME: head
TEST_KUBE_BURNER_ITERATIONS: 15
run: |
cd test/performance
mkdir -p ./results/head
Expand All @@ -89,6 +90,7 @@ jobs:
TEST_INSPECTION_REPORTS_DIR: ${{ github.workspace }}/inspection-reports
TEST_METRICS_DIR: ${{ github.workspace }}/test/performance/results/base-code
TEST_RUN_NAME: base-code
TEST_KUBE_BURNER_ITERATIONS: 15
run: |
cd test/performance
mkdir -p ./results/base-code
Expand All @@ -114,12 +116,12 @@ jobs:
name: performance-results
path: ${{ github.workspace }}/test/performance/results
- name: Prepare inspection reports
if: failure()
if: always()
run: |
tar -czvf inspection-reports.tar.gz -C ${{ github.workspace }} inspection-reports
echo "artifact_name=inspection-reports" | sed 's/:/-/g' >> $GITHUB_ENV
- name: Upload inspection report artifact
if: failure()
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
Expand Down
3 changes: 2 additions & 1 deletion test/performance/tests/test_util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
os.getenv("TEST_KUBE_BURNER_URL")
or "https://github.com/kube-burner/kube-burner/releases/download/v1.2/kube-burner-1.2-Linux-x86_64.tar.gz"
)

# Global kube-burner invocation timeout.
KUBE_BURNER_TIMEOUT = os.getenv("TEST_KUBE_BURNER_TIMEOUT") or "10m"
# The number of kube-burner invocations.
KUBE_BURNER_ITERATIONS = int(os.getenv("TEST_KUBE_BURNER_ITERATIONS") or 1)

# FLAVOR is the flavour to use for running the performance tests.
FLAVOR = os.getenv("TEST_FLAVOR") or ""
Expand Down
42 changes: 31 additions & 11 deletions test/performance/tests/test_util/metrics.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#
# Copyright 2025 Canonical, Ltd.
#
import logging
import os
from typing import List

from test_util import config, harness, util

LOG = logging.getLogger(__name__)


def stop_metrics(instances: List[harness.Instance], process_dict: dict):
"""Stops collecting metrics in the background from each instance."""
Expand Down Expand Up @@ -78,17 +81,34 @@ def configure_kube_burner(instance: harness.Instance):
)


def run_kube_burner(instance: harness.Instance):
def run_kube_burner(
instance: harness.Instance, iterations: int = config.KUBE_BURNER_ITERATIONS
):
"""Copies kubeconfig and runs kube-burner on the instance."""
instance.exec(["mkdir", "-p", "/root/.kube"])
instance.exec(["k8s", "config", ">", "/root/.kube/config"])
instance.exec(
[
"/root/kube-burner",
"init",
"--timeout",
config.KUBE_BURNER_TIMEOUT,
"-c",
"/root/api-intensive.yaml",
]
)

raised_exc = None
for iteration in range(iterations):
LOG.info("Staring kube-burner iteration %s of %s.", iteration, iterations)
try:
instance.exec(
[
"/root/kube-burner",
"init",
"--timeout",
config.KUBE_BURNER_TIMEOUT,
"-c",
"/root/api-intensive.yaml",
]
)
except Exception as ex:
# We'll continue the loop even after encountering failures
# in order to determine if this is a transient failure or if the
# dqlite service was completely compromised (e.g. deadlock or crash).
LOG.exception("kube-burner job failed, continuing...")
raised_exc = ex

# Raise encountered exceptions, if any.
if raised_exc:
raise raised_exc

0 comments on commit b7cb056

Please sign in to comment.