Merge pull request #250 from basecamp/integration-test-healthcheck-wget
Integration test healthcheck wget
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class Mrsk::Utils::HealthcheckPoller
|
class Mrsk::Utils::HealthcheckPoller
|
||||||
TRAEFIK_HEALTHY_DELAY = 1
|
TRAEFIK_HEALTHY_DELAY = 2
|
||||||
|
|
||||||
class HealthcheckError < StandardError; end
|
class HealthcheckError < StandardError; end
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,15 @@ class DeployTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_app_is_up
|
def assert_app_is_up
|
||||||
assert_equal "200", app_response.code
|
code = app_response.code
|
||||||
|
if code != "200"
|
||||||
|
puts "Got response code #{code}, here are the traefik logs:"
|
||||||
|
mrsk :traefik, :logs
|
||||||
|
puts "And here are the load balancer logs"
|
||||||
|
docker_compose :logs, :load_balancer
|
||||||
|
puts "Tried to get the response code again and got #{app_response.code}"
|
||||||
|
end
|
||||||
|
assert_equal "200", code
|
||||||
end
|
end
|
||||||
|
|
||||||
def app_response
|
def app_response
|
||||||
@@ -61,7 +69,10 @@ class DeployTest < ActiveSupport::TestCase
|
|||||||
def wait_for_healthy(timeout: 20)
|
def wait_for_healthy(timeout: 20)
|
||||||
timeout_at = Time.now + timeout
|
timeout_at = Time.now + timeout
|
||||||
while docker_compose("ps -a | tail -n +2 | grep -v '(healthy)' | wc -l", capture: true) != "0"
|
while docker_compose("ps -a | tail -n +2 | grep -v '(healthy)' | wc -l", capture: true) != "0"
|
||||||
|
if timeout_at < Time.now
|
||||||
|
docker_compose("ps -a | tail -n +2 | grep -v '(healthy)'")
|
||||||
raise "Container not healthy after #{timeout} seconds" if timeout_at < Time.now
|
raise "Container not healthy after #{timeout} seconds" if timeout_at < Time.now
|
||||||
|
end
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ FROM ruby:3.2
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y ca-certificates openssh-client curl gnupg docker.io
|
RUN apt-get update --fix-missing && apt-get install -y ca-certificates openssh-client curl gnupg docker.io
|
||||||
|
|
||||||
RUN install -m 0755 -d /etc/apt/keyrings
|
RUN install -m 0755 -d /etc/apt/keyrings
|
||||||
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
@@ -12,7 +12,7 @@ RUN echo \
|
|||||||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
|
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
|
||||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
RUN apt-get update --fix-missing && apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
|
||||||
COPY boot.sh .
|
COPY boot.sh .
|
||||||
COPY app/ .
|
COPY app/ .
|
||||||
|
|||||||
@@ -10,5 +10,8 @@ registry:
|
|||||||
builder:
|
builder:
|
||||||
multiarch: false
|
multiarch: false
|
||||||
healthcheck:
|
healthcheck:
|
||||||
path: /
|
cmd: wget -qO- http://localhost > /dev/null
|
||||||
port: 80
|
traefik:
|
||||||
|
args:
|
||||||
|
accesslog: true
|
||||||
|
accesslog.format: json
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ FROM ubuntu:22.10
|
|||||||
|
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y install openssh-client openssl
|
RUN apt-get update --fix-missing && apt-get -y install openssh-client openssl
|
||||||
|
|
||||||
RUN mkdir ssh && \
|
RUN mkdir ssh && \
|
||||||
ssh-keygen -t rsa -f ssh/id_rsa -N ""
|
ssh-keygen -t rsa -f ssh/id_rsa -N ""
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ FROM ubuntu:22.10
|
|||||||
|
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y install openssh-client openssh-server docker.io
|
RUN apt-get update --fix-missing && apt-get -y install openssh-client openssh-server docker.io
|
||||||
|
|
||||||
RUN mkdir /root/.ssh && ln -s /shared/ssh/id_rsa.pub /root/.ssh/authorized_keys
|
RUN mkdir /root/.ssh && ln -s /shared/ssh/id_rsa.pub /root/.ssh/authorized_keys
|
||||||
RUN mkdir -p /etc/docker/certs.d/registry:4443 && ln -s /shared/certs/domain.crt /etc/docker/certs.d/registry:4443/ca.crt
|
RUN mkdir -p /etc/docker/certs.d/registry:4443 && ln -s /shared/certs/domain.crt /etc/docker/certs.d/registry:4443/ca.crt
|
||||||
|
|||||||
Reference in New Issue
Block a user