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

Unit test for RemoteRepositoryAlivenessCacheManager #1513

Open
5 tasks
sbespalov opened this issue Oct 8, 2019 · 28 comments
Open
5 tasks

Unit test for RemoteRepositoryAlivenessCacheManager #1513

sbespalov opened this issue Oct 8, 2019 · 28 comments

Comments

@sbespalov
Copy link
Member

sbespalov commented Oct 8, 2019

Task Description

We need a Unit Test for RemoteRepositoryAlivenessCacheManager functionality.
The underlying cache within test should be Hazelcast cache instance (distributed).

Tasks

There should be following test cases:

  • check that RemoteRepositoryAlivenessCacheManager.isAlive return true if there is no cached value for particular repository
  • check that RemoteRepositoryAlivenessCacheManager.isAlive return true if there is cached true value for particular repository
  • check that RemoteRepositoryAlivenessCacheManager.isAlive return false if there is cached false value for particular repository
  • check that RemoteRepositoryAlivenessCacheManager.isAlive return true if cache expired
  • check that RemoteRepositoryAlivenessCacheManager.put immediately changes cached value

Useful Links

Task Relationships

This task:

Help

@mwvdev
Copy link

mwvdev commented Oct 8, 2019

I'd like to give this a go.

@carlspring
Copy link
Member

Great! Go ahead and dig in! :)

@mwvdev
Copy link

mwvdev commented Nov 9, 2019

Figured it was time to write a short update on this issue so here goes. I've been unable to find the root cause of why the Hazelcast caches aren't persisting in the unit test scenarios.

I've tried inspecting the Hazelcast caches through debugging and through the Hazelcast management center.

As for the debugging part, I can follow the put instructions all the way to the HazelcastCache instance and I can spot anything wrong except that after the operation, nothing is persisted in the cache. I have also tried creating a proof of concept project that uses the HazelcastConfiguration class, you can check it out here. The test in the POC is able to persist in the cache as expected, and when debugging through the steps it seems to go through the same instructions as the test in this issue, except that values are actually getting persisted.

As for the management center, it seems if I simply start strongbox locally and inspect the Hazelcast cache, then the HazelcastCache does work. See the below screenshot from having started strongbox locally:

Hazelcast management center

It only appears there are issues when caching in the unit test.

I've reached out to the Hazelcast team, and they've pointed me to the documentation on sharding located here. After having read it, I'm not closer to figuring out why values aren't getting cached. They've also made suggestions in a pull request to the POC project but switching Hazelcast to a multicast configuration hasn't helped either.

I'm a bit stuck on this issue to be honest, the tests themselves are fairly easy to write but they're useless if I can't get the Hazelcast cache integration to actually persist when running the unit test. Perhaps someone could try going over this with fresh eyes?

You can see my PR for this issue at #1520.

Thanks!

@carlspring
Copy link
Member

@fuss86 / @sbespalov ,

Any thoughts/advice on this?

@fuss86
Copy link
Contributor

fuss86 commented Nov 10, 2019

@mwvdev thanks for your engagement :) I've prepared a documentation task related to your experiments with management center tool #1581 - please pick it up if you are up for it :)

Referring to the issues you spotted here. I'll enter your branch and try to help :)

@fuss86
Copy link
Contributor

fuss86 commented Nov 10, 2019

@mwvdev could you please make sure that your branch compiles without problems ?

Here is the result of mvn clean install -DskipTests=true command:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.323 s
[INFO] Finished at: 2019-11-10T14:02:55+01:00
[INFO] Final Memory: 147M/697M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project strongbox-commons: Compilation failure: Compilation failure:
[ERROR] strongbox/strongbox-commons/src/main/java/org/carlspring/strongbox/resource/ConfigurationResourceResolver.java:[5,20] package javax.inject does not exist
[ERROR] strongbox/strongbox-commons/src/main/java/org/carlspring/strongbox/booters/TempDirBooter.java:[10,20] package javax.inject does not exist
[ERROR] strongbox/strongbox-commons/src/main/java/org/carlspring/strongbox/resource/ConfigurationResourceResolver.java:[28,6] cannot find symbol
[ERROR]   symbol:   class Inject
[ERROR]   location: class org.carlspring.strongbox.resource.ConfigurationResourceResolver
[ERROR] strongbox/strongbox-commons/src/main/java/org/carlspring/strongbox/resource/ConfigurationResourceResolver.java:[31,6] cannot find symbol
[ERROR]   symbol:   class Inject
[ERROR]   location: class org.carlspring.strongbox.resource.ConfigurationResourceResolver
[ERROR] strongbox/strongbox-commons/src/main/java/org/carlspring/strongbox/booters/TempDirBooter.java:[26,6] cannot find symbol
[ERROR]   symbol:   class Inject
[ERROR]   location: class org.carlspring.strongbox.booters.TempDirBooter
[ERROR] strongbox/strongbox-commons/src/main/java/org/carlspring/strongbox/io/ByteRangeInputStream.java:[41,17] reposition(long) in org.carlspring.strongbox.io.ByteRangeInputStream cannot implement reposition(long) in org.carlspring.commons.io.reloading.Repositioning
[ERROR]   overridden method does not throw java.io.IOException
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :strongbox-commons

and the result of mvn dependency:tree -Dincludes=org.carlspring.strongbox:strongbox-commons filtered to strongbox-storage-api:

[INFO] ------------------------------------------------------------------------
[INFO] Building Strongbox: Storage [API] 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ strongbox-storage-api ---
[INFO] org.carlspring.strongbox:strongbox-storage-api:jar:1.0-SNAPSHOT
[INFO] \- org.carlspring.strongbox:strongbox-configuration:jar:1.0-SNAPSHOT:compile
[INFO]    \- org.carlspring.strongbox:strongbox-commons:jar:1.0-SNAPSHOT:compile
[INFO]
[INFO] ------------------------------------------------------------------------

@mwvdev
Copy link

mwvdev commented Nov 10, 2019

@mwvdev thanks for your engagement :) I've prepared a documentation task related to your experiments with management center tool #1581 - please pick it up if you are up for it :)

No problem! I don't have too much spare time these days but I don't mind trucking along on that documentation issue at my own pace.

@mwvdev could you please make sure that your branch compiles without problems ?

Sure thing, I'll look into it.

@mwvdev
Copy link

mwvdev commented Nov 10, 2019

@fuss86 @sbespalov I had an issue with rebasing. @carlspring helped me sort it out - the branch should compile as expected now.

@fuss86
Copy link
Contributor

fuss86 commented Nov 11, 2019

Hi @mwvdev ,

it looks like the problem is somehow related with our parent.

If you replace

<parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.5.RELEASE</version>
        </parent>

by

       <parent>
            <groupId>org.carlspring.strongbox</groupId>
            <artifactId>strongbox-parent</artifactId>
            <version>1.0-SNAPSHOT</version>
        </parent>

then your poc will fail (logback-spring.xml will be needed to add to the target/strongbox/etc) too.

@fuss86
Copy link
Contributor

fuss86 commented Nov 11, 2019

I've added gist https://gist.github.com/fuss86/cf7ed264c6573814c85ac3ca1512794d comparing 2 parents in your POC. There must be something wrong, please try to analyze it and let us know :)

@carlspring
Copy link
Member

Here's a diff run on the dependency trees of the two:

