Add post-deploy and post-rollback hooks

These replace the custom audit_broadcast_cmd code. An additional env
variable MRSK_RUNTIME is passed to them.

The audit broadcast after booting an accessory has been removed.
This commit is contained in:
Donal McBreen
2023-05-23 08:45:25 +01:00
parent 38023fe538
commit 9fd184dc32
18 changed files with 117 additions and 122 deletions

View File

@@ -0,0 +1,3 @@
#!/bin/sh
echo "Deployed!"
mkdir -p /tmp/${TEST_ID} && touch /tmp/${TEST_ID}/post-deploy

View File

@@ -0,0 +1,3 @@
#!/bin/sh
echo "Rolled back!"
mkdir -p /tmp/${TEST_ID} && touch /tmp/${TEST_ID}/post-rollback

View File

@@ -83,10 +83,10 @@ class IntegrationTest < ActiveSupport::TestCase
assert_equal version, response.body.strip
end
def assert_hooks_ran
[ "pre-build" ].each do |hook|
def assert_hooks_ran(*hooks)
hooks.each do |hook|
file = "/tmp/#{ENV["TEST_ID"]}/#{hook}"
assert_match /File: #{file}/, deployer_exec("stat #{file}", capture: true)
assert_equal "removed '#{file}'", deployer_exec("rm -v #{file}", capture: true).strip
end
end

View File

@@ -7,23 +7,20 @@ class MainTest < IntegrationTest
assert_app_is_down
mrsk :deploy
assert_hooks_ran
assert_app_is_up version: first_version
assert_hooks_ran "pre-build", "post-deploy"
second_version = update_app_rev
mrsk :redeploy
assert_app_is_up version: second_version
assert_hooks_ran "pre-build", "post-deploy"
mrsk :rollback, first_version
assert_hooks_ran "post-rollback"
assert_app_is_up version: first_version
details = mrsk :details, capture: true
assert_match /Traefik Host: vm1/, details
assert_match /Traefik Host: vm2/, details
assert_match /App Host: vm1/, details
@@ -32,7 +29,6 @@ class MainTest < IntegrationTest
assert_match /registry:4443\/app:#{first_version}/, details
audit = mrsk :audit, capture: true
assert_match /Booted app version #{first_version}.*Booted app version #{second_version}.*Booted app version #{first_version}.*/m, audit
end