Jay*_*Zus 10 continuous-integration jetty maven jenkins
我有一个由几个使用maven的模块组成的项目,并自动上传并部署到运行构建及其测试的Jenkins应用程序.
例如,API模块,服务器和客户端.
客户端和服务器都使用API作为依赖关系才能正常工作.客户端在正常使用中通过HTTP连接到服务器的Web服务.
为了能够运行,服务器需要在Jetty上运行.
我有单元测试,通过使用模拟的HTTP请求调用服务器的功能来工作和测试客户端.
我希望能够进行一些集成测试,例如测试2个实体之间的HTTP(和HTTPS)连接,测试超时等,并在不诉诸模拟请求的情况下重现单元测试,更接近真实用例.
似乎这样的事情应该很容易做到,但我找不到一种方法来简单地以可自动化的方式来做.
例如,在我的IDE中手动测试是通过单击服务器项目上的"run war"和在我的应用程序上"运行测试"来完成的.
有没有办法在Jenkins中重现这个简单的过程,所以它是由Maven配置甚至是Jenkins插件自动完成的?
更新:
我正在尝试制作另一个模块,它将使用我的服务器打包产生的战争,并使用Jetty运行它.由于我的服务器的Jetty配置相当复杂,使用由Maven过滤的Spring和https配置,因为缺少类和相关路径不能在该上下文中工作,所以我在新模块中工作时遇到了一些问题.
是否有可能像其他模块一样开始那场战争,而不会跳过重复资源和其他肮脏技巧的箍?
有关信息,我的pom.xml的特定Jetty war部分是:
<configuration>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>${project.parent.basedir}/cmp-service/cmp-webapp/target/cmp-webapp-1.0-SNAPSHOT.war</war>
<contextPath>/cmp</contextPath>
<persistTempDirectory>true</persistTempDirectory>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
</contextHandler>
</contextHandlers>
</configuration>
Run Code Online (Sandbox Code Playgroud)
更新2:
我设法构建了一个启动jetty的功能模块,并使用这个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">
<parent>
<artifactId>parent</artifactId>
<groupId>com.project.test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.project.test.integration-testing</groupId>
<artifactId>integration-testing</artifactId>
<packaging>jar</packaging>
<name>integration-testing</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.0.M2</version>
<configuration>
<contextHandlers>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>
${project.parent.basedir}/myserver/myservice/target/myservice-${project.parent.version}.war
</war>
<contextPath>/cmp</contextPath>
<persistTempDirectory>true</persistTempDirectory>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
</contextHandler>
</contextHandlers>
<contextXml>
${project.parent.basedir}/myserver/myservice/src/test/resources/jetty/jetty-context.xml
</contextXml>
<jettyXml>
${project.parent.basedir}/myserver/myservice/src/test/resources/jetty/jetty.xml,${project.parent.basedir}/myserver/myservice/src/test/resources/jetty/jetty-ssl.xml,${project.parent.basedir}/myserver/myservice/src/test/resources/jetty/jetty-http.xml,${project.parent.basedir}/myserver/myservice/src/test/resources/jetty/jetty-https.xml
</jettyXml>
<systemProperties>
<systemProperty>
<name>scsf.configuration.file</name>
<value>
${project.parent.basedir}/myserver/myservice/src/main/resources/config/cmpserver.properties
</value>
</systemProperty>
<systemProperty>
<name>org.eclipse.jetty.annotations.maxWait</name>
<value>180</value>
</systemProperty>
</systemProperties>
<systemPropertiesFile>
${project.parent.basedir}/myserver/myservice/src/main/resources/config/cmpserver.properties
</systemPropertiesFile>
<daemon>true</daemon>
<stopKey>STOP</stopKey>
<stopPort>10001</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
...
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
您还需要为战争添加依赖关系.
但是(总是有一个但是)运行验证目标时会出现问题.当我在我的集成测试模块中运行验证时,它有点工作.但是,当我在父级中运行验证目标时,它应该调用我的集成测试模块的完全相同的验证目标(如果我正确理解它是如何工作的),一些路径将被区别对待并被解析为,例如, parent/src/...而不是parent/integration-test/src ...
似乎从父级运行我的目标时,执行的上下文发生变化并导致我的应用程序在查找资源等时中断.
有什么我不明白整个过程是如何工作的,有没有办法使它工作?
我已经决定破解我的方式将我的所有路径都变成绝对路径,它有效,但它并不能解释这种行为.
小智 0

你好杰伊,
真的很想简化这里的事情,为什么不连续运行这些作业呢?首先是使用 Maven 进行编译、单元测试和部署任务。对于集成测试,创建另一个使用 Selenium(用于您的 Web 应用程序)和 JMeter(用于您的 Web 服务)等插件的作业。您还可以尝试其他许可证测试套件,例如 Openscript。
Web 服务测试将很棘手,因为您的 Web 服务使用者在另一个客户端上运行。您是否有在客户端应用程序上运行的从属代理?如果有的话,请在从站内运行这些作业。
| 归档时间: |
|
| 查看次数: |
1205 次 |
| 最近记录: |