项目建立在本地但在 travis-ci 容器中失败
Project builds on local but fails in travis-ci container
首先,抱歉英语不好...
我创建了项目 spark-spring (https://github.com/rascorp/spark-spring) 以提供一种将 spring 上下文放入 spark-java 框架的简单方法。
我创建了一个测试来检查服务器是否启动和 returns 一个值。 运行 在我的个人电脑中,所有测试 运行 都可以,但在 travis-ci 中连接测试失败。
本地输出:
Running com.github.rascorp.spark.spring.ConsoleAppInitializerTest
abr 14, 2016 12:46:01 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFORMAÇÕES: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@48140564: startup date [Thu Apr 14 12:46:01 BRT 2016]; root of context hierarchy
abr 14, 2016 12:46:01 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFORMAÇÕES: Loading XML bean definitions from class path resource [application-context-spark-spring-test.xml]
abr 14, 2016 12:46:01 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFORMAÇÕES: Loading XML bean definitions from class path resource [application-context-spark-spring.xml]
[Thread-1] INFO org.eclipse.jetty.util.log - Logging initialized @663ms
[Thread-1] INFO spark.webserver.JettySparkServer - == Spark has ignited ...
[Thread-1] INFO spark.webserver.JettySparkServer - >> Listening on 0.0.0.0:4568
[Thread-1] INFO org.eclipse.jetty.server.Server - jetty-9.3.2.v20150730
[Thread-1] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@55d35d9b{HTTP/1.1,[http/1.1]}{0.0.0.0:4568}
[Thread-1] INFO org.eclipse.jetty.server.Server - Started @734ms
[main] INFO spark.webserver.JettySparkServer - >>> Spark shutting down ...
[main] INFO org.eclipse.jetty.server.ServerConnector - Stopped ServerConnector@55d35d9b{HTTP/1.1,[http/1.1]}{0.0.0.0:4568}
[main] INFO spark.webserver.JettySparkServer - done
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.025 sec - in com.github.rascorp.spark.spring.ConsoleAppInitializerTest
Travis-CI 输出(您可以在此处检查构建:https://travis-ci.org/rascorp/spark-spring/builds/123091116):
Running com.github.rascorp.spark.spring.ConsoleAppInitializerTest
Apr 14, 2016 3:42:15 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6fffcba5: startup date [Thu Apr 14 15:42:15 UTC 2016]; root of context hierarchy
Apr 14, 2016 3:42:15 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [application-context-spark-spring-test.xml]
Apr 14, 2016 3:42:15 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [application-context-spark-spring.xml]
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.876 sec <<< FAILURE!
testContext(com.github.rascorp.spark.spring.ConsoleAppInitializerTest) Time elapsed: 0.035 sec <<< FAILURE!
java.lang.AssertionError: Connection refused
at org.junit.Assert.fail(Assert.java:88)
at com.github.rascorp.spark.spring.ConsoleAppInitializerTest.testContext(ConsoleAppInitializerTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=12=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
谁能帮我解决这个问题?
Travis CI 输出表明一项测试失败。 Travis CI 不一定 运行 与本地机器处于相同的条件。看看你能做些什么来让一个测试在两台机器上都通过。毕竟,如果您不能让它通过 Travis,您怎么知道它可以在除您自己的计算机之外的任何其他计算机上运行?如需调试特定问题的帮助,请参阅 Travis CI Common Build Problems.
我找到问题了!
出现问题是因为测试运行时服务方法不可用。要修复,我需要在 运行 测试之前调用以下代码。
/**
* Waits for the spark server to be initialized.
* If it's already initialized will return immediately
*/
Spark.awaitInitialization();
首先,抱歉英语不好...
我创建了项目 spark-spring (https://github.com/rascorp/spark-spring) 以提供一种将 spring 上下文放入 spark-java 框架的简单方法。
我创建了一个测试来检查服务器是否启动和 returns 一个值。 运行 在我的个人电脑中,所有测试 运行 都可以,但在 travis-ci 中连接测试失败。
本地输出:
Running com.github.rascorp.spark.spring.ConsoleAppInitializerTest
abr 14, 2016 12:46:01 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFORMAÇÕES: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@48140564: startup date [Thu Apr 14 12:46:01 BRT 2016]; root of context hierarchy
abr 14, 2016 12:46:01 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFORMAÇÕES: Loading XML bean definitions from class path resource [application-context-spark-spring-test.xml]
abr 14, 2016 12:46:01 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFORMAÇÕES: Loading XML bean definitions from class path resource [application-context-spark-spring.xml]
[Thread-1] INFO org.eclipse.jetty.util.log - Logging initialized @663ms
[Thread-1] INFO spark.webserver.JettySparkServer - == Spark has ignited ...
[Thread-1] INFO spark.webserver.JettySparkServer - >> Listening on 0.0.0.0:4568
[Thread-1] INFO org.eclipse.jetty.server.Server - jetty-9.3.2.v20150730
[Thread-1] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@55d35d9b{HTTP/1.1,[http/1.1]}{0.0.0.0:4568}
[Thread-1] INFO org.eclipse.jetty.server.Server - Started @734ms
[main] INFO spark.webserver.JettySparkServer - >>> Spark shutting down ...
[main] INFO org.eclipse.jetty.server.ServerConnector - Stopped ServerConnector@55d35d9b{HTTP/1.1,[http/1.1]}{0.0.0.0:4568}
[main] INFO spark.webserver.JettySparkServer - done
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.025 sec - in com.github.rascorp.spark.spring.ConsoleAppInitializerTest
Travis-CI 输出(您可以在此处检查构建:https://travis-ci.org/rascorp/spark-spring/builds/123091116):
Running com.github.rascorp.spark.spring.ConsoleAppInitializerTest
Apr 14, 2016 3:42:15 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6fffcba5: startup date [Thu Apr 14 15:42:15 UTC 2016]; root of context hierarchy
Apr 14, 2016 3:42:15 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [application-context-spark-spring-test.xml]
Apr 14, 2016 3:42:15 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [application-context-spark-spring.xml]
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.876 sec <<< FAILURE!
testContext(com.github.rascorp.spark.spring.ConsoleAppInitializerTest) Time elapsed: 0.035 sec <<< FAILURE!
java.lang.AssertionError: Connection refused
at org.junit.Assert.fail(Assert.java:88)
at com.github.rascorp.spark.spring.ConsoleAppInitializerTest.testContext(ConsoleAppInitializerTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=12=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
谁能帮我解决这个问题?
Travis CI 输出表明一项测试失败。 Travis CI 不一定 运行 与本地机器处于相同的条件。看看你能做些什么来让一个测试在两台机器上都通过。毕竟,如果您不能让它通过 Travis,您怎么知道它可以在除您自己的计算机之外的任何其他计算机上运行?如需调试特定问题的帮助,请参阅 Travis CI Common Build Problems.
我找到问题了!
出现问题是因为测试运行时服务方法不可用。要修复,我需要在 运行 测试之前调用以下代码。
/**
* Waits for the spark server to be initialized.
* If it's already initialized will return immediately
*/
Spark.awaitInitialization();