cta-wave / dpctf-deploy

Repo for Docker deployment. This is basically the repository you need to deploy the Test Runner (and later the Test Execution Framework) locally. It will make the deployment and configuration of all components much easier
Other
2 stars 5 forks source link

improve instructions on being able to access test runner from local network #102

Open jpiesing opened 1 week ago

jpiesing commented 1 week ago

I apologise if there's something hidden but ...

The documentation is silent about making the test runner visible on the local network that it's host is connected to.

There seem to be a number of options for this and none are mentioned.

I think this is one of the places where docker in WSL2 (without D. Desktop) is different from docker on Linux. Docker in WSL2 (without D.D) has an extra level of virtualization and potentially an extra network between it and the local network.

If some form of port forwarding is used then the instructions need to be clear that the IP address entered in the DUT must be the IP address of the PC hosting docker and not the IP address the docker instance is bound to.

jpiesing commented 1 week ago

For example, this article suggests some magic is needed when running docker in WSL2 without D.D. if the test runner is to be accessible from a DUT on the local network.

image

jpiesing commented 3 days ago

@afrawei has got caught by this.

@FritzHeiden Please can you comment on the following when docker runs inside WSL2 without D.D.

1) What IP address should be used in the host_override statement? The IP address of the inside of WSL2 (i.e. ifconfig -a in the bash window) or the IP address of the host PC on its network (i.e. ipconfig) in PowerShell?

2) Do port forwarding rules have to be setup on the host PC something like this ...

netsh interface portproxy add v4tov4 listenport=8000 listenaddress=0.0.0.0 connectport=8000 connectaddress=172.30.28.51 netsh interface portproxy add v4tov4 listenport=8443 listenaddress=0.0.0.0 connectport=8443 connectaddress=172.30.28.51 netsh interface portproxy add v4tov4 listenport=8444 listenaddress=0.0.0.0 connectport=8444 connectaddress=172.30.28.51 netsh interface portproxy add v4tov4 listenport=9000 listenaddress=0.0.0.0 connectport=9000 connectaddress=172.30.28.51 netsh interface portproxy add v4tov4 listenport=80 listenaddress=0.0.0.0 connectport=80 connectaddress=172.30.28.51

If yes, are these the correct and complete set of ports to forward?

(172.30.28.51 is the IP address of the eth0 interface inside WSL2 as printed by ifconfig in bash.)

3) @yanj-github Which IP address should be used in the OF configuration file, the one of the PC on its local network or the one inside of WSL2 (172.30.28.51 in this example).

yanj-github commented 3 days ago

@jpiesing I believe OF is co-located with test runner inside WSL. I think default value test_runner_url = http://localhost:8000 should work. If not, user should use WSL IP address.

Just to add on, I have tried to use default test_runner_url = http://localhost:8000 on WLS it work fine on our end. I'd check if test runner is running by "docker ps" and try connect it on web browser. It might be also worth checking ipv6 some systems by default use ipv6 instead of ipv4. If so disable ipv6.

gitwjr commented 3 days ago

localhost works fine for me. Tried to change to docker IP 172.17.0.1 (found using powershell ifconfig). After changing config.json to that address, closing the terminal, stopping and restarting docker service, and entering "http://172.17.0.1:8000/_wave/index.html" in Chrome it returns "This site can’t be reached172.17.0.1 took too long to respond." using port 8000. Same with Firefox. Changed back to local host, opened new terminal, restarted docker and it worked fine.

afrawei commented 3 days ago

I have my "test_runner_url" setting (inside WSL2) as IP address from local PC + ":8000". Now my environment is up and running after Jon marked out a few lines in hbbtv.js as a temporary workaround

gitwjr commented 3 days ago

Tried to run a test on mobile devices. The mobile devices (Android phone or iPad) will not connect to localhost. They both connect to IP 10.0.0.125. However Chrome on PC will only connect to locallost, not IP (have tried setting config.json to both. Only localhost works. When I run localhost on PC (with config.json set to localhost, and start a session (with mobile using :8000, Iit starts. I then enter the first 8 characters of the token on PC, configure the session and hit enter. The mobile devices say cannot connect to localhost. Seems the redirect to mobile is to localhost. But PC will not connect to IP.

afrawei commented 3 days ago

@gitwjr Let me share what I did and see if it works for you

  1. Check the IP address <x.x.x.x> from WSL2 by ifconfig.

  2. Open Windows Powershell with admin right, and enter below netsh interface portproxy add v4tov4 listenport=8000 listenaddress=0.0.0.0 connectport=8000 connectaddress=<x.x.x.x> netsh interface portproxy add v4tov4 listenport=8443 listenaddress=0.0.0.0 connectport=8443 connectaddress=<x.x.x.x> netsh interface portproxy add v4tov4 listenport=8444 listenaddress=0.0.0.0 connectport=8444 connectaddress=<x.x.x.x> netsh interface portproxy add v4tov4 listenport=9000 listenaddress=0.0.0.0 connectport=9000 connectaddress=<x.x.x.x> netsh interface portproxy add v4tov4 listenport=80 listenaddress=0.0.0.0 connectport=80 connectaddress=<x.x.x.x>

  3. Check IP address on your Windows PC (physical IP) and fill it in config.json Now when you want to connect to TestRunner from other devices, use IP address from 4. Whenever your physical IP is changed, same change shall be adopted in config.json

  4. In observation-config.ini file, you can use IP address from 1 so you don't need to modify it when physical IP is changed

If you have firewall issue, I found useful websites for reference Windows WSL 2 can't ping host machine Access a web server which is running on WSL (Windows Subsystem for Linux) from the local network

louaybassbouss commented 2 days ago

Here is how it works on our side step-by-step:

  1. In Windows Powershell run: ipconfig and copy the local IP address of your windows host e.g. 192.168.1.23 (lets call this <host_ip>). This is the IP you should use in "host_override": "<host_ip>" (see config.json)

  2. In Windows Powsershell run: wsl hostname -I and copy the (first) IP address e.g. 172.24.202.133 (lets call this <wsl_ip>)

  3. In Windows Powershell (must be run as Admin by Admin User!!!!) run: netsh.exe interface portproxy add v4tov4 connectport=8000 connectaddress=0.0.0.0 listenport=8000 listenaddress=<wsl_ip>

Please make sure you use the right IP address (<host_ip> & <wsl_ip>) in the right command/config.

VERY IMPORTANT!!

In some situations, it may happen that the <host_ip> (the IP of the windows host in local network) is unknown for the WSL distribution (it happens to us when the local IP is 192.168.X.X but not for this local IP 10.X.X.X). This is why the host_check.sh script (which runs inside docker inside WSL) fails to ping the <host_ip> (this is I think what happens on @gitwjr side, but not on @afrawei side). For this reason, we recommend to change it to warning and not raise an error. This means you need to change check-host.sh#L21 from exit 1 to exit 0 (if this fixes the issues on your side, we will provide a PR).

After this change, you need to:

  1. rebuild the image: ./build.sh
  2. recreate container: docker-compose up --force-recreate

Please follow these steps and let us know if issue could be solved on your side.

gitwjr commented 2 days ago

I made the above change to hostcheck.sh (its called check-host.sh) in my file: "-" not ""). The test now runs in my PC browser at P 10.0.0.125 instead of just localhost. I can also open the link on my phone. However, when I I try 10.0.0.125:8000/_wave/configuration.htlm on the PC and run a test the phone comes back "can't connect". It is still redirecting to localhost on the phone. If I run a test on my PC using 10.0.0.125 the test runs at localhost and the results pages shows http://localhost:8000/_wave/finish.html?token=3277e188-3944-11ef-8f5d-0242ac110002 when complete. Appears the phone still cannot connect to localhost which is where the test actually runs.

louaybassbouss commented 2 days ago

I made the above change to hostcheck.sh (its called check-host.sh) in my file: "-" not ""). The test now runs in my PC browser at P 10.0.0.125 instead of just localhost. I can also open the link on my phone. However, when I I try 10.0.0.125:8000/_wave/configuration.htlm on the PC and run a test the phone comes back "can't connect". It is still redirecting to localhost on the phone. If I run a test on my PC using 10.0.0.125 the test runs at localhost and the results pages shows http://localhost:8000/_wave/finish.html?token=3277e188-3944-11ef-8f5d-0242ac110002 when complete. Appears the phone still cannot connect to localhost which is where the test actually runs.

ist "host_override": "10.0.0.125"? please make sure to rebuild the image ./build.sh and the recreate container docker-compose up --force-recreate

gitwjr commented 2 days ago

I did both. And changed the config.json to IP from localhost. Before the change IP didn't work on the PC browser, only localhost.

gitwjr commented 2 days ago

But phone still gets redirected to localhost after opening and running the test and can't connect to localhost.

louaybassbouss commented 2 days ago

But phone still gets redirected to localhost after opening and running the test and can't connect to localhost.

yes localhost on phone will not work. can you please paste the content of you config.json?

gitwjr commented 2 days ago

{ "browser_host": "web-platform.test", "alternate_hosts": { "alt": "not-web-platform.test" }, "wave": { "aliases": [], "results": "./results", "timeouts": { "automatic": 100000, "manual": 20000000 }, "enable_results_import": false, "web_root": "/_wave", "persisting_interval": 20, "api_titles": [], "host_override": "10.0.0.125" } }

louaybassbouss commented 2 days ago

I seems be that the docker image which uses localhost in still in docker cache. can you remove the old docker container and create again (run ./build.sh and then docker-compose up --force-recreate).

gitwjr commented 2 days ago

I closed terminal adn opened a new one. Then stopped dpctf and restarted it. Now running on phone. Results show pass. I didn't record it so no OF analysis.

gitwjr commented 2 days ago

I had already rebuilt the container after making the change to host-check.sh. Appears the change doesn't fully flow through until close and reopen. Thanks.

gitwjr commented 2 days ago

Tried to run a test using my PC to host the test an my iPad as the mobile DUT. It appears to start on the iPad, goes to "test about to start", then to "s: waiting; a: initialize". showing 10.0.0.125 in the browser window. It sits there until it comes back "session complete" except results are 2 of 2 tests timed out. No flashing QR codes or video playing. Its an older iPad mini 2, model #ME2772LL/A, software version 12.5.7 so it may not be able to run it? Apple no longer updating it.

gitwjr commented 2 days ago

Tried on iPhone SE. Same result as iPad. But it works on my Pixel 6a.