networknt / light-bot

A microservice based DevOps agent that handles multiple repositories and dependencies
Apache License 2.0
7 stars 3 forks source link

./gradle build failed due to failed tests #59

Closed lanphan closed 5 years ago

lanphan commented 5 years ago

Date: Feb 14, 2019 Source code: at commit a2e7690 (latest one)

I follows tutorial https://doc.networknt.com/tutorial/bot/build-light-bot/ , got failure when running ./gradlew build:

Task :exec-core:test FAILED

com.networknt.bot.core.GenericMultipleCmdTest > testGenericMultipleCmd FAILED java.lang.NoClassDefFoundError at GenericMultipleCmdTest.java:20 Caused by: java.lang.ClassNotFoundException at GenericMultipleCmdTest.java:20

com.networknt.bot.core.CommandExecutorTest > testLsCommand FAILED java.lang.NoClassDefFoundError at CommandExecutorTest.java:43

com.networknt.bot.core.CommandExecutorTest > testSimpleCommand FAILED java.lang.NoClassDefFoundError at CommandExecutorTest.java:23

com.networknt.bot.core.CommandExecutorTest > testGitClone FAILED java.lang.NoClassDefFoundError at CommandExecutorTest.java:66

com.networknt.bot.core.GenericSingleCmdTest > testGenericSingleCmd FAILED java.lang.NoClassDefFoundError at GenericSingleCmdTest.java:14

7 tests completed, 5 failed

I need to skip test in order to have bot-cli-fat file. Please help to review.

stevehu commented 5 years ago

I tested the master branch on my computer and it works fine. If you look at the first error is it trying to create an object and the class is on the src/main folder. There is one other possibility that File cannot be found but that is part of the JDK. I am wondering if you could help to debug into that line to see which class is missing. Also, which JDK are you using? which version? Thanks.

lanphan commented 5 years ago

@stevehu here is more information: 1/ my java version is 1.8, Oracle. java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

2/ detail about failed test: a/ first failed test: 21:02:26.077 [DEBUG] [TestEventLogger] com.networknt.bot.core.GenericMultipleCmdTest > testGenericMultipleCmd FAILED 21:02:26.077 [DEBUG] [TestEventLogger] java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/Module 21:02:26.077 [DEBUG] [TestEventLogger] at com.networknt.config.Config.getInstance(Config.java:76) 21:02:26.077 [DEBUG] [TestEventLogger] at com.networknt.service.SingletonServiceFactory.<clinit>(SingletonServiceFactory.java:26) 21:02:26.077 [DEBUG] [TestEventLogger] at com.networknt.bot.core.cmd.GenericMultipleCmd.<init>(GenericMultipleCmd.java:21) 21:02:26.077 [DEBUG] [TestEventLogger] at com.networknt.bot.core.GenericMultipleCmdTest.testGenericMultipleCmd(GenericMultipleCmdTest.java:20)

b/ 4 next failed tests are the same (I think due to the first one): 21:02:26.082 [DEBUG] [TestEventLogger] com.networknt.bot.core.CommandExecutorTest > testLsCommand FAILED 21:02:26.082 [DEBUG] [TestEventLogger] java.lang.NoClassDefFoundError: Could not initialize class com.networknt.service.SingletonServiceFactory 21:02:26.082 [DEBUG] [TestEventLogger] at com.networknt.bot.core.CommandExecutorTest.testLsCommand(CommandExecutorTest.java:43)

21:02:26.085 [DEBUG] [TestEventLogger] com.networknt.bot.core.CommandExecutorTest > testSimpleCommand FAILED 21:02:26.085 [DEBUG] [TestEventLogger] java.lang.NoClassDefFoundError: Could not initialize class com.networknt.service.SingletonServiceFactory 21:02:26.085 [DEBUG] [TestEventLogger] at com.networknt.bot.core.CommandExecutorTest.testSimpleCommand(CommandExecutorTest.java:23)

21:02:26.088 [DEBUG] [TestEventLogger] com.networknt.bot.core.CommandExecutorTest > testGitClone FAILED 21:02:26.088 [DEBUG] [TestEventLogger] java.lang.NoClassDefFoundError: Could not initialize class com.networknt.service.SingletonServiceFactory 21:02:26.088 [DEBUG] [TestEventLogger] at com.networknt.bot.core.CommandExecutorTest.testGitClone(CommandExecutorTest.java:66)

21:02:26.091 [DEBUG] [TestEventLogger] com.networknt.bot.core.GenericSingleCmdTest > testGenericSingleCmd FAILED 21:02:26.091 [DEBUG] [TestEventLogger] java.lang.NoClassDefFoundError: Could not initialize class com.networknt.service.SingletonServiceFactory 21:02:26.091 [DEBUG] [TestEventLogger] at com.networknt.bot.core.cmd.GenericSingleCmd.<init>(GenericSingleCmd.java:25)

lanphan commented 5 years ago

I switched to OpenJDK 8, still got that problem (I use Mac, using sdk to manage java version) openjdk version "1.8.0_172" OpenJDK Runtime Environment (Zulu 8.30.0.1-macosx) (build 1.8.0_172-b01) OpenJDK 64-Bit Server VM (Zulu 8.30.0.1-macosx) (build 25.172-b01, mixed mode)

ddobrin commented 5 years ago

Hi @lanphan : I have build master on one of my Macs and it builds fine.

Please see the env I am using: ... BUILD SUCCESSFUL in 7s 47 actionable tasks: 47 up-to-date ... ....:~/work/bot/light-bot:>java -version java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

... :~/work/bot/light-bot:>git branch develop

lanphan commented 5 years ago

it's strange ... I did try to ./gradlew clean build --refresh-dependencies, but still got that problem above, nothing change.

My source code is the latest one, on master branch too.

`Lans-MacBook-Pro:light-bot lanphan$ git branch

nothing to commit, working tree clean Lans-MacBook-Pro:light-bot lanphan$ git log commit a2e76904d37ab3c854522c8d90ba9ed06fe52d04 (HEAD -> master, origin/master, origin/HEAD) Author: Steve Hu stevehu@gmail.com Date: Fri Jan 11 22:36:18 2019 -0500

upgrade jackson to 2.9.8

`

ddobrin commented 5 years ago

@lanphan : ran the same command as yourself: ... BUILD SUCCESSFUL in 14s 55 actionable tasks: 55 executed ...

~/work/bot/light-bot:>git log commit a2e76904d37ab3c854522c8d90ba9ed06fe52d04 Author: Steve Hu stevehu@gmail.com Date: Fri Jan 11 22:36:18 2019 -0500

upgrade jackson to 2.9.8
lanphan commented 5 years ago

@ddobrin thanks, after reviewing carefully, I see that it raised problem relating to my jackson-databind jar file, I deleted it in .m2 folder, and run again, it works now.