Skip to content

Commit

Permalink
ci: test monolithic scripts (#179)
Browse files Browse the repository at this point in the history
* ci: test monolithic scripts

* fix spawn

* sleep between backup and restore to allow container to come up
bytestream authored Feb 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f6665cb commit a57c11b
Showing 4 changed files with 119 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-compose-verify.yml
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ jobs:
-w "/v" \
koalaman/shellcheck \
-e SC1091 -e SC1117 \
setup.sh
*.sh
- name: docker compose config test
run: |
25 changes: 24 additions & 1 deletion .github/workflows/docker-monolithic-verify.yml
Original file line number Diff line number Diff line change
@@ -26,9 +26,32 @@ jobs:
-w "/v" \
koalaman/shellcheck \
-e SC1091 -e SC1117 \
setup.sh
*.sh
- name: docker compose config test
run: |
echo "" > .env
docker compose config
- name: install supportpal
run: |
bash setup.sh --local -n --host "http://localhost" --email "[email protected]"
docker compose up -d
sudo apt install -y expect
expect verify-install.exp
sleep 5
curl -fSL -o /tmp/test.txt http://localhost/
if ! grep -q "SupportPal" /tmp/test.txt; then
echo "ERROR: SupportPal is not loading via HTTP"
exit 3
fi
env:
SUPPORTPAL_LICENSE_KEY: "${{ secrets.SUPPORTPAL_MONO_LICENSE_KEY }}"

- name: test backup/restore
run: |
bash backup.sh
sleep 60
bash restore.sh
19 changes: 15 additions & 4 deletions templates/docker-monolithic/setup.sh
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@ usage="Options:
-n Run the command non interactively.
--local The script is being ran from the repository, so don't use CURL to download them.
-r,--ref= Git ref (commit sha, ref name, tag) to run the script on.
-H,--host= Domain name to use with SupportPal.
@@ -14,6 +16,7 @@ usage="Options:
"

# Options
local=0
interactive=1
host=
email=
@@ -23,6 +26,7 @@ while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) echo "$usage" ; exit 0 ;;
-n) interactive=0 ;;
--local) local=1 ;;
-H|--host) host="$2" ; shift ;;
-e|--email) email="$2" ; shift ;;
-r|--ref) ref="$2" ; shift ;;
@@ -186,13 +190,16 @@ create_volume() {
configure() {
# download docker-compose.yml example
printf "generating docker-compose.yml ... "
if [[ -f "docker-compose.yml" ]]; then
if [[ -f "docker-compose.yml" ]] && [[ "$local" -eq 0 ]]; then
echo
echo "error: $(pwd)/docker-compose.yml already exists. Delete the file and try again."
exit 1
fi
curl -fLsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/docker-compose.yml -o docker-compose.yml
curl -fLsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/docker-compose.override.yml -o docker-compose.override.yml

if [[ "$local" -eq 0 ]]; then
curl -fLsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/docker-compose.yml -o docker-compose.yml
curl -fLsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/docker-compose.override.yml -o docker-compose.override.yml
fi

echo "" > .env

@@ -221,7 +228,11 @@ configure() {
fi

# create volumes
bash <(curl -LsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/create_volumes.sh)
if [[ "$local" -eq 0 ]]; then
bash <(curl -LsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/create_volumes.sh)
else
bash create_volumes.sh
fi
}

check_memory() {
79 changes: 79 additions & 0 deletions templates/docker-monolithic/verify-install.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Mon Feb 5 13:07:01 2024
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.

set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}

#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# -Don


set timeout -1

match_max 100000

spawn docker compose exec supportpal bash -c {bash /init/init-helpdesk.sh}

expect "I Accept and Continue (yes/no)*:\r"
send -- "yes\r"

expect "SupportPal requires a valid license to function, please enter one below.*:*"
sleep 1
send "$env(SUPPORTPAL_LICENSE_KEY)\r"

expect "Email*:*"
send -- "[email protected]\r"

expect "Password*:*"
send -- "test\r"

expect "First Name*:*"
send -- "Joe\r"

expect "Last Name*:*"
send -- "Blogs\r"

expect "Brand Name*:*"
send -- "My Company\r"

expect "Enter the full web address of your installation*:*"
send -- "http://localhost\r"

expect "Enter your main company email address*:*"
send -- "[email protected]\r"

expect eof

0 comments on commit a57c11b

Please sign in to comment.