|
1 | 1 | # plotly.js image testing
|
2 | 2 |
|
3 |
| -Test plotly.js with the Plotly Image-Server docker container. |
| 3 | +Test plotly.js with Plotly's image testing docker container. |
4 | 4 |
|
| 5 | +Requirements: |
| 6 | +- `docker` | [installation guidelines](http://docs.docker.com/engine/installation/) |
| 7 | +- `docker-machine` (for Mac and Windows users only) | [installation guidelines](https://docs.docker.com/machine/install-machine/) |
| 8 | +- `docker-compose` | [installation guidelines](https://docs.docker.com/compose/install/) |
5 | 9 |
|
6 |
| -### Run the container with `docker compose` |
| 10 | +### Step 0: Start the docker machine (Mac and Windows users only) |
| 11 | + |
| 12 | +Boot up docker machine (named `default`): |
| 13 | + |
| 14 | +```bash |
| 15 | +docker-machine start default |
| 16 | +``` |
| 17 | + |
| 18 | +Set up the docker environment for `docker-compose`: |
| 19 | + |
| 20 | +```bash |
| 21 | +eval $(docker-machine env default) |
| 22 | +``` |
| 23 | + |
| 24 | +the above evaluates the output of `docker-machine env default`. |
| 25 | + |
| 26 | + |
| 27 | +### Step 1: Run the testing container |
| 28 | + |
| 29 | +Plotly.js uses `docker-compose` to ease the creation/stopping/deletion of the testing docker container. |
7 | 30 |
|
8 |
| -Plotly.js uses `docker-compose` to ease the creation/stopping/deletion of testing docker container, |
9 |
| -please refer [installing docker-compose](https://docs.docker.com/compose/install/) for installation. |
10 | 31 | Inside your `plotly.js` directory, run
|
11 | 32 |
|
12 | 33 | ```bash
|
13 |
| -$ docker-compose up -d |
| 34 | +docker-compose up -d |
14 | 35 | ```
|
15 | 36 |
|
16 | 37 | In the `docker-compose.yml` file, `latest` is the latest Plotly Image-Server docker container version
|
17 | 38 | as listed on [hub.docker.com](https://hub.docker.com/r/plotly/imageserver/tags/) and
|
18 |
| -`imagetest` is the name of the docker container. |
19 |
| - |
| 39 | +`imagetest` is the name of the docker container. The `-d` flag tells docker to start the containers in the background and leave them running. |
20 | 40 |
|
21 |
| -### Run the tests |
| 41 | +### Step 2: Run the image tests |
22 | 42 |
|
23 | 43 | Inside your `plotly.js` directory, run
|
24 | 44 |
|
25 | 45 | ```bash
|
26 | 46 | npm run test-image
|
27 | 47 | ```
|
28 | 48 |
|
29 |
| -### SSH into docker |
| 49 | +if some tests fail, compare their outputs using `npm run start-image_viewer`. |
| 50 | + |
| 51 | +### Step 2b: Make a new baseline image |
| 52 | + |
| 53 | +Inside your `plotly.js` directory, run |
| 54 | + |
| 55 | +```bash |
| 56 | +npm run baseline -- mock.json |
| 57 | +``` |
| 58 | + |
| 59 | +where `mock.json` is the name of a `{"data": [], "layout": {}}` json file found in [`test/image/mocks/`](https://github.com/plotly/plotly.js/tree/master/test/image/mocks). The `"data"` and `"layout"` field are passed to `Plotly.plot` to produce an image saved in [`test/image/baslines`](https://github.com/plotly/plotly.js/tree/master/test/image/baselines). |
| 60 | + |
| 61 | +### Step 3: Stop your testing container |
| 62 | + |
| 63 | +Once done testing, inside your `plotly.js` directory, run |
| 64 | + |
| 65 | +```bash |
| 66 | +docker-compose stop |
| 67 | +``` |
| 68 | + |
| 69 | +Mac and Windows user should also kill their docker-machine (named `default`) once done testing: |
| 70 | + |
| 71 | +```bash |
| 72 | +docker-machine kill default |
| 73 | +``` |
| 74 | + |
| 75 | +### Docker tricks |
| 76 | + |
| 77 | +##### SSH into docker container |
30 | 78 |
|
31 | 79 | ```bash
|
32 | 80 | ssh -p 2022 root@localhost # with password `root`
|
@@ -58,36 +106,40 @@ ssh-keygen -f "${HOME}/.ssh/known_hosts" -R [localhost]:2022
|
58 | 106 |
|
59 | 107 | to remove host information.
|
60 | 108 |
|
| 109 | +##### List docker machines |
| 110 | + |
| 111 | +```bash |
| 112 | +docker-machine ls |
| 113 | +``` |
61 | 114 |
|
62 |
| -### List all images |
| 115 | +##### List all images |
63 | 116 |
|
64 | 117 | ```bash
|
65 | 118 | docker images
|
66 | 119 | ```
|
67 | 120 |
|
68 |
| -### List all containers |
| 121 | +##### List all containers |
69 | 122 |
|
70 | 123 | ```bash
|
71 | 124 | docker ps -a
|
72 | 125 | ```
|
73 | 126 |
|
74 | 127 | whereas `docker ps` lists only the started containers.
|
75 | 128 |
|
76 |
| - |
77 |
| -### Stop your testing container |
| 129 | +##### Remove your testing container |
78 | 130 |
|
79 | 131 | Inside your `plotly.js` directory, run
|
80 | 132 |
|
81 | 133 | ```bash
|
82 |
| -docker-compose stop |
| 134 | +docker-compose rm -f |
83 | 135 | ```
|
84 | 136 |
|
85 |
| -### Remove your testing container |
| 137 | +##### Remove your docker machine |
86 | 138 |
|
87 |
| -Inside your `plotly.js` directory, run |
| 139 | +If named `default`: |
88 | 140 |
|
89 | 141 | ```bash
|
90 |
| -docker-compose rm -f |
| 142 | +docker-machine kill default |
91 | 143 | ```
|
92 | 144 |
|
93 | 145 | For more comprehensive information about docker, please refer to the [docker docs](http://docs.docker.com/).
|
0 commit comments