diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/environment.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/environment.py index 27ac6c269b..8525b26ae2 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/environment.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/environment.py @@ -14,10 +14,10 @@ logger = logging.getLogger(__name__) -def get_snapshot(config: Dict, source_cluster: Cluster, target_cluster: Cluster): +def get_snapshot(config: Dict, source_cluster: Cluster): if 'fs' in config: - return FileSystemSnapshot(config, source_cluster, target_cluster) - return S3Snapshot(config, source_cluster, target_cluster) + return FileSystemSnapshot(config, source_cluster) + return S3Snapshot(config, source_cluster) SCHEMA = { diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py index b86aa56d4a..b4be116e2f 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/snapshot.py @@ -50,10 +50,9 @@ class Snapshot(ABC): """ Interface for creating and managing snapshots. """ - def __init__(self, config: Dict, source_cluster: Cluster, target_cluster: Optional[Cluster] = None) -> None: + def __init__(self, config: Dict, source_cluster: Cluster) -> None: self.config = config self.source_cluster = source_cluster - self.target_cluster = target_cluster v = Validator(SNAPSHOT_SCHEMA) if not v.validate({'snapshot': config}): raise ValueError("Invalid config file for snapshot", v.errors) @@ -77,19 +76,17 @@ def status(self, *args, **kwargs) -> CommandResult: class S3Snapshot(Snapshot): - def __init__(self, config: Dict, source_cluster: Cluster, target_cluster: Cluster) -> None: - super().__init__(config, source_cluster, target_cluster) + def __init__(self, config: Dict, source_cluster: Cluster) -> None: + super().__init__(config, source_cluster) self.snapshot_name = config['snapshot_name'] self.s3_repo_uri = config['s3']['repo_uri'] self.s3_region = config['s3']['aws_region'] def create(self, *args, **kwargs) -> CommandResult: - assert isinstance(self.target_cluster, Cluster) + assert isinstance(self.source_cluster, Cluster) if self.source_cluster.auth_type != AuthMethod.NO_AUTH: raise NotImplementedError("Source cluster authentication is not supported for creating snapshots") - if self.target_cluster.auth_type != AuthMethod.NO_AUTH: - raise NotImplementedError("Target cluster authentication is not supported for creating snapshots") wait = kwargs.get('wait', False) max_snapshot_rate_mb_per_node = kwargs.get('max_snapshot_rate_mb_per_node') command = [ @@ -102,8 +99,6 @@ def create(self, *args, **kwargs) -> CommandResult: if self.source_cluster.allow_insecure: command.append("--source-insecure") - if self.target_cluster.allow_insecure: - command.append("--target-insecure") if not wait: command.append("--no-wait") if max_snapshot_rate_mb_per_node is not None: @@ -125,20 +120,17 @@ def status(self, *args, **kwargs) -> CommandResult: class FileSystemSnapshot(Snapshot): - def __init__(self, config: Dict, source_cluster: Cluster, target_cluster: Cluster) -> None: - super().__init__(config, source_cluster, target_cluster) + def __init__(self, config: Dict, source_cluster: Cluster) -> None: + super().__init__(config, source_cluster) self.snapshot_name = config['snapshot_name'] self.repo_path = config['fs']['repo_path'] def create(self, *args, **kwargs) -> CommandResult: - assert isinstance(self.target_cluster, Cluster) + assert isinstance(self.source_cluster, Cluster) if self.source_cluster.auth_type != AuthMethod.NO_AUTH: raise NotImplementedError("Source cluster authentication is not supported for creating snapshots") - if self.target_cluster.auth_type != AuthMethod.NO_AUTH: - raise NotImplementedError("Target cluster authentication is not supported for creating snapshots") - command = [ "/root/createSnapshot/bin/CreateSnapshot", "--snapshot-name", self.snapshot_name, diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metadata.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metadata.py index 003f385de1..c67cf5342c 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metadata.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_metadata.py @@ -14,8 +14,7 @@ def s3_snapshot(): "aws_region": "us-east-1" } } - return S3Snapshot(snapshot_config, create_valid_cluster(auth_type=AuthMethod.NO_AUTH), - create_valid_cluster(auth_type=AuthMethod.NO_AUTH)) + return S3Snapshot(snapshot_config, create_valid_cluster(auth_type=AuthMethod.NO_AUTH)) @pytest.fixture() @@ -26,8 +25,7 @@ def fs_snapshot(): "repo_path": "/path/for/repo" } } - return FileSystemSnapshot(snapshot_config, create_valid_cluster(auth_type=AuthMethod.NO_AUTH), - create_valid_cluster(auth_type=AuthMethod.NO_AUTH)) + return FileSystemSnapshot(snapshot_config, create_valid_cluster(auth_type=AuthMethod.NO_AUTH)) def test_metadata_init_with_fully_specified_config_succeeds(): diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_snapshot.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_snapshot.py index 5e8fe63d97..123cf0f585 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_snapshot.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_snapshot.py @@ -15,7 +15,7 @@ def test_s3_snapshot_init_succeeds(): }, } } - snapshot = S3Snapshot(config['snapshot'], create_valid_cluster(), create_valid_cluster()) + snapshot = S3Snapshot(config['snapshot'], create_valid_cluster()) assert isinstance(snapshot, Snapshot) @@ -113,7 +113,7 @@ def test_fs_snapshot_create_calls_subprocess_run_with_correct_args(mocker): "--snapshot-name", config["snapshot"]["snapshot_name"], "--file-system-repo-path", config["snapshot"]["fs"]["repo_path"], "--source-host", source.endpoint, - "--source-insecure", "--target-insecure"], + "--source-insecure"], stdout=None, stderr=None, text=True, check=True) @@ -128,7 +128,7 @@ def test_s3_snapshot_create_calls_subprocess_run_with_correct_args(mocker): } } source = create_valid_cluster(auth_type=AuthMethod.NO_AUTH) - snapshot = S3Snapshot(config["snapshot"], source, create_valid_cluster(auth_type=AuthMethod.NO_AUTH)) + snapshot = S3Snapshot(config["snapshot"], source) mock = mocker.patch("subprocess.run") snapshot.create() @@ -138,13 +138,12 @@ def test_s3_snapshot_create_calls_subprocess_run_with_correct_args(mocker): "--s3-repo-uri", config["snapshot"]["s3"]["repo_uri"], "--s3-region", config["snapshot"]["s3"]["aws_region"], "--source-host", source.endpoint, - "--source-insecure", "--target-insecure"], + "--source-insecure", "--no-wait"], stdout=None, stderr=None, text=True, check=True) -@pytest.mark.parametrize("source_auth,target_auth", [(AuthMethod.NO_AUTH, AuthMethod.BASIC_AUTH), - (AuthMethod.BASIC_AUTH, AuthMethod.NO_AUTH)]) -def test_s3_snapshot_create_fails_for_clusters_with_auth(source_auth, target_auth): +@pytest.mark.parametrize("source_auth", [(AuthMethod.BASIC_AUTH)]) +def test_s3_snapshot_create_fails_for_clusters_with_auth(source_auth): config = { "snapshot": { "snapshot_name": "reindex_from_snapshot", @@ -154,16 +153,14 @@ def test_s3_snapshot_create_fails_for_clusters_with_auth(source_auth, target_aut }, } } - snapshot = S3Snapshot(config["snapshot"], create_valid_cluster(auth_type=source_auth), - create_valid_cluster(auth_type=target_auth)) + snapshot = S3Snapshot(config["snapshot"], create_valid_cluster(auth_type=source_auth)) with pytest.raises(NotImplementedError) as excinfo: snapshot.create() assert "authentication is not supported" in str(excinfo.value.args[0]) -@pytest.mark.parametrize("source_auth,target_auth", [(AuthMethod.NO_AUTH, AuthMethod.BASIC_AUTH), - (AuthMethod.BASIC_AUTH, AuthMethod.NO_AUTH)]) -def test_fs_snapshot_create_fails_for_clusters_with_auth(source_auth, target_auth): +@pytest.mark.parametrize("source_auth", [(AuthMethod.BASIC_AUTH)]) +def test_fs_snapshot_create_fails_for_clusters_with_auth(source_auth): config = { "snapshot": { "snapshot_name": "reindex_from_snapshot", @@ -173,7 +170,6 @@ def test_fs_snapshot_create_fails_for_clusters_with_auth(source_auth, target_aut } } with pytest.raises(NotImplementedError) as excinfo: - snapshot = FileSystemSnapshot(config["snapshot"], create_valid_cluster(auth_type=source_auth), - create_valid_cluster(auth_type=target_auth)) + snapshot = FileSystemSnapshot(config["snapshot"], create_valid_cluster(auth_type=source_auth)) snapshot.create() assert "authentication is not supported" in str(excinfo.value.args[0])