{% extends "base.html" %}


{% block title %}Report {% if test %}#{{ uuid }} - {{ format_date(runAt) }}{% else %}Not Found{% end %} - Wight v0.1.0{% end %}

{% block contents %}
<div class="container">
{% if test %}
    <div class="hero-unit">
        <h1>{{ test["config"]["title"] }}</h1>
        <p>{{ test["config"]["description"] }}</p>
        <p><small>This report details the test run at <span class="text-info">{{ format_date(runAt) }}</span>, scheduled by user <span class="text-info">{{ createdBy }}</span>.</small></p>
        <div class="toolbar">
            <div><a href="/report/{{ uuid }}"><i class="icon-file"></i>Permalink for this test</a></div>
            {% if last_result %}
            <div><a href="/diff/{{ last_result }}/{{ uuid }}"><i class="icon-minus-sign"></i>Difference to the previous test</a></div>
            {% end %}
            <div><a href="/trend/{{ team }}/{{ project }}/{{ test["config"]["module"] }}/{{ test["config"]["className"] }}/{{ test["config"]["testName"] }}"><i class="icon-fullscreen"></i>Trend for this project</a></div>
        </div>
    </div>

    <div class="page-header">
      <h1>Bench Configuration <small>details of the configuration for this test</small></h1>
    </div>

    <div class="row">
        <div class="span6">
            <dl class="dl-horizontal">
              <dt>Launched</dt>
              <dd>{{ format_date(test["config"]["testDate"]) }}</dd>
            </dl>
            <dl class="dl-horizontal">
              <dt>Test File</dt>
              <dd><code>{{ test["config"]["module"] }}</code></dd>
            </dl>
            <dl class="dl-horizontal">
              <dt>Test Method</dt>
              <dd><code>{{ test["config"]["className"] }}.{{ test["config"]["testName"] }}</code></dd>
            </dl>
            <dl class="dl-horizontal">
              <dt>Target server</dt>
              <dd><a href="{{ test["config"]["targetServer"] }}">{{ test["config"]["targetServer"] }}</a></dd>
            </dl>
            <dl class="dl-horizontal">
              <dt title="Cycles of concurrent users">Cycles of concurrent users</dt>
              <dd><code>{{ test["config"]["cycles"] }}</code></dd>
            </dl>
            <dl class="dl-horizontal">
              <dt title="Cycle duration">Cycle duration</dt>
              <dd>{{ test["config"]["cycleDuration"] }} seconds</dd>
            </dl>
        </div>
        <div class="span6">
            <dl class="dl-horizontal">
              <dt title="Sleeptime between request">Sleeptime between request</dt>
              <dd>from <span class="text-info">{{ test["config"]["sleepTimeMin"] }}s</span> to <span class="text-info">{{ test["config"]["sleepTimeMax"] }}s</span></dd>
            </dl>
            <dl class="dl-horizontal">
              <dt title="Sleeptime between test case">Sleeptime between test case</dt>
              <dd><span class="text-info">{{ test["config"]["sleepTime"] }}s</span></dd>
            </dl>
            <dl class="dl-horizontal">
              <dt title="Startup delay between thread">Startup delay between thread</dt>
              <dd><span class="text-info">{{ test["config"]["startupDelay"] }}s</span></dd>
            </dl>
            <dl class="dl-horizontal">
              <dt title="Apdex">Apdex</dt>
              <dd>1.5</dd>
            </dl>
            <dl class="dl-horizontal">
              <dt title="FunkLoad version">FunkLoad version</dt>
              <dd>{{ test["config"]["funkloadVersion"] }}</dd>
            </dl>
        </div>
    </div>

    <div class="page-header">
      <h1>Test Results <small>details for tests, pages and requests</small></h1>
    </div>

    <div class="row">
        <div class="span3">
            <h4>activity</h4>
            <ul class="inline totals">
                <li><i class="icon-home"></i><span class="text-info">{{ test["testExecuted"] }}</span> tests</li>
                <li><i class="icon-retweet"></i><span class="text-info">{{ test["pageVisited"] }}</span> pages</li>
                <li><i class="icon-globe"></i><span class="text-info">{{ test["requestMade"] }}</span> requests</li>
            </ul>
        </div>
        <div class="span9 test-results">
            <h2>Test results <small>test statistics per test suite</small></h2>
            <div class="chart test-stats"><svg></svg></div>

            <table class="test-result-table table table-hover table-condensed">
                <thead>
                    <th>Concurrent users</th>
                    <th>Successful tests per second</th>
                    <th>Total</th>
                    <th>Success</th>
                    <th>Error</th>
                </thead>
                <tbody>
                    {% for cycle in test["cycles"] %}
                    <tr>
                        <td>{{ cycle["concurrentUsers"] }}</td>
                        <td>{{ "%.0f" % cycle["test"]["successfulTestsPerSecond"] }}</td>
                        <td>{{ "%.0f" % cycle["test"]["totalTests"] }}</td>
                        <td>{{ "%.0f" % cycle["test"]["successfulTests"] }}</td>
                        <td>{{ "%.2f" % cycle["test"]["failedTestsPercentage"] }}%</td>
                    </tr>
                    {% end %}
                </tbody>
            </table>

            <h2>Page results <small>test statistics per page</small></h2>
            <div class="chart page-stats"><svg></svg></div>
            <div class="chart page-apdex"><svg></svg></div>
            <div class="chart page-response-time"><svg></svg></div>

            <table class="page-stats-table test-result-table table table-hover table-condensed">
                <thead>
                    <th>CUs</th>
                    <th>Apdex</th>
                    <th>SPPS</th>
                    <th>MaxSPPS</th>
                    <th>Total</th>
                    <th>Succ</th>
                    <th>Err</th>
                    <th>Min</th>
                    <th>P10</th>
                    <th>Med</th>
                    <th>Avg</th>
                    <th>P90</th>
                    <th>P95</th>
                    <th>Max</th>
                </thead>
                <tbody>
                    {% for cycle in test["cycles"] %}
                    <tr>
                        <td>{{ cycle["concurrentUsers"] }}</td>
                        <td>{{ "%.1f" % cycle["page"]["apdex"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["successfulPagesPerSecond"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["maxSuccessfulPagesPerSecond"] }}</td>
                        <td>{{ "%.0f" % cycle["page"]["totalRequests"] }}</td>
                        <td>{{ "%.0f" % cycle["page"]["successfulRequests"] }}</td>
                        <td>{{ "%.2f" % cycle["page"]["failedRequestPercentage"] }}%</td>
                        <td>{{ "%.4f" % cycle["page"]["minimum"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["p10"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["p50"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["average"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["p90"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["p95"] }}</td>
                        <td>{{ "%.4f" % cycle["page"]["maximum"] }}</td>
                    </tr>
                    {% end %}
                </tbody>
            </table>
            <p class="legend"><small><i>Min, P10, Med, Avg, P90, P95 and Max values measured in seconds.</i></small></p>

            <h2>Request results <small>test statistics per request</small></h2>
            <div class="chart request-stats"><svg></svg></div>
            <div class="chart request-response-time"><svg></svg></div>

            <table class="page-stats-table test-result-table table table-hover table-condensed">
                <thead>
                    <th>CUs</th>
                    <th>Apdex</th>
                    <th>SPPS</th>
                    <th>MaxSPPS</th>
                    <th>Total</th>
                    <th>Succ</th>
                    <th>Err</th>
                    <th>Min</th>
                    <th>P10</th>
                    <th>Med</th>
                    <th>Avg</th>
                    <th>P90</th>
                    <th>P95</th>
                    <th>Max</th>
                </thead>
                <tbody>
                    {% for cycle in test["cycles"] %}
                    <tr>
                        <td>{{ cycle["concurrentUsers"] }}</td>
                        <td>{{ "%.1f" % cycle["request"]["apdex"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["successfulRequestsPerSecond"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["maxSuccessfulRequestsPerSecond"] }}</td>
                        <td>{{ "%.0f" % cycle["request"]["totalRequests"] }}</td>
                        <td>{{ "%.0f" % cycle["request"]["successfulRequests"] }}</td>
                        <td>{{ "%.2f" % cycle["request"]["failedRequestPercentage"] }}%</td>
                        <td>{{ "%.4f" % cycle["request"]["minimum"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["p10"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["p50"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["average"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["p90"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["p95"] }}</td>
                        <td>{{ "%.4f" % cycle["request"]["maximum"] }}</td>
                    </tr>
                    {% end %}
                </tbody>
            </table>

        </div>
    </div>

    <p class="text-center"><small>Report generated at {{ report_date }}.</small></p>
{% else %}
    <div class="hero-unit">
        <h1>No test result found</h1>
        <p>We are unable to find a test result or load test with uuid {{ uuid }}.</p>
    </div>
{% end %}
</div>
{% end %}

{% block scripts %}
{% if test %}
<script>
    var testSuccessData = [
        {% for cycle in test["cycles"] %}
            { x: {{ cycle["concurrentUsers"] }}, y: {{ cycle["test"]["successfulTestsPerSecond"] }} },
        {% end %}
    ]

    var testFailedData = [
        {% for cycle in test["cycles"] %}
            { x: {{ cycle["concurrentUsers"] }}, y: {{ cycle["test"]["failedTests"] }} },
        {% end %}
    ]

    var pageSuccessData = [
        {% for cycle in test["cycles"] %}
            { x: {{ cycle["concurrentUsers"] }}, y: {{ cycle["page"]["successfulPagesPerSecond"] }} },
        {% end %}
    ]

    var pageFailedData = [
        {% for cycle in test["cycles"] %}
            { x: {{ cycle["concurrentUsers"] }}, y: {{ cycle["page"]["failedRequests"] }} },
        {% end %}
    ]

    var requestSuccessData = [
        {% for cycle in test["cycles"] %}
            { x: {{ cycle["concurrentUsers"] }}, y: {{ cycle["request"]["successfulRequestsPerSecond"] }} },
        {% end %}
    ]

    var requestFailedData = [
        {% for cycle in test["cycles"] %}
            { x: {{ cycle["concurrentUsers"] }}, y: {{ cycle["request"]["failedRequests"] }} },
        {% end %}
    ]

    var apdexData = [
        {% for cycle in test["cycles"] %}
        {
            "label" : {{ cycle["concurrentUsers"] }},
            "value" : {{ cycle["page"]["apdex"] }}
        } ,
        {% end %}
    ];

    var pageResponseTimeData = [
        {% for cycle in test["cycles"] %}
        [
            {{ cycle["concurrentUsers"] }},
            {{ cycle["page"]["minimum"] }},
            {{ cycle["page"]["p10"] }},
            {{ cycle["page"]["p50"] }},
            {{ cycle["page"]["average"] }},
            {{ cycle["page"]["p90"] }},
            {{ cycle["page"]["p95"] }},
            {{ cycle["page"]["maximum"] }}
        ],
        {% end %}
    ];

    var requestResponseTimeData = [
        {% for cycle in test["cycles"] %}
        [
            {{ cycle["concurrentUsers"] }},
            {{ cycle["request"]["minimum"] }},
            {{ cycle["request"]["p10"] }},
            {{ cycle["request"]["p50"] }},
            {{ cycle["request"]["average"] }},
            {{ cycle["request"]["p90"] }},
            {{ cycle["request"]["p95"] }},
            {{ cycle["request"]["maximum"] }}
        ],
        {% end %}
    ];

</script>

<script src="{{ static_url('js/report.js') }}"></script>
{% end %}
{% end %}
