Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ jobs:
git clone https://github.com/tetherless-world/whyis-demo.git
cd whyis-demo/docker/compose/monolithic
WHYIS_IMAGE_TAG=latest WHYIS_DEMO_IMAGE_TAG=latest docker-compose build whyis-demo
- run:
name: Build Cypress image
command: |
cd docker/compose/testing
docker-compose build
- run:
name: Run integration tests
command: .circleci/test-integration.sh tetherlessworld/whyis-demo:latest
Expand Down
26 changes: 18 additions & 8 deletions .circleci/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ mkdir -p test-results/js
echo "`date` Running integration tests in $WHYIS_DEMO_IMAGE"
#JS_REDIRECT=""
#docker run $WHYIS_DEMO_IMAGE bash -c "mkdir -p /apps/whyis/test-results/js && curl -sL https://deb.nodesource.com/setup_12.x | bash - $JS_REDIRECT && apt-get install -y nodejs xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 $JS_REDIRECT && cd /apps/whyis/tests/integration && npm install $JS_REDIRECT && CYPRESS_baseUrl=http://localhost npm run cypress:run $JS_REDIRECT"
JS_REDIRECT=">/apps/whyis/test-results/js/test.out 2>/apps/whyis/test-results/js/test.err"
docker run $WHYIS_DEMO_IMAGE bash -c "mkdir -p /apps/whyis/test-results/js && curl -sL https://deb.nodesource.com/setup_12.x | bash - $JS_REDIRECT && apt-get install -y nodejs xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 $JS_REDIRECT && cd /apps/whyis/tests/integration && npm install $JS_REDIRECT && CYPRESS_baseUrl=http://localhost npm run cypress:run-ci $JS_REDIRECT; cp -p -R cypress/screenshots /apps/whyis/test-results/js; cp -p -R cypress/videos /apps/whyis/test-results/js; cd /apps/whyis && tar cf test-results-js.tar test-results/js && cat test-results-js.tar" >test-results-js.tar
#JS_REDIRECT=">/apps/whyis/test-results/js/test.out 2>/apps/whyis/test-results/js/test.err"
#docker run $WHYIS_DEMO_IMAGE bash -c "mkdir -p /apps/whyis/test-results/js && curl -sL https://deb.nodesource.com/setup_12.x | bash - $JS_REDIRECT && apt-get install -y nodejs xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 $JS_REDIRECT && cd /apps/whyis/tests/integration && npm install $JS_REDIRECT && CYPRESS_baseUrl=http://localhost npm run cypress:run-ci $JS_REDIRECT; cp -p -R cypress/screenshots /apps/whyis/test-results/js; cp -p -R cypress/videos /apps/whyis/test-results/js; cd /apps/whyis && tar cf test-results-js.tar test-results/js && cat test-results-js.tar" >test-results-js.tar

#ERR_REDIRECT="2>/apps/whyis/test-results/js/test.err"

# docker network create whyis-network
# docker run --detach --name whyis $WHYIS_DEMO_IMAGE
# docker run --network container:whyis --name whyis-integration tetherlessworld/whyis-integration:latest

# docker run --name whyis-demo $WHYIS_DEMO_IMAGE bash -c "mkdir -p /apps/whyis/test-results/js && curl -sL https://deb.nodesource.com/setup_12.x | bash - && apt-get install -y nodejs && cd /apps/whyis/tests/integration && npm install && CYPRESS_baseUrl=http://localhost npm run cypress:run-ci && tar cf test-results-js.tar results"

docker-compose -f docker/compose/testing/docker-compose.yml up --abort-on-container-exit
docker cp whyis-integration:/integration/test-results-js.tar test-results/js/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Results probably aren't available yet, here. Need to loop until the file exists or some time has elapsed.
See e.g., the curl + sleep loops I've done before.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that docker-compose should block until the tests are over, which by then, results should exist. tar doesn't seem to complain on CircleCI, so I thought the result tar should be there.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think that's the case. Tar generally doesn't complain if you pass it nothing.


cd test-results/js
tar xf test-results-js.tar
echo "`date` Integration test stdout:"
cat test-results/js/test.out
echo "`date` Integration test stderr:"
cat test-results/js/test.err
if [ "$(ls test-results/js/results*.xml | wc -l)" -lt "1" ]; then

if [ "$(ls results/results*.xml | wc -l)" -lt "1" ]; then
echo "Integration test results.xml does not exist, exiting abnormally"
exit 1
fi
if [ "$(grep -c 'failure ' test-results/js/results*.xml)" -ge 1 ]; then
if [ "$(grep -c 'failure ' results/results*.xml)" -ge 1 ]; then
echo "Integration test results.xml has failures, exiting abnormally"
exit 1
fi
Expand Down
16 changes: 16 additions & 0 deletions docker/compose/testing/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3'
services:
whyis-demo:
container_name: "whyis-demo"
image: ${WHYIS_DEMO_IMAGE:-tetherlessworld/whyis-demo:latest}
whyis-integration:
container_name: "whyis-integration"
build:
context: ../../..
dockerfile: docker/image/whyis-integration/Dockerfile
depends_on:
- whyis-demo
links:
- whyis-demo:whyis
image: tetherlessworld/whyis-integration:latest
command: /docker-entrypoint.sh
9 changes: 9 additions & 0 deletions docker/image/whyis-integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# For running CI purposes
FROM cypress/included:3.2.0

COPY docker/image/whyis-integration/docker-entrypoint.sh /
COPY docker/image/whyis-integration/cypress.json /integration/
COPY tests/integration/cypress /integration/cypress
WORKDIR /integration

ENTRYPOINT ["bash"]
10 changes: 10 additions & 0 deletions docker/image/whyis-integration/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"baseUrl": "http://whyis",
"reporter": "junit",
"reporterOptions": {
"mochaFile": "results/results-[hash].xml",
"toConsole": false
},
"screenshotsFolder": "results/screenshots",
"videosFolder": "results/videos"
}
6 changes: 6 additions & 0 deletions docker/image/whyis-integration/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
CYPRESS_baseUrl=http://whyis

curl --retry 5 --retry-connrefused http://whyis > /dev/null
cypress run --spec cypress/integration/whyis/**/*
tar cf test-results-js.tar results
2 changes: 1 addition & 1 deletion tests/integration/cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"baseUrl": "http://localhost:5000"
"baseUrl": "http://localhost:5000",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a custom cypress.json for CI and copy it in to the Cypress image (or put it in .circleci/) rather than replacing the tests/integration/cypress.json, which should be runnable locally by default and print to stdout.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with the reporter options, Cypress will show the non-xml output, but I'll move the changes to a different file.

}