Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Fix failing tests and run them all in travis #297

Merged
merged 8 commits into from
Jan 31, 2018
Merged

Fix failing tests and run them all in travis #297

merged 8 commits into from
Jan 31, 2018

Conversation

yfouquet
Copy link
Collaborator

As explain in issue #296, all some tests are run by maven, so:

  • adjust maven configuration
  • fix failing tests

As configured in the pom file, only some unit tests are actually runned by travis.
The main effect is that the tests are actually failing for a long time now.
Change pom to play all tests.
- Rename checks to understand what they were actually testing,
- Fix failing tests,
- Remove useless checked Exception (as none is required).

Note that the tests must be improved, but it is not the topic here.
Session are created, not never destroyed.
It creates issues for over tests, so destroy the sessions once the test is done (successful or not).
Tests were failing, but never run.
- sessionClient and keyValueClient has been added in setUp to remove duplication
- some tests were renammed as they did not indicate what the test was doing
- opened sessions are now destroy at the end of the test
- remove unused "throws Exception" in methods signature
- split testAcquireLock in 3 tests
- close opened cache
- rename test method when not explicit
- fix keyStr/valStr (root was not included, so failure)
- fix number of events: +1 as one event is generated at cache start
- replace addListener(...) by reference method when possible (making it readable)
getDebugConfig() is not available in Consul 0.7.2 (so no testable).
However, the assertion is not related to the test.
Hence, remove the failing assertion.
getDebugConfig() is not available in Consul 0.7.2 (so no testable).
Rewrite the tests to do the same thing without getDebugConfig().
Note that we also close the cache.
.stream()
.filter(key -> serviceId.equals(key.getServiceId()) && (port == key.getPort()))
.findFirst()
.orElse(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cannot we use an Option instead of null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


assertEquals(serviceId, health.getService().getId());
assertEquals(serviceId2, health2.getService().getId());
private ServiceHealthKey getServiceHealthKeyFromCache(ServiceHealthCache cache, String serviceId, int port) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems to me it could be static

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Regarding @a.dericbourg review:
- make getServiceHealthKeyFromCache static
- make getServiceHealthKeyFromCache return an Optional (no null)
@adericbourg
Copy link
Collaborator

LGTM

@adericbourg adericbourg merged commit 2181ad7 into rickfast:master Jan 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants