Skip to content

Commit

Permalink
Remove imports from Input module to prevent circular dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Feb 22, 2024
1 parent bd2c516 commit ee8b2e9
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 17 deletions.
2 changes: 1 addition & 1 deletion acto/checker/checker_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion acto/checker/impl/consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion acto/checker/impl/tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions acto/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions acto/input/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from .input import DeterministicInputModel, InputModel
from .testcase import TestCase
2 changes: 1 addition & 1 deletion acto/reproduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions acto/schema/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion acto/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion test/integration_tests/test_cassop_bugs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Integration tests for cass-operator bugs."""

import json
import os
import pathlib
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/integration_tests/test_crdb_bugs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Integration tests for cockroach-operator bugs."""

import json
import os
import pathlib
Expand All @@ -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

Expand Down
52 changes: 52 additions & 0 deletions test/integration_tests/test_learn.py
Original file line number Diff line number Diff line change
@@ -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,
)
2 changes: 1 addition & 1 deletion test/integration_tests/test_rbop_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ee8b2e9

Please sign in to comment.