-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance Test workload (2) (#199)
- Loading branch information
1 parent
1f9ffa3
commit 81298dd
Showing
14 changed files
with
298 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
global: | ||
writeToFile: true | ||
metricsDirectory: collected-metrics | ||
|
||
jobs: | ||
- name: api-intensive | ||
jobIterations: 100 | ||
qps: 500 | ||
burst: 500 | ||
namespacedIterations: true | ||
namespace: api-intensive | ||
podWait: false | ||
cleanup: true | ||
waitFor: [] | ||
waitWhenFinished: true | ||
objects: | ||
- objectTemplate: configmap.yaml | ||
replicas: 10 | ||
- objectTemplate: secret.yaml | ||
replicas: 10 | ||
- name: remove-configmaps-secrets | ||
qps: 100 | ||
burst: 100 | ||
jobType: delete | ||
objects: | ||
- kind: ConfigMap | ||
labelSelector: { kube-burner-job: api-intensive } | ||
- kind: Secret | ||
labelSelector: { kube-burner-job: api-intensive } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Contains the bootstrap configuration for the session instance of the integration tests. | ||
# The session instance persists over test runs and is used to speed-up the integration tests. | ||
cluster-config: | ||
network: | ||
enabled: true | ||
dns: | ||
enabled: true | ||
ingress: | ||
enabled: true | ||
load-balancer: | ||
enabled: true | ||
local-storage: | ||
enabled: true | ||
gateway: | ||
enabled: true | ||
metrics-server: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: configmap-{{.Replica}} | ||
data: | ||
data.yaml: |- | ||
a: 1 | ||
b: 2 | ||
c: 3 | ||
d: "ZviE5QVws2zuKJZMCSkRp0hqHGeP6GgqPRZ8B7l48EwGMhnRAjuNiDhjlpUlFM7comB1ipEEQNf69FeMFXEkSI9ukRVP559Ug497E7u8miZqBzuuo5oXw8zKH2WHz2OtP5uQDdm9x6G4Ki7Lwo84p0Yc82wEJPbJpM2SvO5ze0WOi3jHWqDbmkORhEF2RWBqfe3uzsABU7gi86n4VaFCuD2sFnwVsSjJWDm7psVoMpJWQbBRpzjKhnDHbYXjkobk9gTH7mFxImxGfoQsW716auNO0ATJ6C4SoTdZ1CUngjLD1bkBy35AbfzjIjQGxjrE2gJ0qeBKZo0uwYnAFraCYMZ6uhNQ6B1dO9bELze3TQiQv8CrC4bplhCth62E2lAz6Q095HFbOYKyUeFp0AArEN0LlIxW6JqwV4ssvA1LSt1HnnsYVc0yZO6kFuR5sNRuPxqc01AArNQ4BP9UudQdVagJ15MIcrGhBqpVFoSIdyK2w4eZQwLpZxpXdJCfdSdkJwWND42O07oVkbNt1kpKFJ8M3clYjpZlo5zkRjM90acXiVU7FNn5D6yQkureBO4y2AkYYVkj35VvijvY8VBkEveMiGU4ztsaOR7Px5UsvgPdgvZG2IOUYezfzcF5nyRVwYTQWFuXae3rGHOXi6j0KmAQix2xnezIMPGJSDQPROzbiPYhvtXo2TdAmhJd1DgEyi9lbLrwJ3rwCkZbKl9RsfxoihHnpWWH24wCKizJfSfcXmNR6Bvaj9G2Ldk7ppLBFpwMyxK8w4u3LrduvvRDaKcuQKwopnpRKG4njJMITRrynlprWBWyWaiclnNBxqtYCWYwbyqFwAjg8snkwqFmEhkYlp6kuzEEF8Naz0K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2WnVMNL3xxCzG4eX86Gb2iqFD631vLr0XfhsUBXrJBY1F1pX4M3qSWK93XAQt5DEPhvmdFU8PQgTu5Pj9AISDYAv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: secret-{{.Replica}} | ||
type: Opaque | ||
data: | ||
password: Zm9vb29vb29vb29vb29vbwo= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright 2024 Canonical, Ltd. | ||
# | ||
import logging | ||
|
||
from test_util import harness, metrics | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
def test_single_node_load(session_instance: harness.Instance): | ||
"""Test the performance of a single node cluster with all features enabled.""" | ||
metrics.configure_kube_burner(session_instance) | ||
process_dict = metrics.collect_metrics([session_instance]) | ||
metrics.run_kube_burner(session_instance) | ||
metrics.stop_metrics([session_instance], process_dict) | ||
metrics.pull_metrics([session_instance]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# | ||
# Copyright 2024 Canonical, Ltd. | ||
# | ||
from typing import List | ||
|
||
from test_util import config, harness, util | ||
|
||
|
||
def stop_metrics(instances: List[harness.Instance], process_dict: dict): | ||
"""Stops collecting metrics in the background from each instance.""" | ||
for instance in instances: | ||
process_dict[instance.id].kill() | ||
|
||
|
||
def collect_metrics(instances: List[harness.Instance]): | ||
""" | ||
Starts collecting metrics in the background from each instance. Returns a dictionary | ||
with the process object for each instance. | ||
""" | ||
process_dict = {} | ||
for instance in instances: | ||
pid = instance.exec( | ||
["pgrep", "k8s-dqlite"], text=True, capture_output=True | ||
).stdout.strip() | ||
util.stubbornly(retries=5, delay_s=3).on(instance).exec( | ||
["apt-get", "install", "-y", "sysstat"] | ||
) | ||
subprocess = instance.exec( | ||
[ | ||
"pidstat", | ||
"-druh", | ||
"-p", | ||
pid, | ||
"1", | ||
">", | ||
f"/root/{instance.id}_metrics.log", | ||
], | ||
background=True, | ||
) | ||
process_dict[instance.id] = subprocess | ||
return process_dict | ||
|
||
|
||
def pull_metrics(instances: List[harness.Instance]): | ||
"""Pulls metrics file from each instance to the local machine.""" | ||
for instance in instances: | ||
instance.pull_file( | ||
f"/root/{instance.id}_metrics.log", f"./{instance.id}_metrics.log" | ||
) | ||
|
||
|
||
def configure_kube_burner(instance: harness.Instance): | ||
"""Downloads and sets up `kube-burner` on each instance if it's not already present.""" | ||
if ( | ||
not instance.exec(["test", "-f", "/root/kube-burner"], check=False).returncode | ||
== 0 | ||
): | ||
url = config.KUBE_BURNER_URL | ||
instance.exec(["wget", url]) | ||
instance.exec( | ||
["tar", "-zxvf", "kube-burner-1.2-Linux-x86_64.tar.gz", "kube-burner"] | ||
) | ||
instance.exec(["rm", "kube-burner-1.2-Linux-x86_64.tar.gz"]) | ||
instance.exec(["chmod", "+x", "/root/kube-burner"]) | ||
|
||
instance.exec(["mkdir", "-p", "/root/templates"]) | ||
instance.send_file( | ||
(config.MANIFESTS_DIR / "api-intensive.yaml").as_posix(), | ||
"/root/api-intensive.yaml", | ||
) | ||
instance.send_file( | ||
(config.MANIFESTS_DIR / "secret.yaml").as_posix(), "/root/secret.yaml" | ||
) | ||
instance.send_file( | ||
(config.MANIFESTS_DIR / "configmap.yaml").as_posix(), "/root/configmap.yaml" | ||
) | ||
|
||
|
||
def run_kube_burner(instance: harness.Instance): | ||
"""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", "-c", "/root/api-intensive.yaml"]) |
Oops, something went wrong.