Skip to content

Commit 635d76b

Browse files
committed
Update analysis setup
1 parent 0bc7fe7 commit 635d76b

File tree

8 files changed

+61
-118
lines changed

8 files changed

+61
-118
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ The project is made out of 6 parts:
1414
- (Optional) Run tests to verify server is setup correctly: `sudo docker compose exec header-testing-server bash -c "poetry run -C _hp pytest /app/_hp"`
1515
- The server is now serving all the tests pages and reponses for our paper. Depending on the configuration the server is now available within and outside the Docker network. E.g., by default it should bind to port 80 and 443 and `curl -I http://localhost/_hp/common/empty.html` and `curl -I -k https://localhost/_hp/common/empty.html` (our dummy certificates are not valid, thus `-k`/insecure is required) on the host should return a response from `BaseHTTP/0.6 Python/3.11.5`
1616
2. (Optional) Analysis scripts
17-
- Dockerized jupyter-lab and works on MacOS and Linux
18-
- Run: `(sudo) docker compose exec header-testing-server bash -c "cd /app/_hp/hp/tools/analysis && poetry run jupyter-lab --allow-root --ip 0.0.0.0"` and access the URL printed on your local browser
19-
- Open `analysis_ae.ipynb` and run it to analyze the browser runs; If none of the test runners were executed yet, no
20-
- The files `analysis_may_2024.ipynb` and `analysis_december_2024.ipynb` contain the full analysis for the original browser run and the updated browser run experiments described in the paper, including the output of the analysis. Re-running them requires access to our originally collected data.
17+
- Dockerized and works on MacOS and Linux
18+
- Run: `(sudo) docker compose exec header-testing-server bash -c "cd _hp/hp/tools/analysis && poetry run python analysis_demo.py"` to get some basic statistics about the test runs executed by the unit tests and running browser-test-runners.
19+
- We also provide the data and the analysis scripts used for the paper:
20+
- Download the database from **TODO**
21+
- Import the database into your local postgres: `(sudo) docker compose exec -T postgres pg_restore -U header_user -d http_header_original -v /tmp/data/http_header_original.dump`
22+
- Start the jupyter-lab: `(sudo) docker compose exec header-testing-server bash -c "cd /app/_hp/hp/tools/analysis && poetry run jupyter-lab --allow-root --ip 0.0.0.0"` and access the URL printed on your local browser
23+
- The files `analysis_may_2024.ipynb` and `analysis_december_2024.ipynb` contain the full analysis for the original browser run and the updated browser run experiments described in the paper, including the output of the analysis and can be executed to reproduce the analysis. Note: re-executing these scripts require a large amount of RAM on the docker container >20GB.
2124
3. (Optional) Test runner for desktop linux browsers
22-
- Dockerized and only work on Linux (issues with the MacOS Linux emulation)
23-
- Run: `(sudo) docker compose exec header-testing-server bash -c "cd /app/_hp/hp/tools/crawler/ && poetry run python desktop_selenium.py --debug_browsers --resp_type debug --ignore_certs"` for a quick check that data can be collected
25+
- Dockerized demo works on Linux and macOS; For a full run, the browser runner needs to be installed outside of docker on a linux system.
26+
- Demo run:
27+
- Run: `(sudo) docker compose exec header-testing-server bash -c "cd /app/_hp/hp/tools/crawler/ && poetry run python desktop_selenium.py --debug_browsers --resp_type debug --ignore_certs"` for a quick check that data can be collected
2428
- This should take around 2-3m
25-
- Check `_hp/hp/tools/crawler/logs/desktop-selenium/` for logs, there should be two rows with `Start chrome (128)` and two with `Finish chrome (128)` and no additional rows. The results of these tests can also be seen in the database or checked with the `analysis_ae.ipynb` script
29+
- Check `_hp/hp/tools/crawler/logs/desktop-selenium/` for logs, there should be two rows with `Start chrome (128)` and two with `Finish chrome (128)` and no additional rows. The results of these tests can also be seen in the database or checked with the `analysis_demo.py` script
2630
- Reproduce the basic experiment:
2731
- TODO (copy from below + verify, there are some issues with dockerized setup e.g. `--no-sandbox`?)
2832
- Run `(sudo) docker compose exec header-testing-server bash -c "cd /app/_hp/hp/tools/crawler/ && for i in {1..5}; do poetry run python desktop_selenium.py --num_browsers 50 --resp_type basic --ignore_certs; done"`
@@ -36,7 +40,7 @@ The project is made out of 6 parts:
3640
- Lastly, the modified WPT server needs to be reachable. One option is to modify `/etc/hosts/` to point the required hosts to the docker container (see `_hp/host-config.txt`)
3741
- Then `poetry run python desktop_selenium.py --help` can be used to see all settings of the test runner and then executed as wanted
3842
4. (Optional) Test runner for macOS browser
39-
- Requires access to a macOS device with a display
43+
- Requires access to a macOS device with a display
4044
- The Safari version is bound to the operating system, for an exact reproduction of our results, macOS devices in the correct version are required. To test the test runner on macOS, the used version can be updated in `desktop_selenium.py`
4145
- Requirements: `python=3.11.5`, `poetry` (see `setup.bash`) and access to the modified WPT server
4246
- Install `poetry install`

