OLD | NEW |
1 # Web Page Replay | 1 # Web Page Replay |
2 Web Page Replay (WprGo) is a performance testing tool written in Golang for | 2 Web Page Replay (WprGo) is a performance testing tool written in Golang for |
3 recording and replaying web pages. WprGo is currently used in Telemetry for | 3 recording and replaying web pages. WprGo is currently used in Telemetry for |
4 Chrome benchmarking purposes. This requires go 1.8 and above. This has not been | 4 Chrome benchmarking purposes. This requires go 1.8 and above. This has not been |
5 tested with earlier versions of go. It is supported on Windows, MacOS and Linux. | 5 tested with earlier versions of go. It is supported on Windows, MacOS and Linux. |
6 | 6 |
7 ## Required packages | 7 ## Required packages |
8 | 8 |
9 ``` | 9 ``` |
10 go get github.com/codegangsta/cli | 10 go get github.com/codegangsta/cli |
(...skipping 15 matching lines...) Expand all Loading... |
26 ``` | 26 ``` |
27 ... | 27 ... |
28 | 28 |
29 Ctrl-C | 29 Ctrl-C |
30 | 30 |
31 * Terminal 2: | 31 * Terminal 2: |
32 | 32 |
33 ``` | 33 ``` |
34 google-chrome-beta --user-data-dir=$foo \ | 34 google-chrome-beta --user-data-dir=$foo \ |
35 --host-resolver-rules="MAP *:80 127.0.0.1:8080,MAP *:443 127.0.0.1:8081,EXCLU
DE localhost" | 35 --host-resolver-rules="MAP *:80 127.0.0.1:8080,MAP *:443 127.0.0.1:8081,EXCLU
DE localhost" |
36 --ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PD
xI6I= | |
37 ``` | 36 ``` |
38 ... wait for record servers to start | 37 ... wait for record servers to start |
39 | 38 |
40 ### Replay mode | 39 ### Replay mode |
41 * Terminal 1: | 40 * Terminal 1: |
42 | 41 |
43 Start wpr in replay mode. | 42 Start wpr in replay mode. |
44 ``` | 43 ``` |
45 go run src/wpr.go replay --http_port=8080 --https_port=8081 /tmp/archive.wprgo | 44 go run src/wpr.go replay --http_port=8080 --https_port=8081 /tmp/archive.wprgo |
46 ``` | 45 ``` |
47 | 46 |
48 * Terminal 2: | 47 * Terminal 2: |
49 ``` | 48 ``` |
50 google-chrome-beta --user-data-dir=$bar \ | 49 google-chrome-beta --user-data-dir=$bar \ |
51 --host-resolver-rules="MAP *:80 127.0.0.1:8080,MAP *:443 127.0.0.1:8081,EXCLU
DE localhost" | 50 --host-resolver-rules="MAP *:80 127.0.0.1:8080,MAP *:443 127.0.0.1:8081,EXCLU
DE localhost"` |
52 --ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PD
xI6I= | |
53 ``` | 51 ``` |
54 ... wait for replay servers to start | 52 ... wait for replay servers to start |
55 | 53 |
56 load the page | 54 load the page |
57 | 55 |
58 ## Running on Android | 56 ## Running on Android |
59 | 57 |
60 You will need a Linux host machine and an android device. | 58 You will need a Linux host machine and an android device. |
61 | 59 |
62 * Set up reverse port forwarding | 60 * Set up reverse port forwarding |
63 | 61 |
64 ``` | 62 ``` |
65 adb reverse tcp:8080 tcp:8080 | 63 adb reverse tcp:8080 tcp:8080 |
66 adb reverse tcp:8081 tcp:8081 | 64 adb reverse tcp:8081 tcp:8081 |
67 ``` | 65 ``` |
68 | 66 |
69 * Set up command line arguments | 67 * Set up command line arguments |
70 | 68 |
71 ``` | 69 ``` |
72 build/android/adb_chrome_public_command_line --host-resolver-rules="MAP *:80 127
.0.0.1:8080,MAP *:443 127.0.0.1:8081,EXCLUDE localhost" \ | 70 build/android/adb_chrome_public_command_line '--host-resolver-rules="MAP *:80 12
7.0.0.1:8080,MAP *:443 127.0.0.1:8081,EXCLUDE localhost"' |
73 --ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDx
I6I= | |
74 ``` | 71 ``` |
75 | 72 |
76 * Run wpr.go as usual on the linux machine | 73 * Run wpr.go as usual on the linux machine |
77 | 74 |
78 ### (Optional) Installing test root CA | 75 ### Installing test root CA |
79 | 76 |
80 WebPageReplay uses self signed certificates for Https requests. To make Chrome | 77 WebPageReplay uses self signed certificates for Https requests. To make Chrome |
81 trust these certificates, you can use --ignore-certificate-errors-spki-list | 78 trust these certificates, you can install a test certificate authority as a |
82 like above. If that doesn't work, you may try installing a test certificate | 79 local trust anchor. **Note:** Please do this with care because installing the |
83 authority as a local trust anchor. **Note:** Please do this with care because | 80 test root CA compromises your machine. This is currently only supported on |
84 installing the test root CA compromises your machine. This is currently only | 81 Linux and Android. |
85 supported on Linux and Android. | |
86 | 82 |
87 Installing the test CA. Specify a `--android_device_id` if you'd like to install | 83 Installing the test CA. Specify a `--android_device_id` if you'd like to install |
88 the root CA on an android device. | 84 the root CA on an android device. |
89 ``` | 85 ``` |
90 go run src/wpr.go installroot | 86 go run src/wpr.go installroot |
91 ``` | 87 ``` |
92 Uninstall the test CA. Specify a `--android_device_id` if you'd like to remove | 88 Uninstall the test CA. Specify a `--android_device_id` if you'd like to remove |
93 the root CA from an android device. | 89 the root CA from an android device. |
94 | 90 |
95 ``` | 91 ``` |
96 go run src/wpr.go removeroot | 92 go run src/wpr.go removeroot |
97 ``` | 93 ``` |
98 | 94 |
99 ## Other use cases | 95 ## Other use cases |
100 | 96 |
101 ### Http-to-http2 proxy: | 97 ### Http-to-http2 proxy: |
102 | 98 |
103 * Terminal 1: | 99 * Terminal 1: |
104 ``` | 100 ``` |
105 go run src/wpr.go replay --https_port=8081 --https_to_http_port=8082 \ | 101 go run src/wpr.go replay --https_port=8081 --https_to_http_port=8082 \ |
106 /tmp/archive.wprgo | 102 /tmp/archive.wprgo |
107 ``` | 103 ``` |
108 | 104 |
109 * Terminal 2: | 105 * Terminal 2: |
110 ``` | 106 ``` |
111 google-chrome-beta --user-data-dir=$foo \ | 107 google-chrome-beta --user-data-dir=$foo \ |
112 --host-resolver-rules="MAP *:443 127.0.0.1:8081,EXCLUDE localhost" \ | 108 --host-resolver-rules="MAP *:443 127.0.0.1:8081,EXCLUDE localhost" \ |
113 --ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDx
I6I= \ | |
114 --proxy-server=http=https://127.0.0.1:8082 \ | 109 --proxy-server=http=https://127.0.0.1:8082 \ |
115 --trusted-spdy-proxy=127.0.0.1:8082 | 110 --trusted-spdy-proxy=127.0.0.1:8082 |
116 ``` | 111 ``` |
117 | 112 |
118 ## Inspecting an archive | 113 ## Inspecting an archive |
119 | 114 |
120 httparchive.go is a convenient script to inspect a wprgo archive. Use `ls`,`cat` | 115 httparchive.go is a convenient script to inspect a wprgo archive. Use `ls`,`cat` |
121 and `edit`. Options are available to specify request url host (`--host`) and | 116 and `edit`. Options are available to specify request url host (`--host`) and |
122 path (`--full-path`). | 117 path (`--full-path`). |
123 | 118 |
124 E.g. | 119 E.g. |
125 | 120 |
126 ``` | 121 ``` |
127 go run src/httparchive.go ls /tmp/archive.wprgo --host=example.com --full-path=/
index.html | 122 go run src/httparchive.go ls /tmp/archive.wprgo --host=example.com --full-path=/
index.html |
128 ``` | 123 ``` |
129 | 124 |
130 ## Running unit tests | 125 ## Running unit tests |
131 Run all tests in a specific file. | 126 Run all tests in a specific file. |
132 ``` | 127 ``` |
133 go test transformer_test.go transformer.go | 128 go test transformer_test.go transformer.go |
134 ``` | 129 ``` |
135 | 130 |
136 Run all tests in `webpagereplay` module. | 131 Run all tests in `webpagereplay` module. |
137 ``` | 132 ``` |
138 go test webpagereplay -run '' | 133 go test webpagereplay -run '' |
139 ``` | 134 ``` |
140 | 135 |
141 ## Generate public key hash for --ignore-certificate-errors-spki-list | |
142 wpr_public_hash.txt is generated from wpr_cert.pem using the command below. | |
143 ``` | |
144 openssl x509 -noout -pubkey -in wpr_cert.pem | \ | |
145 openssl pkey -pubin -outform der | \ | |
146 openssl dgst -sha256 -binary | \ | |
147 base64 | |
148 ``` | |
149 | |
150 ## Contribute | 136 ## Contribute |
151 Please read [contributor's guide][contribute]. We use the Catapult | 137 Please read [contributor's guide][contribute]. We use the Catapult |
152 [issue tracker][tracker] for bugs and features. Once your change is reviewed | 138 [issue tracker][tracker] for bugs and features. Once your change is reviewed |
153 and ready for landing, please run `telemetry/bin/update_wpr_go_binary` to update | 139 and ready for landing, please run `telemetry/bin/update_wpr_go_binary` to update |
154 binaries in Google cloud storage. | 140 binaries in Google cloud storage. |
155 | 141 |
156 ## Contact | 142 ## Contact |
157 Please email telemetry@chromium.org. | 143 Please email telemetry@chromium.org. |
158 | 144 |
159 [contribute]: https://github.com/catapult-project/catapult/blob/master/CONTRIBUT
ING.md | 145 [contribute]: https://github.com/catapult-project/catapult/blob/master/CONTRIBUT
ING.md |
160 [tracker]: https://github.com/catapult-project/catapult/issues | 146 [tracker]: https://github.com/catapult-project/catapult/issues |
OLD | NEW |