Skip to content

Commit

Permalink
Merge pull request #1844 from rootfs/stresser
Browse files Browse the repository at this point in the history
chore: fix wrong stressor init in validator
  • Loading branch information
KaiyiLiu1234 authored Nov 14, 2024
2 parents eba0372 + 360d1aa commit 15ddff2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 5 additions & 1 deletion e2e/tools/validator/src/validator/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,11 @@ def stress(cfg: config.Validator, script_path: str, report_dir: str):

click.secho(" * Running stress test ...", fg="green")
remote = Remote(cfg.remote)
stress_test = remote.run_script(script_path)
total_runtime_seconds = cfg.stressor.total_runtime_seconds
curve_type = cfg.stressor.curve_type
stress_test = remote.run_script(
script_path=script_path, target_script="/tmp/stress.sh", t=total_runtime_seconds, c=curve_type
)
res.start_time = stress_test.start_time
res.end_time = stress_test.end_time

Expand Down
11 changes: 3 additions & 8 deletions e2e/tools/validator/src/validator/stresser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def __init__(self, config: config.Remote):
self.user = config.user
self.port = config.port
self.password = config.password
self.total_runtime_seconds = config.total_runtime_seconds
self.curve_type = config.curve_type

self.ssh_client = paramiko.SSHClient()
self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
Expand Down Expand Up @@ -65,16 +63,13 @@ def copy(self, script_path, target_script):
self.ssh_client.exec_command(f"chmod +x {target_script}")
logger.info("copying script %s to remote - %s - successful", script_path, target_script)

def run_script(self, script_path: str) -> ScriptResult:
def run_script(self, script_path: str, target_script: str, **kwargs) -> ScriptResult:
self.connect()
logger.info("Running script %s ...", script_path)

# ruff: noqa: S108 (Suppressed hard-coded path because we want to intentionally copy stress.sh inside `/tmp` dir)
target_script = "/tmp/stress.sh"
cli_options = f"-t {self.total_runtime_seconds} -c {self.curve_type}"
cli_options = " ".join([f"-{k} {v}" for k, v in kwargs.items()]) if kwargs else ""
command = f"{target_script} {cli_options}"
self.copy(script_path, target_script)

logger.info("Running command %s ...", command)
# ruff: noqa: DTZ005 (Suppressed non-time-zone aware object creation as it is not necessary for this use case)
start_time = datetime.now()
_, stdout, stderr = self.ssh_client.exec_command(command)
Expand Down
3 changes: 0 additions & 3 deletions e2e/tools/validator/validations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ config:
mapping:
actual: metal
predicted: vm
stressor:
total_runtime_seconds: 1200
curve_type: default

validations:
- name: node-rapl - kepler-package
Expand Down
4 changes: 4 additions & 0 deletions e2e/tools/validator/validator.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ prometheus:
rate_interval: 20s # Rate interval for Promql, default is 20s, typically 4 x $scrape_interval
steps: 3s # Step duration for Prometheus range queries

stressor:
total_runtime_seconds: 1200
curve_type: default

validations_file: ./validations.yaml # Path to the validations file, default is ./validations.yaml

0 comments on commit 15ddff2

Please sign in to comment.