diff --git a/.github/workflows/aws-proxy.yml b/.github/workflows/aws-proxy.yml index 6827d298..150e2829 100644 --- a/.github/workflows/aws-proxy.yml +++ b/.github/workflows/aws-proxy.yml @@ -1,15 +1,17 @@ name: LocalStack AWS Proxy Extension Tests on: - push: - paths: - - aws-proxy/** - branches: - - main - pull_request: - paths: - - .github/workflows/aws-proxy.yml - - aws-proxy/** +# TODO: temporarily disabled - AWS proxy codebase needs to be fixed, to accommodate recent +# changes in CLI and runtime repos, see: https://github.com/localstack/localstack/pull/13704 +# push: +# paths: +# - aws-proxy/** +# branches: +# - main +# pull_request: +# paths: +# - .github/workflows/aws-proxy.yml +# - aws-proxy/** workflow_dispatch: jobs: diff --git a/README.md b/README.md index 123d77db..a138a81a 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,8 @@ You can install the respective extension by calling `localstack extensions insta | [Stripe](https://github.com/localstack/localstack-extensions/tree/main/stripe) | localstack-extension-stripe | 0.2.0 | Stable | | [Terraform Init](https://github.com/localstack/localstack-extensions/tree/main/terraform-init) | localstack-extension-terraform-init | 0.2.0 | Experimental | | [TypeDB](https://github.com/localstack/localstack-extensions/tree/main/typedb) | localstack-extension-typedb | 0.1.3 | Experimental | -| [ParadeDB](https://github.com/localstack/localstack-extensions/tree/main/paradedb) | localstack-extension-paradedb | 0.1.0 | Experimental | +| [WireMock](https://github.com/localstack/localstack-extensions/tree/main/wiremock) | localstack-wiremock | 0.1.0 | Experimental | +| [ParadeDB](https://github.com/localstack/localstack-extensions/tree/main/paradedb) | localstack-extension-paradedb | 0.1.0 | Experimental | ## Developing Extensions diff --git a/paradedb/localstack_paradedb/extension.py b/paradedb/localstack_paradedb/extension.py index 4732787c..a666bdbf 100644 --- a/paradedb/localstack_paradedb/extension.py +++ b/paradedb/localstack_paradedb/extension.py @@ -3,7 +3,6 @@ from localstack_extensions.utils.docker import ProxiedDockerContainerExtension from localstack import config -from localstack.extensions.api import http # Environment variables for configuration ENV_POSTGRES_USER = "PARADEDB_POSTGRES_USER" @@ -57,23 +56,6 @@ def _tcp_health_check(): tcp_ports=[postgres_port], # Enable TCP proxying through gateway ) - # TODO: this should be migrated into the base class directly ..! - def update_gateway_routes(self, router: http.Router[http.RouteHandler]): - """ - Override to set up only TCP routing without HTTP proxy. - - ParadeDB uses the native PostgreSQL wire protocol (not HTTP), so we - only need TCP protocol routing - not HTTP proxying. Adding an HTTP - proxy without a host restriction would cause all HTTP requests to be - forwarded to the PostgreSQL container, breaking other services. - """ - # Start the container - self.start_container() - - # Set up only TCP protocol routing (skip HTTP proxy from base class) - if self.tcp_ports: - self._setup_tcp_protocol_routing() - def tcp_connection_matcher(self, data: bytes) -> bool: """ Identify PostgreSQL/ParadeDB connections by protocol handshake. diff --git a/paradedb/pyproject.toml b/paradedb/pyproject.toml index de30ab07..70e07018 100644 --- a/paradedb/pyproject.toml +++ b/paradedb/pyproject.toml @@ -25,7 +25,7 @@ dev = [ "boto3", "build", "jsonpatch", - "localstack", + "localstack-core", "psycopg2-binary", "pytest", "rolo", diff --git a/paradedb/tests/test_extension.py b/paradedb/tests/test_extension.py index 1c2504f0..7151488d 100644 --- a/paradedb/tests/test_extension.py +++ b/paradedb/tests/test_extension.py @@ -1,6 +1,7 @@ import boto3 import psycopg2 from localstack.utils.strings import short_uid +from localstack.utils.sync import retry # Connection details for ParadeDB @@ -13,14 +14,16 @@ def get_connection(): - """Create a connection to ParadeDB.""" - return psycopg2.connect( - host=HOST, - port=PORT, - user=USER, - password=PASSWORD, - database=DATABASE, - ) + """Create a connection to ParadeDB, retrying until the server is ready.""" + def _connect(): + return psycopg2.connect( + host=HOST, + port=PORT, + user=USER, + password=PASSWORD, + database=DATABASE, + ) + return retry(_connect, retries=15, sleep=2.0) def test_connect_to_paradedb(): diff --git a/typedb/pyproject.toml b/typedb/pyproject.toml index 32f3cbbd..ff92a59a 100644 --- a/typedb/pyproject.toml +++ b/typedb/pyproject.toml @@ -25,7 +25,7 @@ dev = [ "boto3", "build", "jsonpatch", - "localstack", + "localstack-core", "pytest", "rolo", "ruff", diff --git a/utils/localstack_extensions/utils/docker.py b/utils/localstack_extensions/utils/docker.py index 0909dddc..de625723 100644 --- a/utils/localstack_extensions/utils/docker.py +++ b/utils/localstack_extensions/utils/docker.py @@ -134,11 +134,21 @@ def update_gateway_routes(self, router: http.Router[http.RouteHandler]): ) # note: for simplicity, starting the external container at startup - could be optimized over time ... self.start_container() - # add resource for HTTP/1.1 requests - resource = RuleAdapter(ProxyResource(self.container_host, self.main_port)) - if self.host: - resource = WithHost(self.host, [resource]) - router.add(resource) + + # Determine if HTTP proxy should be set up. Skip it when all container ports are + # TCP-only and no host restriction is set, since a catch-all HTTP proxy would + # intercept all requests and break other services. + uses_http = ( + self.host + and set(self.container_ports) - set(self.tcp_ports or []) + ) + + if uses_http: + # add resource for HTTP/1.1 requests + resource = RuleAdapter(ProxyResource(self.container_host, self.main_port)) + if self.host: + resource = WithHost(self.host, [resource]) + router.add(resource) # apply patches to serve HTTP/2 requests for port in self.http2_ports or []: diff --git a/utils/pyproject.toml b/utils/pyproject.toml index c2cf5f71..b0b71bd7 100644 --- a/utils/pyproject.toml +++ b/utils/pyproject.toml @@ -32,7 +32,7 @@ dev = [ "boto3", "build", "jsonpatch", - "localstack", + "localstack-core", "pytest", "ruff", ] @@ -40,7 +40,7 @@ test = [ "grpcio>=1.60.0", "grpcio-tools>=1.60.0", "jsonpatch", - "localstack", + "localstack-core", "pytest>=7.0", "pytest-timeout>=2.0", ] diff --git a/wiremock/README.md b/wiremock/README.md index 5100b0fe..4d082c40 100644 --- a/wiremock/README.md +++ b/wiremock/README.md @@ -108,6 +108,8 @@ localstack start - `WIREMOCK_API_TOKEN`: Your WireMock Cloud API token (required for runner mode) - `WIREMOCK_CONFIG_DIR`: Path to the directory containing your `.wiremock` folder (required for runner mode) +- `WIREMOCK_IMAGE`: Custom Docker image name for the Wiremock OSS image (default: `wiremock/wiremock`) +- `WIREMOCK_IMAGE_RUNNER`: Custom Docker image name for the Wiremock Cloud runner image (default: `wiremock/wiremock-runner`) Note: When using the LocalStack CLI, prefix environment variables with `LOCALSTACK_` to forward them to the container. @@ -118,3 +120,12 @@ See the `sample-app-runner/` directory for a complete example using Terraform th - Creating an API Gateway - Lambda function that calls WireMock stubs - Integration testing with mocked external APIs + +## Change Log + +- `0.1.1`: Add environment variables to customize the WireMock image names +- `0.1.0`: Initial release of the extension + +## License + +This project is licensed under the Apache License, Version 2.0. diff --git a/wiremock/pyproject.toml b/wiremock/pyproject.toml index 817551a0..dae2581e 100644 --- a/wiremock/pyproject.toml +++ b/wiremock/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "localstack-wiremock" -version = "0.1.0" +version = "0.1.1" description = "WireMock Extension for LocalStack" readme = {file = "README.md", content-type = "text/markdown; charset=UTF-8"} requires-python = ">=3.9" @@ -14,8 +14,8 @@ authors = [ keywords = ["LocalStack", "WireMock"] classifiers = [] dependencies = [ - "priority", - "localstack-extensions-utils" + "localstack-extensions-utils", + "priority" ] [project.urls] @@ -26,7 +26,7 @@ dev = [ "boto3", "build", "jsonpatch", - "localstack", + "localstack-core", "pytest", "rolo", "ruff",