diff --git a/acto/checker/checker_set.py b/acto/checker/checker_set.py index aebf6da607..52a7167569 100644 --- a/acto/checker/checker_set.py +++ b/acto/checker/checker_set.py @@ -7,7 +7,7 @@ from acto.checker.impl.health import HealthChecker from acto.checker.impl.operator_log import OperatorLogChecker from acto.common import flatten_dict -from acto.input import InputModel +from acto.input.input import InputModel from acto.oracle_handle import OracleHandle from acto.result import OracleResults from acto.snapshot import Snapshot diff --git a/acto/checker/impl/consistency.py b/acto/checker/impl/consistency.py index 3e3335063e..8adb25ab4a 100644 --- a/acto/checker/impl/consistency.py +++ b/acto/checker/impl/consistency.py @@ -19,8 +19,8 @@ invalid_input_message, is_subfield, ) -from acto.input import InputModel from acto.input.get_matched_schemas import find_matched_schema +from acto.input.input import InputModel from acto.input.property_attribute import PropertyAttribute from acto.k8s_util.k8sutil import canonicalize_quantity from acto.result import ConsistencyOracleResult, InvalidInputResult diff --git a/acto/checker/impl/tests/test_state.py b/acto/checker/impl/tests/test_state.py index fc7bcc2f39..fa562de08c 100644 --- a/acto/checker/impl/tests/test_state.py +++ b/acto/checker/impl/tests/test_state.py @@ -11,7 +11,7 @@ from acto.checker.impl.consistency import ConsistencyChecker from acto.checker.impl.tests import load_snapshot from acto.common import Diff, PropertyPath -from acto.input import DeterministicInputModel +from acto.input.input import DeterministicInputModel from acto.result import ( ConsistencyOracleResult, InvalidInputResult, diff --git a/acto/engine.py b/acto/engine.py index 7ebaa80d5e..665b877865 100644 --- a/acto/engine.py +++ b/acto/engine.py @@ -21,8 +21,7 @@ from acto.common import kubernetes_client, print_event from acto.constant import CONST from acto.deploy import Deploy -from acto.input import InputModel -from acto.input.input import DeterministicInputModel +from acto.input.input import DeterministicInputModel, InputModel from acto.input.testcase import TestCase from acto.input.testplan import TestGroup from acto.input.value_with_schema import ValueWithSchema, attach_schema_to_value diff --git a/acto/input/__init__.py b/acto/input/__init__.py index f5c2d4db26..e69de29bb2 100644 --- a/acto/input/__init__.py +++ b/acto/input/__init__.py @@ -1,2 +0,0 @@ -from .input import DeterministicInputModel, InputModel -from .testcase import TestCase diff --git a/acto/reproduce.py b/acto/reproduce.py index 43557c49df..9544ad21a1 100644 --- a/acto/reproduce.py +++ b/acto/reproduce.py @@ -13,8 +13,8 @@ from acto import DEFAULT_KUBERNETES_VERSION from acto.engine import Acto -from acto.input import TestCase from acto.input.input import DeterministicInputModel +from acto.input.testcase import TestCase from acto.input.testplan import TestGroup from acto.input.value_with_schema import ValueWithSchema from acto.input.valuegenerator import extract_schema_with_value_generator diff --git a/acto/schema/object.py b/acto/schema/object.py index f7b70fef7c..664c76ffb0 100644 --- a/acto/schema/object.py +++ b/acto/schema/object.py @@ -31,12 +31,8 @@ def __init__(self, path: list, schema: dict) -> None: self.properties: dict[str, BaseSchema] = {} self.additional_properties = None self.required = [] - logger = get_thread_logger(with_prefix=True) if "properties" not in schema and "additionalProperties" not in schema: - logger.warning( - "Object schema %s does not have properties nor additionalProperties", - self.path, - ) + return if "properties" in schema: for property_key, property_schema in schema["properties"].items(): self.properties[property_key] = extract_schema( diff --git a/acto/serialization.py b/acto/serialization.py index 5756f84794..b0f1b4d01b 100644 --- a/acto/serialization.py +++ b/acto/serialization.py @@ -9,7 +9,7 @@ from deepdiff.helper import NotPresent from acto.common import Diff, PropertyPath -from acto.input import TestCase +from acto.input.testcase import TestCase def _serialize_decimal(value: decimal.Decimal): diff --git a/test/integration_tests/test_cassop_bugs.py b/test/integration_tests/test_cassop_bugs.py index 28fc525a0a..db97c86674 100644 --- a/test/integration_tests/test_cassop_bugs.py +++ b/test/integration_tests/test_cassop_bugs.py @@ -1,4 +1,5 @@ """Integration tests for cass-operator bugs.""" + import json import os import pathlib @@ -8,7 +9,7 @@ from acto import acto_config from acto.checker.checker_set import CheckerSet -from acto.input import DeterministicInputModel, InputModel +from acto.input.input import DeterministicInputModel, InputModel from acto.lib.operator_config import OperatorConfig from acto.post_process.post_diff_test import DiffTestResult, PostDiffTest from acto.snapshot import Snapshot diff --git a/test/integration_tests/test_crdb_bugs.py b/test/integration_tests/test_crdb_bugs.py index a1ff260058..310019056a 100644 --- a/test/integration_tests/test_crdb_bugs.py +++ b/test/integration_tests/test_crdb_bugs.py @@ -1,4 +1,5 @@ """Integration tests for cockroach-operator bugs.""" + import json import os import pathlib @@ -8,7 +9,7 @@ from acto import acto_config from acto.checker.checker_set import CheckerSet -from acto.input import DeterministicInputModel, InputModel +from acto.input.input import DeterministicInputModel, InputModel from acto.lib.operator_config import OperatorConfig from acto.snapshot import Snapshot diff --git a/test/integration_tests/test_learn.py b/test/integration_tests/test_learn.py new file mode 100644 index 0000000000..317c026256 --- /dev/null +++ b/test/integration_tests/test_learn.py @@ -0,0 +1,52 @@ +import json +import os +import pathlib +import unittest +from datetime import datetime + +from acto.engine import Acto, apply_testcase +from acto.input.input import DeterministicInputModel +from acto.lib.operator_config import OperatorConfig + +test_dir = pathlib.Path(__file__).parent.resolve() +test_data_dir = os.path.join(test_dir, "test_data") + + +class TestLearnPhase(unittest.TestCase): + """Integration tests for Acto's learning phase.""" + + def test_statefulset_operator(self): + """Test statefulset operator.""" + workdir_path = f"testrun-{datetime.now().strftime('%Y-%m-%d-%H-%M')}" + os.makedirs(workdir_path, exist_ok=True) + + config_path = os.path.join( + test_data_dir, "elastic-on-k8s", "config.json" + ) + with open(config_path, "r", encoding="utf-8") as config_file: + config = json.load(config_file) + if "monkey_patch" in config: + del config["monkey_patch"] + config = OperatorConfig.model_validate(config) + + context_cache = os.path.join( + os.path.dirname(config.seed_custom_resource), "context.json" + ) + + Acto( + workdir_path=workdir_path, + operator_config=config, + cluster_runtime="KIND", + preload_images_=None, + context_file=context_cache, + helper_crd=None, + num_workers=1, + num_cases=1, + dryrun=False, + analysis_only=False, + is_reproduce=False, + input_model=DeterministicInputModel, + apply_testcase_f=apply_testcase, + delta_from=None, + focus_fields=config.focus_fields, + ) diff --git a/test/integration_tests/test_rbop_bugs.py b/test/integration_tests/test_rbop_bugs.py index 7152e6a019..db5a4fe69c 100644 --- a/test/integration_tests/test_rbop_bugs.py +++ b/test/integration_tests/test_rbop_bugs.py @@ -9,7 +9,7 @@ from acto import acto_config from acto.checker.checker_set import CheckerSet -from acto.input import DeterministicInputModel, InputModel +from acto.input.input import DeterministicInputModel, InputModel from acto.lib.operator_config import OperatorConfig from acto.snapshot import Snapshot