Skip to content

Commit

Permalink
chore: Recognize exit status in regression tests (#2571)
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Gershman <[email protected]>
  • Loading branch information
romange authored Feb 12, 2024
1 parent 8ead569 commit 24fcf8d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions tests/dragonfly/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
from dataclasses import dataclass
from typing import Dict, Optional, List, Union
import os
import re
import psutil
import itertools
Expand Down Expand Up @@ -162,6 +163,15 @@ def stop(self, kill=False):
if proc is None:
return

# if we have log files, it means that we started a process.
# if it died before we could stop it, we should raise an exception
if self.log_files:
exitcode = proc.poll()
if exitcode is not None:
if exitcode != 0:
raise Exception(f"Process exited with code {exitcode}")
return

logging.debug(f"Stopping instance on {self._port}")
try:
if kill:
Expand Down Expand Up @@ -193,9 +203,11 @@ def _start(self):
self._port = None

all_args = self.format_args(self.args)
logging.debug(f"Starting instance with arguments {all_args} from {self.params.path}")
arg_str = " ".join(all_args)
bin_path = os.path.realpath(self.params.path)
logging.debug(f"Starting {bin_path} with arguments: {arg_str}")

run_cmd = [self.params.path, *all_args]
run_cmd = [bin_path, *all_args]
if self.params.gdb:
run_cmd = ["gdb", "--ex", "r", "--args"] + run_cmd

Expand Down Expand Up @@ -319,7 +331,7 @@ def create(self, existing_port=None, **kwargs) -> DflyInstance:
args = {**self.args, **kwargs}
args.setdefault("dbfilename", "")
vmod = "dragonfly_connection=1,accept_server=1,listener_interface=1,main_service=1,rdb_save=1,replica=1"
# args.setdefault("vmodule", vmod)
args.setdefault("vmodule", vmod)

for k, v in args.items():
args[k] = v.format(**self.params.env) if isinstance(v, str) else v
Expand Down

0 comments on commit 24fcf8d

Please sign in to comment.