spring-cloud-contract-nodejs icon indicating copy to clipboard operation
spring-cloud-contract-nodejs copied to clipboard

Error running `npm test`

Open decomplected opened this issue 3 years ago • 2 comments

Attempting to run the Spring Cloud Contract example tests I cloned the repo and ran the npm test as described in the README.md. I got the following error ERROR: JAVA_HOME is set to an invalid directory: /root/.sdkman/candidates/java/current/.

Originally I assumed this was an issue with my local install of SDKMAN, but learning the Spring supported docker images also use SDKMAN - I found the directory being called out in the error above matches the Dockerfile's line 19: https://github.com/spring-cloud/spring-cloud-contract/blob/bbb4db35838f62c8e6df7479e64a33bd875f765d/docker/spring-cloud-contract-stub-runner-docker/Dockerfile#L19

I'm running this on a Mac in iTerm2 and from the terminal within IntelliJ with the same results. Here is my terminal output to try and provide additional context:

$ npm -v                                                                                           
6.14.11

$ node -v                                                                                          
v10.24.0

$ java --version                                                                                   
openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

$ echo $SDKMAN_DIR                                                                                 
/Users/[my_home]/.sdkman

$ echo $JAVA_HOME
/Users/[my_home]/.sdkman/candidates/java/current

$ npm test                                                                                         

> [email protected] test /Users/[my_home]/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
> ./run_tests.sh



Running tests against Artifactory


~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs/docker ~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Killing docker_artifactory_1 ... done
Killing docker_mongo_1       ... done
~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Fetching submodules
Submodule path 'spring-cloud-contract-nodejs-external-contracts': checked out '01c1a8a9f0ba4804a907642f48a26a9e3195c1f2'
Entering 'spring-cloud-contract-nodejs-external-contracts'
From https://github.com/spring-cloud-samples/spring-cloud-contract-nodejs-external-contracts
 * branch            master     -> FETCH_HEAD
Successfully rebased and updated detached HEAD.
Building docker
~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs/docker ~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Going to remove docker_artifactory_1, docker_mongo_1
Removing docker_artifactory_1 ... done
Removing docker_mongo_1       ... done
mongo uses an image, skipping
Building artifactory
Step 1/4 : FROM docker.bintray.io/jfrog/artifactory-oss:5.5.1
 ---> add606aca80a
Step 2/4 : MAINTAINER Marcin Grzejszczak <[email protected]>
 ---> Using cache
 ---> f0bb37404ef7
Step 3/4 : COPY artifactory.config.import.yml /var/opt/jfrog/artifactory/etc/artifactory.config.import.yml
 ---> Using cache
 ---> bc69e380670a
Step 4/4 : ENTRYPOINT ["/bin/sh", "-c", "/entrypoint-artifactory.sh"]
 ---> Using cache
 ---> e56f266e24a4

Successfully built e56f266e24a4
Successfully tagged docker_artifactory:latest
Creating docker_mongo_1       ... done
Creating docker_artifactory_1 ... done
~/git/github/spring-cloud-samples/spring-cloud-contract-nodejs
Waiting for 30 seconds for artifactory to boot properly
Working around certificate issues
up to date in 4.965s
[!] 215 vulnerabilities found [1263 packages audited]
    Severity: 89 Low | 14 Moderate | 112 High
    Run `npm audit` for more detail

+ [email protected]
updated 1 package in 6.156s
[!] 215 vulnerabilities found [1263 packages audited]
    Severity: 89 Low | 14 Moderate | 112 High
    Run `npm audit` for more detail

