Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
[Fetch Migration] Changes to fetch_orchestrator to assume local Data …
Browse files Browse the repository at this point in the history
…Prepper process

Instead of accepting a Data Prepper URL endpoint as a parameter, fetch_orchestrator now accepts assumes a localhost endpoint and accepts both a “port” parameter (default 4900) and an “insecure” flag (default False) and constructs the URI via a helper method.

Signed-off-by: Kartik Ganesh <[email protected]>
  • Loading branch information
kartg committed Nov 9, 2023
1 parent 717c236 commit 7a44b65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
21 changes: 17 additions & 4 deletions FetchMigration/python/fetch_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def __get_env_string(name: str) -> Optional[str]:
return None


def get_local_endpoint(port: int = 4900, is_insecure: bool = False) -> str:
protocol = "https"
if is_insecure:
protocol = "http"
return protocol + "://localhost:" + str(port)


def update_target_host(dp_config: dict, target_host: str):
# Inline target host only supports HTTPS, so force it
target_with_protocol = target_host
Expand Down Expand Up @@ -108,13 +115,19 @@ def run(dp_base_path: str, dp_config_file: str, dp_endpoint: str) -> Optional[in
"pipeline_file_path",
help="Path to the Data Prepper pipeline YAML file to parse for source and target endpoint information"
)
# Optional positional argument
arg_parser.add_argument(
"data_prepper_endpoint",
help="Data Prepper endpoint for monitoring the migration"
"port", type=int,
nargs='?', default=4900,
help="Local port at which the Data Prepper process will expose its APIs"
)
# Flags
arg_parser.add_argument("--insecure", "-k", action="store_true",
help="Specifies that the local Data Prepper process is not using SSL")
cli_args = arg_parser.parse_args()
base_path = os.path.expandvars(cli_args.data_prepper_path)
return_code = run(base_path, os.path.expandvars(cli_args.pipeline_file_path), cli_args.data_prepper_endpoint)
data_prepper_endpoint = get_local_endpoint(cli_args.port, cli_args.insecure)
return_code = run(os.path.expandvars(cli_args.data_prepper_path), os.path.expandvars(cli_args.pipeline_file_path),
data_prepper_endpoint)
if return_code == 0:
sys.exit(0)
else:
Expand Down
8 changes: 7 additions & 1 deletion FetchMigration/python/tests/test_fetch_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,15 @@ def test_update_target_host_bad_config(self):
for config in bad_configs:
original = copy.deepcopy(config)
orchestrator.update_target_host(config, "host")
# Bad configs shoudl result in no change
# Bad configs should result in no change
self.assertEqual(config, original)

def test_get_local_endpoint(self):
# Default value for insecure flag (secure endpoint)
self.assertEqual("https://localhost:123", orchestrator.get_local_endpoint(123))
# insecure endpoint
self.assertEqual("http://localhost:123", orchestrator.get_local_endpoint(123, True))


if __name__ == '__main__':
unittest.main()

0 comments on commit 7a44b65

Please sign in to comment.