Gehel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/371956 )
Change subject: fix leaking threads in integration tests
......................................................................
fix leaking threads in integration tests
The RdfRepository in AbstractRdfRepositoryIntegrationTestBase wasn't closed
properly on each test, which make randomized testing leaked thread detector
unhappy. This should help make tests more reliable.
Change-Id: Ie3496814a320f77641142b01e1c99da416b2e2ba
---
M
tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
1 file changed, 26 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/rdf
refs/changes/56/371956/1
diff --git
a/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
b/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
index fa39003..e9e9148 100644
---
a/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
+++
b/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
@@ -33,7 +33,7 @@
/**
* Repository to test with.
*/
- private final RdfRepositoryForTesting rdfRepository;
+ private RdfRepositoryForTesting rdfRepository;
/**
* Build the test against prod wikidata.
@@ -44,10 +44,35 @@
public AbstractRdfRepositoryIntegrationTestBase(WikibaseUris uris) {
this.uris = uris;
+ }
+
+ /**
+ * Initializes the {@link RdfRepository} before each test.
+ *
+ * Since randomized testing ThreadLeakControl checks for leaked thread, not
+ * closing properly the RdfRepository after each test causes random false
+ * negative in the test results. Initializing the RdfRepository for each
+ * test might be slightly less performant, but at least it ensures
+ * reproducible tests.
+ */
+ @Before
+ public void initRdfRepository() {
rdfRepository = new RdfRepositoryForTesting("wdq");
}
/**
+ * Closes the {@link RdfRepository} after each test.
+ *
+ * @throws Exception if error when closing the RdfRepository
+ */
+ @After
+ public void shutdownRdfRepository() throws Exception {
+ if (rdfRepository != null) {
+ rdfRepository.close();
+ }
+ }
+
+ /**
* Uris to test with.
*/
public WikibaseUris uris() {
--
To view, visit https://gerrit.wikimedia.org/r/371956
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3496814a320f77641142b01e1c99da416b2e2ba
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/rdf
Gerrit-Branch: master
Gerrit-Owner: Gehel <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits