From b8c22597750ba5414075d07af26111f721b9a99f Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Fri, 12 Jul 2019 11:27:20 -0700 Subject: [PATCH] test docker image --- .circleci/config.yml | 5 +++++ tests.mk | 30 +++++++++++++++++++++++------- tests/ci/setup.sh | 17 +++++++++++++---- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7bf80df43..7638102fa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,6 +31,11 @@ jobs: shell: /bin/bash command: sudo -E make -e test-ci no_output_timeout: 60m + - run: | + if [ "${CIRCLE_NODE_INDEX}" == "0" ]; then + ./tests/ci/setup.sh docker + DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker + fi - store_artifacts: path: ./coverage.out - store_artifacts: diff --git a/tests.mk b/tests.mk index a42bee00c..c3dfc5fbd 100644 --- a/tests.mk +++ b/tests.mk @@ -47,7 +47,7 @@ ci-dependencies: bats shellcheck xmlstarlet setup-deploy-tests: ifdef ENABLE_DOKKU_TRACE - echo "-----> Enabling tracing" + echo "-----> Enable dokku trace" dokku trace:on endif @echo "Setting dokku.me in /etc/hosts" @@ -66,6 +66,9 @@ ifneq ($(shell ls /root/.ssh/config >/dev/null 2>&1 ; echo $$?),0) else ifeq ($(shell grep dokku.me /root/.ssh/config),) echo "Host dokku.me \\r\\n Port $(DOKKU_SSH_PORT) \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config echo "Host 127.0.0.1 \\r\\n Port 22333 \\r\\n RequestTTY yes \\r\\n IdentityFile /root/.ssh/dokku_test_rsa" >> /root/.ssh/config +else + sed --in-place 's/Port 22 \r/Port $(DOKKU_SSH_PORT) \r/g' /root/.ssh/config + cat /root/.ssh/config endif ifneq ($(wildcard /etc/ssh/sshd_config),) @@ -79,17 +82,28 @@ endif @echo "-----> Installing SSH public key..." sudo sshcommand acl-remove dokku test cat /root/.ssh/dokku_test_rsa.pub | sudo sshcommand acl-add dokku test - # docker exec -ti dokku bash -c "sshcommand acl-remove dokku test" - # docker exec -ti dokku bash -c "echo `cat /root/.ssh/dokku_test_rsa.pub` | sshcommand acl-add dokku test" - - @echo "-----> Intitial SSH connection to populate known_hosts..." - ssh -o StrictHostKeyChecking=no dokku@dokku.me help >/dev/null - ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help >/dev/null ifeq ($(shell grep dokku.me /home/dokku/VHOST 2>/dev/null),) @echo "-----> Setting default VHOST to dokku.me..." echo "dokku.me" > /home/dokku/VHOST endif +ifeq ($(DOKKU_SSH_PORT), 22) + $(MAKE) prime-ssh-known-hosts +endif + +setup-docker-deploy-tests: setup-deploy-tests +ifdef ENABLE_DOKKU_TRACE + echo "-----> Enable dokku trace" + docker exec -ti dokku bash -c "dokku trace:on" +endif + docker exec -ti dokku bash -c "sshcommand acl-remove dokku test" + docker exec -ti dokku bash -c "echo `cat /root/.ssh/dokku_test_rsa.pub` | sshcommand acl-add dokku test" + $(MAKE) prime-ssh-known-hosts + +prime-ssh-known-hosts: + @echo "-----> Intitial SSH connection to populate known_hosts..." + ssh -o StrictHostKeyChecking=no dokku@dokku.me help >/dev/null + ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help >/dev/null lint-setup: @mkdir -p test-results/shellcheck tmp/shellcheck @@ -247,3 +261,5 @@ test-ci: @mkdir -p test-results/bats @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; circleci tests glob *.bats | circleci tests split --split-by=timings --timings-type=classname | xargs)" cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; circleci tests glob *.bats | circleci tests split --split-by=timings --timings-type=classname | xargs) + +test-ci-docker: setup-docker-deploy-tests deploy-test-checks-root deploy-test-config deploy-test-multi deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy diff --git a/tests/ci/setup.sh b/tests/ci/setup.sh index c33bb30da..76d0ae551 100755 --- a/tests/ci/setup.sh +++ b/tests/ci/setup.sh @@ -74,7 +74,6 @@ run_dokku_container() { --env DOKKU_HOSTNAME=dokku.me \ --name dokku \ --publish 3022:22 \ - --publish 22333:22 \ --publish 80:80 \ --publish 443:443 \ --volume /var/lib/dokku:/mnt/dokku \ @@ -124,6 +123,16 @@ setup_circle() { sudo docker pull node:4 } -# shellcheck disable=SC2119 -setup_circle -exit $? +case "$1" in + docker) + sudo /etc/init.d/nginx stop + build_dokku_docker_image + run_dokku_container + ;; + *) + # shellcheck disable=SC2119 + setup_circle + exit $? + ;; +esac +