gazbert / bxbot

A simple Bitcoin trading bot written in Java.
MIT License
775 stars 275 forks source link

TestBotLogfileService is failing #144

Closed zb226 closed 2 years ago

zb226 commented 2 years ago

Describe the bug When building with maven, I get:

[INFO] Running com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService
[ERROR] Tests run: 8, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.147 s <<< FAILURE! - in com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService
[ERROR] whenGetLogfileAsResourceCalledThenExpectLogfileToBeReturned(com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService)  Time elapsed: 0.033 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<...hing EngineConfig...[
]982 [main] 2019-07-20 17:30:21,429 INFO  EngineConfigYamlRepository get() - Validating config...
4983 [main] 2019-07...> but was:<...hing EngineConfig...[
4982 [main] 2019-07-20 17:30:21,429 INFO  EngineConfigYamlRepository get() - Validating config...]
4983 [main] 2019-07...>
        at com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService.whenGetLogfileAsResourceCalledThenExpectLogfileToBeReturned(TestBotLogfileService.java:233)

Just to be sure, I also tried gradle:

com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService > whenGetLogfileAsResourceCalledThenExpectLogfileToBeReturned FAILED
    org.junit.ComparisonFailure at TestBotLogfileService.java:233

To Reproduce As per the docs, run

./mvnw clean install

or

./gradlew clean build

Expected behavior The test should succeed.

Please complete the following information:

gazbert commented 2 years ago

Hi there, have you got the full JUnit stack trace (especially the ComparisonFailure bit) handy?

[ERROR] whenGetLogfileAsResourceCalledThenExpectLogfileToBeReturned(com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService) Time elapsed: 0.033 s <<< FAILURE! org.junit.ComparisonFailure: expected:<...hing EngineConfig...[

I suspect this might be a bug in the test code expecting linux line feeds instead of windows CRs...

gazbert commented 2 years ago

If you want to build the bot in the meantime, you can skip the tests in the maven command line, e.g.

./mvnw -Dmaven.test.skip=true clean install

zb226 commented 2 years ago

I suspect this might be a bug in the test code expecting linux line feeds instead of windows CRs...

Yes, that was my impression as well even though the test uses System.lineSeparator() which should avoid that exact problem?

Hi there, have you got the full JUnit stack trace (especially the ComparisonFailure bit) handy?

The full stack trace would be this - is it what you're after? If not, how can I get that information?

com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService > whenGetLogfileAsResourceCalledThenExpectLogfileToBeReturned FAILED
    org.junit.ComparisonFailure: expected:<...hing EngineConfig...[
    4982 [main] 2019-07-20 17:30:21,429 INFO  EngineConfigYamlRepository get() - Validating config...
]
    4983 [main] 2019-07...> but was:<...hing EngineConfig...[
    4982 [main] 2019-07-20 17:30:21,429 INFO  EngineConfigYamlRepository get() - Validating config...]
    4983 [main] 2019-07...>
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at com.gazbert.bxbot.services.runtime.impl.TestBotLogfileService.whenGetLogfileAsResourceCalledThenExpectLogfileToBeReturned(TestBotLogfileService.java:233)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
        at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
        at com.sun.proxy.$Proxy5.processTestClass(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:412)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:834)
gazbert commented 2 years ago

Definitely a problem here. I get similar issue when UAT 'ing the REST getLogfile endpoint with latest tech-refresh branch:

Caused by: java.lang.NullPointerException
    at com.gazbert.bxbot.services.runtime.impl.BotLogfileServiceImpl.getLogfileHead(BotLogfileServiceImpl.java:95) ~[bxbot-services-1.2.1-SNAPSHOT.jar!/:1.2.1-SNAPSHOT]
    at com.gazbert.bxbot.rest.api.v1.runtime.BotLogfileController.getLogfile(BotLogfileController.java:203) ~[bxbot-rest-api-1.2.1-SNAPSHOT.jar!/:1.2.1-SNAPSHOT]
    at com.gazbert.bxbot.rest.api.v1.runtime.BotLogfileController$$FastClassBySpringCGLIB$$51d28ca3.invoke(<generated>) ~[bxbot-rest-api-1.2.1-SNAPSHOT.jar!/:1.2.1-SNAPSHOT]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.16.jar!/:5.3.16]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783) ~[spring-aop-5.3.16.jar!/:5.3.16]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.16.jar!/:5.3.16]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.16.jar!/:5.3.16]
    at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:61) ~[spring-security-core-5.6.2.jar!/:5.6.2]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.16.jar!/:5.3.16]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.16.jar!/:5.3.16]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) ~[spring-aop-5.3.16.jar!/:5.3.16]
    at com.gazbert.bxbot.rest.api.v1.runtime.BotLogfileController$$EnhancerBySpringCGLIB$$9c1b00c4.getLogfile(<generated>) ~[bxbot-rest-api-1.2.1-SNAPSHOT.jar!/:1.2.1-SNAPSHOT]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.16.jar!/:5.3.16]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.16.jar!/:5.3.16]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.16.jar!/:5.3.16]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.16.jar!/:5.3.16]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.16.jar!/:5.3.16]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.16.jar!/:5.3.16]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.16.jar!/:5.3.16]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.16.jar!/:5.3.16]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.16.jar!/:5.3.16]
    ... 86 more

Something has changed in the Spring Actuator LogFileWebEndpoint.java ... Will fix as part of the 1.3.0 tech-refresh release.

gazbert commented 2 years ago

Fixed. Boot logfile property change resulted in LogFileWebEndpoint not finding the app's logfile: https://github.com/gazbert/bxbot/commit/e681ed61a0b219e8a28c0847cf7e2f2c01049b21

zb226 commented 2 years ago

Can confirm, tests running fine on the tech-refresh branch.

gazbert commented 2 years ago

Released: https://github.com/gazbert/bxbot/releases/tag/v1.3.0