catchpoint / WebPageTest.api-nodejs

WebPageTest API wrapper for NodeJS
MIT License
1.64k stars 173 forks source link

Problems with `webpagetest batch` method #143

Open cweekly opened 3 years ago

cweekly commented 3 years ago

Given a private instance MY-WPT-SERVER with apiKey MY-API-KEY and a plaintext batch-tests.txt file containing:

test https://example.com -k MY-API-KEY -l us-east-1-linux:Chrome.FIOS -L MY-TEST-LABEL-DESKTOP -r 3 -v 
test https://example.com -k MY-API-KEY -l us-east-1-linux:Chrome.FIOS -L MY-TEST-LABEL-MOBILE -r 3 -v -W --device Nexus7

I'd expect running:
webpagetest batch batch-tests.txt -s MY-WPT-SERVER to return a JSON array with 2 objects, e.g.

[
  {
    "statusCode": 200,
    "statusText": "Ok",
    "data": {
      "testId": "210628_T8_1",
      "jsonUrl": "MY-WPT-SERVER/jsonResult.php?test=210628_T8_1",
      "xmlUrl": "MY-WPT-SERVER/xmlResult/210628_T8_1/",
      "userUrl": "MY-WPT-SERVER/result/210628_T8_1/",
      "summaryCSV": "MY-WPT-SERVER/result/210628_T8_1/page_data.csv",
      "detailCSV": "MY-WPT-SERVER/result/210628_T8_1/requests.csv"
    }
  },
  {
    "statusCode": 200,
    "statusText": "Ok",
    "data": {
      "testId": "210628_YQ_2",
      "jsonUrl": "MY-WPT-SERVER/jsonResult.php?test=210628_YQ_2",
      "xmlUrl": "MY-WPT-SERVER/xmlResult/210628_YQ_2/",
      "userUrl": "MY-WPT-SERVER/result/210628_YQ_2/",
      "summaryCSV": "MY-WPT-SERVER/result/210628_YQ_2/page_data.csv",
      "detailCSV": "MY-WPT-SERVER/result/210628_YQ_2/requests.csv"
    }
  }
]

but what I get instead is a 200 OK for the 1st test, and a 400 - Invalid location... for the 2nd test -- even though they use the same location.

[
  {
    "statusCode": 200,
    "statusText": "Ok",
    "data": {
      "testId": "210628_T8_1",
      "jsonUrl": "MY-WPT-SERVER/jsonResult.php?test=210628_T8_1",
      "xmlUrl": "MY-WPT-SERVER/xmlResult/210628_T8_1/",
      "userUrl": "MY-WPT-SERVER/result/210628_T8_1/",
      "summaryCSV": "MY-WPT-SERVER/result/210628_T8_1/page_data.csv",
      "detailCSV": "MY-WPT-SERVER/result/210628_T8_1/requests.csv"
    }
  },
  {
    "statusCode": 400,
    "statusText": "Invalid Location, please try submitting your test request again."
  }
]

Reversing the order of the 2 tests in the .txt file results in the same behavior (ie, whichever is listed 1st works, whichever is listed 2nd fails).

So I'm thinking this has to be a bug in the wrapper.

Thanks in advance for taking a look -- and more generally for creating this awesome, useful tool. :)

cweekly commented 3 years ago

@tkadlec , @pmeenan , @marcelduran, or anyone else, I'd be really grateful for a response. In any case have a great weekend!

tkadlec commented 3 years ago

@cweekly Do you get the same error if you run against the WPT public instance? I'm having no luck reproducing the issue against the public instance so far and trying to pinpoint if it's the private instance that seems to be tripping it up or something else?

cweekly commented 3 years ago

I don't have a public instance API key :/

cweekly commented 3 years ago

I'm guessing the problem relates to the authZ step on first-ever test run.