Skip to content

Commit d78a92b

Browse files
committed
implement review suggestions
1 parent 5c2669c commit d78a92b

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

airbyte-ci/connectors/live-tests/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Options:
3333
-o, --output-directory DIRECTORY
3434
Directory in which connector output and test
3535
results should be stored.
36+
Defaults to the current directory.
3637
--config-path FILE Path to the connector config.
3738
--catalog-path FILE Path to the connector catalog.
3839
--state-path FILE Path to the connector state.

airbyte-ci/connectors/live-tests/src/live_tests/commons/connector_runner.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ class ConnectorRunner:
121121
IN_CONTAINER_CONFIG_PATH = "/data/config.json"
122122
IN_CONTAINER_CATALOG_PATH = "/data/catalog.json"
123123
IN_CONTAINER_STATE_PATH = "/data/state.json"
124-
BASE_IN_CONTAINER_OUTPUT_DIRECTORY = "/tmp"
125-
IN_CONTAINER_OUTPUT_PATH = f"{BASE_IN_CONTAINER_OUTPUT_DIRECTORY}/raw_output.txt"
126-
RELATIVE_ERRORS_PATH = "errors.txt"
127124
MITMPROXY_IMAGE = "mitmproxy/mitmproxy:9.0.1"
128125
HTTP_DUMP_FILE_NAME = "http_dump.mitm"
129126

@@ -146,13 +143,13 @@ def __init__(
146143
self.state = state
147144
self.environment_variables = environment_variables if environment_variables else {}
148145
self.enable_http_cache = enable_http_cache
149-
self.full_command: List[str] = self.get_full_command(command)
146+
self.full_command: List[str] = self._get_full_command(command)
150147

151148
@property
152149
def _connector_under_test_container(self) -> dagger.Container:
153150
return self.connector_under_test.container
154151

155-
def get_full_command(self, command: Command):
152+
def _get_full_command(self, command: Command):
156153
if command is Command.SPEC:
157154
return ["spec"]
158155
elif command is Command.CHECK:
@@ -206,33 +203,33 @@ async def run(
206203
if self.catalog:
207204
container = container.with_new_file(self.IN_CONTAINER_CATALOG_PATH, contents=self.catalog.json())
208205
if self.enable_http_cache:
209-
container = await self.bind_connector_container_to_proxy(container)
206+
container = await self._bind_connector_container_to_proxy(container)
210207
executed_container = await container.with_exec(self.full_command).sync()
211208

212209
return ExecutionResult(
213210
stdout=await executed_container.stdout(),
214211
stderr=await executed_container.stderr(),
215212
executed_container=executed_container,
216-
http_dump=await self.retrieve_http_dump() if self.enable_http_cache else None,
213+
http_dump=await self._retrieve_http_dump() if self.enable_http_cache else None,
217214
)
218215

219-
def get_http_dumps_cache_volume(self) -> dagger.CacheVolume:
216+
def _get_http_dumps_cache_volume(self) -> dagger.CacheVolume:
220217
config_data = self.config.data if self.config else None
221218
proxy_cache_key = hashlib.md5((self.connector_under_test.name + str(config_data)).encode("utf-8")).hexdigest()
222219
return self.dagger_client.cache_volume(f"{self.MITMPROXY_IMAGE}{proxy_cache_key}")
223220

224-
def get_mitmproxy_dir_cache(self) -> dagger.CacheVolume:
221+
def _get_mitmproxy_dir_cache(self) -> dagger.CacheVolume:
225222
return self.dagger_client.cache_volume(self.MITMPROXY_IMAGE)
226223

227-
async def get_proxy_container(
224+
async def _get_proxy_container(
228225
self,
229226
) -> dagger.Container:
230227
proxy_container = (
231228
self.dagger_client.container()
232229
.from_(self.MITMPROXY_IMAGE)
233230
.with_exec(["mkdir", "-p", "/home/mitmproxy/.mitmproxy"], skip_entrypoint=True)
234-
.with_mounted_cache("/dumps", self.get_http_dumps_cache_volume())
235-
.with_mounted_cache("/home/mitmproxy/.mitmproxy", self.get_mitmproxy_dir_cache())
231+
.with_mounted_cache("/dumps", self._get_http_dumps_cache_volume())
232+
.with_mounted_cache("/home/mitmproxy/.mitmproxy", self._get_mitmproxy_dir_cache())
236233
)
237234
previous_dump_files = (
238235
await proxy_container.with_env_variable("CACHEBUSTER", str(uuid.uuid4()))
@@ -254,16 +251,16 @@ async def get_proxy_container(
254251

255252
return proxy_container.with_exec(command)
256253

257-
async def bind_connector_container_to_proxy(self, container: dagger.Container):
258-
proxy_srv = await self.get_proxy_container()
254+
async def _bind_connector_container_to_proxy(self, container: dagger.Container):
255+
proxy_srv = await self._get_proxy_container()
259256
proxy_host, proxy_port = "proxy_server", 8080
260257
cert_path_in_volume = "/mitmproxy_dir/mitmproxy-ca.pem"
261258
requests_cert_path = "/usr/local/lib/python3.9/site-packages/certifi/cacert.pem"
262259
ca_certificate_path = "/usr/local/share/ca-certificates/mitmproxy.crt"
263260

264261
return (
265262
container.with_service_binding(proxy_host, proxy_srv.with_exposed_port(proxy_port).as_service())
266-
.with_mounted_cache("/mitmproxy_dir", self.get_mitmproxy_dir_cache())
263+
.with_mounted_cache("/mitmproxy_dir", self._get_mitmproxy_dir_cache())
267264
.with_exec(["cp", cert_path_in_volume, requests_cert_path], skip_entrypoint=True)
268265
.with_exec(["cp", cert_path_in_volume, ca_certificate_path], skip_entrypoint=True)
269266
.with_env_variable("REQUESTS_CA_BUNDLE", requests_cert_path)
@@ -272,11 +269,11 @@ async def bind_connector_container_to_proxy(self, container: dagger.Container):
272269
.with_env_variable("https_proxy", f"{proxy_host}:{proxy_port}")
273270
)
274271

275-
async def retrieve_http_dump(self) -> dagger.File:
272+
async def _retrieve_http_dump(self) -> dagger.File:
276273
return await (
277274
self.dagger_client.container()
278275
.from_("alpine:latest")
279-
.with_mounted_cache("/dumps", self.get_http_dumps_cache_volume())
276+
.with_mounted_cache("/dumps", self._get_http_dumps_cache_volume())
280277
.with_exec(["mkdir", "/to_export"])
281278
.with_exec(
282279
[
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
22

33
import dagger
4+
import os
45
import sys
56

6-
DAGGER_EXEC_TIMEOUT = dagger.Timeout(60 * 60) # One hour
7+
DAGGER_EXEC_TIMEOUT = dagger.Timeout(int(os.environ.get("DAGGER_EXEC_TIMEOUT", "3600"))) # One hour by default
78
DAGGER_CONFIG = dagger.Config(timeout=DAGGER_EXEC_TIMEOUT, log_output=sys.stderr)

airbyte-ci/connectors/live-tests/src/live_tests/debug/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@click.option(
3535
"-o",
3636
"--output-directory",
37-
help="Directory in which connector output and test results should be stored.",
37+
help="Directory in which connector output and test results should be stored. Defaults to the current directory.",
3838
default=Path("live_tests_debug_reports"),
3939
type=click.Path(file_okay=False, dir_okay=True, resolve_path=True, path_type=Path),
4040
)

0 commit comments

Comments
 (0)