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

Log context cache statistics in the TestContext framework [SPR-12409] #17017

Closed
1 task done
spring-projects-issues opened this issue Nov 3, 2014 · 3 comments
Closed
1 task done
Assignees
Labels
in: test Issues in the test module status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Sam Brannen opened SPR-12409 and commented

Status Quo

The Spring TestContext Framework (TCF) has always cached ApplicationContexts loaded for tests; however, it's always been a bit of a black art knowing (or finding out) exactly how many contexts are loaded within a given test suite.

The information, however, has always been tracked internally within the ContextCache class, and some developers have used reflection to acquire this information. It would therefore be beneficial to many development teams if the context cache statistics were made publicly available, at least as log output.

Deliverables

  1. Log context cache statistics whenever an ApplicationContext is loaded by the TCF.

Affects: 3.0 GA

Referenced from: commits 983ebaf, da04362, a09bc9b, 74500ec

Backported to: 4.0.8, 3.2.12

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Resolved as described in GitHub commit da04362:

Log context cache statistics in the TCF

Prior to this commit, finding out how many application contexts had
been loaded within a test suite required the use of reflection and a
bit of hacking.

This commit addresses this issue by logging ContextCache statistics
whenever an application context is loaded by the Spring TestContext
Framework (TCF).

The log output can be enabled by setting the
"org.springframework.test.context.cache" logging category to DEBUG.

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Reopened for backporting to 3.2.12 and 4.0.8.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

In the course of backporting this, I've also streamlined synchronization within ContextCache: loadContext was already going through a full lock on the ContextCache itself for all operations. Doing DefaultTestContext's remove operation within an the same lock allows for dropping the internal monitor within ContextCache completely.

Juergen

@spring-projects-issues spring-projects-issues added in: test Issues in the test module status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1.2 milestone Jan 11, 2019
This was referenced Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants