首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >启动Hybris服务器以进行JMeter性能测试

启动Hybris服务器以进行JMeter性能测试
EN

Stack Overflow用户
提问于 2019-11-19 20:31:33
回答 4查看 298关注 0票数 0

我正在尝试为我的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服务器,但本地主机也不可访问

代码语言:javascript
复制
    <yrun>
         de.hybris.platform.core.Registry.setCurrentTenantByID("junit");

         de.hybris.platform.util.RedeployUtilities.shutdown();
     </yrun>
EN

回答 4

Stack Overflow用户

发布于 2019-11-19 21:50:42

您可以将“等待”服务器可用的逻辑放在setUp Thread Group下,如下所示:

循环到子采样器成功之前的

然而,通过这种方式,您将在.jtl结果文件中获得额外的负结果,我将使用JSR223采样器和如下代码:

代码语言:javascript
复制
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秒,然后重试。当服务器可用时,它将退出循环并启动其他“正常”线程组。

票数 0
EN

Stack Overflow用户

发布于 2019-11-20 06:14:44

请尝试使用90019002端口。

票数 0
EN

Stack Overflow用户

发布于 2019-11-20 18:09:51

我认为您还需要使用以下内容激活您的租户:

de.hybris.platform.core.Registry.activateTenant(); (请检查您可以在Registery类中使用的可用函数)

代码语言:javascript
复制
<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上下文加载。

代码语言:javascript
复制
<target name="allwebtests" description="">
        <callback extname="" target="before_yunitweb"/>
        <annotationtests annotations="unittests,demotests,integrationtests" web="true"/>
        <callback extname="" target="after_yunitweb"/>
    </target>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58934201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档