From 8f984831ac5fba82644cb569ef042fd85a4833a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 3 Dec 2015 12:05:40 -0500 Subject: [PATCH 1/3] update testing container docs --- test/image/README.md | 70 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/test/image/README.md b/test/image/README.md index 02851f5fa37..117f4b66bdb 100644 --- a/test/image/README.md +++ b/test/image/README.md @@ -1,24 +1,46 @@ # plotly.js image testing -Test plotly.js with the Plotly Image-Server docker container. +Test plotly.js with Plotly's image testing docker container. +Requirements: +- `docker` | [installation guidelines](http://docs.docker.com/engine/installation/) +- `docker-machine` (for Mac and Windows users only) | [installation guidelines](https://docs.docker.com/machine/install-machine/) +- `docker-compose` | [installation guidelines](https://docs.docker.com/compose/install/) + +### Step 0: Start the docker machine (Mac and Windows users only) + +Boot up docker machine (named `default`): + +```bash +docker-machine start default +``` + +Set up the docker environment for `docker-compose`: + +```bash +eval $(docker-machine env default) +``` + +the above evaluates the output of `docker-machine env default`. + + +### Step 1: Run the testing container + +Plotly.js uses `docker-compose` to ease the creation/stopping/deletion of testing docker container. -### Run the container with `docker compose` -Plotly.js uses `docker-compose` to ease the creation/stopping/deletion of testing docker container, -please refer [installing docker-compose](https://docs.docker.com/compose/install/) for installation. Inside your `plotly.js` directory, run ```bash -$ docker-compose up -d +docker-compose up -d ``` In the `docker-compose.yml` file, `latest` is the latest Plotly Image-Server docker container version as listed on [hub.docker.com](https://hub.docker.com/r/plotly/imageserver/tags/) and -`imagetest` is the name of the docker container. +`imagetest` is the name of the docker container. The `-d` flag tells docker to start the containers in the background and leave them running. -### Run the tests +### Step 2: Run the tests Inside your `plotly.js` directory, run @@ -26,7 +48,19 @@ Inside your `plotly.js` directory, run npm run test-image ``` -### SSH into docker +if some tests fail, compare their outputs using `npm run start-image_viewer`. + +### Step 3: Stop your testing container + +Once done testing, inside your `plotly.js` directory, run + +```bash +docker-compose stop +``` + +### Docker tricks + +##### SSH into docker container ```bash ssh -p 2022 root@localhost # with password `root` @@ -58,14 +92,19 @@ ssh-keygen -f "${HOME}/.ssh/known_hosts" -R [localhost]:2022 to remove host information. +##### List docker machines + +```bash +docker-machine ls +``` -### List all images +##### List all images ```bash docker images ``` -### List all containers +##### List all containers ```bash docker ps -a @@ -73,21 +112,20 @@ docker ps -a whereas `docker ps` lists only the started containers. - -### Stop your testing container +##### Remove your testing container Inside your `plotly.js` directory, run ```bash -docker-compose stop +docker-compose rm -f ``` -### Remove your testing container +#### Remove your docker machine -Inside your `plotly.js` directory, run +If named `default`: ```bash -docker-compose rm -f +docker-machine kill default ``` For more comprehensive information about docker, please refer to the [docker docs](http://docs.docker.com/). From 9e0dbde4c7fc1389af336fd7262638935e9de780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 3 Dec 2015 12:16:43 -0500 Subject: [PATCH 2/3] add info about docker-machine kill in step 3 --- test/image/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/image/README.md b/test/image/README.md index 117f4b66bdb..6e3c3659a2b 100644 --- a/test/image/README.md +++ b/test/image/README.md @@ -58,6 +58,12 @@ Once done testing, inside your `plotly.js` directory, run docker-compose stop ``` +Mac and Windows user should also kill their docker-machine (named `default`) once done testing: + +```bash +docker-machine kill default +``` + ### Docker tricks ##### SSH into docker container From d668226fcc0839c91e220b9bcfa5f5031534fac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 3 Dec 2015 12:33:45 -0500 Subject: [PATCH 3/3] Update README.md --- test/image/README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/image/README.md b/test/image/README.md index 6e3c3659a2b..16c31f9f59d 100644 --- a/test/image/README.md +++ b/test/image/README.md @@ -26,8 +26,7 @@ the above evaluates the output of `docker-machine env default`. ### Step 1: Run the testing container -Plotly.js uses `docker-compose` to ease the creation/stopping/deletion of testing docker container. - +Plotly.js uses `docker-compose` to ease the creation/stopping/deletion of the testing docker container. Inside your `plotly.js` directory, run @@ -39,8 +38,7 @@ In the `docker-compose.yml` file, `latest` is the latest Plotly Image-Server doc as listed on [hub.docker.com](https://hub.docker.com/r/plotly/imageserver/tags/) and `imagetest` is the name of the docker container. The `-d` flag tells docker to start the containers in the background and leave them running. - -### Step 2: Run the tests +### Step 2: Run the image tests Inside your `plotly.js` directory, run @@ -50,6 +48,16 @@ npm run test-image if some tests fail, compare their outputs using `npm run start-image_viewer`. +### Step 2b: Make a new baseline image + +Inside your `plotly.js` directory, run + +```bash +npm run baseline -- mock.json +``` + +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). + ### Step 3: Stop your testing container Once done testing, inside your `plotly.js` directory, run @@ -126,7 +134,7 @@ Inside your `plotly.js` directory, run docker-compose rm -f ``` -#### Remove your docker machine +##### Remove your docker machine If named `default`: