Skip to content
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

Jakarta TCKs #33638

Merged
merged 8 commits into from
May 31, 2023
Merged

Jakarta TCKs #33638

merged 8 commits into from
May 31, 2023

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented May 26, 2023

Resolves #28558

  • fix type discovery for classes added by Build Compatible Extensions
  • fix bean archive discovery in strict mode
  • fix discovering bean archives that only contain scopes
  • remove useless Arquillian extension from MP Context Propagation TCK
  • add workaround for Arquillian memory leak
  • improve instantiating test classes through CDI
  • update to CDI TCK 4.0.10
  • add Jakarta TCKs

@Ladicek Ladicek requested review from mkouba and manovotn May 26, 2023 14:29
@Ladicek Ladicek changed the title Add Jakarta TCKs Jakarta TCKs May 26, 2023
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/dependencies Pull requests that update a dependency file area/testing labels May 26, 2023
@Ladicek Ladicek force-pushed the jakarta-tcks branch 4 times, most recently from 6a03312 to 7a55f18 Compare May 29, 2023 17:13
@Ladicek
Copy link
Contributor Author

Ladicek commented May 29, 2023

#33523 was merged and CDI TCK 4.0.10 was released, so this PR is now rebased and ready.

@Ladicek Ladicek marked this pull request as ready for review May 29, 2023 17:16
@Ladicek Ladicek requested a review from geoand May 29, 2023 17:17
@Ladicek
Copy link
Contributor Author

Ladicek commented May 29, 2023

Also adding @geoand for the testing stuff.

@manovotn
Copy link
Contributor

#33523 was merged and CDI TCK 4.0.10 was released, so this PR is now rebased and ready.

Awesome, almost there now! :)

@quarkus-bot

This comment has been minimized.

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know anything about Arquillian unfortunately to be able to provide any meaningful reviewe

@Ladicek
Copy link
Contributor Author

Ladicek commented May 30, 2023

@geoand I was thinking more about this commit: bc3802e It's a tiny thing, but could still use a second pair of eyes :-)

@geoand
Copy link
Contributor

geoand commented May 30, 2023

This class is loaded from the Quarkus CL and so the code can be written directly instead of reflectively

I always love this kind of cleanup! Moving reflection as high up as possible is such an enabler :)

The Build Compatible Extension API specifies that classes added through
`ScannedClasses` during `@Discovery` are always discovered types and
therefore always beans. This requires a change in the type discovery
implementation in the Quarkus ArC extension: all classes added through
`ScannedClasses` are subject to an annotation transformation that adds
a bean defining annotation (`@AdditionalBean`).
The Quarkus ArC extension assumes that the root application archive
is always a bean archive. That doesn't necessarily have to be true
per the CDI specification, but is useful in practice. Therefore, it
needs to be fixed only in strict mode, which is what this commit does.

By default, the root application archive is always a bean archive.
In strict mode, the root application archive goes through the same
scanning process as other application archives.
The Quarkus ArC extension used to discover bean archives that only
contain qualifiers or interceptor bindings. This commit fixes that
to also discover bean archives that only contain scopes.
… TCK

This extension was used to activate/deactivate the CDI request context
before/after each test. The Quarkus Arquillian adapter contains the exact
same extension, so the one in MP Context Propagation TCK is useless.
Arquillian holds onto deployment-scoped (and container-scoped) objects
until its end of life. That allows undeploying and redeploying without
losing contextual data, but is also technically a memory leak. In case
the deployment-scoped objects are large (which is the case in Quarkus,
see `RunningQuarkusApplication`), this memory leak becomes very visible
very soon.

The Quarkus Arquillian adapter is only used to run TCKs for Jakarta
and MicroProfile specifications, which don't need this capability. Also,
the `RunningQuarkusApplication` is unusable after it is closed, so
it makes no sense to keep it around. Hence, `QuarkusDeployableContainer`
no longer stores the `RunningQuarkusApplication` into the deployment
context directly; instead, it stores a holder object (`QuarkusDeployment`)
that can safely be cleaned up after an Arquillian deployment is undeployed.
That makes the Quarkus application unreachable and GC-able. Arquillian
will keep piling up empty objects, which is still a memory leak, but
one that doesn't hurt as much.

This commit also fixes an ordering issue. Previously, the Arquillian
adapter used to delete the Quarkus application directory _before_ shutting
down the application, which could lead to errors. This commit switches
the order: the app is shut down first and only then is it deleted.
This commit moves the code that looks up a test class from CDI into
a dedicated delegate class. This class is loaded from the Quarkus CL
and so the code can be written directly instead of reflectively.

Additionally, the CDI lookup can now correctly instantiate a generic
test class. Such bean cannot be looked up from CDI directly, because
its set of bean types doesn't contain a `Class` object (it contains
a `ParameterizedType` instead). This commit uses a naive approach
for this (iterate through all beans), which is fine, because it's
very uncommon.
- AtInject
- CDI (Lite)
- CDI Lang Model
@Ladicek
Copy link
Contributor Author

Ladicek commented May 30, 2023

Issues should be gone now. The MP Context Propagation TCK used to fail because when refactoring the Arquillian adapter, I forgot to update possible consumers -- fortunately, the consumer in MP ConProp TCK was redundant, so I just deleted it. The MP LRA TCK used to fail because when refactoring the Arquillian adapter, I failed to transform all null checks properly, which I fixed.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@quarkus-bot
Copy link

quarkus-bot bot commented May 30, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

@Ladicek Ladicek merged commit a24a55e into quarkusio:main May 31, 2023
@Ladicek Ladicek deleted the jakarta-tcks branch May 31, 2023 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/dependencies Pull requests that update a dependency file area/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CDI Lite compliance (CDI 4.0)
4 participants