From d7b0d2a4d9a74ce3c4e2390f29f876ee587992bc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 1 Jun 2020 22:57:43 -0400 Subject: [PATCH 01/77] feat: add github-based ci config --- .github/workflows/ci.yaml | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..1e8f019e5 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,69 @@ +name: CI + +on: + pull_request: + branches: + - '*' + push: + branches: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + index: [0, 1, 2,3] + env: + GITHUB_NODE_INDEX: ${{ matrix.compiler }} + name: ci.${{ matrix.index }} + + steps: + - uses: actions/checkout@v2 + + - name: install ci-dependencies + run: make ci-dependencies + + - name: setup tests + run: ./tests/ci/setup.sh + + - name: dokku cleanup:skip + run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup + + - name: resolve dokku.me + run: | + # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 + sudo ip a a 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 + + - name: run pre-tests + run: | + export CIRCLE_SHA1=$GITHUB_SHA + case $GITHUB_NODE_INDEX in + 0) sudo -E make -e lint-ci go-tests ci-go-coverage ;; + 1) sudo -E make -e deploy-test-checks-root deploy-test-config ;; + 2) sudo -E make -e deploy-test-multi ;; + 3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;; + esac + - name: run ci + shell: bash + timeout-minutes: 60 + run: | + sudo -E make -e test-ci + + - name: test docker deploys + run: | + if [ "${GITHUB_NODE_INDEX}" == "0" ]; then + ./tests/ci/setup.sh docker + DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker + fi + + - uses: actions/upload-artifact@v2 + with: + name: coverage.${{ matrix.index }}.out + path: coverage.out + + - uses: actions/upload-artifact@v2 + with: + name: test-results-${{ matrix.index }} + path: test-results From dfaa20e449a9964e1ad9d36d8c03cff5700f850b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:08:21 -0400 Subject: [PATCH 02/77] feat: upgrade herokuish This enables herokuish to be installed when moby-engine is the docker-engine that is available. --- deb.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deb.mk b/deb.mk index 1f6932877..0f9d9f4f0 100644 --- a/deb.mk +++ b/deb.mk @@ -2,7 +2,7 @@ BUILD_DIRECTORY ?= /tmp HEROKUISH_DESCRIPTION = 'Herokuish uses Docker and Buildpacks to build applications like Heroku' HEROKUISH_REPO_NAME ?= gliderlabs/herokuish -HEROKUISH_VERSION ?= 0.5.13 +HEROKUISH_VERSION ?= 0.5.14 HEROKUISH_ARCHITECTURE = amd64 HEROKUISH_PACKAGE_NAME = herokuish_$(HEROKUISH_VERSION)_$(HEROKUISH_ARCHITECTURE).deb @@ -80,7 +80,7 @@ deb-herokuish: --version $(HEROKUISH_VERSION) \ --architecture $(HEROKUISH_ARCHITECTURE) \ --package $(BUILD_DIRECTORY)/$(HEROKUISH_PACKAGE_NAME) \ - --deb-pre-depends 'docker-engine-cs (>= 1.9.1) | docker-engine (>= 1.9.1) | docker-ce | docker-ee' \ + --deb-pre-depends 'docker-engine-cs (>= 1.13.0) | docker-engine (>= 1.13.0) | docker-io (>= 1.13.0) | docker.io (>= 1.13.0) | docker-ce (>= 1.13.0) | docker-ee (>= 1.13.0) | moby-engine' \ --deb-pre-depends sudo \ --after-install /tmp/tmp/post-install \ --url "https://github.com/$(HEROKUISH_REPO_NAME)" \ From ef91685596837e602b11c5aeb196982028bc7a9f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:27:37 -0400 Subject: [PATCH 03/77] tests: disable on pull_request for now --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1e8f019e5..5c108ac30 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,9 +1,9 @@ name: CI on: - pull_request: - branches: - - '*' + # pull_request: + # branches: + # - '*' push: branches: - '*' From 94512166069d04f7e04bdfad6a1931703227d10d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:27:52 -0400 Subject: [PATCH 04/77] refactor: build the package separately from running ci --- .github/workflows/ci.yaml | 36 ++++++++++++++++++++++++++++-------- tests/ci/setup.sh | 26 +++++++++++++++++++------- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5c108ac30..010607684 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,21 +10,41 @@ on: jobs: build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - index: [0, 1, 2,3] - env: - GITHUB_NODE_INDEX: ${{ matrix.compiler }} name: ci.${{ matrix.index }} - steps: - uses: actions/checkout@v2 - name: install ci-dependencies run: make ci-dependencies + - name: build package + run: ./tests/ci/setup.sh build + + - name: upload packages + uses: actions/upload-artifact@v2 + with: + name: build + path: build + + ci: + env: + GITHUB_NODE_INDEX: ${{ matrix.compiler }} + name: ci.${{ matrix.index }} + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + index: [0, 1, 2,3] + + steps: + - uses: actions/checkout@v2 + + - name: download packages + uses: actions/download-artifact@v1 + with: + name: build + - name: setup tests run: ./tests/ci/setup.sh diff --git a/tests/ci/setup.sh b/tests/ci/setup.sh index 7eff42a7c..d12d3305b 100755 --- a/tests/ci/setup.sh +++ b/tests/ci/setup.sh @@ -40,6 +40,11 @@ install_dependencies() { } build_dokku() { + if [[ "$FROM_SOURCE" == "true" ]]; then + sudo -E CI=true make -e install + return + fi + echo "=====> build_dokku on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX" "${ROOT_DIR}/contrib/release-dokku" build } @@ -47,13 +52,10 @@ build_dokku() { install_dokku() { echo "=====> install_dokku on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX" - if [[ "$FROM_SOURCE" == "true" ]]; then - sudo -E CI=true make -e install - return + if [[ ! -f "${ROOT_DIR}/build/deb-filename" ]]; then + build_dokku fi - build_dokku - echo "dokku dokku/hostname string dokku.me" | sudo debconf-set-selections echo "dokku dokku/key_file string /root/.ssh/id_rsa.pub" | sudo debconf-set-selections echo "dokku dokku/nginx_enable boolean true" | sudo debconf-set-selections @@ -102,14 +104,19 @@ check_container() { done } -# shellcheck disable=SC2120 -setup_circle() { +create_package() { echo "=====> setup_circle on CIRCLE_NODE_INDEX: $CIRCLE_NODE_INDEX" sudo -E CI=true make -e sshcommand # need to add the dokku user to the docker group sudo usermod -G docker dokku [[ "$1" == "buildstack" ]] && BUILD_STACK=true make -e stack + install_dependencies + build_dokku +} + +# shellcheck disable=SC2120 +setup_circle() { install_dependencies install_dokku @@ -129,6 +136,11 @@ case "$1" in build_dokku_docker_image run_dokku_container ;; + build) + # shellcheck disable=SC2119 + create_package + exit $? + ;; *) # shellcheck disable=SC2119 setup_circle From 614ba6645023c125d0a7c4d4cb91bbcf88a00b39 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:29:03 -0400 Subject: [PATCH 05/77] tests: enable on pull_request --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 010607684..0b0b897e9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,9 +1,9 @@ name: CI on: - # pull_request: - # branches: - # - '*' + pull_request: + branches: + - '*' push: branches: - '*' From 1ba874ea6238dcd073c381d3dd320db54c5980fd Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:30:30 -0400 Subject: [PATCH 06/77] fix: add runs-on --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0b0b897e9..002741daa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,6 +11,8 @@ on: jobs: build: name: ci.${{ matrix.index }} + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v2 From d682bd52ff5c0cc1fa5707f2489e144db4fad6c8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:42:40 -0400 Subject: [PATCH 07/77] feat: only build image for non-build releases --- contrib/release-dokku | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/release-dokku b/contrib/release-dokku index 6b3fce765..d52990684 100755 --- a/contrib/release-dokku +++ b/contrib/release-dokku @@ -364,9 +364,7 @@ main() { fn-extract-package "$IS_RELEASE" "dokku-${NEXT_VERSION}-1.x86_64.rpm" || log-fail "Error extracting rpm package" cp -f "build/dokku_${NEXT_VERSION}_amd64.deb" build/dokku.deb - if [[ "$RELEASE" == "build" ]]; then - fn-build-docker-image "latest" || log-fail "Error building docker image" - else + if [[ "$RELEASE" != "build" ]]; then fn-publish-package "$IS_RELEASE" "deb" "build/dokku_${NEXT_VERSION}_amd64.deb" || log-fail "Error publishing deb package" fn-publish-package "$IS_RELEASE" "rpm" "build/dokku-${NEXT_VERSION}-1.x86_64.rpm" || log-fail "Error publishing rpm package" fn-build-docker-image "$NEXT_VERSION" || log-fail "Error building docker image" From 5c17bcc71029f7a7c797d22c5ca477c299048fae Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:42:51 -0400 Subject: [PATCH 08/77] chore: minor test fixes --- .github/workflows/ci.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 002741daa..2f59e14a8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,8 +10,10 @@ on: jobs: build: - name: ci.${{ matrix.index }} + name: build runs-on: ubuntu-latest + strategy: + fail-fast: true steps: - uses: actions/checkout@v2 @@ -35,7 +37,7 @@ jobs: needs: build runs-on: ubuntu-latest strategy: - fail-fast: false + fail-fast: true matrix: index: [0, 1, 2,3] From d60140dad84e5370d5aca96f12b0d0a38f5c0963 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 00:44:41 -0400 Subject: [PATCH 09/77] debug: check if there is extra output --- tests.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.mk b/tests.mk index b59fb72f0..4250abee9 100644 --- a/tests.mk +++ b/tests.mk @@ -100,8 +100,8 @@ endif 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 + ssh -o StrictHostKeyChecking=no dokku@dokku.me help + ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help lint-setup: @mkdir -p test-results/shellcheck tmp/shellcheck From db253c15cc76433b33374da1f1056a385756b774 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 01:04:33 -0400 Subject: [PATCH 10/77] feat: cat the contents --- tests.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests.mk b/tests.mk index 4250abee9..d0f42096d 100644 --- a/tests.mk +++ b/tests.mk @@ -100,6 +100,9 @@ endif prime-ssh-known-hosts: @echo "-----> Intitial SSH connection to populate known_hosts..." + cat /home/dokku/.ssh/known_hosts + cat /home/dokku/.ssh/authorized_keys + cat /root/.ssh/config ssh -o StrictHostKeyChecking=no dokku@dokku.me help ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help From b50590e2ad301718a2d72824aeac0ed632f26238 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 01:23:09 -0400 Subject: [PATCH 11/77] debug: fix debug statements --- tests.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.mk b/tests.mk index d0f42096d..b076ae1d8 100644 --- a/tests.mk +++ b/tests.mk @@ -100,9 +100,9 @@ endif prime-ssh-known-hosts: @echo "-----> Intitial SSH connection to populate known_hosts..." - cat /home/dokku/.ssh/known_hosts cat /home/dokku/.ssh/authorized_keys cat /root/.ssh/config + cat /home/dokku/.ssh/config ssh -o StrictHostKeyChecking=no dokku@dokku.me help ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help From ca248a62ec5fd55dc1704ee68dfe1a761ef83e7d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 01:38:11 -0400 Subject: [PATCH 12/77] debug: more logging --- tests.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests.mk b/tests.mk index b076ae1d8..6bef5d06c 100644 --- a/tests.mk +++ b/tests.mk @@ -103,6 +103,8 @@ prime-ssh-known-hosts: cat /home/dokku/.ssh/authorized_keys cat /root/.ssh/config cat /home/dokku/.ssh/config + ping -c1 dokku.me + dig +short dokku.me ssh -o StrictHostKeyChecking=no dokku@dokku.me help ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help From 75a2d3a1ba74ffd87c0b107a4b1c22e1ad361c0a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 12:42:54 -0400 Subject: [PATCH 13/77] debug: more test logging --- tests.mk | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests.mk b/tests.mk index 6bef5d06c..9f126b25a 100644 --- a/tests.mk +++ b/tests.mk @@ -100,13 +100,20 @@ endif prime-ssh-known-hosts: @echo "-----> Intitial SSH connection to populate known_hosts..." + @echo "=====> Authorized Keys" cat /home/dokku/.ssh/authorized_keys + @echo "=====> Root SSH Config" cat /root/.ssh/config + @echo "=====> Dokku SSH Config" cat /home/dokku/.ssh/config + @echo "=====> Ping dokku.me" ping -c1 dokku.me - dig +short dokku.me - ssh -o StrictHostKeyChecking=no dokku@dokku.me help - ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help + @echo "=====> Dig dokku.me" + dig dokku.me + @echo "=====> SSH dokku.me" + ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help + @echo "=====> SSH 127.0.0.1" + ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help lint-setup: @mkdir -p test-results/shellcheck tmp/shellcheck From 1cab6acf695e4860c177095aa8fe5675746ae0ae Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 12:53:06 -0400 Subject: [PATCH 14/77] fix: drop unnecessary cat --- tests.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests.mk b/tests.mk index 9f126b25a..aa955e6d6 100644 --- a/tests.mk +++ b/tests.mk @@ -104,8 +104,6 @@ prime-ssh-known-hosts: cat /home/dokku/.ssh/authorized_keys @echo "=====> Root SSH Config" cat /root/.ssh/config - @echo "=====> Dokku SSH Config" - cat /home/dokku/.ssh/config @echo "=====> Ping dokku.me" ping -c1 dokku.me @echo "=====> Dig dokku.me" From bf7e86fb13eb889faadcc5309ccee481db4c8edf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 13:04:46 -0400 Subject: [PATCH 15/77] fix: drop existing key --- tests.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/tests.mk b/tests.mk index aa955e6d6..f252a0664 100644 --- a/tests.mk +++ b/tests.mk @@ -78,6 +78,7 @@ endif endif @echo "-----> Installing SSH public key..." + rm -f /home/dokku/.ssh/authorized_keys sudo sshcommand acl-remove dokku test cat /root/.ssh/dokku_test_rsa.pub | sudo sshcommand acl-add dokku test From f47a26791743299a0619a497e25635a0b2466263 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 13:30:12 -0400 Subject: [PATCH 16/77] debug: echo empty --- tests.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.mk b/tests.mk index f252a0664..6c5effb18 100644 --- a/tests.mk +++ b/tests.mk @@ -78,7 +78,7 @@ endif endif @echo "-----> Installing SSH public key..." - rm -f /home/dokku/.ssh/authorized_keys + echo "" > /home/dokku/.ssh/authorized_keys sudo sshcommand acl-remove dokku test cat /root/.ssh/dokku_test_rsa.pub | sudo sshcommand acl-add dokku test From a8fd8d1b19705a64ebd1dc5fe8d13a725140a8b9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 13:48:42 -0400 Subject: [PATCH 17/77] debug: more logging --- tests.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests.mk b/tests.mk index 6c5effb18..6a261da61 100644 --- a/tests.mk +++ b/tests.mk @@ -109,6 +109,12 @@ prime-ssh-known-hosts: ping -c1 dokku.me @echo "=====> Dig dokku.me" dig dokku.me + @echo "=====> Private rsa key" + cat /root/.ssh/dokku_test_rsa + @echo "=====> Public rsa key" + cat /root/.ssh/dokku_test_rsa.pub + @echo "=====> SSHD Config" + /etc/ssh/sshd_config @echo "=====> SSH dokku.me" ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help @echo "=====> SSH 127.0.0.1" From 88e01d8a4b34280755e50db81d1b658bba2b682d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 2 Jun 2020 13:57:58 -0400 Subject: [PATCH 18/77] debug: more logging --- tests.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.mk b/tests.mk index 6a261da61..40a2fe88d 100644 --- a/tests.mk +++ b/tests.mk @@ -114,7 +114,7 @@ prime-ssh-known-hosts: @echo "=====> Public rsa key" cat /root/.ssh/dokku_test_rsa.pub @echo "=====> SSHD Config" - /etc/ssh/sshd_config + cat /etc/ssh/sshd_config @echo "=====> SSH dokku.me" ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help @echo "=====> SSH 127.0.0.1" From 6e7e7d35cc9933f69c2e2ef2d59ea5054dc3df1d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 5 Jun 2020 01:33:23 -0400 Subject: [PATCH 19/77] fix: resolve dokku.me locally --- .github/workflows/ci.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2f59e14a8..2735250ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,17 +49,17 @@ jobs: with: name: build + - name: resolve dokku.me + run: | + # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 + sudo ip a a 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 + - name: setup tests run: ./tests/ci/setup.sh - name: dokku cleanup:skip run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - - name: resolve dokku.me - run: | - # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 - sudo ip a a 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 - - name: run pre-tests run: | export CIRCLE_SHA1=$GITHUB_SHA From ef4fe2dbf9bd93c46f74a571e74e02839d22a92e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 7 Jun 2020 14:23:11 -0400 Subject: [PATCH 20/77] debug: show devices and use long-form for ip command --- .circleci/config.yml | 3 ++- .github/workflows/ci.yaml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 05be1eba6..370ecebb8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,8 @@ jobs: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - run: | # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 - sudo ip a a 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 + ifconfig + sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 - run: | case $CIRCLE_NODE_INDEX in 0) sudo -E make -e lint-ci go-tests ci-go-coverage ;; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2735250ea..d81bb1087 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,7 +52,8 @@ jobs: - name: resolve dokku.me run: | # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 - sudo ip a a 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 + ifconfig + sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 - name: setup tests run: ./tests/ci/setup.sh From ca1e188e9a1b0181a769df4af868753deab2f9b8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 7 Jun 2020 14:36:28 -0400 Subject: [PATCH 21/77] fix: use eth0 instead of ens4 The value is different for whatever reason on GH hardware... --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d81bb1087..186c89332 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -51,9 +51,9 @@ jobs: - name: resolve dokku.me run: | - # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 + # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 ifconfig - sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 + sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 - name: setup tests run: ./tests/ci/setup.sh From ee083eb3c3a98896fbec1acd60de6ac836adadef Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 7 Jun 2020 14:56:09 -0400 Subject: [PATCH 22/77] debug: list file permissions --- tests.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests.mk b/tests.mk index 40a2fe88d..4d27156a7 100644 --- a/tests.mk +++ b/tests.mk @@ -115,6 +115,8 @@ prime-ssh-known-hosts: cat /root/.ssh/dokku_test_rsa.pub @echo "=====> SSHD Config" cat /etc/ssh/sshd_config + @echo "=====> ssh file permissions" + ls -lah /root/.ssh/ @echo "=====> SSH dokku.me" ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help @echo "=====> SSH 127.0.0.1" From 2919415d7e3eabb5f03a60aee946a6107872a885 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 7 Jun 2020 15:10:41 -0400 Subject: [PATCH 23/77] fix: set correct perms for ssh key files --- tests.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests.mk b/tests.mk index 4d27156a7..b16a3fd90 100644 --- a/tests.mk +++ b/tests.mk @@ -55,7 +55,8 @@ endif mkdir -p /root/.ssh rm -f /root/.ssh/dokku_test_rsa* echo -e "y\n" | ssh-keygen -f /root/.ssh/dokku_test_rsa -t rsa -N '' - chmod 600 /root/.ssh/dokku_test_rsa* + chmod 600 /root/.ssh/dokku_test_rsa + chmod 644 /root/.ssh/dokku_test_rsa.pub @echo "-----> Setting up ssh config..." ifneq ($(shell ls /root/.ssh/config >/dev/null 2>&1 ; echo $$?),0) From cf35cedd1e6a6d449e41a92765c8b8b8a6edc33d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 01:35:31 -0400 Subject: [PATCH 24/77] debug: show auth log --- tests.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.mk b/tests.mk index b16a3fd90..e637a5c33 100644 --- a/tests.mk +++ b/tests.mk @@ -119,9 +119,9 @@ prime-ssh-known-hosts: @echo "=====> ssh file permissions" ls -lah /root/.ssh/ @echo "=====> SSH dokku.me" - ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help + ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help || { cat /var/log/auth.log && exit 1 } @echo "=====> SSH 127.0.0.1" - ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help + ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help || { cat /var/log/auth.log && exit 1 } lint-setup: @mkdir -p test-results/shellcheck tmp/shellcheck From fb4a2325371af724c978ddb723f6ee607431750d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 01:59:20 -0400 Subject: [PATCH 25/77] debug: exit separately --- tests.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests.mk b/tests.mk index e637a5c33..351cb9797 100644 --- a/tests.mk +++ b/tests.mk @@ -119,9 +119,10 @@ prime-ssh-known-hosts: @echo "=====> ssh file permissions" ls -lah /root/.ssh/ @echo "=====> SSH dokku.me" - ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help || { cat /var/log/auth.log && exit 1 } + ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help || cat /var/log/auth.log @echo "=====> SSH 127.0.0.1" - ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help || { cat /var/log/auth.log && exit 1 } + ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help || cat /var/log/auth.log + exit 1 lint-setup: @mkdir -p test-results/shellcheck tmp/shellcheck From b9cc89e4d2c7fa79201318946040370f5c4bb5c7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 02:09:52 -0400 Subject: [PATCH 26/77] fix: set correct perms on files --- tests.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests.mk b/tests.mk index 351cb9797..49c568906 100644 --- a/tests.mk +++ b/tests.mk @@ -55,6 +55,7 @@ endif mkdir -p /root/.ssh rm -f /root/.ssh/dokku_test_rsa* echo -e "y\n" | ssh-keygen -f /root/.ssh/dokku_test_rsa -t rsa -N '' + chmod 700 /root/.ssh chmod 600 /root/.ssh/dokku_test_rsa chmod 644 /root/.ssh/dokku_test_rsa.pub @@ -82,6 +83,8 @@ endif echo "" > /home/dokku/.ssh/authorized_keys sudo sshcommand acl-remove dokku test cat /root/.ssh/dokku_test_rsa.pub | sudo sshcommand acl-add dokku test + chmod 700 /home/dokku/.ssh + chmod 600 /home/dokku/.ssh/authorized_keys ifeq ($(shell grep dokku.me /home/dokku/VHOST 2>/dev/null),) @echo "-----> Setting default VHOST to dokku.me..." From 03f8922ffd1858db87dc05c6fd2b0486a6549e6e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 02:23:25 -0400 Subject: [PATCH 27/77] chore: remove all debugging code --- tests.mk | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tests.mk b/tests.mk index 49c568906..1d16ef943 100644 --- a/tests.mk +++ b/tests.mk @@ -105,27 +105,10 @@ endif prime-ssh-known-hosts: @echo "-----> Intitial SSH connection to populate known_hosts..." - @echo "=====> Authorized Keys" - cat /home/dokku/.ssh/authorized_keys - @echo "=====> Root SSH Config" - cat /root/.ssh/config - @echo "=====> Ping dokku.me" - ping -c1 dokku.me - @echo "=====> Dig dokku.me" - dig dokku.me - @echo "=====> Private rsa key" - cat /root/.ssh/dokku_test_rsa - @echo "=====> Public rsa key" - cat /root/.ssh/dokku_test_rsa.pub - @echo "=====> SSHD Config" - cat /etc/ssh/sshd_config - @echo "=====> ssh file permissions" - ls -lah /root/.ssh/ @echo "=====> SSH dokku.me" - ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help || cat /var/log/auth.log + ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help @echo "=====> SSH 127.0.0.1" - ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help || cat /var/log/auth.log - exit 1 + ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help lint-setup: @mkdir -p test-results/shellcheck tmp/shellcheck From edf5d292139b34d96fef141e6b0938e0a3704a16 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 02:52:35 -0400 Subject: [PATCH 28/77] tests: set correct user on github actions --- tests/ci/setup.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/ci/setup.sh b/tests/ci/setup.sh index d12d3305b..1559a302d 100755 --- a/tests/ci/setup.sh +++ b/tests/ci/setup.sh @@ -123,8 +123,15 @@ setup_circle() { sudo -E make -e setup-deploy-tests lsb_release -a # setup .dokkurc + + getent passwd | cut -d: -f1 | sort + sudo -E mkdir -p /home/dokku/.dokkurc - sudo -E chown dokku:ubuntu /home/dokku/.dokkurc + if [[ -n "$GITHUB_ACTIONS" ]]; then + sudo -E chown dokku:dokku /home/dokku/.dokkurc + else + sudo -E chown dokku:ubuntu /home/dokku/.dokkurc + fi sudo -E chmod 775 /home/dokku/.dokkurc # pull node:4 image for testing sudo docker pull node:4 From 401ec40566853886e2c14bbec249a5e5e68e90cd Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 03:05:00 -0400 Subject: [PATCH 29/77] fix: intsall ci dependencies in correct job --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 186c89332..cf5830693 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,9 +18,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: install ci-dependencies - run: make ci-dependencies - - name: build package run: ./tests/ci/setup.sh build @@ -55,6 +52,9 @@ jobs: ifconfig sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 + - name: install ci-dependencies + run: make ci-dependencies + - name: setup tests run: ./tests/ci/setup.sh From 3c56a0c323fe43576fedd78082860779953fecde Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 03:20:36 -0400 Subject: [PATCH 30/77] tests: modify to allow better running under github actions --- .github/workflows/ci.yaml | 101 +++++++++++++++++++++++++++++++------- tests.mk | 26 ++++++++++ 2 files changed, 108 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cf5830693..686fbf8d6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,7 @@ jobs: name: build path: build - ci: + unit-tests: env: GITHUB_NODE_INDEX: ${{ matrix.compiler }} name: ci.${{ matrix.index }} @@ -36,7 +36,87 @@ jobs: strategy: fail-fast: true matrix: - index: [0, 1, 2,3] + index: [0, 1, 2, 3, 4] + + steps: + - uses: actions/checkout@v2 + + - name: download packages + uses: actions/download-artifact@v1 + with: + name: build + + - name: resolve dokku.me + run: | + # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 + ifconfig + sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 + + - name: install ci-dependencies + run: make ci-dependencies + + - name: setup tests + run: ./tests/ci/setup.sh + + - name: dokku cleanup:skip + run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup + + - name: run ci + shell: bash + timeout-minutes: 60 + run: | + sudo -E make -e test-ci-${{ matrix.index }} + + - uses: actions/upload-artifact@v2 + with: + name: test-results-${{ matrix.index }} + path: test-results + + docker-deploy-tests: + env: + GITHUB_NODE_INDEX: ${{ matrix.compiler }} + name: ci.${{ matrix.index }} + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: download packages + uses: actions/download-artifact@v1 + with: + name: build + + - name: resolve dokku.me + run: | + # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 + ifconfig + sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 + + - name: install ci-dependencies + run: make ci-dependencies + + - name: setup tests + run: ./tests/ci/setup.sh + + - name: dokku cleanup:skip + run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup + + - name: test docker deploys + run: | + ./tests/ci/setup.sh docker + DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker + + go-tests: + env: + GITHUB_NODE_INDEX: ${{ matrix.compiler }} + name: ci.${{ matrix.index }} + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + index: [0, 1, 2, 3, 4] steps: - uses: actions/checkout@v2 @@ -70,25 +150,8 @@ jobs: 2) sudo -E make -e deploy-test-multi ;; 3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;; esac - - name: run ci - shell: bash - timeout-minutes: 60 - run: | - sudo -E make -e test-ci - - - name: test docker deploys - run: | - if [ "${GITHUB_NODE_INDEX}" == "0" ]; then - ./tests/ci/setup.sh docker - DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker - fi - uses: actions/upload-artifact@v2 with: name: coverage.${{ matrix.index }}.out path: coverage.out - - - uses: actions/upload-artifact@v2 - with: - name: test-results-${{ matrix.index }} - path: test-results diff --git a/tests.mk b/tests.mk index 1d16ef943..df18116da 100644 --- a/tests.mk +++ b/tests.mk @@ -267,4 +267,30 @@ test-ci: @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-0: + @mkdir -p test-results/bats + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 10*.bats | xargs) + +test-ci-1: + @mkdir -p test-results/bats + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 20*.bats | xargs) + +test-ci-2: + @mkdir -p test-results/bats + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 30*.bats | xargs) + +test-ci-3: + @mkdir -p test-results/bats + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 40*.bats | xargs) + +test-ci-4: + @mkdir -p test-results/bats + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 50*.bats | 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 From 7f9f289bd6642c1a2b328f944812bc231a3eea19 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 03:28:29 -0400 Subject: [PATCH 31/77] tests: drop extra unused matrix index --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 686fbf8d6..a12cf7e51 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -116,7 +116,7 @@ jobs: strategy: fail-fast: true matrix: - index: [0, 1, 2, 3, 4] + index: [0, 1, 2, 3] steps: - uses: actions/checkout@v2 From 6d4d8a89ed4e311d5e1ceb83dc33e8dbbc48302e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 03:28:37 -0400 Subject: [PATCH 32/77] fix: correct test logging output --- tests.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests.mk b/tests.mk index df18116da..e7e5c8a96 100644 --- a/tests.mk +++ b/tests.mk @@ -269,27 +269,27 @@ test-ci: test-ci-0: @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 10*.bats | xargs)" cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 10*.bats | xargs) test-ci-1: @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 20*.bats | xargs)" cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 20*.bats | xargs) test-ci-2: @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 20*.bats | xargs)" cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 30*.bats | xargs) test-ci-3: @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 40*.bats | xargs)" cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 40*.bats | xargs) test-ci-4: @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls *.bats | xargs)" + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 50*.bats | xargs)" cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 50*.bats | xargs) From c97fd92fcf14f65429e002236ede42bd2ec044bd Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 03:30:15 -0400 Subject: [PATCH 33/77] fix: correct test naming --- .github/workflows/ci.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a12cf7e51..461ac9b6c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,7 @@ jobs: unit-tests: env: GITHUB_NODE_INDEX: ${{ matrix.compiler }} - name: ci.${{ matrix.index }} + name: unit.${{ matrix.index }} needs: build runs-on: ubuntu-latest strategy: @@ -73,9 +73,7 @@ jobs: path: test-results docker-deploy-tests: - env: - GITHUB_NODE_INDEX: ${{ matrix.compiler }} - name: ci.${{ matrix.index }} + name: docker needs: build runs-on: ubuntu-latest @@ -110,7 +108,7 @@ jobs: go-tests: env: GITHUB_NODE_INDEX: ${{ matrix.compiler }} - name: ci.${{ matrix.index }} + name: go.${{ matrix.index }} needs: build runs-on: ubuntu-latest strategy: From bd3d8a54ad059695714714ae61fd122833ade21d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 03:56:09 -0400 Subject: [PATCH 34/77] fix: correct matrix value --- .github/workflows/ci.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 461ac9b6c..b2e931809 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,8 +28,6 @@ jobs: path: build unit-tests: - env: - GITHUB_NODE_INDEX: ${{ matrix.compiler }} name: unit.${{ matrix.index }} needs: build runs-on: ubuntu-latest @@ -107,7 +105,7 @@ jobs: go-tests: env: - GITHUB_NODE_INDEX: ${{ matrix.compiler }} + GITHUB_NODE_INDEX: ${{ matrix.index }} name: go.${{ matrix.index }} needs: build runs-on: ubuntu-latest From 1738009f6b9db323022e12400eaa686887b9e609 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 03:56:55 -0400 Subject: [PATCH 35/77] fix: set timeout --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b2e931809..11dce6ee0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -99,6 +99,8 @@ jobs: run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - name: test docker deploys + shell: bash + timeout-minutes: 20 run: | ./tests/ci/setup.sh docker DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker From 9ded7e176f0e90951e4f14904696e5684a3587d0 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 04:09:05 -0400 Subject: [PATCH 36/77] tests: simplify step --- .github/workflows/ci.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 11dce6ee0..a0afce5b9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,10 +60,8 @@ jobs: run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - name: run ci - shell: bash timeout-minutes: 60 - run: | - sudo -E make -e test-ci-${{ matrix.index }} + run: sudo -E make -e test-ci-${{ matrix.index }} - uses: actions/upload-artifact@v2 with: From 0932fd7f7cf5c1167e6c90c01d3e72ceb0011357 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 8 Jun 2020 04:09:27 -0400 Subject: [PATCH 37/77] tests: skip pull_request trigger --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a0afce5b9..181bf001e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,9 +1,9 @@ name: CI on: - pull_request: - branches: - - '*' + # pull_request: + # branches: + # - '*' push: branches: - '*' From e9ecc98b3d72b5393875aee60e9e00cd7bc6a1c9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 22:02:48 -0400 Subject: [PATCH 38/77] chore: add report --- .github/workflows/ci.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 181bf001e..07ef3ef0c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -59,6 +59,9 @@ jobs: - name: dokku cleanup:skip run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup + - name: dokku report + run: dokku report + - name: run ci timeout-minutes: 60 run: sudo -E make -e test-ci-${{ matrix.index }} @@ -96,6 +99,9 @@ jobs: - name: dokku cleanup:skip run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup + - name: dokku report + run: dokku report + - name: test docker deploys shell: bash timeout-minutes: 20 @@ -137,6 +143,9 @@ jobs: - name: dokku cleanup:skip run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup + - name: dokku report + run: dokku report + - name: run pre-tests run: | export CIRCLE_SHA1=$GITHUB_SHA From c9e24a055c07455ff0e49374b70131243dc8cc10 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 22:38:47 -0400 Subject: [PATCH 39/77] feat: adjust for usage with circleci workflows --- .circleci/config.yml | 126 +++++++++++++++++++++++++++++++++---------- 1 file changed, 98 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 370ecebb8..9778df2d2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,41 +1,111 @@ -version: 2 -jobs: - build: - machine: - image: ubuntu-1604:201903-01 - parallelism: 4 +version: 2.1 + +commands: + init-tests: + description: "Setup dokku for testing" steps: - checkout - - run: | - make ci-dependencies - - run: | - ./tests/ci/setup.sh - - run: | - echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - - run: | - # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 - ifconfig - sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 - - run: | - case $CIRCLE_NODE_INDEX in - 0) sudo -E make -e lint-ci go-tests ci-go-coverage ;; - 1) sudo -E make -e deploy-test-checks-root deploy-test-config ;; - 2) sudo -E make -e deploy-test-multi ;; - 3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;; - esac + - attach_workspace: + at: /home/circleci/project - run: + name: resolve dokku.me + command: | + # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 + ifconfig + sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 + - run: + name: install ci-dependencies + command: make ci-dependencies + - run: + name: setup tests + command: ./tests/ci/setup.sh + - run: + name: dokku cleanup:skip + command: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup + - run: + name: dokku report + command: dokku report + +executors: + default: + machine: + image: ubuntu-1604:201903-01 + working_directory: /home/circleci/project + +jobs: + build: + executor: default + steps: + - checkout + - run: + name: build package + command: ./tests/ci/setup.sh build + - persist_to_workspace: + root: /home/circleci/project + paths: + - build + docker-deploy-tests: + executor: default + steps: + - init-tests + - run: + name: test docker deploys shell: /bin/bash - command: sudo -E make -e test-ci - no_output_timeout: 60m - - run: | - if [ "${CIRCLE_NODE_INDEX}" == "0" ]; then + no_output_timeout: 20 + command: | ./tests/ci/setup.sh docker DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker - fi + go-tests: + executor: default + parameters: + index: + type: integer + steps: + - init-tests + - run: + name: run pre-tests + command: | + case << parameters.index >> in + 0) sudo -E make -e lint-ci go-tests ci-go-coverage ;; + 1) sudo -E make -e deploy-test-checks-root deploy-test-config ;; + 2) sudo -E make -e deploy-test-multi ;; + 3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;; + esac - store_artifacts: path: ./coverage.out + unit-tests: + executor: default + parameters: + index: + type: integer + steps: + - init-tests + - run: + shell: /bin/bash + command: sudo -E make -e test-ci-<< parameters.index >> + no_output_timeout: 60m - store_artifacts: path: ./test-results destination: test-results - store_test_results: path: test-results + +workflows: + workflow: + jobs: + - build + - docker-deploy-tests: + requires: + - build + - go-tests: + matrix: + parameters: + index: [0, 1, 2, 3] + requires: + - build + - unit-tests: + matrix: + parameters: + index: [0, 1, 2, 3, 4] + requires: + - build From f4bec4a1c8f8e3e967ced47702da7aa73f9bf736 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 22:58:00 -0400 Subject: [PATCH 40/77] fix: use ens4 for circleci --- .circleci/config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9778df2d2..ab7f0b0f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,9 +10,10 @@ commands: - run: name: resolve dokku.me command: | - # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 + # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4 + # this is maybe eth0 on github ifconfig - sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 + sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev ens4 - run: name: install ci-dependencies command: make ci-dependencies From 52ea598ba483797954dbadc5a4c058744ed8966d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 23:21:31 -0400 Subject: [PATCH 41/77] chore: drop bad github-actions code --- .github/workflows/ci.yaml | 162 -------------------------------------- 1 file changed, 162 deletions(-) delete mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 07ef3ef0c..000000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,162 +0,0 @@ -name: CI - -on: - # pull_request: - # branches: - # - '*' - push: - branches: - - '*' - -jobs: - build: - name: build - runs-on: ubuntu-latest - strategy: - fail-fast: true - - steps: - - uses: actions/checkout@v2 - - - name: build package - run: ./tests/ci/setup.sh build - - - name: upload packages - uses: actions/upload-artifact@v2 - with: - name: build - path: build - - unit-tests: - name: unit.${{ matrix.index }} - needs: build - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - index: [0, 1, 2, 3, 4] - - steps: - - uses: actions/checkout@v2 - - - name: download packages - uses: actions/download-artifact@v1 - with: - name: build - - - name: resolve dokku.me - run: | - # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 - ifconfig - sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 - - - name: install ci-dependencies - run: make ci-dependencies - - - name: setup tests - run: ./tests/ci/setup.sh - - - name: dokku cleanup:skip - run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - - - name: dokku report - run: dokku report - - - name: run ci - timeout-minutes: 60 - run: sudo -E make -e test-ci-${{ matrix.index }} - - - uses: actions/upload-artifact@v2 - with: - name: test-results-${{ matrix.index }} - path: test-results - - docker-deploy-tests: - name: docker - needs: build - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: download packages - uses: actions/download-artifact@v1 - with: - name: build - - - name: resolve dokku.me - run: | - # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 - ifconfig - sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 - - - name: install ci-dependencies - run: make ci-dependencies - - - name: setup tests - run: ./tests/ci/setup.sh - - - name: dokku cleanup:skip - run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - - - name: dokku report - run: dokku report - - - name: test docker deploys - shell: bash - timeout-minutes: 20 - run: | - ./tests/ci/setup.sh docker - DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker - - go-tests: - env: - GITHUB_NODE_INDEX: ${{ matrix.index }} - name: go.${{ matrix.index }} - needs: build - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - index: [0, 1, 2, 3] - - steps: - - uses: actions/checkout@v2 - - - name: download packages - uses: actions/download-artifact@v1 - with: - name: build - - - name: resolve dokku.me - run: | - # dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0 - ifconfig - sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0 - - - name: install ci-dependencies - run: make ci-dependencies - - - name: setup tests - run: ./tests/ci/setup.sh - - - name: dokku cleanup:skip - run: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup - - - name: dokku report - run: dokku report - - - name: run pre-tests - run: | - export CIRCLE_SHA1=$GITHUB_SHA - case $GITHUB_NODE_INDEX in - 0) sudo -E make -e lint-ci go-tests ci-go-coverage ;; - 1) sudo -E make -e deploy-test-checks-root deploy-test-config ;; - 2) sudo -E make -e deploy-test-multi ;; - 3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;; - esac - - - uses: actions/upload-artifact@v2 - with: - name: coverage.${{ matrix.index }}.out - path: coverage.out From 0b9cecef4d662e4ecc3c6ce34ac7dcac32fb13d9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 23:23:43 -0400 Subject: [PATCH 42/77] tests: move testing command into config --- .circleci/config.yml | 9 +++++++-- tests.mk | 26 -------------------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ab7f0b0f1..94c9f2226 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,7 +83,10 @@ jobs: - init-tests - run: shell: /bin/bash - command: sudo -E make -e test-ci-<< parameters.index >> + command: | + @mkdir -p test-results/bats + @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls << parameters.index >>*.bats | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls << parameters.index >>*.bats | xargs) no_output_timeout: 60m - store_artifacts: path: ./test-results @@ -98,15 +101,17 @@ workflows: - docker-deploy-tests: requires: - build + - unit-tests - go-tests: matrix: parameters: index: [0, 1, 2, 3] requires: - build + - unit-tests - unit-tests: matrix: parameters: - index: [0, 1, 2, 3, 4] + index: [10, 20, 30, 40, 50, 60] requires: - build diff --git a/tests.mk b/tests.mk index e7e5c8a96..1d16ef943 100644 --- a/tests.mk +++ b/tests.mk @@ -267,30 +267,4 @@ test-ci: @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-0: - @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 10*.bats | xargs)" - cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 10*.bats | xargs) - -test-ci-1: - @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 20*.bats | xargs)" - cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 20*.bats | xargs) - -test-ci-2: - @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 20*.bats | xargs)" - cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 30*.bats | xargs) - -test-ci-3: - @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 40*.bats | xargs)" - cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 40*.bats | xargs) - -test-ci-4: - @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls 50*.bats | xargs)" - cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls 50*.bats | 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 From cf113ecda24d454701a667ed84b71f1c5cf8bf57 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 23:25:08 -0400 Subject: [PATCH 43/77] chore: move apps tests to 60_ They take ~12 minutes on their own... --- tests/unit/{10_apps.bats => 60_apps.bats} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/unit/{10_apps.bats => 60_apps.bats} (100%) diff --git a/tests/unit/10_apps.bats b/tests/unit/60_apps.bats similarity index 100% rename from tests/unit/10_apps.bats rename to tests/unit/60_apps.bats From 90a539125212eafc8123005bf9193210ac8ab9fc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 23:27:17 -0400 Subject: [PATCH 44/77] tests: split out core, nginx and ps tests --- .circleci/config.yml | 2 +- tests/unit/{20_nginx-vhosts_1.bats => 70_nginx-vhosts_1.bats} | 0 tests/unit/{40_nginx-vhosts_2.bats => 70_nginx-vhosts_2.bats} | 0 tests/unit/{40_nginx-vhosts_3.bats => 70_nginx-vhosts_3.bats} | 0 tests/unit/{10_ps-dockerfile.bats => 80_ps-dockerfile.bats} | 0 tests/unit/{10_ps-general.bats => 80_ps-general.bats} | 0 tests/unit/{10_ps-herokuish.bats => 80_ps-herokuish.bats} | 0 tests/unit/{30_core_1.bats => 90_core_1.bats} | 0 tests/unit/{40_core_2.bats => 90_core_2.bats} | 0 9 files changed, 1 insertion(+), 1 deletion(-) rename tests/unit/{20_nginx-vhosts_1.bats => 70_nginx-vhosts_1.bats} (100%) rename tests/unit/{40_nginx-vhosts_2.bats => 70_nginx-vhosts_2.bats} (100%) rename tests/unit/{40_nginx-vhosts_3.bats => 70_nginx-vhosts_3.bats} (100%) rename tests/unit/{10_ps-dockerfile.bats => 80_ps-dockerfile.bats} (100%) rename tests/unit/{10_ps-general.bats => 80_ps-general.bats} (100%) rename tests/unit/{10_ps-herokuish.bats => 80_ps-herokuish.bats} (100%) rename tests/unit/{30_core_1.bats => 90_core_1.bats} (100%) rename tests/unit/{40_core_2.bats => 90_core_2.bats} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 94c9f2226..ed067ddfc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,6 +112,6 @@ workflows: - unit-tests: matrix: parameters: - index: [10, 20, 30, 40, 50, 60] + index: [10, 20, 30, 40, 50, 60, 70, 80, 90] requires: - build diff --git a/tests/unit/20_nginx-vhosts_1.bats b/tests/unit/70_nginx-vhosts_1.bats similarity index 100% rename from tests/unit/20_nginx-vhosts_1.bats rename to tests/unit/70_nginx-vhosts_1.bats diff --git a/tests/unit/40_nginx-vhosts_2.bats b/tests/unit/70_nginx-vhosts_2.bats similarity index 100% rename from tests/unit/40_nginx-vhosts_2.bats rename to tests/unit/70_nginx-vhosts_2.bats diff --git a/tests/unit/40_nginx-vhosts_3.bats b/tests/unit/70_nginx-vhosts_3.bats similarity index 100% rename from tests/unit/40_nginx-vhosts_3.bats rename to tests/unit/70_nginx-vhosts_3.bats diff --git a/tests/unit/10_ps-dockerfile.bats b/tests/unit/80_ps-dockerfile.bats similarity index 100% rename from tests/unit/10_ps-dockerfile.bats rename to tests/unit/80_ps-dockerfile.bats diff --git a/tests/unit/10_ps-general.bats b/tests/unit/80_ps-general.bats similarity index 100% rename from tests/unit/10_ps-general.bats rename to tests/unit/80_ps-general.bats diff --git a/tests/unit/10_ps-herokuish.bats b/tests/unit/80_ps-herokuish.bats similarity index 100% rename from tests/unit/10_ps-herokuish.bats rename to tests/unit/80_ps-herokuish.bats diff --git a/tests/unit/30_core_1.bats b/tests/unit/90_core_1.bats similarity index 100% rename from tests/unit/30_core_1.bats rename to tests/unit/90_core_1.bats diff --git a/tests/unit/40_core_2.bats b/tests/unit/90_core_2.bats similarity index 100% rename from tests/unit/40_core_2.bats rename to tests/unit/90_core_2.bats From ca5c9d6c45fc1f8194ffaec87d60d8a55dfe4332 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 23:41:19 -0400 Subject: [PATCH 45/77] tests: fix syntax --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ed067ddfc..747da1b85 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -84,8 +84,8 @@ jobs: - run: shell: /bin/bash command: | - @mkdir -p test-results/bats - @cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls << parameters.index >>*.bats | xargs)" + mkdir -p test-results/bats + cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls << parameters.index >>*.bats | xargs)" cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls << parameters.index >>*.bats | xargs) no_output_timeout: 60m - store_artifacts: From 02d9c5352039d3b90f75dc9ac6ed3bccd9e71be6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jun 2020 23:53:43 -0400 Subject: [PATCH 46/77] tests: fix syntax --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 747da1b85..5e93ec928 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,8 +85,8 @@ jobs: shell: /bin/bash command: | mkdir -p test-results/bats - cd tests/unit && echo "executing tests: $(shell cd tests/unit ; ls << parameters.index >>*.bats | xargs)" - cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(shell cd tests/unit ; ls << parameters.index >>*.bats | xargs) + cd tests/unit && echo "executing tests: $(cd tests/unit ; ls << parameters.index >>*.bats | xargs)" + cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(cd tests/unit ; ls << parameters.index >>*.bats | xargs) no_output_timeout: 60m - store_artifacts: path: ./test-results From 9c300dc14b7f7f62602aab19e8de52641f73ef4f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 00:04:27 -0400 Subject: [PATCH 47/77] feat: add build cache --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index f4ce217db..eb26cf64c 100644 --- a/common.mk +++ b/common.mk @@ -10,7 +10,7 @@ build-in-docker: clean mkdir -p /tmp/dokku-go-build-cache docker run --rm \ -v $$PWD/../..:$(GO_REPO_ROOT) \ - -v /tmp/dokku-go-build-cache:/root/.cache/go-build \ + -v /tmp/dokku-go-build-cache:/root/.cache \ -e PLUGIN_NAME=$(PLUGIN_NAME) \ -w $(GO_REPO_ROOT)/plugins/$(PLUGIN_NAME) \ $(BUILD_IMAGE) \ From c632b6b358bd4356a48151b102fcad76fe310e11 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 00:04:54 -0400 Subject: [PATCH 48/77] tests: fix cd calls --- .circleci/config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5e93ec928..97a92f5e8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,8 +85,9 @@ jobs: shell: /bin/bash command: | mkdir -p test-results/bats - cd tests/unit && echo "executing tests: $(cd tests/unit ; ls << parameters.index >>*.bats | xargs)" - cd tests/unit && bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(cd tests/unit ; ls << parameters.index >>*.bats | xargs) + cd tests/unit + echo "executing tests: $(ls << parameters.index >>*.bats | xargs)" + bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(ls << parameters.index >>*.bats | xargs) no_output_timeout: 60m - store_artifacts: path: ./test-results From 9d6746001e7009e60341f6ac18a289bd507c9e16 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 00:28:30 -0400 Subject: [PATCH 49/77] chore: revert --- tests.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.mk b/tests.mk index 1d16ef943..caceecc90 100644 --- a/tests.mk +++ b/tests.mk @@ -106,9 +106,9 @@ endif prime-ssh-known-hosts: @echo "-----> Intitial SSH connection to populate known_hosts..." @echo "=====> SSH dokku.me" - ssh -vvv -o StrictHostKeyChecking=no dokku@dokku.me help + ssh -o StrictHostKeyChecking=no dokku@dokku.me help >/dev/null @echo "=====> SSH 127.0.0.1" - ssh -vvv -o StrictHostKeyChecking=no dokku@127.0.0.1 help + ssh -o StrictHostKeyChecking=no dokku@127.0.0.1 help >/dev/null lint-setup: @mkdir -p test-results/shellcheck tmp/shellcheck From ae67f14f9bfbccfc75ce89efe647ac95f2fb10c0 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 00:29:58 -0400 Subject: [PATCH 50/77] chore: quieter test output --- tests/unit/test_helper.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 5ca474caa..e90b4474a 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -20,8 +20,8 @@ SKIPPED_TEST_ERR_MSG="previous test failed! skipping remaining tests..." global_setup() { [[ ! -f "${BATS_PARENT_TMPNAME}.skip" ]] || skip "$SKIPPED_TEST_ERR_MSG" - dokku apps:list - docker container ls + dokku apps:list --quiet + docker container ls --quiet free -m docker container ls --quiet | xargs -n1 docker container rm -f || true } From f083561ee7cc5bb611e8b71a9132445968dc097b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 00:32:42 -0400 Subject: [PATCH 51/77] feat: add test for remote ssh during deploy_app --- tests/unit/test_helper.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index e90b4474a..1e460cc7e 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -268,6 +268,8 @@ deploy_app() { local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"} local TMP=${CUSTOM_TMP:=$(mktemp -d "/tmp/dokku.me.XXXXX")} + ssh -o StrictHostKeyChecking=no dokku@dokku.me version + rmdir "$TMP" && cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/$APP_TYPE" "$TMP" # shellcheck disable=SC2086 From 3084ac098eb15722ef2975c57877c41dcd00d9af Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 00:48:11 -0400 Subject: [PATCH 52/77] fix: correct quiet flag --- tests/unit/test_helper.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 1e460cc7e..8332da4c6 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -20,7 +20,7 @@ SKIPPED_TEST_ERR_MSG="previous test failed! skipping remaining tests..." global_setup() { [[ ! -f "${BATS_PARENT_TMPNAME}.skip" ]] || skip "$SKIPPED_TEST_ERR_MSG" - dokku apps:list --quiet + dokku --quiet apps:list docker container ls --quiet free -m docker container ls --quiet | xargs -n1 docker container rm -f || true From 9d747b7c822a197bacb872ac5139468136219f17 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 01:09:52 -0400 Subject: [PATCH 53/77] chore: drop check --- tests/unit/test_helper.bash | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 8332da4c6..4bba6f132 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -268,8 +268,6 @@ deploy_app() { local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"} local TMP=${CUSTOM_TMP:=$(mktemp -d "/tmp/dokku.me.XXXXX")} - ssh -o StrictHostKeyChecking=no dokku@dokku.me version - rmdir "$TMP" && cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/$APP_TYPE" "$TMP" # shellcheck disable=SC2086 From a5d53711ee2f609ceffddedb281854d40853cdbe Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 01:10:07 -0400 Subject: [PATCH 54/77] fix: run tests as root --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 97a92f5e8..55f8a2fd1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -87,7 +87,7 @@ jobs: mkdir -p test-results/bats cd tests/unit echo "executing tests: $(ls << parameters.index >>*.bats | xargs)" - bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(ls << parameters.index >>*.bats | xargs) + sudo -E bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(ls << parameters.index >>*.bats | xargs) no_output_timeout: 60m - store_artifacts: path: ./test-results From 59910749b7e9dfdfda962d38d572869451414026 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 01:31:52 -0400 Subject: [PATCH 55/77] feat: persist images through workspace --- .circleci/config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 55f8a2fd1..73eebeaa8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,6 +7,11 @@ commands: - checkout - attach_workspace: at: /home/circleci/project + - run: + name: restore docker images + command: | + docker load -i build/herokuish.tar + docker load -i build/node.tar - run: name: resolve dokku.me command: | @@ -41,6 +46,13 @@ jobs: - run: name: build package command: ./tests/ci/setup.sh build + - run: + name: save docker images + command: | + HEROKUISH_VERSION=$(grep HEROKUISH_VERSION "${ROOT_DIR}/deb.mk" | head -n1 | cut -d' ' -f3) + docker save -o build/herokuish.tar gliderlabs/herokuish:$HEROKUISH_VERSION + docker pull node:4 + docker save -o build/node.tar node:4 - persist_to_workspace: root: /home/circleci/project paths: From 62e0ba695257affcc92283b38b7ed86e28c1f56b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 01:45:51 -0400 Subject: [PATCH 56/77] fix: remove extra variable --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 73eebeaa8..8f2710bfe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,7 +49,7 @@ jobs: - run: name: save docker images command: | - HEROKUISH_VERSION=$(grep HEROKUISH_VERSION "${ROOT_DIR}/deb.mk" | head -n1 | cut -d' ' -f3) + HEROKUISH_VERSION=$(grep HEROKUISH_VERSION deb.mk | head -n1 | cut -d' ' -f3) docker save -o build/herokuish.tar gliderlabs/herokuish:$HEROKUISH_VERSION docker pull node:4 docker save -o build/node.tar node:4 From 7ffe0c3b587d5591155c858afb82eee5373d40dd Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 01:57:52 -0400 Subject: [PATCH 57/77] fix: pull the docker image down --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8f2710bfe..7cf5a687a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,6 +50,7 @@ jobs: name: save docker images command: | HEROKUISH_VERSION=$(grep HEROKUISH_VERSION deb.mk | head -n1 | cut -d' ' -f3) + docker pull gliderlabs/herokuish:$HEROKUISH_VERSION docker save -o build/herokuish.tar gliderlabs/herokuish:$HEROKUISH_VERSION docker pull node:4 docker save -o build/node.tar node:4 From f23413742a010909dc05b6871dcb6512c51f9aaf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 02:07:16 -0400 Subject: [PATCH 58/77] fix: use correct tag --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cf5a687a..80479d60f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,7 +51,7 @@ jobs: command: | HEROKUISH_VERSION=$(grep HEROKUISH_VERSION deb.mk | head -n1 | cut -d' ' -f3) docker pull gliderlabs/herokuish:$HEROKUISH_VERSION - docker save -o build/herokuish.tar gliderlabs/herokuish:$HEROKUISH_VERSION + docker save -o build/herokuish.tar gliderlabs/herokuish:v$HEROKUISH_VERSION docker pull node:4 docker save -o build/node.tar node:4 - persist_to_workspace: From a9e130b090f3a51db40eb22bfc3ac2a612fb37c4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 02:17:59 -0400 Subject: [PATCH 59/77] fix: here too --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 80479d60f..ccc12ad4d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,7 +50,7 @@ jobs: name: save docker images command: | HEROKUISH_VERSION=$(grep HEROKUISH_VERSION deb.mk | head -n1 | cut -d' ' -f3) - docker pull gliderlabs/herokuish:$HEROKUISH_VERSION + docker pull gliderlabs/herokuish:v$HEROKUISH_VERSION docker save -o build/herokuish.tar gliderlabs/herokuish:v$HEROKUISH_VERSION docker pull node:4 docker save -o build/node.tar node:4 From ef46db5d6b4e2c75ac19d1f49d61d2abccf86b99 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 13:04:04 -0400 Subject: [PATCH 60/77] chore: switch to node:4-alpine This is a smaller image that should speed up tests... --- .circleci/config.yml | 4 ++-- tests/apps/dockerfile-dokku-scale/Dockerfile | 2 +- tests/apps/dockerfile-noexpose/Dockerfile | 2 +- tests/apps/dockerfile-procfile-bad/Dockerfile | 2 +- tests/apps/dockerfile-procfile/Dockerfile | 2 +- tests/apps/dockerfile/Dockerfile | 2 +- tests/ci/setup.sh | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ccc12ad4d..a8f0cf276 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,8 +52,8 @@ jobs: HEROKUISH_VERSION=$(grep HEROKUISH_VERSION deb.mk | head -n1 | cut -d' ' -f3) docker pull gliderlabs/herokuish:v$HEROKUISH_VERSION docker save -o build/herokuish.tar gliderlabs/herokuish:v$HEROKUISH_VERSION - docker pull node:4 - docker save -o build/node.tar node:4 + docker pull node:4-alpine + docker save -o build/node.tar node:4-alpine - persist_to_workspace: root: /home/circleci/project paths: diff --git a/tests/apps/dockerfile-dokku-scale/Dockerfile b/tests/apps/dockerfile-dokku-scale/Dockerfile index fa82185d5..7deb109af 100644 --- a/tests/apps/dockerfile-dokku-scale/Dockerfile +++ b/tests/apps/dockerfile-dokku-scale/Dockerfile @@ -1,4 +1,4 @@ -FROM node:4 +FROM node:4-alpine EXPOSE 3001/udp EXPOSE 3000/tcp diff --git a/tests/apps/dockerfile-noexpose/Dockerfile b/tests/apps/dockerfile-noexpose/Dockerfile index 86399657a..4bf4105fe 100644 --- a/tests/apps/dockerfile-noexpose/Dockerfile +++ b/tests/apps/dockerfile-noexpose/Dockerfile @@ -1,4 +1,4 @@ -FROM node:4 +FROM node:4-alpine COPY . /app WORKDIR /app diff --git a/tests/apps/dockerfile-procfile-bad/Dockerfile b/tests/apps/dockerfile-procfile-bad/Dockerfile index fa82185d5..7deb109af 100644 --- a/tests/apps/dockerfile-procfile-bad/Dockerfile +++ b/tests/apps/dockerfile-procfile-bad/Dockerfile @@ -1,4 +1,4 @@ -FROM node:4 +FROM node:4-alpine EXPOSE 3001/udp EXPOSE 3000/tcp diff --git a/tests/apps/dockerfile-procfile/Dockerfile b/tests/apps/dockerfile-procfile/Dockerfile index fa82185d5..7deb109af 100644 --- a/tests/apps/dockerfile-procfile/Dockerfile +++ b/tests/apps/dockerfile-procfile/Dockerfile @@ -1,4 +1,4 @@ -FROM node:4 +FROM node:4-alpine EXPOSE 3001/udp EXPOSE 3000/tcp diff --git a/tests/apps/dockerfile/Dockerfile b/tests/apps/dockerfile/Dockerfile index 5b7dfd4fc..f6116d259 100644 --- a/tests/apps/dockerfile/Dockerfile +++ b/tests/apps/dockerfile/Dockerfile @@ -1,4 +1,4 @@ -FROM node:4 +FROM node:4-alpine EXPOSE 3001/udp EXPOSE 3000/tcp diff --git a/tests/ci/setup.sh b/tests/ci/setup.sh index 1559a302d..97f619636 100755 --- a/tests/ci/setup.sh +++ b/tests/ci/setup.sh @@ -133,8 +133,8 @@ setup_circle() { sudo -E chown dokku:ubuntu /home/dokku/.dokkurc fi sudo -E chmod 775 /home/dokku/.dokkurc - # pull node:4 image for testing - sudo docker pull node:4 + # pull node:4-alpine image for testing + sudo docker pull node:4-alpine } case "$1" in From fb7bac4652bdddd04ef504e8c1da7250d48e3b87 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 13:05:25 -0400 Subject: [PATCH 61/77] tests: split out tests more --- .circleci/config.yml | 2 +- tests/unit/{20_resource.bats => 100_resource.bats} | 0 tests/unit/{70_nginx-vhosts_2.bats => 110_nginx-vhosts_2.bats} | 0 tests/unit/{10_git.bats => 120_git.bats} | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename tests/unit/{20_resource.bats => 100_resource.bats} (100%) rename tests/unit/{70_nginx-vhosts_2.bats => 110_nginx-vhosts_2.bats} (100%) rename tests/unit/{10_git.bats => 120_git.bats} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index a8f0cf276..60611f6e9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -126,6 +126,6 @@ workflows: - unit-tests: matrix: parameters: - index: [10, 20, 30, 40, 50, 60, 70, 80, 90] + index: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120] requires: - build diff --git a/tests/unit/20_resource.bats b/tests/unit/100_resource.bats similarity index 100% rename from tests/unit/20_resource.bats rename to tests/unit/100_resource.bats diff --git a/tests/unit/70_nginx-vhosts_2.bats b/tests/unit/110_nginx-vhosts_2.bats similarity index 100% rename from tests/unit/70_nginx-vhosts_2.bats rename to tests/unit/110_nginx-vhosts_2.bats diff --git a/tests/unit/10_git.bats b/tests/unit/120_git.bats similarity index 100% rename from tests/unit/10_git.bats rename to tests/unit/120_git.bats From 5fd04001d85be038e08697c1020cff496be3bf15 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 13:22:47 -0400 Subject: [PATCH 62/77] feat: split out test files and execute them manually This breaks the old grouping mechanism, but honestly that was a weird way of doing it. --- .circleci/config.yml | 37 ++++++++++++++- tests/unit/50_init_1.bats | 24 ---------- tests/unit/50_init_2.bats | 24 ---------- tests/unit/50_init_3.bats | 24 ---------- .../unit/{40_app-json.bats => app-json.bats} | 0 tests/unit/{60_apps.bats => apps.bats} | 0 .../{20_build-env.bats => build-env.bats} | 0 .../{30_buildpacks.bats => buildpacks.bats} | 0 tests/unit/{10_certs.bats => certs.bats} | 0 tests/unit/{10_checks.bats => checks.bats} | 0 tests/unit/{30_client.bats => client.bats} | 0 ...fig-oddities.bats => config-oddities.bats} | 0 tests/unit/{20_config.bats => config.bats} | 0 tests/unit/{90_core_1.bats => core_1.bats} | 0 tests/unit/{90_core_2.bats => core_2.bats} | 0 ...ocker-options.bats => docker-options.bats} | 0 tests/unit/{20_domains.bats => domains.bats} | 0 tests/unit/{30_events.bats => events.bats} | 0 tests/unit/{120_git.bats => git.bats} | 0 tests/unit/init.bats | 46 +++++++++++++++++++ tests/unit/{20_network.bats => network.bats} | 0 ...ginx-vhosts_1.bats => nginx-vhosts_1.bats} | 0 ...ginx-vhosts_2.bats => nginx-vhosts_2.bats} | 0 ...ginx-vhosts_3.bats => nginx-vhosts_3.bats} | 0 tests/unit/{40_plugin.bats => plugin.bats} | 0 tests/unit/{40_proxy.bats => proxy.bats} | 0 ..._ps-dockerfile.bats => ps-dockerfile.bats} | 0 .../{80_ps-general.bats => ps-general.bats} | 0 ...80_ps-herokuish.bats => ps-herokuish.bats} | 0 tests/unit/{10_repo.bats => repo.bats} | 0 tests/unit/{40_report.bats => report.bats} | 0 .../unit/{100_resource.bats => resource.bats} | 0 ...local.bats => scheduler-docker-local.bats} | 0 .../unit/{30_ssh_keys.bats => ssh_keys.bats} | 0 tests/unit/{20_storage.bats => storage.bats} | 0 tests/unit/{40_tags.bats => tags.bats} | 0 tests/unit/{10_tar.bats => tar.bats} | 0 tests/unit/{40_trace.bats => trace.bats} | 0 tests/unit/{10_version.bats => version.bats} | 0 39 files changed, 82 insertions(+), 73 deletions(-) delete mode 100644 tests/unit/50_init_1.bats delete mode 100644 tests/unit/50_init_2.bats delete mode 100644 tests/unit/50_init_3.bats rename tests/unit/{40_app-json.bats => app-json.bats} (100%) rename tests/unit/{60_apps.bats => apps.bats} (100%) rename tests/unit/{20_build-env.bats => build-env.bats} (100%) rename tests/unit/{30_buildpacks.bats => buildpacks.bats} (100%) rename tests/unit/{10_certs.bats => certs.bats} (100%) rename tests/unit/{10_checks.bats => checks.bats} (100%) rename tests/unit/{30_client.bats => client.bats} (100%) rename tests/unit/{30_config-oddities.bats => config-oddities.bats} (100%) rename tests/unit/{20_config.bats => config.bats} (100%) rename tests/unit/{90_core_1.bats => core_1.bats} (100%) rename tests/unit/{90_core_2.bats => core_2.bats} (100%) rename tests/unit/{20_docker-options.bats => docker-options.bats} (100%) rename tests/unit/{20_domains.bats => domains.bats} (100%) rename tests/unit/{30_events.bats => events.bats} (100%) rename tests/unit/{120_git.bats => git.bats} (100%) create mode 100644 tests/unit/init.bats rename tests/unit/{20_network.bats => network.bats} (100%) rename tests/unit/{70_nginx-vhosts_1.bats => nginx-vhosts_1.bats} (100%) rename tests/unit/{110_nginx-vhosts_2.bats => nginx-vhosts_2.bats} (100%) rename tests/unit/{70_nginx-vhosts_3.bats => nginx-vhosts_3.bats} (100%) rename tests/unit/{40_plugin.bats => plugin.bats} (100%) rename tests/unit/{40_proxy.bats => proxy.bats} (100%) rename tests/unit/{80_ps-dockerfile.bats => ps-dockerfile.bats} (100%) rename tests/unit/{80_ps-general.bats => ps-general.bats} (100%) rename tests/unit/{80_ps-herokuish.bats => ps-herokuish.bats} (100%) rename tests/unit/{10_repo.bats => repo.bats} (100%) rename tests/unit/{40_report.bats => report.bats} (100%) rename tests/unit/{100_resource.bats => resource.bats} (100%) rename tests/unit/{30_scheduler-docker-local.bats => scheduler-docker-local.bats} (100%) rename tests/unit/{30_ssh_keys.bats => ssh_keys.bats} (100%) rename tests/unit/{20_storage.bats => storage.bats} (100%) rename tests/unit/{40_tags.bats => tags.bats} (100%) rename tests/unit/{10_tar.bats => tar.bats} (100%) rename tests/unit/{40_trace.bats => trace.bats} (100%) rename tests/unit/{10_version.bats => version.bats} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 60611f6e9..957ee6b9b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -126,6 +126,41 @@ workflows: - unit-tests: matrix: parameters: - index: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120] + index: + - app-json + - apps + - build-env + - buildpacks + - certs + - checks + - client + - config-oddities + - config + - core_1 + - core_2 + - docker-options + - domains + - events + - git + - init + - network + - nginx-vhosts_1 + - nginx-vhosts_2 + - nginx-vhosts_3 + - plugin + - proxy + - ps-dockerfile + - ps-general + - ps-herokuish + - repo + - report + - resource + - scheduler-docker-local + - ssh_keys + - storage + - tags + - tar + - trace + - version requires: - build diff --git a/tests/unit/50_init_1.bats b/tests/unit/50_init_1.bats deleted file mode 100644 index 98581d63b..000000000 --- a/tests/unit/50_init_1.bats +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -setup() { - global_setup - create_app -} - -teardown() { - destroy_app - global_teardown -} - -@test "(init) buildpack" { - source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" - local APP="zombies-buildpack" - deploy_app "$APP" - local CIDS=$(get_app_container_ids "$APP") - - run "$DOCKER_BIN" container top "$CIDS" - echo "output: $output" - assert_output_contains "" "0" -} diff --git a/tests/unit/50_init_2.bats b/tests/unit/50_init_2.bats deleted file mode 100644 index c0b5d459a..000000000 --- a/tests/unit/50_init_2.bats +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -setup() { - global_setup - create_app -} - -teardown() { - destroy_app - global_teardown -} - -@test "(init) dockerfile no tini" { - source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" - local APP="zombies-dockerfile-no-tini" - deploy_app "$APP" - local CIDS=$(get_app_container_ids "$APP") - - run "$DOCKER_BIN" container top "$CIDS" - echo "output: $output" - assert_output_contains "" "0" -} diff --git a/tests/unit/50_init_3.bats b/tests/unit/50_init_3.bats deleted file mode 100644 index 77c354b1b..000000000 --- a/tests/unit/50_init_3.bats +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -setup() { - global_setup - create_app -} - -teardown() { - destroy_app - global_teardown -} - -@test "(init) dockerfile with tini" { - source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" - local APP="zombies-dockerfile-tini" - deploy_app "$APP" - local CIDS=$(get_app_container_ids "$APP") - - run "$DOCKER_BIN" container top "$CIDS" - echo "output: $output" - assert_output_contains "" "0" -} diff --git a/tests/unit/40_app-json.bats b/tests/unit/app-json.bats similarity index 100% rename from tests/unit/40_app-json.bats rename to tests/unit/app-json.bats diff --git a/tests/unit/60_apps.bats b/tests/unit/apps.bats similarity index 100% rename from tests/unit/60_apps.bats rename to tests/unit/apps.bats diff --git a/tests/unit/20_build-env.bats b/tests/unit/build-env.bats similarity index 100% rename from tests/unit/20_build-env.bats rename to tests/unit/build-env.bats diff --git a/tests/unit/30_buildpacks.bats b/tests/unit/buildpacks.bats similarity index 100% rename from tests/unit/30_buildpacks.bats rename to tests/unit/buildpacks.bats diff --git a/tests/unit/10_certs.bats b/tests/unit/certs.bats similarity index 100% rename from tests/unit/10_certs.bats rename to tests/unit/certs.bats diff --git a/tests/unit/10_checks.bats b/tests/unit/checks.bats similarity index 100% rename from tests/unit/10_checks.bats rename to tests/unit/checks.bats diff --git a/tests/unit/30_client.bats b/tests/unit/client.bats similarity index 100% rename from tests/unit/30_client.bats rename to tests/unit/client.bats diff --git a/tests/unit/30_config-oddities.bats b/tests/unit/config-oddities.bats similarity index 100% rename from tests/unit/30_config-oddities.bats rename to tests/unit/config-oddities.bats diff --git a/tests/unit/20_config.bats b/tests/unit/config.bats similarity index 100% rename from tests/unit/20_config.bats rename to tests/unit/config.bats diff --git a/tests/unit/90_core_1.bats b/tests/unit/core_1.bats similarity index 100% rename from tests/unit/90_core_1.bats rename to tests/unit/core_1.bats diff --git a/tests/unit/90_core_2.bats b/tests/unit/core_2.bats similarity index 100% rename from tests/unit/90_core_2.bats rename to tests/unit/core_2.bats diff --git a/tests/unit/20_docker-options.bats b/tests/unit/docker-options.bats similarity index 100% rename from tests/unit/20_docker-options.bats rename to tests/unit/docker-options.bats diff --git a/tests/unit/20_domains.bats b/tests/unit/domains.bats similarity index 100% rename from tests/unit/20_domains.bats rename to tests/unit/domains.bats diff --git a/tests/unit/30_events.bats b/tests/unit/events.bats similarity index 100% rename from tests/unit/30_events.bats rename to tests/unit/events.bats diff --git a/tests/unit/120_git.bats b/tests/unit/git.bats similarity index 100% rename from tests/unit/120_git.bats rename to tests/unit/git.bats diff --git a/tests/unit/init.bats b/tests/unit/init.bats new file mode 100644 index 000000000..80b1bbf33 --- /dev/null +++ b/tests/unit/init.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app +} + +teardown() { + destroy_app + global_teardown +} + +@test "(init) buildpack" { + source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" + local APP="zombies-buildpack" + deploy_app "$APP" + local CIDS=$(get_app_container_ids "$APP") + + run "$DOCKER_BIN" container top "$CIDS" + echo "output: $output" + assert_output_contains "" "0" +} + +@test "(init) dockerfile no tini" { + source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" + local APP="zombies-dockerfile-no-tini" + deploy_app "$APP" + local CIDS=$(get_app_container_ids "$APP") + + run "$DOCKER_BIN" container top "$CIDS" + echo "output: $output" + assert_output_contains "" "0" +} + +@test "(init) dockerfile with tini" { + source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" + local APP="zombies-dockerfile-tini" + deploy_app "$APP" + local CIDS=$(get_app_container_ids "$APP") + + run "$DOCKER_BIN" container top "$CIDS" + echo "output: $output" + assert_output_contains "" "0" +} diff --git a/tests/unit/20_network.bats b/tests/unit/network.bats similarity index 100% rename from tests/unit/20_network.bats rename to tests/unit/network.bats diff --git a/tests/unit/70_nginx-vhosts_1.bats b/tests/unit/nginx-vhosts_1.bats similarity index 100% rename from tests/unit/70_nginx-vhosts_1.bats rename to tests/unit/nginx-vhosts_1.bats diff --git a/tests/unit/110_nginx-vhosts_2.bats b/tests/unit/nginx-vhosts_2.bats similarity index 100% rename from tests/unit/110_nginx-vhosts_2.bats rename to tests/unit/nginx-vhosts_2.bats diff --git a/tests/unit/70_nginx-vhosts_3.bats b/tests/unit/nginx-vhosts_3.bats similarity index 100% rename from tests/unit/70_nginx-vhosts_3.bats rename to tests/unit/nginx-vhosts_3.bats diff --git a/tests/unit/40_plugin.bats b/tests/unit/plugin.bats similarity index 100% rename from tests/unit/40_plugin.bats rename to tests/unit/plugin.bats diff --git a/tests/unit/40_proxy.bats b/tests/unit/proxy.bats similarity index 100% rename from tests/unit/40_proxy.bats rename to tests/unit/proxy.bats diff --git a/tests/unit/80_ps-dockerfile.bats b/tests/unit/ps-dockerfile.bats similarity index 100% rename from tests/unit/80_ps-dockerfile.bats rename to tests/unit/ps-dockerfile.bats diff --git a/tests/unit/80_ps-general.bats b/tests/unit/ps-general.bats similarity index 100% rename from tests/unit/80_ps-general.bats rename to tests/unit/ps-general.bats diff --git a/tests/unit/80_ps-herokuish.bats b/tests/unit/ps-herokuish.bats similarity index 100% rename from tests/unit/80_ps-herokuish.bats rename to tests/unit/ps-herokuish.bats diff --git a/tests/unit/10_repo.bats b/tests/unit/repo.bats similarity index 100% rename from tests/unit/10_repo.bats rename to tests/unit/repo.bats diff --git a/tests/unit/40_report.bats b/tests/unit/report.bats similarity index 100% rename from tests/unit/40_report.bats rename to tests/unit/report.bats diff --git a/tests/unit/100_resource.bats b/tests/unit/resource.bats similarity index 100% rename from tests/unit/100_resource.bats rename to tests/unit/resource.bats diff --git a/tests/unit/30_scheduler-docker-local.bats b/tests/unit/scheduler-docker-local.bats similarity index 100% rename from tests/unit/30_scheduler-docker-local.bats rename to tests/unit/scheduler-docker-local.bats diff --git a/tests/unit/30_ssh_keys.bats b/tests/unit/ssh_keys.bats similarity index 100% rename from tests/unit/30_ssh_keys.bats rename to tests/unit/ssh_keys.bats diff --git a/tests/unit/20_storage.bats b/tests/unit/storage.bats similarity index 100% rename from tests/unit/20_storage.bats rename to tests/unit/storage.bats diff --git a/tests/unit/40_tags.bats b/tests/unit/tags.bats similarity index 100% rename from tests/unit/40_tags.bats rename to tests/unit/tags.bats diff --git a/tests/unit/10_tar.bats b/tests/unit/tar.bats similarity index 100% rename from tests/unit/10_tar.bats rename to tests/unit/tar.bats diff --git a/tests/unit/40_trace.bats b/tests/unit/trace.bats similarity index 100% rename from tests/unit/40_trace.bats rename to tests/unit/trace.bats diff --git a/tests/unit/10_version.bats b/tests/unit/version.bats similarity index 100% rename from tests/unit/10_version.bats rename to tests/unit/version.bats From ef5a4b08d6434941a85a9f163008ee5152ba1518 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 13:24:03 -0400 Subject: [PATCH 63/77] tests: time the docker load calls --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 957ee6b9b..706bbc324 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,8 +10,8 @@ commands: - run: name: restore docker images command: | - docker load -i build/herokuish.tar - docker load -i build/node.tar + time docker load -i build/herokuish.tar + time docker load -i build/node.tar - run: name: resolve dokku.me command: | From 570fcce2ee4741dbe529585b0ccfbb85290e8e24 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 13:25:01 -0400 Subject: [PATCH 64/77] fix: use string --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 706bbc324..425fdacac 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,7 +91,7 @@ jobs: executor: default parameters: index: - type: integer + type: string steps: - init-tests - run: From 8557ec12266fa0209d22d4f451f631f341e5aba2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 13:28:30 -0400 Subject: [PATCH 65/77] chore: rename unit-tests to test Looks nicer in the ui. --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 425fdacac..49467dcec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -87,7 +87,7 @@ jobs: esac - store_artifacts: path: ./coverage.out - unit-tests: + test: executor: default parameters: index: @@ -115,15 +115,15 @@ workflows: - docker-deploy-tests: requires: - build - - unit-tests + - test - go-tests: matrix: parameters: index: [0, 1, 2, 3] requires: - build - - unit-tests - - unit-tests: + - test + - test: matrix: parameters: index: From b6bf22812b9393e7146381cb8295a7aa07516c6a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 13:53:39 -0400 Subject: [PATCH 66/77] fix: add bash This is preferable to having a very large image that is based on debian/ubuntu. --- tests/apps/dockerfile-dokku-scale/Dockerfile | 2 ++ tests/apps/dockerfile-noexpose/Dockerfile | 2 ++ tests/apps/dockerfile-procfile-bad/Dockerfile | 2 ++ tests/apps/dockerfile-procfile/Dockerfile | 2 ++ tests/apps/dockerfile/Dockerfile | 2 ++ 5 files changed, 10 insertions(+) diff --git a/tests/apps/dockerfile-dokku-scale/Dockerfile b/tests/apps/dockerfile-dokku-scale/Dockerfile index 7deb109af..eee648649 100644 --- a/tests/apps/dockerfile-dokku-scale/Dockerfile +++ b/tests/apps/dockerfile-dokku-scale/Dockerfile @@ -1,5 +1,7 @@ FROM node:4-alpine +RUN apk add --no-cache bash + EXPOSE 3001/udp EXPOSE 3000/tcp EXPOSE 3003 diff --git a/tests/apps/dockerfile-noexpose/Dockerfile b/tests/apps/dockerfile-noexpose/Dockerfile index 4bf4105fe..61aa17519 100644 --- a/tests/apps/dockerfile-noexpose/Dockerfile +++ b/tests/apps/dockerfile-noexpose/Dockerfile @@ -1,5 +1,7 @@ FROM node:4-alpine +RUN apk add --no-cache bash + COPY . /app WORKDIR /app RUN npm install diff --git a/tests/apps/dockerfile-procfile-bad/Dockerfile b/tests/apps/dockerfile-procfile-bad/Dockerfile index 7deb109af..eee648649 100644 --- a/tests/apps/dockerfile-procfile-bad/Dockerfile +++ b/tests/apps/dockerfile-procfile-bad/Dockerfile @@ -1,5 +1,7 @@ FROM node:4-alpine +RUN apk add --no-cache bash + EXPOSE 3001/udp EXPOSE 3000/tcp EXPOSE 3003 diff --git a/tests/apps/dockerfile-procfile/Dockerfile b/tests/apps/dockerfile-procfile/Dockerfile index 7deb109af..eee648649 100644 --- a/tests/apps/dockerfile-procfile/Dockerfile +++ b/tests/apps/dockerfile-procfile/Dockerfile @@ -1,5 +1,7 @@ FROM node:4-alpine +RUN apk add --no-cache bash + EXPOSE 3001/udp EXPOSE 3000/tcp EXPOSE 3003 diff --git a/tests/apps/dockerfile/Dockerfile b/tests/apps/dockerfile/Dockerfile index f6116d259..eef0c10e8 100644 --- a/tests/apps/dockerfile/Dockerfile +++ b/tests/apps/dockerfile/Dockerfile @@ -1,5 +1,7 @@ FROM node:4-alpine +RUN apk add --no-cache bash + EXPOSE 3001/udp EXPOSE 3000/tcp EXPOSE 3003 From 81717f67f3f74321c91681a6ffb719c2705917bb Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 14:31:25 -0400 Subject: [PATCH 67/77] tests: drop loading of image from cache It is slower than hitting the network... --- .circleci/config.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 49467dcec..aa20deb83 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,11 +7,6 @@ commands: - checkout - attach_workspace: at: /home/circleci/project - - run: - name: restore docker images - command: | - time docker load -i build/herokuish.tar - time docker load -i build/node.tar - run: name: resolve dokku.me command: | @@ -46,14 +41,6 @@ jobs: - run: name: build package command: ./tests/ci/setup.sh build - - run: - name: save docker images - command: | - HEROKUISH_VERSION=$(grep HEROKUISH_VERSION deb.mk | head -n1 | cut -d' ' -f3) - docker pull gliderlabs/herokuish:v$HEROKUISH_VERSION - docker save -o build/herokuish.tar gliderlabs/herokuish:v$HEROKUISH_VERSION - docker pull node:4-alpine - docker save -o build/node.tar node:4-alpine - persist_to_workspace: root: /home/circleci/project paths: From 008b3627514c521ab35b9155731a1a70291657d6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 17:02:27 -0400 Subject: [PATCH 68/77] feat: switch to null buildpack for performance --- tests/apps/python/.buildpacks | 1 + tests/apps/python/CHECKS | 5 ++++ tests/apps/python/Procfile | 54 ++++++++++++++++++++++++++++++++++ tests/apps/python/app.json | 8 +++++ tests/apps/python/check_deploy | 5 ++++ tests/apps/python/null | 0 tests/apps/python/web.py | 17 +++++++++++ tests/apps/python/worker.py | 11 +++++++ tests/unit/test_helper.bash | 2 +- 9 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 tests/apps/python/.buildpacks create mode 100644 tests/apps/python/CHECKS create mode 100644 tests/apps/python/Procfile create mode 100644 tests/apps/python/app.json create mode 100644 tests/apps/python/check_deploy create mode 100644 tests/apps/python/null create mode 100644 tests/apps/python/web.py create mode 100644 tests/apps/python/worker.py diff --git a/tests/apps/python/.buildpacks b/tests/apps/python/.buildpacks new file mode 100644 index 000000000..b86e298c6 --- /dev/null +++ b/tests/apps/python/.buildpacks @@ -0,0 +1 @@ +https://github.com/dokku/buildpack-null.git diff --git a/tests/apps/python/CHECKS b/tests/apps/python/CHECKS new file mode 100644 index 000000000..52a9225d1 --- /dev/null +++ b/tests/apps/python/CHECKS @@ -0,0 +1,5 @@ +WAIT=2 # wait 2 seconds +TIMEOUT=5 # set timeout to 5 seconds +ATTEMPTS=2 # try 2 times + +/ python/http.server diff --git a/tests/apps/python/Procfile b/tests/apps/python/Procfile new file mode 100644 index 000000000..def474954 --- /dev/null +++ b/tests/apps/python/Procfile @@ -0,0 +1,54 @@ +############################### +# DEVELOPMENT # +############################### + +# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job) +cron: python3 worker.py +web: python3 web.py # testing inline comment +worker: python3 worker.py +custom: echo -n +release: touch /app/release.test + + +# Old version with separate processes (use this if you have issues with the threaded version) +# web: bundle exec rails server +# schedule: bundle exec rails runner bin/schedule.rb +# twitter: bundle exec rails runner bin/twitter_stream.rb +# dj: bundle exec script/delayed_job run + +############################### +# PRODUCTION # +############################### + +# You need to copy or link config/unicorn.rb.example to config/unicorn.rb for both production versions. +# Have a look at the deployment guides, if you want to set up huginn on your server: +# https://github.com/cantino/huginn/doc + +# Using the threaded worker (consumes less RAM but can run slower) +# web: bundle exec unicorn -c config/unicorn.rb +# jobs: bundle exec rails runner bin/threaded.rb + +# Old version with separate processes (use this if you have issues with the threaded version) +# web: bundle exec unicorn -c config/unicorn.rb +# schedule: bundle exec rails runner bin/schedule.rb +# twitter: bundle exec rails runner bin/twitter_stream.rb +# dj: bundle exec script/delayed_job run + +############################### +# Multiple DelayedJob workers # +############################### +# Per default Huginn can just run one agent at a time. Using a lot of agents or calling slow +# external services frequently might require more DelayedJob workers (an indicator for this is +# a backlog in your 'Job Management' page). +# Every uncommented line starts an additional DelayedJob worker. This works for development, production +# and for the threaded and separate worker processes. Keep in mind one worker needs about 300MB of RAM. +# +#dj2: bundle exec script/delayed_job -i 2 run +#dj3: bundle exec script/delayed_job -i 3 run +#dj4: bundle exec script/delayed_job -i 4 run +#dj5: bundle exec script/delayed_job -i 5 run +#dj6: bundle exec script/delayed_job -i 6 run +#dj7: bundle exec script/delayed_job -i 7 run +#dj8: bundle exec script/delayed_job -i 8 run +#dj9: bundle exec script/delayed_job -i 9 run +#dj10: bundle exec script/delayed_job -i 10 run diff --git a/tests/apps/python/app.json b/tests/apps/python/app.json new file mode 100644 index 000000000..0dbdea3ec --- /dev/null +++ b/tests/apps/python/app.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "dokku": { + "predeploy": "touch /app/predeploy.test", + "postdeploy": "touch /app/postdeploy.test" + } + } +} diff --git a/tests/apps/python/check_deploy b/tests/apps/python/check_deploy new file mode 100644 index 000000000..db53f009f --- /dev/null +++ b/tests/apps/python/check_deploy @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +output="$(curl -s -S "$1")" +echo "$output" +test "$output" == "python/http.server" diff --git a/tests/apps/python/null b/tests/apps/python/null new file mode 100644 index 000000000..e69de29bb diff --git a/tests/apps/python/web.py b/tests/apps/python/web.py new file mode 100644 index 000000000..b3e8ef728 --- /dev/null +++ b/tests/apps/python/web.py @@ -0,0 +1,17 @@ +import http.server +import os + + +class GetHandler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header("Content-Type", "text/plain; charset=utf-8") + self.end_headers() + self.wfile.write("python/http.server".encode("utf-8")) + + +if __name__ == "__main__": + port = int(os.getenv("PORT", 5000)) + server = http.server.HTTPServer(("0.0.0.0", port), GetHandler) + print("Listening on port {0}".format(port)) + server.serve_forever() diff --git a/tests/apps/python/worker.py b/tests/apps/python/worker.py new file mode 100644 index 000000000..30fd58b59 --- /dev/null +++ b/tests/apps/python/worker.py @@ -0,0 +1,11 @@ +import time + + +def main(): + print("sleeping for 60 seconds") + while True: + time.sleep(60) + + +if __name__ == "__main__": + main() diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 4bba6f132..99cef20d5 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -263,7 +263,7 @@ assert_urls() { deploy_app() { declare APP_TYPE="$1" GIT_REMOTE="$2" CUSTOM_TEMPLATE="$3" CUSTOM_PATH="$4" - local APP_TYPE=${APP_TYPE:="nodejs-express"} + local APP_TYPE=${APP_TYPE:="python"} local GIT_REMOTE=${GIT_REMOTE:="dokku@dokku.me:$TEST_APP"} local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"} local TMP=${CUSTOM_TMP:=$(mktemp -d "/tmp/dokku.me.XXXXX")} From 42a46df51fc0952b361d007f05558b7141a69e30 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 17:03:49 -0400 Subject: [PATCH 69/77] chore: group tests and adjust parallelism --- .circleci/config.yml | 111 ++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 33 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aa20deb83..6cc6b7e36 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,6 +26,26 @@ commands: - run: name: dokku report command: dokku report + run-bats: + description: "Run bats tests" + parameters: + index: + type: string + steps: + - run: + shell: /bin/bash + command: | + mkdir -p test-results/bats + cd tests/unit + echo "executing tests: $(ls << parameters.index >>*.bats | xargs)" + sudo -E bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(ls << parameters.index >>*.bats | xargs) + no_output_timeout: 60m + - store_artifacts: + path: ./test-results + destination: test-results + - store_test_results: + path: test-results + executors: default: @@ -74,26 +94,35 @@ jobs: esac - store_artifacts: path: ./coverage.out - test: + quick-test: executor: default parameters: index: type: string steps: - init-tests - - run: - shell: /bin/bash - command: | - mkdir -p test-results/bats - cd tests/unit - echo "executing tests: $(ls << parameters.index >>*.bats | xargs)" - sudo -E bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(ls << parameters.index >>*.bats | xargs) - no_output_timeout: 60m - - store_artifacts: - path: ./test-results - destination: test-results - - store_test_results: - path: test-results + - run-bats: + index: << parameters.index >> + medium-test: + executor: default + parallelism: 1 + parameters: + index: + type: string + steps: + - init-tests + - run-bats: + index: << parameters.index >> + slow-test: + executor: default + parallelism: 1 + parameters: + index: + type: string + steps: + - init-tests + - run-bats: + index: << parameters.index >> workflows: workflow: @@ -102,52 +131,68 @@ workflows: - docker-deploy-tests: requires: - build - - test + - quick-test + - medium-test + - slow-test - go-tests: matrix: parameters: index: [0, 1, 2, 3] requires: - build - - test - - test: + - quick-test + - medium-test + - slow-test + - quick-test: matrix: parameters: index: - app-json - - apps - - build-env - buildpacks - certs - - checks - - client - - config-oddities - config - - core_1 - - core_2 + - config-oddities - docker-options - domains - events - - git - init - - network - - nginx-vhosts_1 - - nginx-vhosts_2 - nginx-vhosts_3 - plugin - proxy - - ps-dockerfile - ps-general - - ps-herokuish - - repo - report - - resource - scheduler-docker-local - ssh_keys - storage - - tags - tar - trace - version requires: - build + - medium-test: + matrix: + parameters: + index: + - build-env + - checks + - client + - core_2 + - network + - nginx-vhosts_1 + - ps-herokuish + - repo + - tags + requires: + - build + - slow-test: + matrix: + parameters: + index: + - apps + - core_1 + - git + - nginx-vhosts_2 + - ps-dockerfile + - resource + requires: + - build From 36ceca7a946b9376cd2e57f16093f1f4a58d4b4a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 18:08:00 -0400 Subject: [PATCH 70/77] feat: split tests out even more and start deploy tests in parallel --- .circleci/config.yml | 85 ++--- tests/unit/{apps.bats => apps_1.bats} | 164 --------- tests/unit/apps_2.bats | 175 ++++++++++ tests/unit/core_1.bats | 103 ------ tests/unit/core_3.bats | 120 +++++++ tests/unit/git_1.bats | 73 ++++ tests/unit/{git.bats => git_2.bats} | 60 ---- tests/unit/nginx-vhosts_1.bats | 97 ------ tests/unit/nginx-vhosts_2.bats | 315 ------------------ tests/unit/nginx-vhosts_4.bats | 71 ++++ tests/unit/nginx-vhosts_5.bats | 62 ++++ tests/unit/nginx-vhosts_6.bats | 312 +++++++++++++++++ tests/unit/nginx-vhosts_7.bats | 57 ++++ tests/unit/ps-dockerfile-1.bats | 124 +++++++ ...ps-herokuish.bats => ps-dockerfile-2.bats} | 110 +++--- tests/unit/ps-dockerfile.bats | 270 --------------- tests/unit/ps-herokuish-1.bats | 61 ++++ tests/unit/ps-herokuish-2.bats | 96 ++++++ tests/unit/{resource.bats => resource_1.bats} | 91 ----- tests/unit/resource_2.bats | 104 ++++++ 20 files changed, 1347 insertions(+), 1203 deletions(-) rename tests/unit/{apps.bats => apps_1.bats} (58%) create mode 100644 tests/unit/apps_2.bats create mode 100644 tests/unit/core_3.bats create mode 100644 tests/unit/git_1.bats rename tests/unit/{git.bats => git_2.bats} (55%) create mode 100644 tests/unit/nginx-vhosts_4.bats create mode 100644 tests/unit/nginx-vhosts_5.bats create mode 100644 tests/unit/nginx-vhosts_6.bats create mode 100644 tests/unit/nginx-vhosts_7.bats create mode 100644 tests/unit/ps-dockerfile-1.bats rename tests/unit/{ps-herokuish.bats => ps-dockerfile-2.bats} (63%) delete mode 100644 tests/unit/ps-dockerfile.bats create mode 100644 tests/unit/ps-herokuish-1.bats create mode 100644 tests/unit/ps-herokuish-2.bats rename tests/unit/{resource.bats => resource_1.bats} (52%) create mode 100644 tests/unit/resource_2.bats diff --git a/.circleci/config.yml b/.circleci/config.yml index 6cc6b7e36..db61097a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,7 +94,7 @@ jobs: esac - store_artifacts: path: ./coverage.out - quick-test: + test: executor: default parameters: index: @@ -103,26 +103,6 @@ jobs: - init-tests - run-bats: index: << parameters.index >> - medium-test: - executor: default - parallelism: 1 - parameters: - index: - type: string - steps: - - init-tests - - run-bats: - index: << parameters.index >> - slow-test: - executor: default - parallelism: 1 - parameters: - index: - type: string - steps: - - init-tests - - run-bats: - index: << parameters.index >> workflows: workflow: @@ -131,68 +111,61 @@ workflows: - docker-deploy-tests: requires: - build - - quick-test - - medium-test - - slow-test - go-tests: matrix: parameters: index: [0, 1, 2, 3] requires: - build - - quick-test - - medium-test - - slow-test - - quick-test: + - test + - test: matrix: parameters: index: - app-json + - apps_1 + - apps_2 + - build-env - buildpacks - certs - - config + - checks + - client - config-oddities + - config + - core_1 + - core_2 + - core_3 - docker-options - domains - events + - git_1 + - git_2 - init + - network + - nginx-vhosts_1 + - nginx-vhosts_2 - nginx-vhosts_3 + - nginx-vhosts_4 + - nginx-vhosts_5 + - nginx-vhosts_6 + - nginx-vhosts_7 - plugin - proxy + - ps-dockerfile-1 + - ps-dockerfile-2 - ps-general + - ps-herokuish-1 + - ps-herokuish-2 + - repo - report + - resource_1 + - resource_2 - scheduler-docker-local - ssh_keys - storage + - tags - tar - trace - version requires: - build - - medium-test: - matrix: - parameters: - index: - - build-env - - checks - - client - - core_2 - - network - - nginx-vhosts_1 - - ps-herokuish - - repo - - tags - requires: - - build - - slow-test: - matrix: - parameters: - index: - - apps - - core_1 - - git - - nginx-vhosts_2 - - ps-dockerfile - - resource - requires: - - build diff --git a/tests/unit/apps.bats b/tests/unit/apps_1.bats similarity index 58% rename from tests/unit/apps.bats rename to tests/unit/apps_1.bats index 1a19699db..f09753bca 100644 --- a/tests/unit/apps.bats +++ b/tests/unit/apps_1.bats @@ -228,170 +228,6 @@ teardown() { assert_success } -@test "(apps) apps:clone" { - deploy_app - run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku apps:list | grep $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404" - echo "output: $output" - echo "status: $status" - assert_output "" - run /bin/bash -c "dokku --force apps:destroy great-test-name" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(apps) apps:clone (no app)" { - run /bin/bash -c "dokku apps:create $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku buildpacks:add $TEST_APP https://github.com/heroku/heroku-buildpack-ruby.git" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku git:set $TEST_APP deploy-branch SOME_BRANCH_NAME" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku network:set $TEST_APP attach-post-create test-network" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku resource:limit --memory 100 $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku scheduler-docker-local:set $TEST_APP disable-chown true" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku apps:list | grep $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku buildpacks:report great-test-name --buildpacks-list" - echo "output: $output" - echo "status: $status" - assert_success - assert_output "https://github.com/heroku/heroku-buildpack-ruby.git" - run /bin/bash -c "dokku git:report great-test-name --git-deploy-branch" - echo "output: $output" - echo "status: $status" - assert_success - assert_output "SOME_BRANCH_NAME" - run /bin/bash -c "dokku network:report great-test-name --network-attach-post-create" - echo "output: $output" - echo "status: $status" - assert_success - assert_output "test-network" - run /bin/bash -c "dokku nginx:report great-test-name --nginx-bind-address-ipv4" - echo "output: $output" - echo "status: $status" - assert_success - assert_output "127.0.0.1" - run /bin/bash -c "dokku resource:report great-test-name --resource-_default_.limit.memory" - echo "output: $output" - echo "status: $status" - assert_success - assert_output "100" - run /bin/bash -c "dokku scheduler-docker-local:report great-test-name --scheduler-docker-local-disable-chown" - echo "output: $output" - echo "status: $status" - assert_success - assert_output "true" - - run /bin/bash -c "dokku --force apps:destroy great-test-name" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(apps) apps:clone ssl-app" { - run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_PROXY_PORT_MAP=https:443:5000 DOKKU_PROXY_SSL_PORT=443" - deploy_app - run /bin/bash -c "dokku apps:clone $TEST_APP app-without-ssl" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku --quiet proxy:ports app-without-ssl | xargs" - echo "output: $output" - echo "status: $status" - assert_output "http 80 5000" - run /bin/bash -c "dokku config:get app-without-ssl DOKKU_PROXY_SSL_PORT" - echo "output: $output" - echo "status: $status" - assert_output "" - run /bin/bash -c "dokku --force apps:destroy app-without-ssl" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(apps) apps:clone --skip-deploy" { - deploy_app - run /bin/bash -c "dokku apps:clone --skip-deploy $TEST_APP great-test-name" - echo "output: $output" - echo "status: $status" - assert_success - run [ -d /home/dokku/great-test-name/tls ] - assert_failure - run [ -f /home/dokku/great-test-name/URLS ] - assert_failure - run [ -f /home/dokku/great-test-name/VHOST ] - assert_failure - run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404" - echo "output: $output" - echo "status: $status" - assert_failure - run /bin/bash -c "dokku --force apps:destroy great-test-name" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(apps) apps:clone --ignore-existing" { - deploy_app - run /bin/bash -c "dokku apps:create great-test-name" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku apps:clone --ignore-existing $TEST_APP great-test-name" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku --force apps:destroy great-test-name" - echo "output: $output" - echo "status: $status" - assert_success -} - @test "(apps) apps:exists" { run /bin/bash -c "dokku apps:exists $TEST_APP" echo "output: $output" diff --git a/tests/unit/apps_2.bats b/tests/unit/apps_2.bats new file mode 100644 index 000000000..71b846d4c --- /dev/null +++ b/tests/unit/apps_2.bats @@ -0,0 +1,175 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup +} + +teardown() { + global_teardown +} + +@test "(apps) apps:clone" { + deploy_app + run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku apps:list | grep $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404" + echo "output: $output" + echo "status: $status" + assert_output "" + run /bin/bash -c "dokku --force apps:destroy great-test-name" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(apps) apps:clone (no app)" { + run /bin/bash -c "dokku apps:create $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku buildpacks:add $TEST_APP https://github.com/heroku/heroku-buildpack-ruby.git" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku git:set $TEST_APP deploy-branch SOME_BRANCH_NAME" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku network:set $TEST_APP attach-post-create test-network" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku resource:limit --memory 100 $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku scheduler-docker-local:set $TEST_APP disable-chown true" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku apps:clone $TEST_APP great-test-name" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku apps:list | grep $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku buildpacks:report great-test-name --buildpacks-list" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "https://github.com/heroku/heroku-buildpack-ruby.git" + run /bin/bash -c "dokku git:report great-test-name --git-deploy-branch" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "SOME_BRANCH_NAME" + run /bin/bash -c "dokku network:report great-test-name --network-attach-post-create" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "test-network" + run /bin/bash -c "dokku nginx:report great-test-name --nginx-bind-address-ipv4" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "127.0.0.1" + run /bin/bash -c "dokku resource:report great-test-name --resource-_default_.limit.memory" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "100" + run /bin/bash -c "dokku scheduler-docker-local:report great-test-name --scheduler-docker-local-disable-chown" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "true" + + run /bin/bash -c "dokku --force apps:destroy great-test-name" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(apps) apps:clone ssl-app" { + run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_PROXY_PORT_MAP=https:443:5000 DOKKU_PROXY_SSL_PORT=443" + deploy_app + run /bin/bash -c "dokku apps:clone $TEST_APP app-without-ssl" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku --quiet proxy:ports app-without-ssl | xargs" + echo "output: $output" + echo "status: $status" + assert_output "http 80 5000" + run /bin/bash -c "dokku config:get app-without-ssl DOKKU_PROXY_SSL_PORT" + echo "output: $output" + echo "status: $status" + assert_output "" + run /bin/bash -c "dokku --force apps:destroy app-without-ssl" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(apps) apps:clone --skip-deploy" { + deploy_app + run /bin/bash -c "dokku apps:clone --skip-deploy $TEST_APP great-test-name" + echo "output: $output" + echo "status: $status" + assert_success + run [ -d /home/dokku/great-test-name/tls ] + assert_failure + run [ -f /home/dokku/great-test-name/URLS ] + assert_failure + run [ -f /home/dokku/great-test-name/VHOST ] + assert_failure + run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url great-test-name` | grep 404" + echo "output: $output" + echo "status: $status" + assert_failure + run /bin/bash -c "dokku --force apps:destroy great-test-name" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "curl --silent --write-out '%{http_code}\n' `dokku url $TEST_APP` | grep 200" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(apps) apps:clone --ignore-existing" { + deploy_app + run /bin/bash -c "dokku apps:create great-test-name" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku apps:clone --ignore-existing $TEST_APP great-test-name" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku --force apps:destroy great-test-name" + echo "output: $output" + echo "status: $status" + assert_success +} diff --git a/tests/unit/core_1.bats b/tests/unit/core_1.bats index fe488c838..fdaa43765 100644 --- a/tests/unit/core_1.bats +++ b/tests/unit/core_1.bats @@ -50,109 +50,6 @@ teardown() { docker rm $RANDOM_RUN_CID } -@test "(core) run (with DOKKU_RM_CONTAINER/--rm-container)" { - deploy_app - - run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\"" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_RM_CONTAINER=1" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\"" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku config:unset --no-restart $TEST_APP DOKKU_RM_CONTAINER" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku config:set --global DOKKU_RM_CONTAINER=1" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\"" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku config:unset --global DOKKU_RM_CONTAINER" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(core) run (detached)" { - deploy_app - - RANDOM_RUN_CID="$(dokku --label=com.dokku.test-label=value --detach run $TEST_APP sleep 300)" - run /bin/bash -c "docker inspect -f '{{ .State.Status }}' $RANDOM_RUN_CID" - echo "output: $output" - echo "status: $status" - assert_output "running" - - run /bin/bash -c "docker inspect $RANDOM_RUN_CID --format '{{ index .Config.Labels \"com.dokku.test-label\" }}'" - echo "output: $output" - echo "status: $status" - assert_output "value" - - run /bin/bash -c "docker stop $RANDOM_RUN_CID" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku cleanup" - echo "output: $output" - echo "status: $status" - assert_success - sleep 5 # wait for dokku cleanup to happen in the background -} - -@test "(core) run (with tty)" { - deploy_app - run /bin/bash -c "dokku run $TEST_APP ls /app/package.json" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(core) run (without tty)" { - deploy_app - run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(core) run command from Procfile" { - deploy_app - run /bin/bash -c "dokku run $TEST_APP custom 'hi dokku' | tail -n 1" - echo "output: $output" - echo "status: $status" - - assert_success - assert_output 'hi dokku' -} - @test "(core) port exposure (dockerfile raw port)" { source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" cat< $DOCKERFILE diff --git a/tests/unit/core_3.bats b/tests/unit/core_3.bats new file mode 100644 index 000000000..d60b113c8 --- /dev/null +++ b/tests/unit/core_3.bats @@ -0,0 +1,120 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app + DOCKERFILE="$BATS_TMPDIR/Dockerfile" +} + +teardown() { + rm -rf /home/dokku/$TEST_APP/tls + destroy_app + dokku config:unset --global DOKKU_RM_CONTAINER + rm -f "$DOCKERFILE" + global_teardown +} + +@test "(core) run (with DOKKU_RM_CONTAINER/--rm-container)" { + deploy_app + + run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\"" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_RM_CONTAINER=1" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\"" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku config:unset --no-restart $TEST_APP DOKKU_RM_CONTAINER" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku config:set --global DOKKU_RM_CONTAINER=1" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\"" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku config:unset --global DOKKU_RM_CONTAINER" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(core) run (detached)" { + deploy_app + + RANDOM_RUN_CID="$(dokku --label=com.dokku.test-label=value --detach run $TEST_APP sleep 300)" + run /bin/bash -c "docker inspect -f '{{ .State.Status }}' $RANDOM_RUN_CID" + echo "output: $output" + echo "status: $status" + assert_output "running" + + run /bin/bash -c "docker inspect $RANDOM_RUN_CID --format '{{ index .Config.Labels \"com.dokku.test-label\" }}'" + echo "output: $output" + echo "status: $status" + assert_output "value" + + run /bin/bash -c "docker stop $RANDOM_RUN_CID" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku cleanup" + echo "output: $output" + echo "status: $status" + assert_success + sleep 5 # wait for dokku cleanup to happen in the background +} + +@test "(core) run (with tty)" { + deploy_app + run /bin/bash -c "dokku run $TEST_APP ls /app/package.json" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(core) run (without tty)" { + deploy_app + run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(core) run command from Procfile" { + deploy_app + run /bin/bash -c "dokku run $TEST_APP custom 'hi dokku' | tail -n 1" + echo "output: $output" + echo "status: $status" + + assert_success + assert_output 'hi dokku' +} diff --git a/tests/unit/git_1.bats b/tests/unit/git_1.bats new file mode 100644 index 000000000..63bf3714b --- /dev/null +++ b/tests/unit/git_1.bats @@ -0,0 +1,73 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app +} + +teardown() { + destroy_app + global_teardown +} + +@test "(git) git:help" { + run /bin/bash -c "dokku git" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via git" + help_output="$output" + + run /bin/bash -c "dokku git:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via git" + assert_output "$help_output" +} + +@test "(git) ensure GIT_REV env var is set" { + deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku config:get $TEST_APP GIT_REV" + echo "output: $output" + echo "status: $status" + assert_output_exists +} + +@test "(git) disable GIT_REV" { + run /bin/bash -c "dokku git:set $TEST_APP rev-env-var" + echo "output: $output" + echo "status: $status" + assert_success + + deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku config:get $TEST_APP GIT_REV" + echo "output: $output" + echo "status: $status" + assert_output "" +} + +@test "(git) customize the GIT_REV environment variable" { + run /bin/bash -c "dokku git:set $TEST_APP rev-env-var GIT_REV_ALT" + echo "output: $output" + echo "status: $status" + assert_success + + deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku config:get $TEST_APP GIT_REV_ALT" + echo "output: $output" + echo "status: $status" + assert_output_exists +} diff --git a/tests/unit/git.bats b/tests/unit/git_2.bats similarity index 55% rename from tests/unit/git.bats rename to tests/unit/git_2.bats index d258b4c01..d9ad4e084 100644 --- a/tests/unit/git.bats +++ b/tests/unit/git_2.bats @@ -12,20 +12,6 @@ teardown() { global_teardown } -@test "(git) git:help" { - run /bin/bash -c "dokku git" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage app deploys via git" - help_output="$output" - - run /bin/bash -c "dokku git:help" - echo "output: $output" - echo "status: $status" - assert_output_contains "Manage app deploys via git" - assert_output "$help_output" -} - @test "(git) deploy specific branch" { run /bin/bash -c "dokku git:set --global deploy-branch global-branch" echo "output: $output" @@ -62,52 +48,6 @@ teardown() { run /bin/bash -c "dokku git:set --global deploy-branch" } -@test "(git) ensure GIT_REV env var is set" { - deploy_app - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku config:get $TEST_APP GIT_REV" - echo "output: $output" - echo "status: $status" - assert_output_exists -} - -@test "(git) disable GIT_REV" { - run /bin/bash -c "dokku git:set $TEST_APP rev-env-var" - echo "output: $output" - echo "status: $status" - assert_success - - deploy_app - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku config:get $TEST_APP GIT_REV" - echo "output: $output" - echo "status: $status" - assert_output "" -} - -@test "(git) customize the GIT_REV environment variable" { - run /bin/bash -c "dokku git:set $TEST_APP rev-env-var GIT_REV_ALT" - echo "output: $output" - echo "status: $status" - assert_success - - deploy_app - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku config:get $TEST_APP GIT_REV_ALT" - echo "output: $output" - echo "status: $status" - assert_output_exists -} - @test "(git) git:initialize" { run /bin/bash -c "test -d $DOKKU_ROOT/$TEST_APP/refs" echo "output: $output" diff --git a/tests/unit/nginx-vhosts_1.bats b/tests/unit/nginx-vhosts_1.bats index 5c45c2411..2995e478c 100644 --- a/tests/unit/nginx-vhosts_1.bats +++ b/tests/unit/nginx-vhosts_1.bats @@ -69,100 +69,3 @@ teardown() { check_urls http://${TEST_APP}.dokku.me assert_http_success http://${TEST_APP}.dokku.me } - -@test "(nginx-vhosts) nginx:build-config (without global VHOST but real HOSTNAME)" { - rm "$DOKKU_ROOT/VHOST" - echo "${TEST_APP}.dokku.me" > "$DOKKU_ROOT/HOSTNAME" - deploy_app - - HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") - check_urls http://${HOSTNAME}:[0-9]+ - - URLS=$(dokku --quiet urls "$TEST_APP") - for URL in $URLS; do - assert_http_success $URL - done -} - -@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv4 address set as HOSTNAME)" { - rm "$DOKKU_ROOT/VHOST" - echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME" - deploy_app - - HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") - check_urls http://${HOSTNAME}:[0-9]+ - - URLS=$(dokku --quiet urls "$TEST_APP") - for URL in $URLS; do - assert_http_success $URL - done -} - -@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv6 address set as HOSTNAME)" { - rm "$DOKKU_ROOT/VHOST" - echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME" - deploy_app - - HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") - check_urls http://${HOSTNAME}:[0-9]+ -} - -@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add pre deploy)" { - rm "$DOKKU_ROOT/VHOST" - create_app - add_domain "www.test.app.dokku.me" - deploy_app - assert_nonssl_domain "www.test.app.dokku.me" -} - -@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add post deploy)" { - rm "$DOKKU_ROOT/VHOST" - deploy_app - add_domain "www.test.app.dokku.me" - check_urls http://www.test.app.dokku.me - assert_http_success http://www.test.app.dokku.me -} - -@test "(nginx-vhosts) nginx:build-config (xip.io style hostnames)" { - echo "127.0.0.1.xip.io.dokku.me" > "$DOKKU_ROOT/VHOST" - deploy_app - - check_urls http://${TEST_APP}.127.0.0.1.xip.io.dokku.me - assert_http_success http://${TEST_APP}.127.0.0.1.xip.io.dokku.me -} - -@test "(nginx-vhosts) nginx:build-config (dockerfile expose)" { - deploy_app dockerfile - - add_domain "www.test.app.dokku.me" - check_urls http://${TEST_APP}.dokku.me:3000 - check_urls http://${TEST_APP}.dokku.me:3003 - check_urls http://www.test.app.dokku.me:3000 - check_urls http://www.test.app.dokku.me:3003 - assert_http_success http://${TEST_APP}.dokku.me:3000 - assert_http_success http://${TEST_APP}.dokku.me:3003 - assert_http_success http://www.test.app.dokku.me:3000 - assert_http_success http://www.test.app.dokku.me:3003 - -} - -@test "(nginx-vhosts) nginx:build-config (multiple networks)" { - deploy_app - - create_attach_network - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(nginx-vhosts) nginx:build-config (global DOKKU_PROXY_PORT)" { - local GLOBAL_PORT=30999 - run /bin/bash -c "dokku config:set --global DOKKU_PROXY_PORT=${GLOBAL_PORT}" - - deploy_app - check_urls http://${TEST_APP}.dokku.me:${GLOBAL_PORT} - assert_http_success http://${TEST_APP}.dokku.me:${GLOBAL_PORT} - - run /bin/bash -c "dokku config:unset --global DOKKU_PROXY_PORT" -} diff --git a/tests/unit/nginx-vhosts_2.bats b/tests/unit/nginx-vhosts_2.bats index e5d944879..ed985806f 100644 --- a/tests/unit/nginx-vhosts_2.bats +++ b/tests/unit/nginx-vhosts_2.bats @@ -16,102 +16,6 @@ teardown() { global_teardown } -@test "(nginx-vhosts) nginx (no server tokens)" { - deploy_app - run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | grep -E '^Server' | grep -E '[0-9]+'" - echo "output: $output" - echo "status: $status" - assert_failure -} - -@test "(nginx-vhosts) logging" { - deploy_app - - run [ -a "/var/log/nginx/$TEST_APP-access.log" ] - echo "output: $output" - echo "status: $status" - assert_success - - run [ -a "/var/log/nginx/$TEST_APP-error.log" ] - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:access-logs $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:error-logs $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(nginx-vhosts) log-path" { - deploy_app - - run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path off" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" - - run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" 0 - - run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path off" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" - - run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" 0 -} - @test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" { setup_test_tls add_domain "node-js-app.dokku.me" @@ -152,222 +56,3 @@ teardown() { assert_ssl_domain "www.test.dokku.me" assert_ssl_domain "www.test.app.dokku.me" } - -@test "(nginx-vhosts) nginx:build-config (wildcard SSL and custom nginx template)" { - setup_test_tls wildcard - add_domain "wildcard1.dokku.me" - add_domain "wildcard2.dokku.me" - deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_ssl_nginx_template - - assert_ssl_domain "wildcard1.dokku.me" - assert_ssl_domain "wildcard2.dokku.me" - assert_http_redirect "http://${CUSTOM_TEMPLATE_SSL_DOMAIN}" "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}:443/" - assert_http_success "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}" -} - -@test "(nginx-vhosts) nginx:build-config (custom nginx template - no ssl)" { - add_domain "www.test.app.dokku.me" - run deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku ps:scale $TEST_APP worker=1" - echo "output: $output" - echo "status: $status" - assert_success - - assert_nonssl_domain "www.test.app.dokku.me" - assert_http_success "customtemplate.dokku.me" - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "${TEST_APP}-worker-5000" -} - -@test "(nginx-vhosts) nginx:build-config (failed validate_nginx)" { - run deploy_app nodejs-express dokku@dokku.me:$TEST_APP bad_custom_nginx_template - echo "output: $output" - echo "status: $status" - assert_failure -} - -@test "(nginx-vhosts) nginx:set hsts" { - setup_test_tls wildcard - local HSTS_CONF="/home/dokku/${TEST_APP}/nginx.conf.d/hsts.conf" - - run deploy_app - echo "output: $output" - echo "status: $status" - assert_success - assert_output_contains "Enabling HSTS" - - run /bin/bash -c "test -f $HSTS_CONF" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=15724800'" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "cat $HSTS_CONF | grep preload" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku nginx:set $TEST_APP hsts-include-subdomains false" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku nginx:set $TEST_APP hsts-max-age 120" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=120'" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:set $TEST_APP hsts-preload true" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - run /bin/bash -c "cat $HSTS_CONF | grep preload" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:set $TEST_APP hsts false" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - assert_output_contains "Enabling HSTS" 0 - - run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf.d/hsts.conf" - echo "output: $output" - echo "status: $status" - assert_failure -} - -@test "(nginx-vhosts) nginx:set bind-address" { - run deploy_app - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6 ::1" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "[::1]:80;" - assert_output_contains "127.0.0.1:80;" - - run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "[::1]:80;" 0 - assert_output_contains "127.0.0.1:80;" 0 -} - -@test "(nginx-vhosts) nginx:validate-config" { - deploy_app - run /bin/bash -c "dokku nginx:validate-config" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:validate-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf" - - run /bin/bash -c "dokku nginx:validate-config" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku nginx:validate-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku nginx:validate-config --clean" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:validate-config" - echo "output: $output" - echo "status: $status" - assert_success - - echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf" - - run /bin/bash -c "dokku nginx:validate-config $TEST_APP --clean" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:validate-config" - echo "output: $output" - echo "status: $status" - assert_success -} diff --git a/tests/unit/nginx-vhosts_4.bats b/tests/unit/nginx-vhosts_4.bats new file mode 100644 index 000000000..97f576b87 --- /dev/null +++ b/tests/unit/nginx-vhosts_4.bats @@ -0,0 +1,71 @@ +#!/usr/bin/env bats + +load test_helper +source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions" + +setup() { + global_setup + [[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak" + [[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak" +} + +teardown() { + detach_delete_network + destroy_app + [[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST" + [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME" + global_teardown +} + +@test "(nginx-vhosts) nginx:build-config (without global VHOST but real HOSTNAME)" { + rm "$DOKKU_ROOT/VHOST" + echo "${TEST_APP}.dokku.me" > "$DOKKU_ROOT/HOSTNAME" + deploy_app + + HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") + check_urls http://${HOSTNAME}:[0-9]+ + + URLS=$(dokku --quiet urls "$TEST_APP") + for URL in $URLS; do + assert_http_success $URL + done +} + +@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv4 address set as HOSTNAME)" { + rm "$DOKKU_ROOT/VHOST" + echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME" + deploy_app + + HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") + check_urls http://${HOSTNAME}:[0-9]+ + + URLS=$(dokku --quiet urls "$TEST_APP") + for URL in $URLS; do + assert_http_success $URL + done +} + +@test "(nginx-vhosts) nginx:build-config (without global VHOST and IPv6 address set as HOSTNAME)" { + rm "$DOKKU_ROOT/VHOST" + echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME" + deploy_app + + HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME") + check_urls http://${HOSTNAME}:[0-9]+ +} + +@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add pre deploy)" { + rm "$DOKKU_ROOT/VHOST" + create_app + add_domain "www.test.app.dokku.me" + deploy_app + assert_nonssl_domain "www.test.app.dokku.me" +} + +@test "(nginx-vhosts) nginx:build-config (without global VHOST and domains:add post deploy)" { + rm "$DOKKU_ROOT/VHOST" + deploy_app + add_domain "www.test.app.dokku.me" + check_urls http://www.test.app.dokku.me + assert_http_success http://www.test.app.dokku.me +} diff --git a/tests/unit/nginx-vhosts_5.bats b/tests/unit/nginx-vhosts_5.bats new file mode 100644 index 000000000..70dbf1971 --- /dev/null +++ b/tests/unit/nginx-vhosts_5.bats @@ -0,0 +1,62 @@ +#!/usr/bin/env bats + +load test_helper +source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions" + +setup() { + global_setup + [[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak" + [[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak" +} + +teardown() { + detach_delete_network + destroy_app + [[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST" + [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME" + global_teardown +} + +@test "(nginx-vhosts) nginx:build-config (xip.io style hostnames)" { + echo "127.0.0.1.xip.io.dokku.me" > "$DOKKU_ROOT/VHOST" + deploy_app + + check_urls http://${TEST_APP}.127.0.0.1.xip.io.dokku.me + assert_http_success http://${TEST_APP}.127.0.0.1.xip.io.dokku.me +} + +@test "(nginx-vhosts) nginx:build-config (dockerfile expose)" { + deploy_app dockerfile + + add_domain "www.test.app.dokku.me" + check_urls http://${TEST_APP}.dokku.me:3000 + check_urls http://${TEST_APP}.dokku.me:3003 + check_urls http://www.test.app.dokku.me:3000 + check_urls http://www.test.app.dokku.me:3003 + assert_http_success http://${TEST_APP}.dokku.me:3000 + assert_http_success http://${TEST_APP}.dokku.me:3003 + assert_http_success http://www.test.app.dokku.me:3000 + assert_http_success http://www.test.app.dokku.me:3003 + +} + +@test "(nginx-vhosts) nginx:build-config (multiple networks)" { + deploy_app + + create_attach_network + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(nginx-vhosts) nginx:build-config (global DOKKU_PROXY_PORT)" { + local GLOBAL_PORT=30999 + run /bin/bash -c "dokku config:set --global DOKKU_PROXY_PORT=${GLOBAL_PORT}" + + deploy_app + check_urls http://${TEST_APP}.dokku.me:${GLOBAL_PORT} + assert_http_success http://${TEST_APP}.dokku.me:${GLOBAL_PORT} + + run /bin/bash -c "dokku config:unset --global DOKKU_PROXY_PORT" +} diff --git a/tests/unit/nginx-vhosts_6.bats b/tests/unit/nginx-vhosts_6.bats new file mode 100644 index 000000000..efde0a5d8 --- /dev/null +++ b/tests/unit/nginx-vhosts_6.bats @@ -0,0 +1,312 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + [[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak" + [[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak" + create_app +} + +teardown() { + destroy_app 0 $TEST_APP + [[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST" + [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME" + global_teardown +} + +@test "(nginx-vhosts) nginx (no server tokens)" { + deploy_app + run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | grep -E '^Server' | grep -E '[0-9]+'" + echo "output: $output" + echo "status: $status" + assert_failure +} + +@test "(nginx-vhosts) logging" { + deploy_app + + run [ -a "/var/log/nginx/$TEST_APP-access.log" ] + echo "output: $output" + echo "status: $status" + assert_success + + run [ -a "/var/log/nginx/$TEST_APP-error.log" ] + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:access-logs $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:error-logs $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(nginx-vhosts) log-path" { + deploy_app + + run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path off" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" + + run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" 0 + + run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path off" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" + + run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" 0 +} + +@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" { + setup_test_tls + add_domain "node-js-app.dokku.me" + add_domain "test.dokku.me" + deploy_app + dokku nginx:show-config $TEST_APP + assert_ssl_domain "node-js-app.dokku.me" + assert_http_redirect "http://test.dokku.me" "https://test.dokku.me:443/" +} + +@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" { + setup_test_tls wildcard + add_domain "wildcard1.dokku.me" + add_domain "wildcard2.dokku.me" + deploy_app + dokku nginx:show-config $TEST_APP + assert_ssl_domain "wildcard1.dokku.me" + assert_ssl_domain "wildcard2.dokku.me" +} + +@test "(nginx-vhosts) nginx:set hsts" { + setup_test_tls wildcard + local HSTS_CONF="/home/dokku/${TEST_APP}/nginx.conf.d/hsts.conf" + + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "Enabling HSTS" + + run /bin/bash -c "test -f $HSTS_CONF" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=15724800'" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "cat $HSTS_CONF | grep preload" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku nginx:set $TEST_APP hsts-include-subdomains false" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "cat $HSTS_CONF | grep includeSubdomains" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku nginx:set $TEST_APP hsts-max-age 120" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "cat $HSTS_CONF | grep 'max-age=120'" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:set $TEST_APP hsts-preload true" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "cat $HSTS_CONF | grep preload" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:set $TEST_APP hsts false" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "Enabling HSTS" 0 + + run /bin/bash -c "test -f $DOKKU_ROOT/$TEST_APP/nginx.conf.d/hsts.conf" + echo "output: $output" + echo "status: $status" + assert_failure +} + +@test "(nginx-vhosts) nginx:set bind-address" { + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4 127.0.0.1" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6 ::1" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "[::1]:80;" + assert_output_contains "127.0.0.1:80;" + + run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv4" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:set $TEST_APP bind-address-ipv6" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "[::1]:80;" 0 + assert_output_contains "127.0.0.1:80;" 0 +} + +@test "(nginx-vhosts) nginx:validate-config" { + deploy_app + run /bin/bash -c "dokku nginx:validate-config" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:validate-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf" + + run /bin/bash -c "dokku nginx:validate-config" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku nginx:validate-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku nginx:validate-config --clean" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:validate-config" + echo "output: $output" + echo "status: $status" + assert_success + + echo "invalid config" > "/home/dokku/${TEST_APP}/nginx.conf" + + run /bin/bash -c "dokku nginx:validate-config $TEST_APP --clean" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:validate-config" + echo "output: $output" + echo "status: $status" + assert_success +} diff --git a/tests/unit/nginx-vhosts_7.bats b/tests/unit/nginx-vhosts_7.bats new file mode 100644 index 000000000..060676d28 --- /dev/null +++ b/tests/unit/nginx-vhosts_7.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + [[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak" + [[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak" + create_app +} + +teardown() { + destroy_app 0 $TEST_APP + [[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST" + [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME" + global_teardown +} + +@test "(nginx-vhosts) nginx:build-config (wildcard SSL and custom nginx template)" { + setup_test_tls wildcard + add_domain "wildcard1.dokku.me" + add_domain "wildcard2.dokku.me" + deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_ssl_nginx_template + + assert_ssl_domain "wildcard1.dokku.me" + assert_ssl_domain "wildcard2.dokku.me" + assert_http_redirect "http://${CUSTOM_TEMPLATE_SSL_DOMAIN}" "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}:443/" + assert_http_success "https://${CUSTOM_TEMPLATE_SSL_DOMAIN}" +} + +@test "(nginx-vhosts) nginx:build-config (custom nginx template - no ssl)" { + add_domain "www.test.app.dokku.me" + run deploy_app nodejs-express dokku@dokku.me:$TEST_APP custom_nginx_template + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:scale $TEST_APP worker=1" + echo "output: $output" + echo "status: $status" + assert_success + + assert_nonssl_domain "www.test.app.dokku.me" + assert_http_success "customtemplate.dokku.me" + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "${TEST_APP}-worker-5000" +} + +@test "(nginx-vhosts) nginx:build-config (failed validate_nginx)" { + run deploy_app nodejs-express dokku@dokku.me:$TEST_APP bad_custom_nginx_template + echo "output: $output" + echo "status: $status" + assert_failure +} diff --git a/tests/unit/ps-dockerfile-1.bats b/tests/unit/ps-dockerfile-1.bats new file mode 100644 index 000000000..bba89ed30 --- /dev/null +++ b/tests/unit/ps-dockerfile-1.bats @@ -0,0 +1,124 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app +} + +teardown() { + destroy_app + global_teardown +} + +@test "(ps) dockerfile" { + deploy_app dockerfile + run /bin/bash -c "dokku ps:stop $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_failure + done + + run /bin/bash -c "dokku ps:start $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_success + done + + run /bin/bash -c "dokku ps:restart $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_success + done + + run /bin/bash -c "dokku ps:rebuild $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_success + done +} + +@test "(ps:scale) dockerfile non-existent process" { + run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2" + echo "output: $output" + echo "status: $status" + assert_success + + destroy_app + create_app + deploy_app dockerfile-procfile + run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2" + echo "output: $output" + echo "status: $status" + assert_failure +} + +@test "(ps:scale) dockerfile" { + run /bin/bash -c "dokku ps:scale $TEST_APP web=2" + echo "output: $output" + echo "status: $status" + assert_success + + deploy_app dockerfile + CIDS="" + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do + CIDS+=$(< $CID_FILE) + CIDS+=" " + done + CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") + run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:scale $TEST_APP web=1" + echo "output: $output" + echo "status: $status" + assert_success + CIDS="" + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do + CIDS+=$(< $CID_FILE) + CIDS+=" " + done + CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") + run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:scale $TEST_APP web=0" + echo "output: $output" + echo "status: $status" + assert_success + CIDS="" + shopt -s nullglob + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do + CIDS+=$(< $CID_FILE) + CIDS+=" " + done + run /bin/bash -c "[[ -z \"$CIDS\" ]]" + echo "output: $output" + echo "status: $status" + assert_success +} diff --git a/tests/unit/ps-herokuish.bats b/tests/unit/ps-dockerfile-2.bats similarity index 63% rename from tests/unit/ps-herokuish.bats rename to tests/unit/ps-dockerfile-2.bats index 1d77ce4ce..759f9013e 100644 --- a/tests/unit/ps-herokuish.bats +++ b/tests/unit/ps-dockerfile-2.bats @@ -9,12 +9,40 @@ setup() { teardown() { destroy_app - destroy_app 0 "$MYAPP" || true global_teardown } -@test "(ps) herokuish" { - deploy_app +@test "(ps:scale) dockerfile dokku-scale" { + run /bin/bash -c "dokku ps:scale $TEST_APP web=2" + echo "output: $output" + echo "status: $status" + assert_success + + deploy_app dockerfile-dokku-scale + CIDS="" + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do + CIDS+=$(< $CID_FILE) + CIDS+=" " + done + CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") + run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:scale $TEST_APP web=1" + echo "output: $output" + echo "status: $status" + assert_failure + + run /bin/bash -c "dokku ps:report $TEST_APP --ps-can-scale" + echo "output: $output" + echo "status: $status" + assert_output "false" +} + +@test "(ps) dockerfile with procfile" { + deploy_app dockerfile-procfile run /bin/bash -c "dokku ps:stop $TEST_APP" echo "output: $output" echo "status: $status" @@ -60,24 +88,36 @@ teardown() { done } -@test "(ps:scale) herokuish" { +@test "(ps) dockerfile with bad procfile" { + run deploy_app dockerfile-procfile-bad + echo "output: $output" + echo "status: $status" + assert_failure + + run create_app + assert_success +} + +@test "(ps:scale) dockerfile with procfile" { run /bin/bash -c "dokku ps:scale $TEST_APP web=2 worker=2" echo "output: $output" echo "status: $status" assert_success - deploy_app + deploy_app dockerfile-procfile for PROC_TYPE in web worker; do - CIDS="" - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do - CIDS+=$(< $CID_FILE) - CIDS+=" " - done - CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") - run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2" + run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc" echo "output: $output" echo "status: $status" assert_success + goodlines="" + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do + cid=$(< $CID_FILE) + assert_output_contains "$cid" + goodlines+=$(echo "$output" | grep "$cid") + done + output="$goodlines" + assert_output_contains "node ${PROC_TYPE}.js" 2 done run /bin/bash -c "dokku ps:scale $TEST_APP web=1 worker=1" @@ -85,23 +125,25 @@ teardown() { echo "status: $status" assert_success for PROC_TYPE in web worker; do - CIDS="" - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do - CIDS+=$(< $CID_FILE) - CIDS+=" " - done - CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") - run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1" + run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc" echo "output: $output" echo "status: $status" assert_success + goodlines="" + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do + cid=$(< $CID_FILE) + assert_output_contains "$cid" + goodlines+=$(echo "$output" | grep "$cid") + done + output="$goodlines" + assert_output_contains "node ${PROC_TYPE}.js" done - run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0 invalid-process=0" + run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0" echo "output: $output" echo "status: $status" assert_success - for PROC_TYPE in web worker invalid-process; do + for PROC_TYPE in web worker; do CIDS="" shopt -s nullglob for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do @@ -115,29 +157,3 @@ teardown() { assert_success done } - -@test "(ps:restore) herokuish" { - MYAPP="manual-randomtestapp-1" - create_app "$MYAPP" - deploy_app - - run /bin/bash -c "dokku ps:stop $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku apps:list" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku ps:restore" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku --quiet ps:report $TEST_APP | grep -q exited" - echo "output: $output" - echo "status: $status" - assert_success -} diff --git a/tests/unit/ps-dockerfile.bats b/tests/unit/ps-dockerfile.bats deleted file mode 100644 index a32a296b4..000000000 --- a/tests/unit/ps-dockerfile.bats +++ /dev/null @@ -1,270 +0,0 @@ -#!/usr/bin/env bats - -load test_helper - -setup() { - global_setup - create_app -} - -teardown() { - destroy_app - global_teardown -} - -@test "(ps) dockerfile" { - deploy_app dockerfile - run /bin/bash -c "dokku ps:stop $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_failure - done - - run /bin/bash -c "dokku ps:start $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_success - done - - run /bin/bash -c "dokku ps:restart $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_success - done - - run /bin/bash -c "dokku ps:rebuild $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_success - done -} - -@test "(ps:scale) dockerfile non-existent process" { - run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2" - echo "output: $output" - echo "status: $status" - assert_success - - destroy_app - create_app - deploy_app dockerfile-procfile - run /bin/bash -c "dokku ps:scale $TEST_APP non-existent=2" - echo "output: $output" - echo "status: $status" - assert_failure -} - -@test "(ps:scale) dockerfile" { - run /bin/bash -c "dokku ps:scale $TEST_APP web=2" - echo "output: $output" - echo "status: $status" - assert_success - - deploy_app dockerfile - CIDS="" - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do - CIDS+=$(< $CID_FILE) - CIDS+=" " - done - CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") - run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku ps:scale $TEST_APP web=1" - echo "output: $output" - echo "status: $status" - assert_success - CIDS="" - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do - CIDS+=$(< $CID_FILE) - CIDS+=" " - done - CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") - run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku ps:scale $TEST_APP web=0" - echo "output: $output" - echo "status: $status" - assert_success - CIDS="" - shopt -s nullglob - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do - CIDS+=$(< $CID_FILE) - CIDS+=" " - done - run /bin/bash -c "[[ -z \"$CIDS\" ]]" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(ps:scale) dockerfile dokku-scale" { - run /bin/bash -c "dokku ps:scale $TEST_APP web=2" - echo "output: $output" - echo "status: $status" - assert_success - - deploy_app dockerfile-dokku-scale - CIDS="" - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do - CIDS+=$(< $CID_FILE) - CIDS+=" " - done - CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") - run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku ps:scale $TEST_APP web=1" - echo "output: $output" - echo "status: $status" - assert_failure - - run /bin/bash -c "dokku ps:report $TEST_APP --ps-can-scale" - echo "output: $output" - echo "status: $status" - assert_output "false" -} - -@test "(ps) dockerfile with procfile" { - deploy_app dockerfile-procfile - run /bin/bash -c "dokku ps:stop $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_failure - done - - run /bin/bash -c "dokku ps:start $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_success - done - - run /bin/bash -c "dokku ps:restart $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_success - done - - run /bin/bash -c "dokku ps:rebuild $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do - run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" - echo "output: $output" - echo "status: $status" - assert_success - done -} - -@test "(ps) dockerfile with bad procfile" { - run deploy_app dockerfile-procfile-bad - echo "output: $output" - echo "status: $status" - assert_failure - - run create_app - assert_success -} - -@test "(ps:scale) dockerfile with procfile" { - run /bin/bash -c "dokku ps:scale $TEST_APP web=2 worker=2" - echo "output: $output" - echo "status: $status" - assert_success - - deploy_app dockerfile-procfile - for PROC_TYPE in web worker; do - run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc" - echo "output: $output" - echo "status: $status" - assert_success - goodlines="" - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do - cid=$(< $CID_FILE) - assert_output_contains "$cid" - goodlines+=$(echo "$output" | grep "$cid") - done - output="$goodlines" - assert_output_contains "node ${PROC_TYPE}.js" 2 - done - - run /bin/bash -c "dokku ps:scale $TEST_APP web=1 worker=1" - echo "output: $output" - echo "status: $status" - assert_success - for PROC_TYPE in web worker; do - run /bin/bash -c "docker ps --format '{{.ID}} {{.Command}}' --no-trunc" - echo "output: $output" - echo "status: $status" - assert_success - goodlines="" - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do - cid=$(< $CID_FILE) - assert_output_contains "$cid" - goodlines+=$(echo "$output" | grep "$cid") - done - output="$goodlines" - assert_output_contains "node ${PROC_TYPE}.js" - done - - run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0" - echo "output: $output" - echo "status: $status" - assert_success - for PROC_TYPE in web worker; do - CIDS="" - shopt -s nullglob - for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do - CIDS+=$(< $CID_FILE) - CIDS+=" " - done - shopt -u nullglob - run /bin/bash -c "[[ -z \"$CIDS\" ]]" - echo "output: $output" - echo "status: $status" - assert_success - done -} diff --git a/tests/unit/ps-herokuish-1.bats b/tests/unit/ps-herokuish-1.bats new file mode 100644 index 000000000..c6002ef66 --- /dev/null +++ b/tests/unit/ps-herokuish-1.bats @@ -0,0 +1,61 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app +} + +teardown() { + destroy_app + destroy_app 0 "$MYAPP" || true + global_teardown +} + +@test "(ps) herokuish" { + deploy_app + run /bin/bash -c "dokku ps:stop $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_failure + done + + run /bin/bash -c "dokku ps:start $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_success + done + + run /bin/bash -c "dokku ps:restart $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_success + done + + run /bin/bash -c "dokku ps:rebuild $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.*; do + run /bin/bash -c "docker ps -q --no-trunc | grep -q $(< $CID_FILE)" + echo "output: $output" + echo "status: $status" + assert_success + done +} diff --git a/tests/unit/ps-herokuish-2.bats b/tests/unit/ps-herokuish-2.bats new file mode 100644 index 000000000..0dc232717 --- /dev/null +++ b/tests/unit/ps-herokuish-2.bats @@ -0,0 +1,96 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app +} + +teardown() { + destroy_app + destroy_app 0 "$MYAPP" || true + global_teardown +} + +@test "(ps:scale) herokuish" { + run /bin/bash -c "dokku ps:scale $TEST_APP web=2 worker=2" + echo "output: $output" + echo "status: $status" + assert_success + + deploy_app + for PROC_TYPE in web worker; do + CIDS="" + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do + CIDS+=$(< $CID_FILE) + CIDS+=" " + done + CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") + run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 2" + echo "output: $output" + echo "status: $status" + assert_success + done + + run /bin/bash -c "dokku ps:scale $TEST_APP web=1 worker=1" + echo "output: $output" + echo "status: $status" + assert_success + for PROC_TYPE in web worker; do + CIDS="" + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do + CIDS+=$(< $CID_FILE) + CIDS+=" " + done + CIDS_PATTERN=$(echo $CIDS | sed -e "s: :|:g") + run /bin/bash -c "docker ps -q --no-trunc | grep -E \"$CIDS_PATTERN\" | wc -l | grep 1" + echo "output: $output" + echo "status: $status" + assert_success + done + + run /bin/bash -c "dokku ps:scale $TEST_APP web=0 worker=0 invalid-process=0" + echo "output: $output" + echo "status: $status" + assert_success + for PROC_TYPE in web worker invalid-process; do + CIDS="" + shopt -s nullglob + for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.$PROC_TYPE.*; do + CIDS+=$(< $CID_FILE) + CIDS+=" " + done + shopt -u nullglob + run /bin/bash -c "[[ -z \"$CIDS\" ]]" + echo "output: $output" + echo "status: $status" + assert_success + done +} + +@test "(ps:restore) herokuish" { + MYAPP="manual-randomtestapp-1" + create_app "$MYAPP" + deploy_app + + run /bin/bash -c "dokku ps:stop $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku apps:list" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:restore" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku --quiet ps:report $TEST_APP | grep -q exited" + echo "output: $output" + echo "status: $status" + assert_success +} diff --git a/tests/unit/resource.bats b/tests/unit/resource_1.bats similarity index 52% rename from tests/unit/resource.bats rename to tests/unit/resource_1.bats index 5a3e61571..0a828e729 100644 --- a/tests/unit/resource.bats +++ b/tests/unit/resource_1.bats @@ -100,85 +100,6 @@ teardown() { assert_output "0" } -@test "(resource) resource:reserve" { - run /bin/bash -c "dokku resource:reserve $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "resource reservation $TEST_APP information" - - deploy_app - run /bin/bash -c "dokku resource:reserve --memory 512MB $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) - run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" - echo "output: $output" - echo "status: $status" - assert_output "0" - - dokku ps:rebuild "$TEST_APP" - CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) - run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" - echo "output: $output" - echo "status: $status" - assert_output "536870912" - - run /bin/bash -c "dokku resource:reserve --memory 1024MB --process-type worker $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku resource:reserve --cpu 0.5 --process-type worker $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - dokku ps:rebuild "$TEST_APP" - CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) - run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" - echo "output: $output" - echo "status: $status" - assert_output "536870912" - - run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - dokku ps:rebuild "$TEST_APP" - CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) - run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" - echo "output: $output" - echo "status: $status" - assert_output "536870912" - - run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - dokku ps:rebuild "$TEST_APP" - CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) - run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" - echo "output: $output" - echo "status: $status" - assert_output "536870912" - - run /bin/bash -c "dokku resource:reserve-clear $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - dokku ps:rebuild "$TEST_APP" - CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) - run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" - echo "output: $output" - echo "status: $status" - assert_output "0" -} - @test "(resource) resource:limit-clear" { run /bin/bash -c "dokku resource:limit-clear $TEST_APP" echo "output: $output" @@ -190,15 +111,3 @@ teardown() { echo "status: $status" assert_success } - -@test "(resource) resource:reserve-clear" { - run /bin/bash -c "dokku resource:reserve-clear $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success -} diff --git a/tests/unit/resource_2.bats b/tests/unit/resource_2.bats new file mode 100644 index 000000000..ab5ce4141 --- /dev/null +++ b/tests/unit/resource_2.bats @@ -0,0 +1,104 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + create_app +} + +teardown() { + destroy_app + global_teardown +} + +@test "(resource) resource:reserve" { + run /bin/bash -c "dokku resource:reserve $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "resource reservation $TEST_APP information" + + deploy_app + run /bin/bash -c "dokku resource:reserve --memory 512MB $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" + echo "output: $output" + echo "status: $status" + assert_output "0" + + dokku ps:rebuild "$TEST_APP" + CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" + echo "output: $output" + echo "status: $status" + assert_output "536870912" + + run /bin/bash -c "dokku resource:reserve --memory 1024MB --process-type worker $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku resource:reserve --cpu 0.5 --process-type worker $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + dokku ps:rebuild "$TEST_APP" + CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" + echo "output: $output" + echo "status: $status" + assert_output "536870912" + + run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + dokku ps:rebuild "$TEST_APP" + CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" + echo "output: $output" + echo "status: $status" + assert_output "536870912" + + run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + dokku ps:rebuild "$TEST_APP" + CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" + echo "output: $output" + echo "status: $status" + assert_output "536870912" + + run /bin/bash -c "dokku resource:reserve-clear $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + dokku ps:rebuild "$TEST_APP" + CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1) + run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID" + echo "output: $output" + echo "status: $status" + assert_output "0" +} + +@test "(resource) resource:reserve-clear" { + run /bin/bash -c "dokku resource:reserve-clear $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku resource:reserve-clear --process-type web $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success +} From 1ecb9585ef635c8ad4de4df63d1c263f2407f178 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 18:35:29 -0400 Subject: [PATCH 71/77] fix: correct test for new null buildpack --- tests/unit/core_3.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/core_3.bats b/tests/unit/core_3.bats index d60b113c8..66c271d3f 100644 --- a/tests/unit/core_3.bats +++ b/tests/unit/core_3.bats @@ -95,7 +95,7 @@ teardown() { @test "(core) run (with tty)" { deploy_app - run /bin/bash -c "dokku run $TEST_APP ls /app/package.json" + run /bin/bash -c "dokku run $TEST_APP ls /app/null" echo "output: $output" echo "status: $status" assert_success @@ -103,7 +103,7 @@ teardown() { @test "(core) run (without tty)" { deploy_app - run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json" + run /bin/bash -c ": |dokku run $TEST_APP ls /app/null" echo "output: $output" echo "status: $status" assert_success From dabe90a0de63c741f050bc76f81f6c7f74da68bf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 19:01:59 -0400 Subject: [PATCH 72/77] fix: properly handle new default app --- tests/unit/buildpacks.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/buildpacks.bats b/tests/unit/buildpacks.bats index c45794699..f5e374c81 100644 --- a/tests/unit/buildpacks.bats +++ b/tests/unit/buildpacks.bats @@ -268,7 +268,7 @@ teardown() { echo "status: $status" assert_success - run /bin/bash -c "dokku buildpacks:set $TEST_APP https://github.com/heroku/heroku-buildpack-nodejs" + run /bin/bash -c "dokku buildpacks:set $TEST_APP https://github.com/dokku/buildpack-null" echo "output: $output" echo "status: $status" assert_success @@ -286,7 +286,7 @@ teardown() { run /bin/bash -c "dokku ps:rebuild $TEST_APP" echo "output: $output" echo "status: $status" - assert_success + assert_failure run destroy_app echo "output: $output" From 5ad7ece8d3791d874eb88582b6bd777de5f31566 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 20:35:11 -0400 Subject: [PATCH 73/77] chore: split out nginx-vhosts tests --- tests/unit/nginx-vhosts_6.bats | 108 ---------------------------- tests/unit/nginx-vhosts_8.bats | 125 +++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 108 deletions(-) create mode 100644 tests/unit/nginx-vhosts_8.bats diff --git a/tests/unit/nginx-vhosts_6.bats b/tests/unit/nginx-vhosts_6.bats index efde0a5d8..0ff29f4e5 100644 --- a/tests/unit/nginx-vhosts_6.bats +++ b/tests/unit/nginx-vhosts_6.bats @@ -24,114 +24,6 @@ teardown() { assert_failure } -@test "(nginx-vhosts) logging" { - deploy_app - - run [ -a "/var/log/nginx/$TEST_APP-access.log" ] - echo "output: $output" - echo "status: $status" - assert_success - - run [ -a "/var/log/nginx/$TEST_APP-error.log" ] - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:access-logs $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:error-logs $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success -} - -@test "(nginx-vhosts) log-path" { - deploy_app - - run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path off" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" - - run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" 0 - - run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path off" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" - - run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:build-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku nginx:show-config $TEST_APP" - echo "output: $output" - echo "status: $status" - assert_output_contains "off;" 0 -} - -@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" { - setup_test_tls - add_domain "node-js-app.dokku.me" - add_domain "test.dokku.me" - deploy_app - dokku nginx:show-config $TEST_APP - assert_ssl_domain "node-js-app.dokku.me" - assert_http_redirect "http://test.dokku.me" "https://test.dokku.me:443/" -} - -@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" { - setup_test_tls wildcard - add_domain "wildcard1.dokku.me" - add_domain "wildcard2.dokku.me" - deploy_app - dokku nginx:show-config $TEST_APP - assert_ssl_domain "wildcard1.dokku.me" - assert_ssl_domain "wildcard2.dokku.me" -} - @test "(nginx-vhosts) nginx:set hsts" { setup_test_tls wildcard local HSTS_CONF="/home/dokku/${TEST_APP}/nginx.conf.d/hsts.conf" diff --git a/tests/unit/nginx-vhosts_8.bats b/tests/unit/nginx-vhosts_8.bats new file mode 100644 index 000000000..c90095a02 --- /dev/null +++ b/tests/unit/nginx-vhosts_8.bats @@ -0,0 +1,125 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + global_setup + [[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak" + [[ -f "$DOKKU_ROOT/HOSTNAME" ]] && cp -fp "$DOKKU_ROOT/HOSTNAME" "$DOKKU_ROOT/HOSTNAME.bak" + create_app +} + +teardown() { + destroy_app 0 $TEST_APP + [[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST" + [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" && chown dokku:dokku "$DOKKU_ROOT/HOSTNAME" + global_teardown +} + +@test "(nginx-vhosts) logging" { + deploy_app + + run [ -a "/var/log/nginx/$TEST_APP-access.log" ] + echo "output: $output" + echo "status: $status" + assert_success + + run [ -a "/var/log/nginx/$TEST_APP-error.log" ] + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:access-logs $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:error-logs $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success +} + +@test "(nginx-vhosts) log-path" { + deploy_app + + run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path off" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" + + run /bin/bash -c "dokku nginx:set $TEST_APP access-log-path" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" 0 + + run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path off" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" + + run /bin/bash -c "dokku nginx:set $TEST_APP error-log-path" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:build-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku nginx:show-config $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_output_contains "off;" 0 +} + +@test "(nginx-vhosts) nginx:build-config (with SSL and unrelated domain)" { + setup_test_tls + add_domain "node-js-app.dokku.me" + add_domain "test.dokku.me" + deploy_app + dokku nginx:show-config $TEST_APP + assert_ssl_domain "node-js-app.dokku.me" + assert_http_redirect "http://test.dokku.me" "https://test.dokku.me:443/" +} + +@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" { + setup_test_tls wildcard + add_domain "wildcard1.dokku.me" + add_domain "wildcard2.dokku.me" + deploy_app + dokku nginx:show-config $TEST_APP + assert_ssl_domain "wildcard1.dokku.me" + assert_ssl_domain "wildcard2.dokku.me" +} From 59f1ba20db8f421aebe0feea401dcf9bb5599a71 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 20:37:01 -0400 Subject: [PATCH 74/77] fix: switch to binary --- tests/unit/core_2.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/core_2.bats b/tests/unit/core_2.bats index 21a7d3e65..9a0de63d1 100644 --- a/tests/unit/core_2.bats +++ b/tests/unit/core_2.bats @@ -22,7 +22,7 @@ teardown() { @test "(core) run (with --options)" { deploy_app - run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version" + run /bin/bash -c "dokku --force --quiet run $TEST_APP python -V" echo "output: $output" echo "status: $status" assert_success From 564de7434bf70b7bad0db3d9446864874ff1d9d5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 20:48:16 -0400 Subject: [PATCH 75/77] fix: update tests for non-cache using app --- tests/unit/repo.bats | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/unit/repo.bats b/tests/unit/repo.bats index 9df856052..960836908 100644 --- a/tests/unit/repo.bats +++ b/tests/unit/repo.bats @@ -4,11 +4,9 @@ load test_helper setup() { global_setup - deploy_app } teardown() { - destroy_app global_teardown } @@ -27,11 +25,21 @@ teardown() { } @test "(repo) repo:gc, repo:purge-cache" { + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "dokku repo:gc $TEST_APP" echo "output: $output" echo "status: $status" assert_success + run /bin/bash -c "touch $DOKKU_ROOT/$TEST_APP/cache/derp" + echo "output: $output" + echo "status: $status" + assert_success + run /bin/bash -c "find $DOKKU_ROOT/$TEST_APP/cache -type f | wc -l | grep 0" echo "output: $output" echo "status: $status" @@ -44,4 +52,9 @@ teardown() { echo "output: $output" echo "status: $status" assert_success + + run destroy_app + echo "output: $output" + echo "status: $status" + assert_success } From a4c67d50eead38ccc587ded8a230a46153e38aac Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 20:58:36 -0400 Subject: [PATCH 76/77] chore: switch back to normal parallelism This brings us back full-circle, but with a better understanding of the underlying test suite. --- .circleci/config.yml | 95 +++++++------------------------------------- 1 file changed, 15 insertions(+), 80 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index db61097a4..1404cc33f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,26 +26,6 @@ commands: - run: name: dokku report command: dokku report - run-bats: - description: "Run bats tests" - parameters: - index: - type: string - steps: - - run: - shell: /bin/bash - command: | - mkdir -p test-results/bats - cd tests/unit - echo "executing tests: $(ls << parameters.index >>*.bats | xargs)" - sudo -E bats --formatter bats-format-junit -e -T -o ../../test-results/bats $(ls << parameters.index >>*.bats | xargs) - no_output_timeout: 60m - - store_artifacts: - path: ./test-results - destination: test-results - - store_test_results: - path: test-results - executors: default: @@ -78,15 +58,13 @@ jobs: DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker go-tests: executor: default - parameters: - index: - type: integer + parallelism: 4 steps: - init-tests - run: name: run pre-tests command: | - case << parameters.index >> in + case $CIRCLE_NODE_INDEX in 0) sudo -E make -e lint-ci go-tests ci-go-coverage ;; 1) sudo -E make -e deploy-test-checks-root deploy-test-config ;; 2) sudo -E make -e deploy-test-multi ;; @@ -96,13 +74,19 @@ jobs: path: ./coverage.out test: executor: default - parameters: - index: - type: string + parallelism: 4 steps: - init-tests - - run-bats: - index: << parameters.index >> + - run: + command: | + sudo -E make -e test-ci + no_output_timeout: 60m + shell: /bin/bash + - store_artifacts: + path: ./test-results + destination: test-results + - store_test_results: + path: test-results workflows: workflow: @@ -111,61 +95,12 @@ workflows: - docker-deploy-tests: requires: - build + - test - go-tests: - matrix: - parameters: - index: [0, 1, 2, 3] requires: - build - test - test: - matrix: - parameters: - index: - - app-json - - apps_1 - - apps_2 - - build-env - - buildpacks - - certs - - checks - - client - - config-oddities - - config - - core_1 - - core_2 - - core_3 - - docker-options - - domains - - events - - git_1 - - git_2 - - init - - network - - nginx-vhosts_1 - - nginx-vhosts_2 - - nginx-vhosts_3 - - nginx-vhosts_4 - - nginx-vhosts_5 - - nginx-vhosts_6 - - nginx-vhosts_7 - - plugin - - proxy - - ps-dockerfile-1 - - ps-dockerfile-2 - - ps-general - - ps-herokuish-1 - - ps-herokuish-2 - - repo - - report - - resource_1 - - resource_2 - - scheduler-docker-local - - ssh_keys - - storage - - tags - - tar - - trace - - version requires: - build + - go-tests From 726d55f7719b2819d3a835b8328c1e131af9cdbc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 20 Jun 2020 21:01:33 -0400 Subject: [PATCH 77/77] fix: get rid of circular dependency --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1404cc33f..e3c3476a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,7 +99,6 @@ workflows: - go-tests: requires: - build - - test - test: requires: - build