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

Separate slow tests from fast tests #19

Open
remkop opened this issue Apr 1, 2020 · 3 comments
Open

Separate slow tests from fast tests #19

remkop opened this issue Apr 1, 2020 · 3 comments

Comments

@remkop
Copy link
Collaborator

remkop commented Apr 1, 2020

When running the maven build with mvn clean package, the tests to run for several hours and at some point seem to get stuck.

It would make sense to me to separate fast tests ("unit tests") from slow-running tests ("integration", "acceptance" or "system" tests).

On the one hand, developers need fast feedback to make sure their changes did not break anything, and on the other hand we need a set of thorough tests that require a complete system setup.

There are several ways to accomplish this with Maven:

  • class or package naming conventions
  • separate module for slow-running tests
  • JUnit Categories

Optionally, we can use the Maven failsafe plugin for integration tests. With the failsafe plugin enabled, we can run the following:

  1. mvn test (will run only the basic unit tests, and will stop the build if any of them fails),
  2. mvn integration-test (will run integration tests, and will not stop the build if any of them fails), and
  3. mvn verify (will stop the build if an integration test fails).

Resources:

The main problem will be going through the existing tests and filtering the slow ones from the fast ones. Perhaps we can automate this from the test log.

@remkop remkop changed the title Separate slow and fast tests Separate slow tests from fast tests Apr 1, 2020
@petermr
Copy link
Owner

petermr commented Apr 1, 2020 via email

@remkop
Copy link
Collaborator Author

remkop commented Apr 1, 2020

Separation: already done!

I missed this, but looking at the POM, it turns out that both the Surefire and the Failsafe plugins are already configured. So, we can already use Maven to run the unit tests separately from the integration tests by using the naming conventions for these plugins:

  • mvn test or mvn package will only run the tests named Test*.java, *Test.java and *TestCase.java
  • mvn verify or mvn install will also run the tests named IT*.java, *IT.java and *ITCase.java

I suspect that all that is needed is to rename some long-running tests from ...Test.java to ...IT.java and that will help a lot.

Triaging Findings

I found the following slow-running tests:

  • JBrowserTest it took more than 10 minutes to run this test. I went ahead and renamed this to JBrowserIT.

  • AMIDictionaryTest Tests run: 39, Failures: 3, Errors: 29, Skipped: 0, Time elapsed: 826.646 sec. It gets stuck in testCreateFromMediawikiTemplateListURL for 2 minutes, in testCreateFromMediawikiTemplateURL for 6+ minutes, and again in testCreateFromMediawikiTemplateListURLOld. I changed the test to run those specific ones in a separate thread that times out after 10 seconds. If these tests require more time perhaps they can be moved into an IT test?

  • org.contentmine.ami.tools.AMISectionToolTest Tests run: 26, Failures: 8, Errors: 4, Skipped: 0, Time elapsed: 151.685 sec (the bulk in testAddAbstracts 48.087 sec and testAddBacks 14.658 sec) - no action taken yet

  • org.contentmine.ami.tools.AMITransformToolTest Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 28.736 sec - no action taken yet

  • org.contentmine.ami.tools.AMIWordsToolTest Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 23.569 sec - no action taken yet

  • org.contentmine.graphics.svg.cache.SVGCacheTest Tests run: 5, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 145.624 sec - no action taken yet

  • org.contentmine.norma.sections.SectionTest Tests run: 21, Failures: 2, Errors: 2, Skipped: 2, Time elapsed: 202.66 sec - no action taken yet

Overall

Also, there are quite a few test failures. One cause I can see is the test relying on data files existing in absolute paths like: "/Users/pm286/projects/openVirus/dictionaries/". Can these files be committed to somewhere under /src/test/resources/? I can provide a utility that converts a resource path to an absolute path that can be passed as an argument to the tool that is being tested.

@petermr
Copy link
Owner

petermr commented Apr 2, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants