catchpoint / WebPageTest.agent

Cross-platform WebPageTest agent
Other
210 stars 138 forks source link

Empty test result, only orange start_page #648

Open spetroll opened 5 months ago

spetroll commented 5 months ago

Hi, I'm trying to run an agent locally in a docker agent and used https://github.com/catchpoint/WebPageTest/tree/master/docker/local as a guide.

After a few tweaks I had the agent and web-ui running and could start a test. It shows as completed, but the test results are empty. The screenshot of the page (it was supposed to test http://google.com ) came back completely orange. After searching through the logs it appears as this is the start_page defined here. It apparently never navigated to the target site.

image

I have uploaded the log from the agent container here.

Thats all I found out by myself, not sure how I can debug this any further. Any help is very much appreciated.

caseycarroll commented 4 months ago

Seeing this as well.

When I run a test on google.com, I notice these logs immediately after the test kicks off.

2024-03-29 23:59:23 06:59:23.367 - [{'command': 'navigate', 'target': 'https://www.google.com', 'record': True}]
2024-03-29 23:59:23 06:59:23.367 - Preparing browser
2024-03-29 23:59:23 06:59:23.368 - Terminating all instances of chrome
2024-03-29 23:59:23 chrome: no process found
2024-03-29 23:59:23 06:59:23.370 - Flushing DNS
2024-03-29 23:59:23 dnsmasq: unrecognized service
2024-03-29 23:59:23 sudo: rndc: command not found
2024-03-29 23:59:23 sudo: systemd-resolve: command not found
2024-03-29 23:59:23 sd_bus_open_system: No such file or directory
2024-03-29 23:59:23 06:59:23.399 - Clearing profile /wptagent/work/b509392c2d8f-172.18.0.2/browser.240330_BN_6.1

After these logs the devtools websocket eventually connects and that's when the agent navigates the brower to http:\/\/127.0.0.1:8888\/orange.html.

At a high level, I see:

  1. navigate command (set to google.com)
  2. prepare browser step (includes flushing dns)
  3. open chrome
  4. some errors i.e. failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
  5. devtools websocket connects
  6. browser navigates to start_page
    • {"id":5,"method":"Page.navigate","params":{"url":"http:\/\/127.0.0.1:8888\/orange.html"}}

Maybe there's something to the "could not parse server address" errors...

BTW, to get the docker-compose set up to work on my windows machine, I had to manually add these changes from the following PRs:

caseycarroll commented 4 months ago

Actually, I do eventually see the logs indicate a navigate command was passed to the agent. It seems like the video recording stops immediately after the navigation command is sent.

2024-03-29 23:59:25 06:59:25.607 - <- {"id":21,"result":{}}
2024-03-29 23:59:25 06:59:25.607 - Processing script command:
2024-03-29 23:59:25 06:59:25.607 - {'command': 'navigate', 'target': 'https://www.google.com', 'record': True}
2024-03-29 23:59:25 06:59:25.607 - -> {"id":22,"method":"Browser.grantPermissions","params":{"origin":"https:\/\/www.google.com","permissions":["geolocation","videoCapture","audioCapture","sensors","idleDetection","wakeLockScreen"]}}
2024-03-29 23:59:25 06:59:25.609 - <- {"id":22,"result":{}}
2024-03-29 23:59:26 06:59:26.345 - ffmpeg: frame=    9 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
2024-03-29 23:59:26 06:59:26.610 - Stopping video capture
2024-03-29 23:59:26 06:59:26.610 - -> {"id":23,"method":"DOMSnapshot.captureSnapshot","params":{"computedStyles":["background-image"],"includePaintOrder":false,"includeDOMRects":true}}
2024-03-29 23:59:26 06:59:26.612 - <- {"id":23,"result":{"documents":[{"documentURL":0,"title":1,"baseURL":0,"contentLanguage":-1,"encodingName":2,"publicId":-1,"systemId":-1,"frameId":3,"nodes":{"parentIndex":[-1,0,1,2,2,4,2,2,7,2,1,1,11
2024-03-29 23:59:26 06:59:26.612 - -> {"id":24,"method":"Tracing.end","params":{}}
caseycarroll commented 4 months ago

Aha! In my case I did not set up traffic shaping on my host. This means I had to turn off traffic shaping when running the docker container. After disabling traffic shaping, I had to explicitly select "Native Connection" in the "Advanced Configuration" Connection dropdown before running my test.

To turn off traffic shaping, you will need to add the environment variable SHAPER=none when you run the agent container. (standalone or via docker-compose in the main project).

When a WPT test runs, it starts at the orange page. The browser controller then receives a navigation command with the target url. The browser navigation is triggered by a script. At a high level, that script is something like window.location = targetUrl. This script will not run if an error is present. If there is something misconfigured with your traffic shaping, an error occurs and the script will not run. In my case, my Advanced Configuration/Connection was set to Cable when the agent was configured for no traffic shaping. Once the advanced configuration matched my agent's traffic configuration, the script ran and my test executed as expected.

I'm running this on a Windows machine. The docker instructions don't provide guidance for windows machines, so I'm not sure how to proceed at the moment. https://github.com/catchpoint/WebPageTest.agent/blob/master/docs/docker.md

At least I finally ran a successful test on my local machine!