Skip to content

Commit

Permalink
Enable E2E on CI with dockerized Windshaft
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 5d89bfa
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 17:36:26 2018 +0200

    Rename job name

commit 4284ccd
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 16:36:27 2018 +0200

    Update docker node versions

commit 94048f9
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 16:29:41 2018 +0200

    Change E2E test zoom

commit a87a825
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 16:15:30 2018 +0200

    change e2e test reference

commit f488f0e
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 16:11:23 2018 +0200

    Change zoom on E2E

commit d3cf033
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 13:05:35 2018 +0200

    Remove unneeded SQL preparation scripts

commit e2aee7d
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 13:04:46 2018 +0200

    Remove production-only E2E test

commit c8682f4
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 13:04:04 2018 +0200

    Improve DEVELOPERS.md

commit f224cf5
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 11:23:08 2018 +0200

    Enforce tile order

commit ea91cae
Author: David Manzanares <[email protected]>
Date:   Thu Jul 19 11:14:35 2018 +0200

    Add Docker installation link

commit e545fa8
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 18:57:30 2018 +0200

    Fix local e2e testing

commit 7f1e39a
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 17:33:11 2018 +0200

    Add docs about docker and e2e testing

commit d9a209f
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 17:22:55 2018 +0200

    Use production rendering settings

commit e0cf180
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 16:29:40 2018 +0200

    WIP

commit 7db4172
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 15:02:23 2018 +0200

    FIX

commit 912c586
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:51:23 2018 +0200

    POC

commit 67f698a
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:47:32 2018 +0200

    POC

commit 849a97a
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:41:23 2018 +0200

    FIX

commit 7b63f72
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:40:37 2018 +0200

    POC

commit b3d6669
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:22:36 2018 +0200

    Fix linting

commit 0ea81c4
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:17:23 2018 +0200

    WIP

commit c6e33aa
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:10:36 2018 +0200

    WIP

commit 81f2ef0
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 14:05:51 2018 +0200

    WIP

commit 731a1fc
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 13:14:26 2018 +0200

    WIP

commit dbe9984
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 13:10:42 2018 +0200

    Use Cache on CI

commit ea3fa8e
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 13:03:48 2018 +0200

    WIP

commit caec3c2
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:54:10 2018 +0200

    WIP

commit 3ba0aeb
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:46:40 2018 +0200

    WIP

commit dd30c07
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:41:22 2018 +0200

    WIP

commit f5fc1c7
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:39:46 2018 +0200

    WIP

commit 7e2861c
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:33:17 2018 +0200

    WIP

commit 5f2d835
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:26:56 2018 +0200

    WIP

commit d184d99
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:19:19 2018 +0200

    WIP

commit 3d52ab6
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 12:15:48 2018 +0200

    WIP

commit 07febd1
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:53:51 2018 +0200

    WIP

commit 907dfa3
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:52:34 2018 +0200

    WIP

commit 7dfde73
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:45:47 2018 +0200

    WIP

commit 19cb68d
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:42:00 2018 +0200

    WIP

commit 9c67fe4
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:39:38 2018 +0200

    WIP

commit c8b2923
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:38:48 2018 +0200

    WIP

commit f8f8a46
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:36:51 2018 +0200

    WIP

commit 6bb739d
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:34:59 2018 +0200

    WIP

commit cf463ca
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:29:56 2018 +0200

    WIP

commit a27b46a
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:28:04 2018 +0200

    WIP

commit ae18b6a
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:27:04 2018 +0200

    WIP

commit e2094f2
Author: David Manzanares <[email protected]>
Date:   Wed Jul 18 11:25:37 2018 +0200

    CircleCI WIP

commit de01ae5
Author: David M <[email protected]>
Date:   Tue Jul 17 19:03:15 2018 +0200

    WIP CI change

commit 1d85eb7
Author: David M <[email protected]>
Date:   Tue Jul 17 17:10:17 2018 +0200

    E2E with dockerized Windshaft PoC
  • Loading branch information
David Manzanares committed Jul 19, 2018
1 parent 84afcd0 commit dc50331
Show file tree
Hide file tree
Showing 26 changed files with 1,823 additions and 121 deletions.
73 changes: 26 additions & 47 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,45 @@
version: 2

jobs:

lint:
E2E:
docker:
# specify the version you desire here
- image: circleci/node@sha256:317e12895d27814da19d88af5da3743248fc48c349cc250ffdf17f290f257d96
- image: circleci/node:8-browsers
- image: carto/windshaft-cartovl-testing
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- restore_cache: # special step to restore the dependency cache
key: dependency-cache-{{ checksum "package.json" }}
- run: yarn install
- run: yarn lint
- run: yarn docs
- save_cache: # special step to save the dependency cache
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: echo "127.0.0.1 localhost.localhost.lan" | sudo tee -a /etc/hosts
- run: yarn build:dev && yarn wait-on http://localhost.localhost.lan:8181 && yarn mocha test/acceptance/e2e.test.js --timeout 10000

test-unit:
test-unit-lint-docs:
docker:
# specify the version you desire here
- image: circleci/node@sha256:317e12895d27814da19d88af5da3743248fc48c349cc250ffdf17f290f257d96
- image: circleci/node:8-browsers
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- restore_cache: # special step to restore the dependency cache
key: dependency-cache-{{ checksum "package.json" }}
- run: yarn install
- run: yarn test:unit
- save_cache:
- save_cache: # special step to save the dependency cache
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- ./node_modules
- run: yarn test:unit
- run: yarn lint
- run: yarn docs