--- spring-boot-starter-parent	2019-11-11 12:52:02.132369427 +0000
+++ strongbox-parent-1.0-SNAPSHOT	2019-11-11 12:52:36.723360982 +0000
@@ -4,17 +4,16 @@
 [INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.5.RELEASE:compile
 [INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.5.RELEASE:compile
 [INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
-[INFO] |  |  |  |  +- ch.qos.logback:logback-core:jar:1.2.3:compile
-[INFO] |  |  |  |  \- org.slf4j:slf4j-api:jar:1.7.26:compile
+[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
 [INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.2:compile
 [INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
-[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.26:compile
+[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
 [INFO] |  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
 [INFO] |  |  \- org.yaml:snakeyaml:jar:1.23:runtime
 [INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.1.5.RELEASE:compile
-[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.8:compile
-[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
-[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.8:compile
+[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.0:compile
+[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.0:compile
+[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.10.0:compile
 [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.8:compile
 [INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.8:compile
 [INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.8:compile
@@ -22,7 +21,7 @@
 [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.19:compile
 [INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.19:compile
 [INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.19:compile
-[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.16.Final:compile
+[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.17.Final:compile
 [INFO] |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
 [INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
 [INFO] |  |  \- com.fasterxml:classmate:jar:1.4.0:compile
@@ -40,11 +39,29 @@
 [INFO] +- org.springframework:spring-test:jar:5.1.7.RELEASE:test
 [INFO] |  \- org.springframework:spring-core:jar:5.1.7.RELEASE:compile
 [INFO] |     \- org.springframework:spring-jcl:jar:5.1.7.RELEASE:compile
-[INFO] \- org.junit.jupiter:junit-jupiter:jar:5.4.0:test
-[INFO]    +- org.junit.jupiter:junit-jupiter-api:jar:5.3.2:test
-[INFO]    |  +- org.apiguardian:apiguardian-api:jar:1.0.0:test
-[INFO]    |  +- org.opentest4j:opentest4j:jar:1.1.1:test
-[INFO]    |  \- org.junit.platform:junit-platform-commons:jar:1.3.2:test
-[INFO]    +- org.junit.jupiter:junit-jupiter-params:jar:5.3.2:test
-[INFO]    \- org.junit.jupiter:junit-jupiter-engine:jar:5.3.2:test
-[INFO]       \- org.junit.platform:junit-platform-engine:jar:1.3.2:test
+[INFO] +- org.junit.jupiter:junit-jupiter:jar:5.4.0:test
+[INFO] |  +- org.junit.jupiter:junit-jupiter-api:jar:5.4.0:test
+[INFO] |  |  +- org.opentest4j:opentest4j:jar:1.1.1:test
+[INFO] |  |  \- org.junit.platform:junit-platform-commons:jar:1.4.0:test
+[INFO] |  +- org.junit.jupiter:junit-jupiter-params:jar:5.4.0:test
+[INFO] |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.4.0:test
+[INFO] +- org.codehaus.sonar-plugins.java:sonar-jacoco-listeners:jar:2.4:test
+[INFO] +- org.junit.platform:junit-platform-launcher:jar:1.4.0:test
+[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.0.0:test
+[INFO] |  \- org.junit.platform:junit-platform-engine:jar:1.4.0:test
+[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.5.RELEASE:test
+[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.5.RELEASE:test
+[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
+[INFO] |  |  +- net.minidev:json-smart:jar:2.3:test
+[INFO] |  |  |  \- net.minidev:accessors-smart:jar:1.2:test
+[INFO] |  |  |     \- org.ow2.asm:asm:jar:6.0:test
+[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
+[INFO] |  +- org.assertj:assertj-core:jar:3.11.1:test
+[INFO] |  +- org.mockito:mockito-core:jar:3.1.0:test
+[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.9.12:test
+[INFO] |  |  \- net.bytebuddy:byte-buddy-agent:jar:1.9.12:test
+[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
+[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
+[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.6.2:test
+[INFO] \- org.codehaus.janino:janino:jar:3.0.6:compile
+[INFO]    \- org.codehaus.janino:commons-compiler:jar:3.0.6:compile

@carlspring
Copy link
Member

I think the main difference is coming from this bit:

+[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.5.RELEASE:test
+[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.5.RELEASE:test
+[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
+[INFO] |  |  +- net.minidev:json-smart:jar:2.3:test
+[INFO] |  |  |  \- net.minidev:accessors-smart:jar:1.2:test
+[INFO] |  |  |     \- org.ow2.asm:asm:jar:6.0:test
+[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
+[INFO] |  +- org.assertj:assertj-core:jar:3.11.1:test
+[INFO] |  +- org.mockito:mockito-core:jar:3.1.0:test
+[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.9.12:test
+[INFO] |  |  \- net.bytebuddy:byte-buddy-agent:jar:1.9.12:test
+[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
+[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
+[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.6.2:test
+[INFO] \- org.codehaus.janino:janino:jar:3.0.6:compile
+[INFO]    \- org.codehaus.janino:commons-compiler:jar:3.0.6:compile

Could org.springframework.boot:spring-boot-starter-test:jar:2.1.5.RELEASE:test be the culprit?

@mwvdev
Copy link

mwvdev commented Nov 11, 2019

it looks like the problem is somehow related with our parent.

@fuss86 That's great news! Or it's at least a step in the right direction :)

I've added gist https://gist.github.com/fuss86/cf7ed264c6573814c85ac3ca1512794d comparing 2 parents in your POC. There must be something wrong, please try to analyze it and let us know :)

@fuss86 Will do.

Could org.springframework.boot:spring-boot-starter-test:jar:2.1.5.RELEASE:test be the culprit?

@carlspring It seems likely. I'll do a bit of digging around.

@mwvdev
Copy link

mwvdev commented Nov 11, 2019

Could org.springframework.boot:spring-boot-starter-test:jar:2.1.5.RELEASE:test be the culprit?

@carlspring Come to think of it, this might also explain why I've only observed this in a test scenario.

@carlspring
Copy link
Member

@mwvdev ,

Would you be able to pick it up from here?

@mwvdev
Copy link

mwvdev commented Nov 11, 2019

Would you be able to pick it up from here?

Yes, I've got a few things to try out now.

@carlspring
Copy link
Member

Great! Good luck! :)

@carlspring
Copy link
Member

@anki2189 ,

Would you like to help @mwvdev with this issue?

@mwvdev
Copy link

mwvdev commented Nov 19, 2019

Any help would be appreciated, I've tried everything I could think of and I still haven't been able to identify why this works when using spring-boot-starter-parent and doesn't work when using strongbox-parent.

@anki2189

This comment has been minimized.

@carlspring

This comment has been minimized.

@anki2189

This comment has been minimized.

@carlspring

This comment has been minimized.

@carlspring
Copy link
Member

@sbespalov : Just a reminder to check, if we can now close this task with your recent changes...?

@anki2189
Copy link
Member

POC tests are still failing.

@gugatkesheladze
Copy link

i'll do it

@steve-todorov steve-todorov removed the hacktoberfest Pre-selected issues for Hacktoberfest label Oct 1, 2021
@pk97
Copy link

pk97 commented Oct 1, 2022

Is this issue still open?

@sawilkhan
Copy link

Can i work on this?

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

Successfully merging a pull request may close this issue.

9 participants