appending output to nohup.out
Sc Contract Version [3.0.2-SNAPSHOT]
Application URL [http://host.docker.internal:9876]
Artifactory URL [http://host.docker.internal:8081/artifactory/libs-release-local]
Project Version [0.0.1.RELEASE]
Setting project name to [bookstore]
Running the build

ERROR: JAVA_HOME is set to an invalid directory: /root/.sdkman/candidates/java/current/

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

npm ERR! Test failed.  See above for more details.

Thoughts?

decomplected avatar Mar 08 '21 17:03 decomplected

Isn't there any solution for this yet? :(

HasithaAthukorala avatar Apr 23 '21 07:04 HasithaAthukorala

It works on my machine :tm:

  spring-cloud-contract-nodejs git:(sc-contract) npm test

> [email protected] test /home/marcin/repo/spring-cloud-contract-nodejs
> ./run_tests.sh



Running tests against Artifactory


~/repo/spring-cloud-contract-nodejs/docker ~/repo/spring-cloud-contract-nodejs
~/repo/spring-cloud-contract-nodejs
Fetching submodules
Entering 'spring-cloud-contract-nodejs-external-contracts'
From https://github.com/spring-cloud-samples/spring-cloud-contract-nodejs-external-contracts
 * branch            master     -> FETCH_HEAD
Updating 01c1a8a..9996c87
error: Your local changes to the following files would be overwritten by merge:
        pom.xml
Please commit your changes or stash them before you merge.
Aborting
fatal: run_command returned non-zero status for spring-cloud-contract-nodejs-external-contracts
.
Building docker
~/repo/spring-cloud-contract-nodejs/docker ~/repo/spring-cloud-contract-nodejs
No stopped containers
mongo uses an image, skipping
Building artifactory
Step 1/4 : FROM docker.bintray.io/jfrog/artifactory-oss:5.5.1
5.5.1: Pulling from jfrog/artifactory-oss
...
Digest: sha256:5dce3af709326417748d12f88f362f56a34329950271fedc4706eceb48321e62
Status: Downloaded newer image for docker.bintray.io/jfrog/artifactory-oss:5.5.1
 ---> add606aca80a
Step 2/4 : MAINTAINER Marcin Grzejszczak <[email protected]>
 ---> Running in 16f40f3f3387
Removing intermediate container 16f40f3f3387
 ---> 757995265207
Step 3/4 : COPY artifactory.config.import.yml /var/opt/jfrog/artifactory/etc/artifactory.config.import.yml
 ---> aba2ce89b704
Step 4/4 : ENTRYPOINT ["/bin/sh", "-c", "/entrypoint-artifactory.sh"]
 ---> Running in c97e39a0b681
Removing intermediate container c97e39a0b681
 ---> 02a57f271978

Successfully built 02a57f271978
Successfully tagged docker_artifactory:latest
Pulling mongo (mongo:jessie)...
jessie: Pulling from library/mongo
...
Digest: sha256:3e00936a4fbd17003cfd33ca808f03ada736134774bfbc3069d3757905a4a326
Status: Downloaded newer image for mongo:jessie
Creating docker_artifactory_1 ... done
Creating docker_mongo_1       ... done
~/repo/spring-cloud-contract-nodejs
Waiting for 30 seconds for artifactory to boot properly
Failed to kill app
Working around certificate issues
up to date in 6.022s
[!] 355 vulnerabilities found [1287 packages audited]
    Severity: 204 Low | 30 Moderate | 121 High
    Run `npm audit` for more detail

+ [email protected]
updated 1 package in 7.487s
[!] 355 vulnerabilities found [1287 packages audited]
    Severity: 204 Low | 30 Moderate | 121 High
    Run `npm audit` for more detail

nohup: appending output to 'nohup.out'
Sc Contract Version [3.0.2-SNAPSHOT]
Application URL [http://172.18.0.1:9876]
Artifactory URL [http://172.18.0.1:8081/artifactory/libs-release-local]
Project Version [0.0.1.RELEASE]
Setting project name to [bookstore]
Running the build
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/6.4/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
> Task :buildSrc:compileJava UP-TO-DATE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:processResources NO-SOURCE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Task :buildSrc:assemble UP-TO-DATE
> Task :buildSrc:compileTestJava NO-SOURCE
> Task :buildSrc:compileTestGroovy NO-SOURCE
> Task :buildSrc:processTestResources NO-SOURCE
> Task :buildSrc:testClasses UP-TO-DATE
> Task :buildSrc:test NO-SOURCE
> Task :buildSrc:check UP-TO-DATE
> Task :buildSrc:build UP-TO-DATE

> Configure project :
Will use contracts from the mounted [/contracts] folder

> Task :clean
> Task :compileJava NO-SOURCE
> Task :compileGroovy NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :bootJarMainClassName
> Task :bootJar SKIPPED
> Task :jar SKIPPED
> Task :copyContracts
> Task :generateClientStubs
> Task :verifierStubsJar
> Task :assemble

> Task :compileTestJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :compileTestGroovy NO-SOURCE
> Task :processTestResources
> Task :testClasses
> Task :test
> Task :generateContractTests

> Task :compileContractTestJava
Note: /spring-cloud-contract/build/generated-test-sources/contractTest/java/contracts/ContractVerifierTest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :compileContractTestGroovy NO-SOURCE
> Task :processContractTestResources NO-SOURCE
> Task :contractTestClasses

> Task :contractTest
2021-04-26 07:29:00.753  INFO 174 --- [extShutdownHook] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 3.4.3 (camel-1) is shutting down
2021-04-26 07:29:00.760  INFO 174 --- [extShutdownHook] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 3.4.3 (camel-1) uptime 1.326 seconds
2021-04-26 07:29:00.760  INFO 174 --- [extShutdownHook] o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 3.4.3 (camel-1) is shutdown in 0.007 seconds
Results: (2 tests, 2 successes, 0 failures, 0 skipped)

> Task :cleanOutput UP-TO-DATE
> Task :copyOutput
> Task :check
> Task :build
> Task :publishToMavenLocal SKIPPED
> Task :publish UP-TO-DATE

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 38s
13 actionable tasks: 12 executed, 1 up-to-date

marcingrzejszczak avatar Apr 26 '21 07:04 marcingrzejszczak