Merge branch 'main' into fix/ssh-auth-methods
This commit is contained in:
@@ -2,6 +2,8 @@ require_relative "integration_test"
|
||||
|
||||
class AccessoryTest < IntegrationTest
|
||||
test "boot, stop, start, restart, logs, remove" do
|
||||
kamal :envify
|
||||
|
||||
kamal :accessory, :boot, :busybox
|
||||
assert_accessory_running :busybox
|
||||
|
||||
@@ -19,6 +21,8 @@ class AccessoryTest < IntegrationTest
|
||||
|
||||
kamal :accessory, :remove, :busybox, "-y"
|
||||
assert_accessory_not_running :busybox
|
||||
|
||||
kamal :env, :delete
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -2,6 +2,8 @@ require_relative "integration_test"
|
||||
|
||||
class AppTest < IntegrationTest
|
||||
test "stop, start, boot, logs, images, containers, exec, remove" do
|
||||
kamal :envify
|
||||
|
||||
kamal :deploy
|
||||
|
||||
assert_app_is_up
|
||||
|
||||
@@ -2,6 +2,8 @@ FROM ruby:3.2
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV VERBOSE=true
|
||||
|
||||
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
|
||||
@@ -23,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.name "Deployer"
|
||||
RUN git init && git add . && git commit -am "Initial version"
|
||||
RUN git init && echo ".env" >> .gitignore && git add . && git commit -am "Initial version"
|
||||
|
||||
HEALTHCHECK --interval=1s CMD pgrep sleep
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@ image: app
|
||||
servers:
|
||||
- vm1
|
||||
- vm2
|
||||
env:
|
||||
clear:
|
||||
CLEAR_TOKEN: '4321'
|
||||
secret:
|
||||
- SECRET_TOKEN
|
||||
|
||||
registry:
|
||||
server: registry:4443
|
||||
username: root
|
||||
@@ -12,7 +18,7 @@ builder:
|
||||
args:
|
||||
COMMIT_SHA: <%= `git rev-parse HEAD` %>
|
||||
healthcheck:
|
||||
cmd: wget -qO- http://localhost > /dev/null
|
||||
cmd: wget -qO- http://localhost > /dev/null || exit 1
|
||||
traefik:
|
||||
args:
|
||||
accesslog: true
|
||||
|
||||
@@ -2,6 +2,8 @@ require_relative "integration_test"
|
||||
|
||||
class LockTest < IntegrationTest
|
||||
test "acquire, release, status" do
|
||||
kamal :envify
|
||||
|
||||
kamal :lock, :acquire, "-m 'Integration Tests'"
|
||||
|
||||
status = kamal :lock, :status, capture: true
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
require_relative "integration_test"
|
||||
|
||||
class MainTest < IntegrationTest
|
||||
test "deploy, redeploy, rollback, details and audit" do
|
||||
test "envify, deploy, redeploy, rollback, details and audit" do
|
||||
kamal :envify
|
||||
assert_local_env_file "SECRET_TOKEN=1234"
|
||||
assert_remote_env_file "SECRET_TOKEN=1234\nCLEAR_TOKEN=4321"
|
||||
|
||||
first_version = latest_app_version
|
||||
|
||||
assert_app_is_down
|
||||
@@ -30,12 +34,9 @@ class MainTest < IntegrationTest
|
||||
|
||||
audit = kamal :audit, capture: true
|
||||
assert_match /Booted app version #{first_version}.*Booted app version #{second_version}.*Booted app version #{first_version}.*/m, audit
|
||||
end
|
||||
|
||||
test "envify" do
|
||||
kamal :envify
|
||||
|
||||
assert_equal "SECRET_TOKEN=1234", deployer_exec("cat .env", capture: true)
|
||||
kamal :env, :delete
|
||||
assert_no_remote_env_file
|
||||
end
|
||||
|
||||
test "config" do
|
||||
@@ -49,11 +50,23 @@ class MainTest < IntegrationTest
|
||||
assert_equal "registry:4443/app", config[:repository]
|
||||
assert_equal "registry:4443/app:#{version}", config[:absolute_image]
|
||||
assert_equal "app-#{version}", config[:service_with_version]
|
||||
assert_equal [], config[:env_args]
|
||||
assert_equal [], config[:volume_args]
|
||||
assert_equal({ user: "root", keepalive: true, keepalive_interval: 30, log_level: :fatal }, config[:ssh_options])
|
||||
assert_equal({ "multiarch" => false, "args" => { "COMMIT_SHA" => version } }, config[:builder])
|
||||
assert_equal [ "--log-opt", "max-size=\"10m\"" ], config[:logging]
|
||||
assert_equal({ "path" => "/up", "port" => 3000, "max_attempts" => 7, "cmd" => "wget -qO- http://localhost > /dev/null" }, config[:healthcheck])
|
||||
assert_equal({ "path" => "/up", "port" => 3000, "max_attempts" => 7, "exposed_port" => 3999, "cord"=>"/tmp/kamal-cord", "cmd"=>"wget -qO- http://localhost > /dev/null || exit 1" }, config[:healthcheck])
|
||||
end
|
||||
|
||||
private
|
||||
def assert_local_env_file(contents)
|
||||
assert_equal contents, deployer_exec("cat .env", capture: true)
|
||||
end
|
||||
|
||||
def assert_remote_env_file(contents)
|
||||
assert_equal contents, docker_compose("exec vm1 cat /root/.kamal/env/roles/app-web.env", capture: true)
|
||||
end
|
||||
|
||||
def assert_no_remote_env_file
|
||||
assert_equal "nofile", docker_compose("exec vm1 stat /root/.kamal/env/roles/app-web.env 2> /dev/null || echo nofile", capture: true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ require_relative "integration_test"
|
||||
|
||||
class TraefikTest < IntegrationTest
|
||||
test "boot, reboot, stop, start, restart, logs, remove" do
|
||||
kamal :envify
|
||||
|
||||
kamal :traefik, :boot
|
||||
assert_traefik_running
|
||||
|
||||
@@ -33,6 +35,8 @@ class TraefikTest < IntegrationTest
|
||||
|
||||
kamal :traefik, :remove
|
||||
assert_traefik_not_running
|
||||
|
||||
kamal :env, :delete
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user