TODOS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
- [ ] Move all configs in one place/less places?
55
- [ ] Remove hardcoded stuff
66
- [ ] Test, test, test! + fix bugs/remove manual steps (e.g., brave is currently manually managed?)
7-
- [ ] analysis_ae.ipynb basic analysis script that simply works
7+
- [x] analysis_demo.py basic analysis script that simply works
8+
- [ ] original data archive + import to recreate analysis
89
- [ ] Improve and update REAMDE! What is where and so on
910
- [ ] Create artifact eval document
1011
- [ ] ...

_hp/hp/tools/analysis/analysis_ae.ipynb

Lines changed: 0 additions & 35 deletions
This file was deleted.

_hp/hp/tools/analysis/analysis_december_2024.ipynb

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
{
1515
"cell_type": "markdown",
1616
"id": "35ccff59-8ebc-4fe8-8b0e-cf8dfe03ef49",
17-
"metadata": {
18-
"jp-MarkdownHeadingCollapsed": true
19-
},
17+
"metadata": {},
2018
"source": [
2119
"# Setup"
2220
]
@@ -41,7 +39,7 @@
4139
},
4240
{
4341
"cell_type": "code",
44-
"execution_count": 3,
42+
"execution_count": null,
4543
"id": "a5639063-07f2-4283-ba32-098aa5b57671",
4644
"metadata": {},
4745
"outputs": [
@@ -70,7 +68,9 @@
7068
"JOIN \"Response\" ON \"Result\".response_id = \"Response\".id JOIN \"Browser\" ON \"Result\".browser_id = \"Browser\".id\n",
7169
"WHERE \"Browser\".name != 'Unknown' AND \"Response\".resp_type != 'debug';\n",
7270
"\"\"\"\n",
73-
"df = get_data(Config(), initial_data)\n",
71+
"config = Config()\n",
72+
"config.DB_NAME = \"http_header_original\"\n",
73+
"df = get_data(config, initial_data)\n",
7474
"df = add_columns(df)"
7575
]
7676
},
@@ -110,7 +110,7 @@
110110
"responses = \"\"\"\n",
111111
"SELECT * from \"Response\";\n",
112112
"\"\"\"\n",
113-
"responses = get_data(Config(), responses)"
113+
"responses = get_data(config, responses)"
114114
]
115115
},
116116
{
@@ -120,38 +120,7 @@
120120
"source": [
121121
"# Overview\n",
122122
"- Collected between 885730 and 1558656 results for 12 browsers (original)\n",
123-
"- Collected between 885730 and 898346results for 4 browsers (update december)"
124-
]
125-
},
126-
{
127-
"cell_type": "code",
128-
"execution_count": 6,
129-
"id": "589725d1-b403-4c0c-9fb1-219560b382c3",
130-
"metadata": {},
131-
"outputs": [],
132-
"source": [
133-
"# Only keep main and finished browsers\n",
134-
"# Remove other browsers/os\n",
135-
"# iOS unfinished browsers: old chrome (26), old brave (27), opera (28), safari (30), brave (54)\n",
136-
"# edge (same as chrome, only desktop): 44\n",
137-
"# duckduckgo (very old webview version): 66\n",
138-
"# opera (same as chrome, only mobile): 63\n",
139-
"# chrome (HSTS testing only): 70\n",
140-
"# brave (android shields disabled): 65\n",
141-
"# chrome (test version): 71\n",
142-
"\n",
143-
"df = df.loc[~df[\"browser_id\"].isin([30, 27, 26, 54, 28, 66, 63, 44, 70, 65, 71])]"
144-
]
145-
},
146-
{
147-
"cell_type": "code",
148-
"execution_count": 7,
149-
"id": "16c48765-0460-427a-b2cf-7e084bbd4788",
150-
"metadata": {},
151-
"outputs": [],
152-
"source": [
153-
"# Do not analyze OAC as it is only supported in Chromium + noisy \n",
154-
"df = df.loc[~df[\"test_name\"].str.startswith(\"oac\")]"
123+
"- Collected between 885730 and 898346 results for 4 browsers (update december)"
155124
]
156125
},
157126
{
@@ -9789,9 +9758,7 @@
97899758
{
97909759
"cell_type": "markdown",
97919760
"id": "ba9dc4c8-af9d-461a-8428-81c243a1eae7",
9792-
"metadata": {
9793-
"jp-MarkdownHeadingCollapsed": true
9794-
},
9761+
"metadata": {},
97959762
"source": [
97969763
"## PerformanceAPI\n",
97979764
"- Testfile: `perfAPI-tao.sub.html`\n",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pandas as pd
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
import re
5+
import json
6+
7+
from datetime import datetime
8+
9+
from utils import get_data, Config, clean_url, make_clickable, add_columns
10+
11+
initial_data = """
12+
SELECT "Result".*,
13+
"Response".raw_header, "Response".status_code, "Response".label, "Response".resp_type,
14+
"Browser".name, "Browser".version, "Browser".headless_mode, "Browser".os, "Browser".automation_mode, "Browser".add_info
15+
FROM "Result"
16+
JOIN "Response" ON "Result".response_id = "Response".id JOIN "Browser" ON "Result".browser_id = "Browser".id;
17+
"""
18+
df = get_data(Config(), initial_data)
19+
df = add_columns(df)
20+
21+
print(f"Collected {len(df)} results:")
22+
23+
print(df.groupby(['browser'])['test_name'].value_counts())
24+
25+
print(f"Example row:\n {df.iloc[-1]}")

_hp/hp/tools/analysis/analysis_may_2024.ipynb

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 2,
66
"id": "961069ec-1248-4bef-b760-65030ca43783",
77
"metadata": {},
88
"outputs": [],
@@ -14,16 +14,14 @@
1414
{
1515
"cell_type": "markdown",
1616
"id": "35ccff59-8ebc-4fe8-8b0e-cf8dfe03ef49",
17-
"metadata": {
18-
"jp-MarkdownHeadingCollapsed": true
19-
},
17+
"metadata": {},
2018
"source": [
2119
"# Setup"
2220
]
2321
},
2422
{
2523
"cell_type": "code",
26-
"execution_count": 2,
24+
"execution_count": 3,
2725
"id": "69930996-4101-4f83-8162-3560b81ef2f9",
2826
"metadata": {},
2927
"outputs": [],
@@ -41,14 +39,15 @@
4139
},
4240
{
4341
"cell_type": "code",
44-
"execution_count": 154,
42+
"execution_count": 6,
4543
"id": "a5639063-07f2-4283-ba32-098aa5b57671",
4644
"metadata": {},
4745
"outputs": [
4846
{
4947
"name": "stdout",
5048
"output_type": "stream",
5149
"text": [
50+
"Config(DB_HOST='postgres', DB_NAME='http_header_original', DB_USER='header_user', DB_PASSWORD='header_password', DB_PORT='5432')\n",
5251
"Connecting to the PostgreSQL database...\n",
5352
"Connection successful\n"
5453
]
@@ -67,7 +66,9 @@
6766
"JOIN \"Response\" ON \"Result\".response_id = \"Response\".id JOIN \"Browser\" ON \"Result\".browser_id = \"Browser\".id\n",
6867
"WHERE \"Browser\".name != 'Unknown';\n",
6968
"\"\"\"\n",
70-
"df = get_data(Config(), initial_data)\n",
69+
"config = Config()\n",
70+
"config.DB_NAME = \"http_header_original\"\n",
71+
"df = get_data(config, initial_data)\n",
7172
"df = add_columns(df)"
7273
]
7374
},
@@ -107,15 +108,13 @@
107108
"responses = \"\"\"\n",
108109
"SELECT * from \"Response\";\n",
109110
"\"\"\"\n",
110-
"responses = get_data(Config(), responses)"
111+
"responses = get_data(config, responses)"
111112
]
112113
},
113114
{
114115
"cell_type": "markdown",
115116
"id": "4d838597-a856-47fd-b0e2-42005c0c5e95",
116-
"metadata": {
117-
"jp-MarkdownHeadingCollapsed": true
118-
},
117+
"metadata": {},
119118
"source": [
120119
"# Overview\n",
121120
"- Collected between 885730 and 1558656 results for 12 browsers"
@@ -128,27 +127,8 @@
128127
"metadata": {},
129128
"outputs": [],
130129
"source": [
131-
"# Only main and finished browsers\n",
132-
"# Remove other browsers/os\n",
133-
"# iOS unfinished browsers: old chrome (26), old brave (27), opera (28), safari (30), brave (54)\n",
134-
"# edge (same as chrome, only desktop): 44\n",
135-
"# duckduckgo (very old webview version): 66\n",
136-
"# opera (same as chrome, only mobile: 63\n",
137-
"# chrome (HSTS testing only): 70\n",
138-
"# brave (android shields disabled): 65\n",
139-
"\n",
140-
"df = df.loc[~df[\"browser_id\"].isin([30, 27, 26, 54, 28, 66, 63, 44, 70, 65])]"
141-
]
142-
},
143-
{
144-
"cell_type": "code",
145-
"execution_count": 157,
146-
"id": "16c48765-0460-427a-b2cf-7e084bbd4788",
147-
"metadata": {},
148-
"outputs": [],
149-
"source": [
150-
"# Do not analyze OAC as it is only supported in Chromium + noisy \n",
151-
"df = df.loc[~df[\"test_name\"].str.startswith(\"oac\")]"
130+
"# Drop the browsers added in the second experiment in December\n",
131+
"df = df.loc[~df[\"browser_id\"].isin([73, 74, 75, 76])]"
152132
]
153133
},
154134
{

data/.gitkeep

Whitespace-only changes.

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
services:
22
postgres:
3-
image: postgres:15
3+
image: postgres:17
44
environment:
55
POSTGRES_DB: http_header_demo
66
POSTGRES_USER: header_user
77
POSTGRES_PASSWORD: header_password
88
volumes:
99
- postgres_data:/var/lib/postgresql/data
10+
- ./data:/tmp/data
1011
ports:
1112
- "5432:5432"
1213
healthcheck:

0 commit comments

Comments
 (0)