test-user:
docker:
# specify the version you desire here
- image: circleci/node@sha256:317e12895d27814da19d88af5da3743248fc48c349cc250ffdf17f290f257d96
- image: circleci/node:8-browsers
working_directory: ~/repo
steps:
- checkout
Expand All @@ -63,7 +62,7 @@ jobs:
test-integration:
docker:
# specify the version you desire here
- image: circleci/node@sha256:317e12895d27814da19d88af5da3743248fc48c349cc250ffdf17f290f257d96
- image: circleci/node:8-browsers
working_directory: ~/repo
steps:
- checkout
Expand All @@ -80,31 +79,11 @@ jobs:
key: v1-dependencies-{{ checksum "package.json" }}
- run: xvfb-run -a yarn test:render

test-acceptance:
docker:
# specify the version you desire here
- image: circleci/node@sha256:317e12895d27814da19d88af5da3743248fc48c349cc250ffdf17f290f257d96
working_directory: ~/repo
steps:
- checkout
- run: Xvfb :98 &
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: xvfb-run -a yarn test:e2e

workflows:
version: 2
build_and_test:
jobs:
- lint
- test-unit
- E2E
- test-unit-lint-docs
- test-integration
- test-user
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ secrets.json
temp/
test/acceptance/e2e/**/*.html
test/integration/render/**/*.html
test/acceptance/docker/Windshaft-cartodb/
8 changes: 7 additions & 1 deletion DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,19 @@ Adding `x-` at the beginning of any test folder marks this test to be ignored.

### Acceptance tests (E2E tests)

This end to end tests cover the entire library by perfoming tests againts real servers. This is done through iterative screenshot testing, comparing `test` screenshots against its reference images.
This end to end tests cover the entire library by performing tests against real servers. This is done through iterative screenshot testing, comparing `test` screenshots against its reference images. To achieve real E2E testing, a Windshaft-cartodb server is deployed within a Docker container.

To install Docker, follow the instructions on https://docs.docker.com/install/

You'll also need to add `127.0.0.1 localhost.localhost.lan` your `/etc/hosts/` file.

```bash
# Running the tests
$ yarn test:e2e
```

To rebuild the Docker image run: `docker build -t carto/windshaft-cartovl-testing test/acceptance/docker/`

#### Generating new references

To create new tests, crate a new folder with a new `scenario.js` file and run the following command:
Expand Down
2 changes: 1 addition & 1 deletion debug/local-windshaft.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<!-- Include CARTO VL JS -->
<script src="../../dist/carto-vl.js"></script>
<script src="../dist/carto-vl.js"></script>
<!-- Include Mapbox GL JS -->
<script src="https://libs.cartocdn.com/mapbox-gl/v0.45.0-carto1/mapbox-gl.js"></script>
<!-- Include Mapbox GL CSS -->
Expand Down
12 changes: 12 additions & 0 deletions e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

ALREADY_UP="$(docker ps |grep `cat .docker.run | cut -c 1-12`|wc -l)"

if [ "$ALREADY_UP" -eq "0" ]; then
echo Running
docker run -d -p 127.0.0.1:8181:8181 -v `pwd`/test/acceptance/docker:/mnt carto/windshaft-cartovl-testing ./deploy.sh > .docker.run
fi

yarn build:dev && yarn wait-on http://localhost.localhost.lan:8181 && mocha test/acceptance/e2e.test.js --timeout 10000;

# docker kill `cat .docker.run`
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"sloc": "^0.2.0",
"svg-inline-loader": "^0.8.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"wait-on": "^2.1.0",
"webpack": "^4.0.0",
"webpack-cli": "^2.1.4",
"webpack-glsl-loader": "^1.0.1"
Expand All @@ -93,7 +94,7 @@
"test:render": "yarn build:dev && mocha test/integration/render/render.test.js --timeout 5000",
"test:render:clean": "rm -rf test/integration/render/scenarios/**/**/reference.png",
"test:render:prepare": "yarn build:dev && node test/integration/render/render.prepare.js ",
"test:e2e": "yarn build:dev && mocha test/acceptance/e2e.test.js --timeout 10000",
"test:e2e": "./e2e.sh",
"test:e2e:clean": "rm -rf test/acceptance/e2e/**/reference.png",
"test:e2e:prepare": "yarn build:dev && node test/acceptance/e2e.prepare.js ",
"test:benchmark": "node test/benchmark/benchmark.js",
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/RenderLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export default class RenderLayer {

getActiveDataframes () {
this.dataframes = this.dataframes.filter(df => !df.freed);
return this.dataframes.filter(df => df.active && df.numVertex);
let active = this.dataframes.filter(df => df.active && df.numVertex);
if (active.length && active[0].orderID !== undefined) {
active = active.sort((a, b) => a.orderID - b.orderID);
}
return active;
}

hasDataframes () {
Expand Down
1 change: 1 addition & 0 deletions src/sources/TileClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class TileClient {
tiles.forEach(({ x, y, z }) => {
this._cache.get(`${x},${y},${z}`, () => this._requestDataframe(x, y, z, responseToDataframeTransformer)).then(
dataframe => {
dataframe.orderID = x + y / 1000;
if (dataframe.empty) {
needToComplete--;
} else {
Expand Down
20 changes: 20 additions & 0 deletions test/acceptance/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM carto/nodejs6-xenial-pg101

RUN set -ex \
&& npm install -g [email protected]

WORKDIR /srv

COPY config/ ./config/
COPY test/ ./test/
COPY prepare.sh ./
RUN set -ex \
&& /etc/init.d/postgresql start \
&& bash prepare.sh

WORKDIR /mnt
COPY deploy.sh ./

ENTRYPOINT [ "./deploy.sh" ]

EXPOSE 8181
Loading

0 comments on commit dc50331

Please sign in to comment.