gpt4 book ai didi

java - 项目建立在本地但在 travis-ci 容器中失败

转载 作者:行者123 更新时间:2023-11-30 08:38:19 24 4
gpt4 key购买 nike

首先,抱歉英语不好...

我创建了项目 spark-spring ( https://github.com/rascorp/spark-spring ) 以提供一种将 spring 上下文放入 spark-java 框架的简单方法。

我创建了一个测试来检查服务器是否启动并返回一个值。在我的个人电脑上运行,所有测试运行正常,但在 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$1.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$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.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)

谁能帮我解决这个问题?

最佳答案

我找到问题了!

出现该问题是因为测试运行时服务方法不可用。要修复,我需要在运行测试之前调用以下代码。

/**
* Waits for the spark server to be initialized.
* If it's already initialized will return immediately
*/
Spark.awaitInitialization();

关于java - 项目建立在本地但在 travis-ci 容器中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36628326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com