Skip to content

Commit

Permalink
Refactor chactos
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Sep 25, 2024
1 parent c05a036 commit be887a0
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 319 deletions.
30 changes: 0 additions & 30 deletions acto/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
from acto.engine import Acto, apply_testcase
from acto.input.input import DeterministicInputModel
from acto.lib.operator_config import OperatorConfig
from chactos.fault_injection_config import FaultInjectionConfig
from acto.post_process.post_diff_test import PostDiffTest
from chactos.fault_injections import ChactosDriver
from acto.utils.error_handler import handle_excepthook, thread_excepthook
from acto.utils.thread_logger import get_thread_logger

Expand All @@ -38,14 +36,6 @@
help="Operator porting config path",
required=True,
)
parser.add_argument(
"--fault_injection_config",
"-fjc",
dest="fault_injection_config",
help="Operator porting fault injection config path",
required=False,
default="",
)
parser.add_argument(
"--cluster-runtime",
"-r",
Expand Down Expand Up @@ -131,15 +121,6 @@
del config["monkey_patch"]
config = OperatorConfig.model_validate(config)

if args.fault_injection_config != "":
with open(
args.fault_injection_config, "r", encoding="utf-8"
) as fault_injection_config_file:
fault_injection_config = json.load(fault_injection_config_file)
fault_injection_config = FaultInjectionConfig.model_validate(
fault_injection_config
)

logger.info("Acto started with [%s]", sys.argv)
logger.info("Operator config: %s", config)

Expand Down Expand Up @@ -183,16 +164,5 @@
p.post_process(post_diff_test_dir, num_workers=args.num_workers)
p.check(post_diff_test_dir, num_workers=args.num_workers)

# logger.info("Acto invokes Chactos for fault injection")

# chactos = ChactosDriver(
# testrun_dir=args.workdir_path,
# operator_config=config,
# fault_injection_config=fault_injection_config,
# context_file=context_cache,
# worker_id=0,
# )
# chactos.run()

end_time = datetime.now()
logger.info("Acto end to end finished in %s", end_time - start_time)
5 changes: 5 additions & 0 deletions acto/kubernetes_engine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,8 @@ def get_node_list(self, name: str):
# no nodes can be found, returning an empty array
return []
return p.stdout.strip().split("\n")

@staticmethod
def cluster_name(acto_namespace: int, worker_id: int) -> str:
"""Helper function to generate cluster name"""
return f"acto-{acto_namespace}-cluster-{worker_id}"
33 changes: 28 additions & 5 deletions chactos/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import logging
from datetime import datetime

from chactos.fault_injection_config import FaultInjectionConfig
from chactos.fault_injections import ExperimentDriver
from lib.operator_config import OperatorConfig

from chactos.fault_injections import ChactosDriver

parser = argparse.ArgumentParser(
description="Automatic, Continuous Testing for k8s/openshift Operators"
Expand All @@ -20,9 +21,23 @@
"--config",
"-c",
dest="config",
help="Operator config path",
required=True,
)
parser.add_argument(
"--fi-config",
"-fic",
dest="fi_config",
help="Operator fault injection config path",
required=True,
)
parser.add_argument(
"--testrun-dir",
"-td",
dest="testrun_dir",
help="Testrun directory to load the inputs from",
required=True,
)
args = parser.parse_args()

logging.basicConfig(
Expand All @@ -33,9 +48,17 @@
logging.getLogger("sh").setLevel(logging.ERROR)

with open(args.config, "r", encoding="utf-8") as config_file:
config = json.load(config_file)
config_data = json.load(config_file)
operator_config = OperatorConfig.model_validate(config_data)

with open(args.fi_config, "r", encoding="utf-8") as fi_config_file:
fi_config_data = json.load(fi_config_file)
fi_config = OperatorConfig.model_validate(fi_config_data)

driver = ExperimentDriver(
operator_config=FaultInjectionConfig.model_validate(config), worker_id=0
driver = ChactosDriver(
testrun_dir=args.testrun_dir,
work_dir=args.workdir_path,
operator_config=operator_config,
fault_injection_config=fi_config,
)
driver.run()
Loading

0 comments on commit be887a0

Please sign in to comment.