-
Notifications
You must be signed in to change notification settings - Fork 154
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
Convert main integration tests into reusable backbox tests #590
base: main
Are you sure you want to change the base?
Conversation
...n-tests/src/main/java/org/apache/polaris/service/it/ext/PolarisIntegrationTestExtension.java
Show resolved
Hide resolved
...n-tests/src/main/java/org/apache/polaris/service/it/ext/PolarisIntegrationTestExtension.java
Show resolved
Hide resolved
|
||
@Override | ||
public URI baseUri() { | ||
return URI.create(String.format("http://localhost:%d", ext.getLocalPort())); |
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.
The old TestEnv
extension could modify this to hit a remote Polaris server afaict.
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.
My thinking was that remote cases would have their own Server Manager impl.
The old TestEnvironmentExtension
is too intertwined with existing whitebox DW extensions... I though we'd have a totally new interface and gradually migrate TestEnvironmentExtension
use cases to it.
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.
To clarify: if a remote server is available outside the JUnit5 lifecycle, one can simply make an Server Manager impl. that returned a pre-configured URI and Realm, and then use a JUnit5 "suite" to execute tests from the new test module.
|
||
@Override | ||
public ClientCredentials adminCredentials() { | ||
return new ClientCredentials("test-admin", "test-secret"); |
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.
The old TestEnv
extension used to append a "test ID" to the generated credentials afaict.
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.
I'm not sure that the purpose of that append was, TBH 😅 I believe having one admin user per realm (as in this case) is sufficient.
Currently, there's only one realm for Server Manager instance, so other implementations can chose to use unique admin user names, if they prefer.
|
||
AuthToken adminToken(); | ||
|
||
ClientCredentials adminCredentials(); |
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.
Where has the Snowman
user gone?
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.
Into the Nothing. The Server Manager provides "root" (admin) credentials. Tests create extra principals when they need to.
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.
I am fine with that, although my impression was that the snowman user was introduced precisely to avoid using the root user for all admin tasks. Let's wait and see what @andrew4699 says.
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.
I moved the work done by the SnowmanCredentialsExtension
into specific test classes... hopefully maintaining the same functionality as before (the "snowman" principals used to be created using "admin" tokens too). Those can be found by searching for "snowman" in Principal names in the new test code. I believe explicit principal manipulation by test code is easier to follow and maintain than if it is done by a test extension.
The principal and role manipulation logic moved to the methods in the new ManagementApi
class.
b6a6012
to
8b7325e
Compare
* Introduce new module: `integration-tests` to contain the test code for backbox integration tests * Refactors existing main integration tests to avoid relying on Dropwizard internals. * Add new test extension for managing the test environment with custom server managers discovered via `ServiceLoader` * Use Dropwizard test extentions for the reference implementation of `PolarisServerManager`. Custom server builds can provide their own environment-specific implementations. * Add helper classes for REST API (Management and Catalog) * Run reusable tests by extending them in the DW module. Using test suites is also possible, but it only uses one gradle test worker, so test parallelism is reduced. At the same time running tests in parallel withing the same JVM using JUnit5 threads currently leads to errors.
8b7325e
to
90ee9d0
Compare
I noticed that 3 other tests use the Dropwizard extension and could be considered as "integration" tests:
We could create "black-box" versions of those while still keeping the "white-box" ones around, wdyt? |
.stream() | ||
.collect( | ||
Collectors.toMap(PolarisFeatureConfig::name, PolarisFeatureConfig::value)); | ||
return new Env(manager.realm(), manager.startServer(featureConfig)); |
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.
I'm struggling to adapt this to Quarkus. In a Quarkus test (integration or not), the application will be running already when the extension is executed, and it's not possible to change the feature configs at that moment. The only way to change the application config is through a QuarkusTestProfile
afaik. I don't think we can use a QuarkusTestResourceLifecycleManager
to launch the application itself on demand; that's intended for dependent resources like databases etc. I think the @PolarisFeatureConfig
annotation would eventually go away completely with Quarkus.
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.
Let me see if we this can be refactored to fit Quarkus better
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.
On a closer look at the test that use @PolarisFeatureConfig
I tend to think that those tests are an overkill to have at the integration test level. The test variations merely check how configuration keys are resolved between catalog properties, server config and default values. I believe that part can be done by a unit test.
I'll try and refactor the blackbox tests to rely only on default config settings.
|
|
Introduce new module:
integration-tests
to contain the test code for backbox integration testsRefactors existing main integration tests to avoid relying on Dropwizard internals.
Add new test extension for managing the test environment with custom server managers discovered via
ServiceLoader
Use Dropwizard test extentions for the reference implementation of
PolarisServerManager
. Custom server builds can provide their own environment-specific implementations.Add helper classes for REST API (Management and Catalog)
Run reusable tests by extending them in the DW module. Using test suites is also possible, but it only uses one gradle test worker, so test parallelism is reduced. At the same time running tests in parallel withing the same JVM using JUnit5 threads currently leads to errors.
This PR is meant to be the first step towards #524. Subsequent PRs can certainly enhance the testing framework more.