Skip to content

Commit 7c33004

Browse files
committed
Merge pull request #67 from plotly/etpinard-patch-1
Better image testing docs
2 parents 4a32ea7 + d668226 commit 7c33004

File tree

1 file changed

+69
-17
lines changed

1 file changed

+69
-17
lines changed

test/image/README.md

+69-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,80 @@
11
# plotly.js image testing
22

3-
Test plotly.js with the Plotly Image-Server docker container.
3+
Test plotly.js with Plotly's image testing docker container.
44

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/)
59

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.
730

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.
1031
Inside your `plotly.js` directory, run
1132

1233
```bash
13-
$ docker-compose up -d
34+
docker-compose up -d
1435
```
1536

1637
In the `docker-compose.yml` file, `latest` is the latest Plotly Image-Server docker container version
1738
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.
2040

21-
### Run the tests
41+
### Step 2: Run the image tests
2242

2343
Inside your `plotly.js` directory, run
2444

2545
```bash
2646
npm run test-image
2747
```
2848

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
3078

3179
```bash
3280
ssh -p 2022 root@localhost # with password `root`
@@ -58,36 +106,40 @@ ssh-keygen -f "${HOME}/.ssh/known_hosts" -R [localhost]:2022
58106

59107
to remove host information.
60108

109+
##### List docker machines
110+
111+
```bash
112+
docker-machine ls
113+
```
61114

62-
### List all images
115+
##### List all images
63116

64117
```bash
65118
docker images
66119
```
67120

68-
### List all containers
121+
##### List all containers
69122

70123
```bash
71124
docker ps -a
72125
```
73126

74127
whereas `docker ps` lists only the started containers.
75128

76-
77-
### Stop your testing container
129+
##### Remove your testing container
78130

79131
Inside your `plotly.js` directory, run
80132

81133
```bash
82-
docker-compose stop
134+
docker-compose rm -f
83135
```
84136

85-
### Remove your testing container
137+
##### Remove your docker machine
86138

87-
Inside your `plotly.js` directory, run
139+
If named `default`:
88140

89141
```bash
90-
docker-compose rm -f
142+
docker-machine kill default
91143
```
92144

93145
For more comprehensive information about docker, please refer to the [docker docs](http://docs.docker.com/).

0 commit comments

Comments
 (0)