| OLD | NEW |
| 1 # Clovis in the Cloud: Developer Guide | 1 # Clovis in the Cloud: Developer Guide |
| 2 | 2 |
| 3 This document describes how to collect Chromium traces using Google Compute | 3 This document describes how to collect Chromium traces using Google Compute |
| 4 Engine. | 4 Engine. |
| 5 | 5 |
| 6 [TOC] | 6 [TOC] |
| 7 | 7 |
| 8 ## Initial setup | 8 ## Initial setup |
| 9 | 9 |
| 10 Install the [gcloud command line tool][1]. | 10 Install the [gcloud command line tool][1]. |
| 11 | 11 |
| 12 ## Deploy the code | 12 ## Deploy the code |
| 13 | 13 |
| 14 ```shell | 14 ```shell |
| 15 # Build Chrome (do not use the component build). | 15 # Build Chrome (do not use the component build). |
| 16 BUILD_DIR=out/Release | 16 BUILD_DIR=out/Release |
| 17 ninja -C $BUILD_DIR -j1000 -l60 chrome chrome_sandbox | 17 ninja -C $BUILD_DIR -j1000 -l60 chrome chrome_sandbox |
| 18 | 18 |
| 19 # Deploy to GCE | 19 # Deploy to GCE |
| 20 # CLOUD_STORAGE_PATH is the path in Google Cloud Storage under which the | 20 # CLOUD_STORAGE_PATH is the path in Google Cloud Storage under which the |
| 21 # Clovis deployment will be uploaded. | 21 # Clovis deployment will be uploaded. |
| 22 | 22 |
| 23 ./tools/android/loading/gce/deploy.sh $BUILD_DIR $CLOUD_STORAGE_PATH | 23 ./tools/android/loading/cloud/backend/deploy.sh $BUILD_DIR $CLOUD_STORAGE_PATH |
| 24 ``` | 24 ``` |
| 25 | 25 |
| 26 ## Start the app in the cloud | 26 ## Start the app in the cloud |
| 27 | 27 |
| 28 Create an instance using latest ubuntu LTS: | 28 Create an instance using latest ubuntu LTS: |
| 29 | 29 |
| 30 ```shell | 30 ```shell |
| 31 gcloud compute instances create clovis-tracer-1 \ | 31 gcloud compute instances create clovis-tracer-1 \ |
| 32 --machine-type n1-standard-1 \ | 32 --machine-type n1-standard-1 \ |
| 33 --image ubuntu-14-04 \ | 33 --image ubuntu-14-04 \ |
| 34 --zone europe-west1-c \ | 34 --zone europe-west1-c \ |
| 35 --scopes cloud-platform \ | 35 --scopes cloud-platform,https://www.googleapis.com/auth/cloud-taskqueue \ |
| 36 --metadata cloud-storage-path=$CLOUD_STORAGE_PATH,auto-start=true \ | 36 --metadata cloud-storage-path=$CLOUD_STORAGE_PATH,taskqueue_tag=some_tag \ |
| 37 --metadata-from-file \ | 37 --metadata-from-file \ |
| 38 startup-script=$CHROMIUM_SRC/tools/android/loading/gce/startup-script.sh | 38 startup-script=$CHROMIUM_SRC/tools/android/loading/cloud/backend/startup-sc
ript.sh |
| 39 ``` | 39 ``` |
| 40 | 40 |
| 41 **Note:** To start an instance without automatically starting the app on it, | 41 **Note:** To start an instance without automatically starting the app on it, |
| 42 remove the `--metadata auto-start=true` argument. This can be useful when doing | 42 add a `auto-start=false` metadata. This can be useful when doing iterative |
| 43 iterative development on the instance, to be able to restart the app manually. | 43 development on the instance, to be able to restart the app manually. |
| 44 | 44 |
| 45 This should output the IP address of the instance. | 45 This should output the IP address of the instance. |
| 46 Otherwise the IP address can be retrieved by doing: | 46 Otherwise the IP address can be retrieved by doing: |
| 47 | 47 |
| 48 ```shell | 48 ```shell |
| 49 gcloud compute instances list | 49 gcloud compute instances list |
| 50 ``` | 50 ``` |
| 51 | 51 |
| 52 **Note:** It can take a few minutes for the instance to start. You can follow | 52 **Note:** It can take a few minutes for the instance to start. You can follow |
| 53 the progress of the startup script on the gcloud console web interface (menu | 53 the progress of the startup script on the gcloud console web interface (menu |
| 54 "Compute Engine" > "VM instances" then click on your instance and scroll down to | 54 "Compute Engine" > "VM instances" then click on your instance and scroll down to |
| 55 see the "Serial console output") or from the command line using: | 55 see the "Serial console output") or from the command line using: |
| 56 | 56 |
| 57 ```shell | 57 ```shell |
| 58 gcloud compute instances get-serial-port-output clovis-tracer-1 | 58 gcloud compute instances get-serial-port-output clovis-tracer-1 |
| 59 ``` | 59 ``` |
| 60 | 60 |
| 61 ## Use the app | 61 ## Use the app |
| 62 | 62 |
| 63 Check that `http://<instance-ip>:8080/test` prints `hello` when opened in a | 63 Create tasks from the associated AppEngine application, see [documentation][3]. |
| 64 browser. | 64 Make sure the `taskqueue_tag` of the AppEngine request matches the one of the |
| 65 | 65 ComputeEngine instances. |
| 66 To send a list of URLs to process: | |
| 67 | |
| 68 ```shell | |
| 69 curl -X POST -d @urls.json http://<instance-ip>:8080/set_tasks | |
| 70 ``` | |
| 71 | |
| 72 where `urls.json` is a JSON dictionary with the keys: | |
| 73 | |
| 74 * `urls`: array of URLs | |
| 75 * `repeat_count`: Number of times each URL will be loaded. Each load of a URL | |
| 76 generates a separate trace file. Optional. | |
| 77 * `emulate_device`: Name of the device to emulate. Optional. | |
| 78 * `emulate_network`: Type of network emulation. Optional. | |
| 79 | |
| 80 You can follow the progress at `http://<instance-ip>:8080/status`. | |
| 81 | 66 |
| 82 ## Stop the app in the cloud | 67 ## Stop the app in the cloud |
| 83 | 68 |
| 84 ```shell | 69 ```shell |
| 85 gcloud compute instances delete clovis-tracer-1 | 70 gcloud compute instances delete clovis-tracer-1 |
| 86 ``` | 71 ``` |
| 87 | 72 |
| 88 ## Connect to the instance with SSH | 73 ## Connect to the instance with SSH |
| 89 | 74 |
| 90 ```shell | 75 ```shell |
| 91 gcloud compute ssh clovis-tracer-1 | 76 gcloud compute ssh clovis-tracer-1 |
| 92 ``` | 77 ``` |
| 93 | 78 |
| 94 ## Use the app locally | 79 ## Use the app locally |
| 95 | 80 |
| 96 From a new directory, set up a local environment: | 81 From a new directory, set up a local environment: |
| 97 | 82 |
| 98 ```shell | 83 ```shell |
| 99 virtualenv env | 84 virtualenv env |
| 100 source env/bin/activate | 85 source env/bin/activate |
| 101 pip install -r $CHROMIUM_SRC/tools/android/loading/gce/pip_requirements.txt | 86 pip install -r \ |
| 87 $CHROMIUM_SRC/tools/android/loading/cloud/backend/pip_requirements.txt |
| 88 ``` |
| 89 |
| 90 The first time, you may need to get more access tokens: |
| 91 |
| 92 ```shell |
| 93 gcloud beta auth application-default login --scopes \ |
| 94 https://www.googleapis.com/auth/cloud-taskqueue \ |
| 95 https://www.googleapis.com/auth/cloud-platform |
| 102 ``` | 96 ``` |
| 103 | 97 |
| 104 Create a JSON file describing the deployment configuration: | 98 Create a JSON file describing the deployment configuration: |
| 105 | 99 |
| 106 ```shell | 100 ```shell |
| 107 # CONFIG_FILE is the output json file. | 101 # CONFIG_FILE is the output json file. |
| 108 # PROJECT_NAME is the Google Cloud project. | 102 # PROJECT_NAME is the Google Cloud project. |
| 109 # CLOUD_STORAGE_PATH is the path in Google Storage where generated traces will | 103 # CLOUD_STORAGE_PATH is the path in Google Storage where generated traces will |
| 110 # be stored. | 104 # be stored. |
| 111 # CHROME_PATH is the path to the Chrome executable on the host. | 105 # CHROME_PATH is the path to the Chrome executable on the host. |
| 112 # CHROMIUM_SRC is the Chromium src directory. | 106 # CHROMIUM_SRC is the Chromium src directory. |
| 113 cat >$CONFIG_FILE << EOF | 107 cat >$CONFIG_FILE << EOF |
| 114 { | 108 { |
| 115 "project_name" : "$PROJECT_NAME", | 109 "project_name" : "$PROJECT_NAME", |
| 116 "cloud_storage_path" : "$CLOUD_STORAGE_PATH", | 110 "cloud_storage_path" : "$CLOUD_STORAGE_PATH", |
| 117 "chrome_path" : "$CHROME_PATH", | 111 "chrome_path" : "$CHROME_PATH", |
| 118 "src_path" : "$CHROMIUM_SRC" | 112 "src_path" : "$CHROMIUM_SRC", |
| 113 "taskqueue_tag" : "some_tag" |
| 119 } | 114 } |
| 120 EOF | 115 EOF |
| 121 ``` | 116 ``` |
| 122 | 117 |
| 123 Launch the app, passing the path to the deployment configuration file: | 118 Launch the app, passing the path to the deployment configuration file: |
| 124 | 119 |
| 125 ```shell | 120 ```shell |
| 126 gunicorn --workers=1 --bind 127.0.0.1:8080 \ | 121 python $CHROMIUM_SRC/tools/android/loading/cloud/backend/worker.py \ |
| 127 --pythonpath $CHROMIUM_SRC/tools/android/loading/gce \ | 122 --config $CONFIG_FILE |
| 128 'main:StartApp('\"$CONFIG_FILE\"')' | |
| 129 ``` | 123 ``` |
| 130 | 124 |
| 131 You can now [use the app][2], which is located at http://localhost:8080. | 125 You can now [use the app][2]. |
| 132 | 126 |
| 133 Tear down the local environment: | 127 Tear down the local environment: |
| 134 | 128 |
| 135 ```shell | 129 ```shell |
| 136 deactivate | 130 deactivate |
| 137 ``` | 131 ``` |
| 138 | 132 |
| 139 [1]: https://cloud.google.com/sdk | 133 [1]: https://cloud.google.com/sdk |
| 140 [2]: #Use-the-app | 134 [2]: #Use-the-app |
| 135 [3]: ../frontend/README.md |
| OLD | NEW |