-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtesting.sh
More file actions
executable file
·144 lines (110 loc) · 5.75 KB
/
Copy pathtesting.sh
File metadata and controls
executable file
·144 lines (110 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
#region Container Variables ------------------------------------------------------------
# shellcheck disable=SC3040
set -o pipefail || true
set -eu
echo '## Local testing of docker container versions ##'
export INPUT_CONTAINER_NAME='firebirdsql'
export INPUT_FIREBIRD_DATABASE='my_database.fdb'
export INPUT_FIREBIRD_USER='my_user'
export INPUT_FIREBIRD_PASSWORD='my_password'
export INPUT_FIREBIRD_CONF='ConnectionTimeout=180,DeadlockTimeout=10'
export INPUT_NETWORK_NAME='fbtest'
export FIREBIRD_DATA='/var/lib/firebird/data',
#endregion -----------------------------------------------------------------------------
#region Functions ----------------------------------------------------------------------
export MI=0; INPUT_VERSION='';
msg() { MI=$((MI+1)) ; >&2 printf '\e[93m#%s \e[94m#%d\e[0m %s\n' "${INPUT_VERSION}" "${MI}" "$*"; }
fail() { >&2 printf "\e[91m#%d\e[93m Failed\e[0m: %s ##\n" "${MI}" "$*" && exit 99; }
hr(){ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - ; }
ident() { sed -e 's/^/ /' ; }
require() { if command -v "${1:-}" >/dev/null; then msg "Found: ${1:-}"; else fail "Missing cmd line app: ${1:-}"; fi; }
remove_it() { docker rm --volumes --force "${INPUT_CONTAINER_NAME}" > /dev/null 2> /dev/null || true ; }
remove_net() { docker network rm "${INPUT_NETWORK_NAME}" > /dev/null 2> /dev/null || true ; }
#endregion -----------------------------------------------------------------------------
#region Main ---------------------------------------------------------------------------
require 'docker'
remove_it; remove_net
docker network create "${INPUT_NETWORK_NAME}" 2> /dev/null || true;
for INPUT_VERSION in latest 5 5.0.2 5-noble 5-jammy 4 4.0.5 3 3.0.12; do
MI=0; hr;
export INPUT_VERSION;
msg "Testing the docker container for FirebirdSQL server version: ${INPUT_VERSION}:"
if ! ./entrypoint.sh | ident; then
remove_it; remove_net
fail "error creating the container with version: ${INPUT_VERSION:-}";
fi
IP_ADDRESS="$( docker container inspect -f '{{.NetworkSettings.IPAddress}}' "${INPUT_CONTAINER_NAME}" )"
if [ -z "${IP_ADDRESS:-}" ]; then
IP_ADDRESS="$( docker container inspect -f "{{.NetworkSettings.Networks.${INPUT_NETWORK_NAME}.IPAddress}}" "${INPUT_CONTAINER_NAME}" )"
fi
if [ -z "${IP_ADDRESS:-}" ]; then
remove_it; remove_net
fail "unable to find the IP address of container version ${INPUT_VERSION:-} in the network ${INPUT_NETWORK_NAME:-}";
fi
msg "Querying the FirebirdSQL server inside the docker container at [${IP_ADDRESS}]..."
# shellcheck disable=SC2016
if ! echo 'SELECT * FROM rdb$database;' |
docker run -i --rm --name "${INPUT_CONTAINER_NAME}-client2" \
--network "${INPUT_NETWORK_NAME}" --env IP_ADDRESS="${IP_ADDRESS}" \
"firebirdsql/firebird:${INPUT_VERSION:-}" \
sh -c isql -bail -quiet -echo -merge -m2 -z \
-user "${INPUT_FIREBIRD_USER}" -password "${INPUT_FIREBIRD_PASSWORD}" \
"${IP_ADDRESS}:${FIREBIRD_DATA}/${INPUT_FIREBIRD_DATABASE}" | ident;
then
hr; remove_it; remove_net
fail "error connecting with version: ${INPUT_VERSION:-}";
fi
msg "Removing the FirebirdSQL server docker container...\n\n"
remove_it
done
hr; remove_net
msg '# Testing mapped volumes support ##'
VOLUME_HOST_DIR='/tmp/firebird-test-data'
VOLUME_CONTAINER_DIR='/var/lib/firebird/data'
sudo mkdir -p "${VOLUME_HOST_DIR}"
sudo chmod 777 "${VOLUME_HOST_DIR}"
export INPUT_VOLUMES="${VOLUME_HOST_DIR}:${VOLUME_CONTAINER_DIR}"
export INPUT_NETWORK_NAME='fbtest-vol'
docker network create "${INPUT_NETWORK_NAME}" 2> /dev/null || true;
for INPUT_VERSION in latest 5 4 3; do
MI=0; hr;
export INPUT_VERSION;
msg "Testing mapped volume for FirebirdSQL server version: ${INPUT_VERSION}:"
if ! ./entrypoint.sh | ident; then
remove_it; remove_net
fail "error creating the container with volumes and version: ${INPUT_VERSION:-}";
fi
IP_ADDRESS="$( docker container inspect -f '{{.NetworkSettings.IPAddress}}' "${INPUT_CONTAINER_NAME}" )"
if [ -z "${IP_ADDRESS:-}" ]; then
IP_ADDRESS="$( docker container inspect -f "{{.NetworkSettings.Networks.${INPUT_NETWORK_NAME}.IPAddress}}" "${INPUT_CONTAINER_NAME}" )"
fi
if [ -z "${IP_ADDRESS:-}" ]; then
remove_it; remove_net
fail "unable to find the IP address of container (with volumes) version ${INPUT_VERSION:-} in the network ${INPUT_NETWORK_NAME:-}";
fi
msg "Querying the FirebirdSQL server (with volume) inside the docker container at [${IP_ADDRESS}]..."
# shellcheck disable=SC2016
if ! echo 'SELECT * FROM rdb$database;' |
docker run -i --rm --name "${INPUT_CONTAINER_NAME}-client3" \
--network "${INPUT_NETWORK_NAME}" --env IP_ADDRESS="${IP_ADDRESS}" \
"firebirdsql/firebird:${INPUT_VERSION:-}" \
sh -c isql -bail -quiet -echo -merge -m2 -z \
-user "${INPUT_FIREBIRD_USER}" -password "${INPUT_FIREBIRD_PASSWORD}" \
"${IP_ADDRESS}:${VOLUME_CONTAINER_DIR}/${INPUT_FIREBIRD_DATABASE}" | ident;
then
hr; remove_it; remove_net
fail "error connecting (with volumes) with version: ${INPUT_VERSION:-}";
fi
msg "Verifying database file exists on host at [${VOLUME_HOST_DIR}/${INPUT_FIREBIRD_DATABASE}]..."
if [ ! -f "${VOLUME_HOST_DIR}/${INPUT_FIREBIRD_DATABASE}" ]; then
hr; remove_it; remove_net
fail "database file not found on host volume for version: ${INPUT_VERSION:-}";
fi
msg "Removing the FirebirdSQL server docker container (with volumes)...\n\n"
remove_it
done
hr; remove_net
msg '# Successfully Finished ##'
exit 0
#endregion -----------------------------------------------------------------------------