-
Notifications
You must be signed in to change notification settings - Fork 45
Synchronizer: Add local docker-compose harness for manual sync testing #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
saidixith002
wants to merge
1
commit into
apache:main
Choose a base branch
from
saidixith002:polaris-synchronizer/manual-test-docker-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # Manual Test Setup | ||
|
|
||
| Brings up two independent Apache Polaris instances (source + target) to | ||
| manually validate `polaris-synchronizer`, including the `--skip-iceberg-content` | ||
| flag, without needing Postgres/RDS or S3/MinIO: | ||
|
|
||
| * Both instances use Polaris's default **in-memory metastore** (no datasource | ||
| configured). | ||
| * Both instances share a single **FILE storage volume**, mounted at the same | ||
| path in each container — so table metadata written by source is readable | ||
| by target, and a full sync (including namespace/table content) actually | ||
| succeeds. This lets you run the full sync and the `--skip-iceberg-content` | ||
| sync back-to-back in the same session and compare the results. | ||
|
|
||
| `polaris-init` seeds SOURCE with a catalog, principal, principal-role, | ||
| catalog-role, grant, namespace, and table. TARGET is left completely empty — | ||
| `polaris-synchronizer` is responsible for creating everything there. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| cd polaris-synchronizer/manual-test | ||
| docker compose up --build -d | ||
| docker compose ps # wait for polaris-init to show "Exited (0)" | ||
| cat seed/credentials.json | ||
| ``` | ||
|
|
||
| Polaris REST/management APIs are reachable at `http://localhost:8181` (source) | ||
| and `http://localhost:8183` (target). | ||
|
|
||
| Build the CLI jar from the `polaris-synchronizer` root: | ||
|
|
||
| ```bash | ||
| cd .. | ||
| ./gradlew assemble | ||
| # jar is at cli/build/libs/polaris-synchronizer-cli.jar | ||
| ``` | ||
|
|
||
| ### Step 1: Create a read-only omnipotent principal on source | ||
|
|
||
| ```bash | ||
| java -jar cli/build/libs/polaris-synchronizer-cli.jar create-omnipotent-principal \ | ||
| --polaris-api-connection-properties base-url=http://localhost:8181 \ | ||
| --polaris-api-connection-properties oauth2-server-uri=http://localhost:8181/api/catalog/v1/oauth/tokens \ | ||
| --polaris-api-connection-properties credential=root:s3cr3t \ | ||
| --polaris-api-connection-properties scope=PRINCIPAL_ROLE:ALL \ | ||
| --replace | ||
| ``` | ||
|
|
||
| Note the `clientId`/`clientSecret` printed at the end — this is | ||
| `SOURCE_OMNI_ID` / `SOURCE_OMNI_SECRET` below. | ||
|
|
||
| ### Step 2: Create a read-write omnipotent principal on target | ||
|
|
||
| ```bash | ||
| java -jar cli/build/libs/polaris-synchronizer-cli.jar create-omnipotent-principal \ | ||
| --polaris-api-connection-properties base-url=http://localhost:8183 \ | ||
| --polaris-api-connection-properties oauth2-server-uri=http://localhost:8183/api/catalog/v1/oauth/tokens \ | ||
| --polaris-api-connection-properties credential=root:s3cr3t \ | ||
| --polaris-api-connection-properties scope=PRINCIPAL_ROLE:ALL \ | ||
| --replace \ | ||
| --write-access | ||
| ``` | ||
|
|
||
| Note the credentials printed here — this is `TARGET_OMNI_ID` / `TARGET_OMNI_SECRET`. | ||
|
|
||
| Since TARGET starts with no catalogs, this step will report 0 catalogs | ||
| processed — that's expected. `sync-polaris` will create the target's catalog | ||
| before syncing catalog-roles/grants, so there's nothing to set up yet. | ||
|
|
||
| ### Step 3a: Run with `--skip-iceberg-content` | ||
|
|
||
| ```bash | ||
| java -jar cli/build/libs/polaris-synchronizer-cli.jar sync-polaris \ | ||
| --source-properties base-url=http://localhost:8181 \ | ||
| --source-properties credential=root:s3cr3t \ | ||
| --source-properties oauth2-server-uri=http://localhost:8181/api/catalog/v1/oauth/tokens \ | ||
| --source-properties scope=PRINCIPAL_ROLE:ALL \ | ||
| --source-properties omnipotent-principal-name=<name-from-step-1> \ | ||
| --source-properties omnipotent-principal-client-id=<SOURCE_OMNI_ID> \ | ||
| --source-properties omnipotent-principal-client-secret=<SOURCE_OMNI_SECRET> \ | ||
| --target-properties base-url=http://localhost:8183 \ | ||
| --target-properties credential=root:s3cr3t \ | ||
| --target-properties oauth2-server-uri=http://localhost:8183/api/catalog/v1/oauth/tokens \ | ||
| --target-properties scope=PRINCIPAL_ROLE:ALL \ | ||
| --target-properties omnipotent-principal-name=<name-from-step-2> \ | ||
| --target-properties omnipotent-principal-client-id=<TARGET_OMNI_ID> \ | ||
| --target-properties omnipotent-principal-client-secret=<TARGET_OMNI_SECRET> \ | ||
| --skip-iceberg-content | ||
| ``` | ||
|
|
||
| Catalog, catalog-role, and grant sync complete, but namespace/table sync is | ||
| skipped entirely — verify below that target has zero namespaces. | ||
|
|
||
| ### Step 3b: Re-run without `--skip-iceberg-content` (full sync) | ||
|
|
||
| Drop `--skip-iceberg-content` from the same command and re-run it. Since the | ||
| storage volume is shared, `test_table`'s metadata is now readable by target | ||
| too, so namespace/table sync succeeds this time — target ends up with the | ||
| namespace and table that were skipped in Step 3a. | ||
|
|
||
| ### Verify on target | ||
|
|
||
| ```bash | ||
| TARGET_TOKEN=$(curl -sf -X POST http://localhost:8183/api/catalog/v1/oauth/tokens \ | ||
| -d "grant_type=client_credentials&client_id=root&client_secret=s3cr3t&scope=PRINCIPAL_ROLE:ALL" \ | ||
| | jq -r '.access_token') | ||
|
|
||
| curl -sf http://localhost:8183/api/management/v1/catalogs/test-catalog/catalog-roles \ | ||
| -H "Authorization: Bearer $TARGET_TOKEN" | jq | ||
|
|
||
| # After Step 3a (--skip-iceberg-content), this returns an empty list. | ||
| # After Step 3b (full sync), this returns test_ns. | ||
| curl -sf http://localhost:8183/api/catalog/v1/test-catalog/namespaces \ | ||
| -H "Authorization: Bearer $TARGET_TOKEN" | jq | ||
| ``` | ||
|
|
||
| Tear down with: | ||
|
|
||
| ```bash | ||
| docker compose down -v | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| services: | ||
|
|
||
| # ── Polaris instances ──────────────────────────────────────────────────────── | ||
| # Official Apache Polaris image. No Postgres/RDS — Polaris defaults to its | ||
| # in-memory metastore when no datasource is configured. Both instances share | ||
| # a single FILE storage volume mounted at the same path, so metadata written | ||
| # by source is readable by target — this lets a full sync (including | ||
| # namespace/table content) actually succeed, so you can compare it against | ||
| # a `--skip-iceberg-content` run in this example. | ||
|
|
||
| polaris-source: | ||
| image: apache/polaris:1.1.0-incubating | ||
| container_name: polaris-source | ||
| hostname: polaris-source | ||
| ports: | ||
| - "8181:8181" | ||
| - "8182:8182" | ||
| environment: | ||
| POLARIS_BOOTSTRAP_CREDENTIALS: POLARIS,root,s3cr3t | ||
| JAVA_OPTS_APPEND: >- | ||
| -Dpolaris.readiness.ignore-severe-issues=true | ||
| -Dpolaris.features."SUPPORTED_CATALOG_STORAGE_TYPES"=["FILE"] | ||
| -Dpolaris.features."ALLOW_INSECURE_STORAGE_TYPES"=true | ||
| -Dpolaris.features."ALLOW_UNSTRUCTURED_TABLE_LOCATION"=true | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-sf", "http://localhost:8182/q/health/ready"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 20 | ||
| start_period: 20s | ||
| volumes: | ||
| - shared-storage:/tmp/polaris | ||
| networks: | ||
| - polaris-net | ||
|
|
||
| polaris-target: | ||
| image: apache/polaris:1.1.0-incubating | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not 1.6.0? 😉 |
||
| container_name: polaris-target | ||
| hostname: polaris-target | ||
| ports: | ||
| - "8183:8181" | ||
| - "8184:8182" | ||
| environment: | ||
| POLARIS_BOOTSTRAP_CREDENTIALS: POLARIS,root,s3cr3t | ||
| JAVA_OPTS_APPEND: >- | ||
| -Dpolaris.readiness.ignore-severe-issues=true | ||
| -Dpolaris.features."SUPPORTED_CATALOG_STORAGE_TYPES"=["FILE"] | ||
| -Dpolaris.features."ALLOW_INSECURE_STORAGE_TYPES"=true | ||
| -Dpolaris.features."ALLOW_UNSTRUCTURED_TABLE_LOCATION"=true | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-sf", "http://localhost:8182/q/health/ready"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 20 | ||
| start_period: 20s | ||
| volumes: | ||
| - shared-storage:/tmp/polaris | ||
| networks: | ||
| - polaris-net | ||
|
|
||
| # ── Init container ──────────────────────────────────────────────────────── | ||
| # Seeds SOURCE with: catalog + principal + principal-role + catalog-role + | ||
| # grant + namespace + table. TARGET is left completely empty — polaris-synchronizer | ||
| # is responsible for creating the catalog/catalog-role/grants (and, unless | ||
| # --skip-iceberg-content is used, the namespace/table) on the target. | ||
|
|
||
| polaris-init: | ||
| build: | ||
| context: ./init | ||
| container_name: polaris-init | ||
| dns_search: "." | ||
| depends_on: | ||
| polaris-source: | ||
| condition: service_healthy | ||
| polaris-target: | ||
| condition: service_healthy | ||
| volumes: | ||
| - ./seed:/seed | ||
| restart: "no" | ||
| networks: | ||
| - polaris-net | ||
|
|
||
| networks: | ||
| polaris-net: | ||
| driver: bridge | ||
|
|
||
| volumes: | ||
| shared-storage: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM alpine:3.19 | ||
| RUN apk add --no-cache curl jq bash | ||
| COPY init.sh /init.sh | ||
| RUN chmod +x /init.sh | ||
| ENTRYPOINT ["/bin/bash", "/init.sh"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why advise users to dump credentials to STDOUT?