我正在尝试为我的Jenkins PR-Build for a Hybris平台自动执行JMeter性能测试。
显然,为了运行我的JMeter性能脚本,hybrisserver需要先启动,以便本地主机可用。
我的方法是以与集成测试相同的方式启动服务器,然后执行性能测试。我可以看到服务器的启动方式与集成测试目标中的启动方式相同,但是我从jmeter脚本发出的所有请求都失败了,因为localhost不可用。
有人能帮上忙吗?
编辑:Approach to start the Hybris Server as its done for the integration test
编辑:在我的ANT目标中启动Hybris服务器的方法,它运行我的JMeter性能测试-它也启动Hybris服务器,但本地主机也不可访问
<yrun>
de.hybris.platform.core.Registry.setCurrentTenantByID("junit");
de.hybris.platform.util.RedeployUtilities.shutdown();
</yrun>发布于 2019-11-19 21:50:42
您可以将“等待”服务器可用的逻辑放在setUp Thread Group下,如下所示:
循环到子采样器成功之前的
的
然而,通过这种方式,您将在.jtl结果文件中获得额外的负结果,我将使用JSR223采样器和如下代码:
SampleResult.setIgnore()
def attempt = 1
def host = 'localhost'
def port = 8080
while (true) {
try {
def s = new Socket(host, port)
if (s.isConnected()) {
log.info('Server is available, starting the test')
s.close()
break
}
}
catch (Exception ex) {
log.info('Server is not available after ' + attempt + ' attempts, retrying...')
attempt++
sleep(5000)
}
}它将尝试与给定端点建立Socket连接,如果失败,请等待5秒,然后重试。当服务器可用时,它将退出循环并启动其他“正常”线程组。

发布于 2019-11-20 06:14:44
请尝试使用9001或9002端口。
发布于 2019-11-20 18:09:51
我认为您还需要使用以下内容激活您的租户:
de.hybris.platform.core.Registry.activateTenant(); (请检查您可以在Registery类中使用的可用函数)
<yrun>
de.hybris.platform.core.Registry.activateTenant(de.hybris.platform.core.Registry.getTenantByID("junit"));
de.hybris.platform.util.RedeployUtilities.shutdown();
</yrun>另外,检查platform/build.xml中的web=true是否触发了web上下文加载。
<target name="allwebtests" description="">
<callback extname="" target="before_yunitweb"/>
<annotationtests annotations="unittests,demotests,integrationtests" web="true"/>
<callback extname="" target="after_yunitweb"/>
</target>https://stackoverflow.com/questions/58934201
复制相似问题