How to generate Individual Hits report using commands in Linux

ranjithcranjithc Posts: 5

Hi,
I am running my load tests in Linux and the .rpt file will get generated once the test got completed.
Generating individual hits report from the .rpt file takes more time since the file size will be high (around 350 MB) and also it takes more time to copy from linux machine to windows machine.
Please let me know if there are any commands available to generate individual hits report from Linux machine.

Thanks in advance

Ranjith

Best Answer

Answers

  • SergeiSergei Posts: 19

    You can add the Individual Hits graph to your HTML report and have the HTML report automatically generated if you are running your load test from command line mode. First verify that the Individual Hits are included into the HTML report configuration - see Reviewing and Customizing Load Test Results -> Viewing a Report -> Configuring HTML Report Options section of the docs for steps. Then run Load Test with the -allReport command like so: loadtest -minutes ${minutes} -allReports ${pathToReportsDirectory} ${scenario} (see details in Load Test Command Line Interface section of the docs). Load Test will create an HTML report (as well as the binary and xml) with an individual hits graph under that path.

  • ranjithcranjithc Posts: 5

    Hi,
    Thanks for your reply.
    In my HTML report i'm getting the individual hits as a graph.
    To know the response time of a single hit in my load test, i can save the individual hits report as a .csv file which can be done in user interface mode (in windows machine).
    I would like to know whether any command line option is available in Linux to save the individual report in .csv format (like how HTML report is being saved using -allReport command).

    Thanks in Advance.

    Regards,
    Ranjith

  • SergeiSergei Posts: 19

    Hi Ranjith,

    There is no command line option to save individual hits in a .cvs table separately from the report, it is possible however to save hit details with the help of a custom/scriptable QOS metric. Although QOS metrics are designed to process relevant data in the report and produce a success/failure output, it is possible to use metrics for other types of processing of the report data, which in your case is exporting of the individual hits.

    Below in a Jython script for a custom QOS metric that writes hits in the same format as the "Export Individual Hits" option in the Load Test report graph view. The QOS metric will be applied at the completion of a load test. You will need to modify the path of the destination file in the script to the one that is relevant for your case:

    hitsFile = open('REPLACE_WITH_PATH_TO_FILE/hits.csv','w')

        from com.parasoft.api.loadtest import QOSUtil
        from com.parasoft.api.loadtest.output import MergedOutputConstants
        from com.parasoft.simulator.api.output import *
        from com.parasoft.simulator.output.raw import *
        from com.parasoft.simulator.output.view.table import *
    
        # See Help->API->Scripting API
        # See Help->API->Component API
        def exportIndividualHits(args):
            ltReport = args.getOutput()
            hitsFile = open('REPLACE_WITH_PATH_TO_FILE/hits.csv','w')
            hits = ltReport.getHits()
            outputMap = SingleOutputNameResolver.getTestNameMap(ltReport.getOutput().getMergedOutput())
            rawOutput = ltReport.getOutput().getRawOutput()
            hitsFile.write('Machine, Profile, Test, Success, Start Time (ms), Execution Time (ms), Request Size (bytes), Response Size (bytes), Error String' + '\n')
            for hit in hits :
              testName = SingleOutputNameResolver.resolveTestName(outputMap, hit)
              if not 'Test Suite' in testName: # filter out Test Suite hits
                hitsFile.write(SingleOutputNameResolver.resolveInstance(rawOutput, hit) + ', ')
                hitsFile.write(SingleOutputNameResolver.resolveProfile(rawOutput, hit) + ', ')
                hitsFile.write(testName + ', ')
                if hit.getState() == SingleOutput.HIT_SUCCESS :
                   hitsFile.write('Success, ')
                else :
                   hitsFile.write('Failure, ')  
                hitsFile.write(str(hit.getStartTime()) + ',')
                hitsFile.write(str(hit.getExeTime()) + ',')
                hitsFile.write(str(hit.getBytesOut()) + ',')
                hitsFile.write(str(hit.getBytesIn()) + ',')
                hitsFile.write(TableErrorString(hit.getHitOutput()).getFormattedString())
                hitsFile.write('\n')
    
            hitsFile.close()
            return QOSUtil.newMetric('Pass', '')
    

    Thanks,
    -Sergei

  • ranjithcranjithc Posts: 5

    Hi Sergei,
    Thanks a lot for your reply.
    I tried with custom QOS metrics that you shared in my loadtest . I observed a compilation error (Traceback (most recent call last):
    File "", line 6, in
    ImportError: No module named table)
    When i tried removing the line " from com.parasoft.simulator.output.view.table import *" i'm getting an error message (Traceback (most recent call last):
    File "", line 13, in exportIndividualHits
    AttributeError: 'com.parasoft.simulator.output.LoadTestOutputImpl' object has no attribute 'getOutput') once the test got over.

    Please find the attached images for your reference.

    Could you please help here.

    Thanks in advance.

    Regards,
    Ranjith

  • SergeiSergei Posts: 19

    Hi Ranjith,

    Judging by the screenshots, you are using a (very) old version of Load Test - you can see it in Help->About. I tested the script with Load Test 9.10, which is the latest version. Please update to the latest versions of SOAtest/LoadTest. Also because of the nature of the functionality you've requested, the script is using some non-API calls, so it is sensitive to the SOAtest/LoadTest version.

    -Sergei

  • ranjithcranjithc Posts: 5

    Hi Sergei,

    Thanks for your response.
    I checked with parasoft version 9.9 and i'm able to generate individual hits report.
    But when checked in the report, the data are being populated for the first hit only and not for all the hits (eg. my run count from html report is 49 and from individual hits report is 1).
    I guess the for loop is exiting after capturing the first hit.
    Since i'm not faimiliar with jython script, i could not compile it and fix it.
    Could you please help in this.
    Or is there any alternate java code or javascript code available for capturing the individual hits.

    Thanks in advance.

    Regards,
    Ranjith

  • ranjithcranjithc Posts: 5

    Hi Sergei,

    This has worked fine with parasoft version 9.9.5.
    Thanks

Sign In or Register to comment.