Skip to content

[#13962] improvement(test): Add test service providers, with external MySQL and PostgreSQL - #16

Draft
nevzheng wants to merge 1 commit into
claude/13962-test-service-providers-spipfrom
claude/13962-test-service-providers-poc
Draft

nevzheng wants to merge 1 commit into
claude/13962-test-service-providers-spipfrom
claude/13962-test-service-providers-poc

Conversation

@nevzheng

Copy link
Copy Markdown
Owner

Requested by Nevin · project thread

Proof of concept for the SPIP PR it is stacked on. Supersedes apache#13838.

What changes were proposed in this pull request?

  • Provider layer in integration-test-common: ServiceEndpoint, ServiceSpec<E>, ServiceProvider, and ContainerSuite.getService(spec), which asks providers in order and keeps the first answer: ServiceLoader plug-ins, then ExternalServiceProvider (gravitino.test.<service>.* properties), then ContainerServiceProvider (today's containers).
  • MySQL and PostgreSQL first: DatabaseEndpoint, implemented by DatabaseContainer and by the new ExternalDatabase. On an external server, database names carry a random per-JVM token, and a run drops only what it created.
  • coreMySQLTest / corePostgreSQLTest pass GRAVITINO_TEST_<MYSQL|POSTGRESQL>_URL, _USER and _PASSWORD to the test JVM; with them set, the lane starts no container and needs no Docker.
  • BaseIT, BackendTestExtension, AbstractEntityStorageTest and the partition statistics tests take the login from the endpoint instead of root/root.
  • New CI job core-test-external-db runs both lanes against GitHub Actions service containers and checks that no other container started.

Why are the changes needed?

Tests can only get services by starting containers, so they cannot run where Docker is unavailable or services are already provided, such as Kubernetes services.

Fix: apache#13962

Does this PR introduce any user-facing change?

No. Tests only; without the variables, behaviour is unchanged.

How was this patch tested?

  • New unit tests TestServiceResolver and TestExternalDatabase (10 tests).
  • ./gradlew :core:coreMySQLTest :core:corePostgreSQLTest -PskipDockerTests=true against local MySQL 8.0 and PostgreSQL 16 servers with the variables set: 594 tests each, 0 failures, no databases left behind, [TEST-SERVICE-SOURCE] ... provider=external logged.
  • The container path was not run here (no Docker); the core-test jobs cover it.

Generated by Claude Code

…ternal MySQL and PostgreSQL

Proof of concept for the SPIP in design-docs/testing/containers/.

Tests ask ContainerSuite.getService(ServiceSpec) for a service and get a
ServiceEndpoint. ContainerSuite asks ServiceProviders in order and keeps
the first answer: providers listed through ServiceLoader, then
ExternalServiceProvider (gravitino.test.<service>.* properties), then
ContainerServiceProvider (today's containers).

MySQL and PostgreSQL are the first services: DatabaseEndpoint is
implemented by DatabaseContainer and by ExternalDatabase. The core
MySQL and PostgreSQL lanes pass GRAVITINO_TEST_<MYSQL|POSTGRESQL>_URL,
_USER and _PASSWORD to the test JVM; with them set, the lane starts no
container and needs no Docker. Database names on an external server
carry a random per-JVM token, and a run drops only what it created.
BaseIT, BackendTestExtension, AbstractEntityStorageTest and the
partition statistics tests take the login from the endpoint instead of
root/root.

A new core-test-external-db CI job runs both lanes against GitHub
Actions service containers and checks that no other container started.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant