Make integration test app to deploy configurable

This commit is contained in:
Donal McBreen
2024-03-21 12:09:59 +00:00
parent 474b76cf47
commit ba40d026d0
4 changed files with 17 additions and 8 deletions

View File

@@ -50,6 +50,13 @@ services:
volumes: volumes:
- shared:/shared - shared:/shared
vm3:
privileged: true
build:
context: docker/vm
volumes:
- shared:/shared
load_balancer: load_balancer:
build: build:
context: docker/load_balancer context: docker/load_balancer

View File

@@ -1,6 +1,6 @@
FROM ruby:3.2 FROM ruby:3.2
WORKDIR /app WORKDIR /
ENV VERBOSE=true ENV VERBOSE=true
@@ -17,7 +17,7 @@ RUN echo \
RUN apt-get update --fix-missing && 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 *.sh . COPY *.sh .
COPY app/ . COPY app/ app/
RUN rm -rf /root/.ssh RUN rm -rf /root/.ssh
RUN ln -s /shared/ssh /root/.ssh RUN ln -s /shared/ssh /root/.ssh
@@ -25,7 +25,7 @@ RUN mkdir -p /etc/docker/certs.d/registry:4443 && ln -s /shared/certs/domain.crt
RUN git config --global user.email "deployer@example.com" RUN git config --global user.email "deployer@example.com"
RUN git config --global user.name "Deployer" RUN git config --global user.name "Deployer"
RUN git init && echo ".env" >> .gitignore && git add . && git commit -am "Initial version" RUN cd app && git init && echo ".env" >> .gitignore && git add . && git commit -am "Initial version"
HEALTHCHECK --interval=1s CMD pgrep sleep HEALTHCHECK --interval=1s CMD pgrep sleep

View File

@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
git commit -am 'Update rev' --amend cd $1 && git commit -am 'Update rev' --amend

View File

@@ -7,6 +7,7 @@ class IntegrationTest < ActiveSupport::TestCase
docker_compose "up --build -d" docker_compose "up --build -d"
wait_for_healthy wait_for_healthy
setup_deployer setup_deployer
@app = "app"
end end
teardown do teardown do
@@ -34,8 +35,9 @@ class IntegrationTest < ActiveSupport::TestCase
result result
end end
def deployer_exec(*commands, **options) def deployer_exec(*commands, workdir: nil, **options)
docker_compose("exec deployer #{commands.join(" ")}", **options) workdir ||= "/#{@app}"
docker_compose("exec --workdir #{workdir} deployer #{commands.join(" ")}", **options)
end end
def kamal(*commands, **options) def kamal(*commands, **options)
@@ -72,7 +74,7 @@ class IntegrationTest < ActiveSupport::TestCase
end end
def update_app_rev def update_app_rev
deployer_exec "./update_app_rev.sh" deployer_exec "./update_app_rev.sh #{@app}", workdir: "/"
latest_app_version latest_app_version
end end
@@ -115,7 +117,7 @@ class IntegrationTest < ActiveSupport::TestCase
end end
def setup_deployer def setup_deployer
deployer_exec("./setup.sh") unless $DEPLOYER_SETUP deployer_exec("./setup.sh", workdir: "/") unless $DEPLOYER_SETUP
$DEPLOYER_SETUP = true $DEPLOYER_SETUP = true
end end