0
votes

I am trying to automate JMeter performance tests for my Jenkins PR-Build for a Hybris Platform.

In order to run my JMeter performance script obviously the hybrisserver needs to start first so that localhost is available.

My approach was to start the server the same way as its done for integration tests and then execute the performance tests. I can see that the server is starting up just the same way as in the integrationtests target but all my requests from jmeter script are failing as localhost is not available.

Can anyone help with that?

Edit: Approach to start the Hybris Server as its done for the integration test

Edit: Approach to start Hybris Server within my ANT Target which runs my JMeter Performance Test - it also starts Hybris Server but localhost is not reachable aswell

    <yrun>
         de.hybris.platform.core.Registry.setCurrentTenantByID("junit");

         de.hybris.platform.util.RedeployUtilities.shutdown();
     </yrun>
4
Hi @Theo - Please add up the commands and any related screenshots if possible. How you are trying to achieve it when you say same way as its done for integration tests?. Please add a little more info and you will attract more answers. Thankswww.hybriscx.com
Hi thanks for the hint. I added more informationTheo
Hi @Theo, I think you also need to call Registry.activateMasterTenant(); or activateTenantwww.hybriscx.com

4 Answers

0
votes

You can put your logic which will "wait" for server to become available under setUp Thread Group, something like:

however this way you will get extra negative results in your .jtl results file, I would go for JSR223 Sampler and the code like:

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)
    }
}

it will try to establish a Socket connection with the given endpoint and in case of failure wait for 5 seconds and retry. When the server becomes available it will exit the loop and start other "normal" Thread Groups.

enter image description here

0
votes

Please try at 9001 or 9002 ports.

0
votes

I think you will also need to activate your tenant using something like...
de.hybris.platform.core.Registry.activateTenant(); (please check for available functions you can use in Registery class)

<yrun>
         de.hybris.platform.core.Registry.activateTenant(de.hybris.platform.core.Registry.getTenantByID("junit"));
         de.hybris.platform.util.RedeployUtilities.shutdown();
</yrun>

Also, check for web=true in platform/build.xml if something triggers the web context loading.

<target name="allwebtests" description="">
        <callback extname="" target="before_yunitweb"/>
        <annotationtests annotations="unittests,demotests,integrationtests" web="true"/>
        <callback extname="" target="after_yunitweb"/>
    </target>
0
votes

You can start an embedded server using the "@NeedsEmbeddedServer" annotation, this is for example used in the Spock (BDD) tests in the "ycommercewebservicestest" extension.

Please note that this will use the "junit" tenant and the embedded server runs on the ports 8001 (http) and 8002 (https) by default.

You can check the ports in your properties:

# specifies default http port for embedded server
embeddedserver.http.port=8001

# specifies default https port for embedded server
embeddedserver.ssl.port=8002

For Example:

@IntegrationTest
@NeedsEmbeddedServer(webExtensions = {"ycommercewebservices"})
public class ExampleWebTest extends ServicelayerTest {

    @Test
    public void exampleTest() {
        // YOUR IMPLEMENTATION
    }
}