-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
KubernetesTest / NamespaceExtension will run for every test class in the module #5315
Comments
Haven't checked it, but this might be happening for the other Jupiter Extensions+Annotations too (in case it's a bug). Also note: and:
Our tests are actually configured to automatically run these extensions automatically (In case you're reporting this for the Fabric8 Client and not for an external project). If this is happening at a different project, make sure that the |
This is running in keycloak. autodetection must already be enabled by quarkus. When autodetection is enabled, then the null check here https://github.com/fabric8io/kubernetes-client/blob/master/junit/kubernetes-junit-jupiter/src/main/java/io/fabric8/junit/jupiter/NamespaceExtension.java#L110 allows for the namespace to be created even if the test class is not annotated. |
I don't see a good way to fix this upstream. This is mostly the problem with autodetection enabled, I've had this problem in other projects too (not sure if JUnit offers a good solution to just enable some or filter the enabled extensions). The workaround is to actually add the annotation and disable the namespace creation, but this is ugly too. |
So your expectation is that with autodetection enabled that every class, regardless of whether it has an annotation, should have the NamespaceExtension run? |
Well, that's not my expectation, is what I've had problems like this with other projects. IMO if you start running into these issues you should disable autodetection. The other alternative is to remove our SPI provided extensions and then annotate all of our tests. Or somewhat refactor this and create the SPI declaration in the test module. |
Could https://github.com/fabric8io/kubernetes-client/blob/master/junit/kubernetes-junit-jupiter/src/main/java/io/fabric8/junit/jupiter/NamespaceExtension.java#L110 not create the namespace if the annotation is null? |
I guess it could, but then we need to annotate our tests. |
Oh, I forgot about LoadKubernetesManifests - KubernetesTest is not required everywhere you'd expect the NamespaceExtension to be triggered. So either the extension logic would have to check for all such annotations, or keycloak will need annotate it's other test classes if we want to disable the namespace creation. |
I think it's a matter of deciding if we stop populating the SPI file, produce it at a different module - |
The trouble with that is quarkus seems to be implicitly relying on automatic extension loading, it's not a choice that keycloak is making directly. |
Which IMO is wrong on the Quarkus side. Even more considering that Quarkus is not 100% JUnit behavior compliant. Anyway, the easiest move is to provide the junit-platform.properties in a different module (e.g. |
Here's where they are setting the default: They talk about using a different one here https://github.com/quarkusio/quarkus/blob/main/docs/src/main/asciidoc/getting-started-testing.adoc#10-testing-different-profiles - just introducing another module will result in a warning, the quarkus one will need excluded. I'm not sure what QuarkusTest mechanisms may then not work correctly. I'll try it out locally and see. |
As long as a single test class is annotated, KubernetesTest / NamespaceExtension will run for every test class in the module regardless of whether the test is annotated.
The text was updated successfully, but these errors were encountered: