@cryptotaxi247 / netdata-1 / commits / ffb5791a4

CI runtime check cleanup (#16713)

* Centralize runtime check code used throughout CI. * Add checks to confirm that each of the agent dashboards can be fetched.

Austin S. Hemmelgarn committed Jan 17, 2024 at 08:24 UTC ffb5791a4fa8ef1fadbfc85fa9dea07f008419f3
4 files changed +62 -118
.github/scripts/docker-test.sh
+8 -42
@@ -1,41 +1,8 @@
1 #!/bin/sh
2
3 -export DEBIAN_FRONTEND=noninteractive
4 -
5 -wait_for() {
6 - host="${1}"
7 - port="${2}"
8 - name="${3}"
9 - timeout="30"
10 -
11 - if command -v nc > /dev/null ; then
12 - netcat="nc"
13 - elif command -v netcat > /dev/null ; then
14 - netcat="netcat"
15 - else
16 - printf "Unable to find a usable netcat command.\n"
17 - return 1
18 - fi
19 -
20 - printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
21 -
22 - sleep 30
3 +SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
4
24 - i=0
25 - while ! ${netcat} -z "${host}" "${port}"; do
26 - sleep 1
27 - if [ "$i" -gt "$timeout" ]; then
28 - printf "Timed out!\n"
29 - docker ps -a
30 - echo "::group::Netdata container logs"
31 - docker logs netdata 2>&1
32 - echo "::endgroup::"
33 - return 1
34 - fi
35 - i="$((i + 1))"
36 - done
37 - printf "OK\n"
38 -}
5 +export DEBIAN_FRONTEND=noninteractive
6
7 if [ -z "$(command -v nc 2>/dev/null)" ] && [ -z "$(command -v netcat 2>/dev/null)" ]; then
8 sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y netcat
@@ -55,10 +22,9 @@ docker run -d --name=netdata \
22 --security-opt apparmor=unconfined \
23 netdata/netdata:test
24
58 -wait_for localhost 19999 netdata || exit 1
59 -
60 -curl -sS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
61 -
62 -cat ./response
63 -
64 -jq '.version' ./response || exit 1
25 +if ! "${SCRIPT_DIR}/../../packaging/runtime-check.sh"; then
26 + docker ps -a
27 + echo "::group::Netdata container logs"
28 + docker logs netdata 2>&1
29 + echo "::endgroup::"
30 +fi
.github/scripts/pkg-test.sh
+3 -38
@@ -1,5 +1,7 @@
1 #!/bin/sh
2
3 +SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
4 +
5 install_debian_like() {
6 # This is needed to ensure package installs don't prompt for any user input.
7 export DEBIAN_FRONTEND=noninteractive
@@ -94,37 +96,6 @@ dump_log() {
96 cat ./netdata.log
97 }
98
97 -wait_for() {
98 - host="${1}"
99 - port="${2}"
100 - name="${3}"
101 - timeout="30"
102 -
103 - if command -v nc > /dev/null ; then
104 - netcat="nc"
105 - elif command -v netcat > /dev/null ; then
106 - netcat="netcat"
107 - else
108 - printf "Unable to find a usable netcat command.\n"
109 - return 1
110 - fi
111 -
112 - printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
113 -
114 - sleep 30
115 -
116 - i=0
117 - while ! ${netcat} -z "${host}" "${port}"; do
118 - sleep 1
119 - if [ "$i" -gt "$timeout" ]; then
120 - printf "Timed out!\n"
121 - return 1
122 - fi
123 - i="$((i + 1))"
124 - done
125 - printf "OK\n"
126 -}
127 -
99 case "${DISTRO}" in
100 debian | ubuntu)
101 install_debian_like
@@ -151,12 +122,6 @@ trap dump_log EXIT
122
123 /usr/sbin/netdata -D > ./netdata.log 2>&1 &
124
154 -wait_for localhost 19999 netdata || exit 1
155 -
156 -curl -sS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
157 -
158 -cat ./response
159 -
160 -jq '.version' ./response || exit 1
125 +"${SCRIPT_DIR}/../../packaging/runtime-check.sh" || exit 1
126
127 trap - EXIT
packaging/makeself/jobs/90-netdata-runtime-check.sh
+1 -38
@@ -8,47 +8,10 @@ dump_log() {
8 cat ./netdata.log
9 }
10
11 -wait_for() {
12 - host="${1}"
13 - port="${2}"
14 - name="${3}"
15 - timeout="30"
16 -
17 - if command -v nc > /dev/null ; then
18 - netcat="nc"
19 - elif command -v netcat > /dev/null ; then
20 - netcat="netcat"
21 - else
22 - printf "Unable to find a usable netcat command.\n"
23 - return 1
24 - fi
25 -
26 - printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
27 -
28 - sleep 30
29 -
30 - i=0
31 - while ! ${netcat} -z "${host}" "${port}"; do
32 - sleep 1
33 - if [ "$i" -gt "$timeout" ]; then
34 - printf "Timed out!\n"
35 - return 1
36 - fi
37 - i="$((i + 1))"
38 - done
39 - printf "OK\n"
40 -}
41 -
11 trap dump_log EXIT
12
13 "${NETDATA_INSTALL_PATH}/bin/netdata" -D > ./netdata.log 2>&1 &
14
46 -wait_for localhost 19999 netdata || exit 1
47 -
48 -curl -sS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
49 -
50 -cat ./response
51 -
52 -jq '.version' ./response || exit 1
15 +"${NETDATA_SOURCE_PATH}/packaging/runtime-check.sh" || exit 1
16
17 trap - EXIT
packaging/runtime-check.sh new
+50
@@ -0,0 +1,50 @@
1 +#!/bin/sh
2 +
3 +wait_for() {
4 + host="${1}"
5 + port="${2}"
6 + name="${3}"
7 + timeout="30"
8 +
9 + if command -v nc > /dev/null ; then
10 + netcat="nc"
11 + elif command -v netcat > /dev/null ; then
12 + netcat="netcat"
13 + else
14 + printf "Unable to find a usable netcat command.\n"
15 + return 1
16 + fi
17 +
18 + printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
19 +
20 + sleep 30
21 +
22 + i=0
23 + while ! ${netcat} -z "${host}" "${port}"; do
24 + sleep 1
25 + if [ "$i" -gt "$timeout" ]; then
26 + printf "Timed out!\n"
27 + return 2
28 + fi
29 + i="$((i + 1))"
30 + done
31 + printf "OK\n"
32 +}
33 +
34 +wait_for localhost 19999 netdata
35 +
36 +case $? in
37 + 1) exit 2 ;;
38 + 2) exit 3 ;;
39 +esac
40 +
41 +curl -sfS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
42 +
43 +cat ./response
44 +
45 +jq '.version' ./response || exit 1
46 +
47 +curl -sfS http://127.0.0.1:19999/index.html || exit 1
48 +curl -sfS http://127.0.0.1:19999/v0/index.html || exit 1
49 +curl -sfS http://127.0.0.1:19999/v1/index.html || exit 1
50 +curl -sfS http://127.0.0.1:19999/v2/index.html || exit 1