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= |
36 ``` | 37 ``` |
37 ... wait for record servers to start | 38 ... wait for record servers to start |
38 | 39 |
39 ### Replay mode | 40 ### Replay mode |
40 * Terminal 1: | 41 * Terminal 1: |
41 | 42 |
42 Start wpr in replay mode. | 43 Start wpr in replay mode. |
43 ``` | 44 ``` |
44 go run src/wpr.go replay --http_port=8080 --https_port=8081 /tmp/archive.wprgo | 45 go run src/wpr.go replay --http_port=8080 --https_port=8081 /tmp/archive.wprgo |
45 ``` | 46 ``` |
46 | 47 |
47 * Terminal 2: | 48 * Terminal 2: |
48 ``` | 49 ``` |
49 google-chrome-beta --user-data-dir=$bar \ | 50 google-chrome-beta --user-data-dir=$bar \ |
50 --host-resolver-rules="MAP *:80 127.0.0.1:8080,MAP *:443 127.0.0.1:8081,EXCLU
DE localhost"` | 51 --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= |
51 ``` | 53 ``` |
52 ... wait for replay servers to start | 54 ... wait for replay servers to start |
53 | 55 |
54 load the page | 56 load the page |
55 | 57 |
56 ## Running on Android | 58 ## Running on Android |
57 | 59 |
58 You will need a Linux host machine and an android device. | 60 You will need a Linux host machine and an android device. |
59 | 61 |
60 * Set up reverse port forwarding | 62 * Set up reverse port forwarding |
61 | 63 |
62 ``` | 64 ``` |
63 adb reverse tcp:8080 tcp:8080 | 65 adb reverse tcp:8080 tcp:8080 |
64 adb reverse tcp:8081 tcp:8081 | 66 adb reverse tcp:8081 tcp:8081 |
65 ``` | 67 ``` |
66 | 68 |
67 * Set up command line arguments | 69 * Set up command line arguments |
68 | 70 |
69 ``` | 71 ``` |
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"' | 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" \ |
| 73 --ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDx
I6I= |
71 ``` | 74 ``` |
72 | 75 |
73 * Run wpr.go as usual on the linux machine | 76 * Run wpr.go as usual on the linux machine |
74 | 77 |
75 ### Installing test root CA | 78 ### (Optional) Installing test root CA |
76 | 79 |
77 WebPageReplay uses self signed certificates for Https requests. To make Chrome | 80 WebPageReplay uses self signed certificates for Https requests. To make Chrome |
78 trust these certificates, you can install a test certificate authority as a | 81 trust these certificates, you can use --ignore-certificate-errors-spki-list |
79 local trust anchor. **Note:** Please do this with care because installing the | 82 like above. If that doesn't work, you may try installing a test certificate |
80 test root CA compromises your machine. This is currently only supported on | 83 authority as a local trust anchor. **Note:** Please do this with care because |
81 Linux and Android. | 84 installing the test root CA compromises your machine. This is currently only |
| 85 supported on Linux and Android. |
82 | 86 |
83 Installing the test CA. Specify a `--android_device_id` if you'd like to install | 87 Installing the test CA. Specify a `--android_device_id` if you'd like to install |
84 the root CA on an android device. | 88 the root CA on an android device. |
85 ``` | 89 ``` |
86 go run src/wpr.go installroot | 90 go run src/wpr.go installroot |
87 ``` | 91 ``` |
88 Uninstall the test CA. Specify a `--android_device_id` if you'd like to remove | 92 Uninstall the test CA. Specify a `--android_device_id` if you'd like to remove |
89 the root CA from an android device. | 93 the root CA from an android device. |
90 | 94 |
91 ``` | 95 ``` |
92 go run src/wpr.go removeroot | 96 go run src/wpr.go removeroot |
93 ``` | 97 ``` |
94 | 98 |
95 ## Other use cases | 99 ## Other use cases |
96 | 100 |
97 ### Http-to-http2 proxy: | 101 ### Http-to-http2 proxy: |
98 | 102 |
99 * Terminal 1: | 103 * Terminal 1: |
100 ``` | 104 ``` |
101 go run src/wpr.go replay --https_port=8081 --https_to_http_port=8082 \ | 105 go run src/wpr.go replay --https_port=8081 --https_to_http_port=8082 \ |
102 /tmp/archive.wprgo | 106 /tmp/archive.wprgo |
103 ``` | 107 ``` |
104 | 108 |
105 * Terminal 2: | 109 * Terminal 2: |
106 ``` | 110 ``` |
107 google-chrome-beta --user-data-dir=$foo \ | 111 google-chrome-beta --user-data-dir=$foo \ |
108 --host-resolver-rules="MAP *:443 127.0.0.1:8081,EXCLUDE localhost" \ | 112 --host-resolver-rules="MAP *:443 127.0.0.1:8081,EXCLUDE localhost" \ |
| 113 --ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDx
I6I= \ |
109 --proxy-server=http=https://127.0.0.1:8082 \ | 114 --proxy-server=http=https://127.0.0.1:8082 \ |
110 --trusted-spdy-proxy=127.0.0.1:8082 | 115 --trusted-spdy-proxy=127.0.0.1:8082 |
111 ``` | 116 ``` |
112 | 117 |
113 ## Inspecting an archive | 118 ## Inspecting an archive |
114 | 119 |
115 httparchive.go is a convenient script to inspect a wprgo archive. Use `ls`,`cat` | 120 httparchive.go is a convenient script to inspect a wprgo archive. Use `ls`,`cat` |
116 and `edit`. Options are available to specify request url host (`--host`) and | 121 and `edit`. Options are available to specify request url host (`--host`) and |
117 path (`--full-path`). | 122 path (`--full-path`). |
118 | 123 |
119 E.g. | 124 E.g. |
120 | 125 |
121 ``` | 126 ``` |
122 go run src/httparchive.go ls /tmp/archive.wprgo --host=example.com --full-path=/
index.html | 127 go run src/httparchive.go ls /tmp/archive.wprgo --host=example.com --full-path=/
index.html |
123 ``` | 128 ``` |
124 | 129 |
125 ## Running unit tests | 130 ## Running unit tests |
126 Run all tests in a specific file. | 131 Run all tests in a specific file. |
127 ``` | 132 ``` |
128 go test transformer_test.go transformer.go | 133 go test transformer_test.go transformer.go |
129 ``` | 134 ``` |
130 | 135 |
131 Run all tests in `webpagereplay` module. | 136 Run all tests in `webpagereplay` module. |
132 ``` | 137 ``` |
133 go test webpagereplay -run '' | 138 go test webpagereplay -run '' |
134 ``` | 139 ``` |
135 | 140 |
| 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 |
136 ## Contribute | 150 ## Contribute |
137 Please read [contributor's guide][contribute]. We use the Catapult | 151 Please read [contributor's guide][contribute]. We use the Catapult |
138 [issue tracker][tracker] for bugs and features. Once your change is reviewed | 152 [issue tracker][tracker] for bugs and features. Once your change is reviewed |
139 and ready for landing, please run `telemetry/bin/update_wpr_go_binary` to update | 153 and ready for landing, please run `telemetry/bin/update_wpr_go_binary` to update |
140 binaries in Google cloud storage. | 154 binaries in Google cloud storage. |
141 | 155 |
142 ## Contact | 156 ## Contact |
143 Please email telemetry@chromium.org. | 157 Please email telemetry@chromium.org. |
144 | 158 |
145 [contribute]: https://github.com/catapult-project/catapult/blob/master/CONTRIBUT
ING.md | 159 [contribute]: https://github.com/catapult-project/catapult/blob/master/CONTRIBUT
ING.md |
146 [tracker]: https://github.com/catapult-project/catapult/issues | 160 [tracker]: https://github.com/catapult-project/catapult/issues |
OLD | NEW |