1

I'm trying to include WebPagetest tests as a part of my continuous integration process. In other words I'd like to have broken build whenever a critical performance metric is out of range.

WebPagetest provides restful API to drive it.

Most of my tests are FitNesse-based so I'd like to express my performance requirements in FitNesse language.

Is there a Java client that is able to drive WebPagetest, verify if the results are within required ranges and produce them in some format (for example JUnit). Ideally I'd like to have a set of FitNesse fixtures that allow to invoke WebPagetest.

wheleph
  • 7,974
  • 7
  • 40
  • 57

1 Answers1

2

I don't know of a specific fixture for this tool, but its REST API (requesting XML or JSON as response format) seems easy enough to consume using a standard REST fixture.

You could, for instance, use my XmlHttpTest in a script table: setting input parameters using 'set value', doing a 'get from' and then checking result elements/values using 'xPath'.

To make the wiki tables a bit nicer you could either write a subclass of a standard fixture, or create some scenarios.

For example (with scenarios)

|scenario |start web pagetest                                                             |location                    |
|set value|http://stackoverflow.com/questions/34595522/java-testing-client-for-webpagetest|for                |url     |
|set value|<your key>                                                                     |for                |k       |
|set value|@{location}                                                                    |for                |location|
|set value|xml                                                                            |for                |f       |
|get from |http://www.webpagetest.org/runtest.php                                                                      |
|show     |response                                                                                                    |
|check    |xPath                                                                          |//statusCode/text()|200     |
|$xmlUrl= |xPath                                                                          |//xmlUrl/text()             |

|scenario           |get web pagetest result|url                                 |
|clear values                                                                    |
|set value          |xml                    |for                       |f        |
|get from           |@{url}                                                      |
|show               |response                                                    |
|check              |xPath                  |//statusCode/text()       |200      |
|$firstViewAverage= |xPath                  |//average/firstView/loadTime/text() |
|$repeatViewAverage=|xPath                  |//average/repeatView/loadTime/text()|


|script|xml http test|

|start web pagetest       |
|location         |xmlUrl?|
|Dulles:Chrome.DSL|$url1= |
|Dulles:Firefox   |$url2= |

|script         |
|wait|40|seconds|

|get web pagetest result                   |
|url  |firstViewAverage?|repeatViewAverage?|
|$url1|<4000            |<3000             |
|$url2|<2000            |<1000             |
Fried Hoeben
  • 3,247
  • 16
  • 14
  • I like your approach. The only drawback I see there is explicit wait for 40 seconds. But it's not too hard to implement different step that probes testStatus.php periodically and completes once the report is ready (or timeout happens). – wheleph Jan 06 '16 at 09:14
  • Indeed the wait for 40 seconds can easily be replaced (in custom Java) by some polling on the service. (My Fit SOAP fixtures have a default implementation for this, but I haven't ported this to the Slim HttpTest yet.) – Fried Hoeben Jan 06 '16 at 12:39