Java 连接重置错误-运行mvn clean install to run功能时

Java 连接重置错误-运行mvn clean install to run功能时,java,karate,Java,Karate,我们使用Maven原型生成了一个空手道测试项目,以测试几个不同的API服务。 我们有一个功能文件,它使用一个端点执行测试,当这个端点在我们的机器上本地运行时,它可以正常工作。但是,我们希望在CI环境中运行这些空手道测试,在该环境中,我们在开发环境中使用指向(已部署)服务的url。在CI管道上运行mvn clean install时,运行该功能时会出现错误: com.intuit.karate.exception.KarateException: MyFeatureTest.feature:8

我们使用Maven原型生成了一个空手道测试项目,以测试几个不同的API服务。 我们有一个功能文件,它使用一个端点执行测试,当这个端点在我们的机器上本地运行时,它可以正常工作。但是,我们希望在CI环境中运行这些空手道测试,在该环境中,我们在开发环境中使用指向(已部署)服务的url。在CI管道上运行
mvn clean install
时,运行该功能时会出现错误:

 com.intuit.karate.exception.KarateException:
 MyFeatureTest.feature:8 -
 java.net.SocketException: Connection reset
我们的配置

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>our-karate-tests</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.version>3.6.0</maven.compiler.version>
    <karate.version>0.9.5</karate.version>
  </properties>

  <dependencies>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-apache</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.intuit.karate</groupId>
        <artifactId>karate-junit4</artifactId>
        <version>${karate.version}</version>
        <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>            
        </plugins>        
    </build>       
</project>
MyFeatureTest.feature

Feature: test an endpoint
    Background:
        * url 'https://dev.myapplication.com/api/signin'
        * configure ssl = true

    Scenario: test request
        Given request {"username":"john", "password":"doe"}
        When method post
        Then status 200
        And match response == {resp:"success"}
我们尝试过的:

我们能够通过邮递员毫无问题地调用服务(本地和部署的服务)。我们还尝试了执行不同的方法,例如get。奇怪的是,连接重置错误发生在我们的CI环境中,但是当我们在本地运行该功能时,会得到一个
org.apache.http.conn.ConnectTimeoutException:connect tohttps://dev.myapplication.com:443 失败:连接超时


我们感觉它与空手道apache客户端有关,但我们也尝试使用apache jersey。不幸的是,当我们使用jersey客户端时也会遇到同样的问题。我们还认为它可能与SSL有关。但是,即使使用非ssl服务(并从功能中删除ssl配置),也会出现相同的问题。我们试图测试来自非https网站(如web.archive.org)和https网站(如google.com)的响应,但同样徒劳,我们只是测试GET请求。不过,同样的问题还是出现了。

听起来很像您需要处理HTTP代理

如果是这种情况,请参阅文档:


听起来很像是要处理HTTP代理

如果是这种情况,请参阅文档:


非常感谢您的及时回复,彼得!好了,我们在开发环境中不使用任何代理,但我只能在明天确定-我会尽快回复您!奇怪的是,如果我们使用邮递员运行相同的请求,我们在空手道中执行的请求仍然可以正常工作,对吗?@Doritos no这很常见,因为邮递员会自动使用您的系统/浏览器代理(我知情的猜测)-如果您仍然被卡住,我也无能为力,除非您给我一种复制的方法,抱歉:|这毕竟是代理问题!谢谢非常感谢您的及时回复,彼得!好了,我们在开发环境中不使用任何代理,但我只能在明天确定-我会尽快回复您!奇怪的是,如果我们使用邮递员运行相同的请求,我们在空手道中执行的请求仍然可以正常工作,对吗?@Doritos no这很常见,因为邮递员会自动使用您的系统/浏览器代理(我知情的猜测)-如果您仍然被卡住,我也无能为力,除非您给我一种复制的方法,抱歉:|这毕竟是代理问题!谢谢
Feature: test an endpoint
    Background:
        * url 'https://dev.myapplication.com/api/signin'
        * configure ssl = true

    Scenario: test request
        Given request {"username":"john", "password":"doe"}
        When method post
        Then status 200
        And match response == {resp:"success"}
* configure proxy = 'http://my.proxy.host:8080'