Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: enable load test #821

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ jobs:
sudo chmod a+x neofs-s3-gw
working-directory: neofs-testcases

- name: Checkout xk6-neofs repository
roman-khimov marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/checkout@v4
with:
repository: nspcc-dev/xk6-neofs
ref: master
path: xk6-neofs

- name: Build xk6-neofs
timeout-minutes: 5
run: |
make install_xk6
make build
working-directory: xk6-neofs

- name: Prepare venv
id: prepare_venv
timeout-minutes: 30
Expand Down
82 changes: 82 additions & 0 deletions neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import pickle
import random
import shutil
import socket
import stat
import string
Expand Down Expand Up @@ -865,3 +866,84 @@ def _launch_process(self):
stderr=stderr_fp,
env=rest_gw_env,
)


class XK6:
def __init__(self, neofs_env: NeoFSEnv):
self.neofs_env = neofs_env
self.xk6_dir = os.getenv("XK6_DIR", "../xk6-neofs")
self.wallet = NodeWallet(
path=NeoFSEnv._generate_temp_file(prefix="xk6_wallet"),
address="",
password=self.neofs_env.default_password,
)
self.neofs_env.generate_storage_wallet(self.wallet, label="xk6")
self.config = neofs_env.generate_cli_config(self.wallet)

@allure.step("Run K6 Loader")
def run(
self,
endpoints: list[str],
out="grpc.json",
duration=30,
write_obj_size=8192,
readers=2,
writers=2,
registry_file="registry.bolt",
scenario="grpc.js",
):
if not os.path.exists(self.xk6_dir):
raise RuntimeError("Invalid xk6 directory")
command = (
f"{self.xk6_dir}/xk6-neofs "
f"run "
f"-e DURATION={duration} "
f"-e WRITE_OBJ_SIZE={write_obj_size} "
f"-e READERS={readers} "
f"-e WRITERS={writers} "
f"-e REGISTRY_FILE={registry_file} "
f"-e GRPC_ENDPOINTS={endpoints[0]} "
f"-e PREGEN_JSON={out} "
f"{self.xk6_dir}/scenarios/{scenario} "
)
result = self.neofs_env.shell.exec(command)
assert not result.return_code, "RC after k6 load is not zero"
assert "neofs_obj_get_fails" not in result.stdout, "some GET requests failed, see logs"
assert "neofs_obj_put_fails" not in result.stdout, "some PUT requests failed, see logs"

@allure.step("Prepare containers and objects for k6 load run")
def prepare(
self,
endpoints: list[str],
size=1024,
containers=1,
out="grpc.json",
preload_obj=250,
policy="REP 2 IN X CBF 1 SELECT 2 FROM * AS X",
workers=2,
):
if not os.path.exists(self.xk6_dir):
raise RuntimeError("Invalid xk6 directory")

command = (
f"{self.xk6_dir}/scenarios/preset/preset_grpc.py "
f"--size {size} "
f"--containers {containers} "
f"--out {out} "
f"--endpoint {endpoints[0]} "
f"--preload_obj {preload_obj} "
f'--policy "{policy}" '
f"--wallet {self.wallet.path} "
f"--config {self.config} "
f"--workers {workers} "
)
result = self.neofs_env.shell.exec(command)
assert not result.return_code, "RC after k6 prepare script is not zero"
assert (
f"Total Containers has been created: {containers}" in result.stdout
), "Prepare script didn't create requested containers"
assert (
f"Total Objects has been created: {preload_obj}" in result.stdout
), "Prepare script didn't create requested objects"

shutil.copy(out, os.path.join(self.xk6_dir, "scenarios"))
1 change: 1 addition & 0 deletions neofs-testlib/neofs_testlib/env/templates/network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ storage:
s3: {{ default_password }}
http: {{ default_password }}
rest: {{ default_password }}
xk6: {{ default_password }}
Loading
Loading