Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.env
.env.example
.git
.gitignore
dist
images
test
docker-compose.yml
LICENSE
README-short.txt
*.md
/.env
/.env.example
/.git
/.gitignore
/dist
/docs
/images
/test
/docker-compose.yml
/LICENSE
/README-short.txt
/*.md
!README.md
**/*.mk
**/Makefile
**/Makefile
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.env
packages
dist
/.env
/dist
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@

Summary of release changes.

### 2.3.2 - Unreleased

- Deprecate Makefile target `logs-delayed`; replaced with `logsdef`.
- Updates source image to [2.6.1](https://github.com/jdeathe/centos-ssh/releases/tag/2.6.1).
- Updates `mysql-community-server` package to 5.7.27-1.
- Updates `psmisc` package to 22.20-16.
- Updates `test/health_status` helper script with for consistency.
- Updates Makefile target `logs` to accept `[OPTIONS]` (e.g `make -- logs -ft`).
- Updates info/error output for consistency.
- Updates healthcheck failure messages to remove EOL character that is rendered in status response.
- Updates wrapper script; only emit "waiting on" info message if bootstrap hasn't completed.
- Updates ordering of Tags and respective Dockerfile links in README.md for readability.
- Adds improved test workflow; added `test-setup` target to Makefile.
- Adds Makefile target `logsdef` to handle deferred logs output within a target chain.
- Adds `/docs` directory for supplementary documentation.
- Fixes validation failure of 0 second --timeout value in `test/health_status`.

### 2.3.1 - 2019-08-23

- Updates healthcheck script for consistency.
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jdeathe/centos-ssh:2.6.0
FROM jdeathe/centos-ssh:2.6.1

ARG RELEASE_VERSION="2.3.1"

Expand All @@ -19,11 +19,11 @@ RUN { printf -- \
&& yum -y install \
--setopt=tsflags=nodocs \
--disableplugin=fastestmirror \
mysql-community-client-5.7.26-1.el7 \
mysql-community-common-5.7.26-1.el7 \
mysql-community-libs-5.7.26-1.el7 \
mysql-community-server-5.7.26-1.el7 \
psmisc-22.20-15.el7 \
mysql-community-client-5.7.27-1.el7 \
mysql-community-common-5.7.27-1.el7 \
mysql-community-libs-5.7.27-1.el7 \
mysql-community-server-5.7.27-1.el7 \
psmisc-22.20-16.el7 \
sshpass-1.06-2.el7 \
&& yum versionlock add \
mysql-community-* \
Expand Down
45 changes: 38 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Targets:
images Show container's image details.
load Loads from the distribution package. Requires
DOCKER_IMAGE_TAG variable.
logs Display log output from the running container.
logs-delayed Display log output from the running container after
backing off for STARTUP_TIME seconds. This can be
necessary when chaining make targets together.
logs [OPTIONS] Display log output from the container.
logsdef Display log output from the container deferred for
STARTUP_TIME seconds. This will work in a chain
unlike the logs target.
logs-delayed [DEPRECATED] Replaced with logsdef.
pause Pause the running container.
pull Pull the release image from the registry. Requires
the DOCKER_IMAGE_TAG variable.
Expand All @@ -45,6 +46,7 @@ Targets:
stop Stop the container when in a running state.
terminate Unpause, stop and remove the container.
test Run all test cases.
test-setup Install test dependencies.
top [ps OPTIONS] Display the running processes of the container.
unpause Unpause the container when in a paused state.

Expand Down Expand Up @@ -161,6 +163,7 @@ endef
_require-docker-image-tag \
_require-docker-release-tag \
_require-package-path \
_require-root \
_test-prerequisites \
_usage \
all \
Expand All @@ -176,6 +179,7 @@ endef
images \
load \
logs \
logsdef \
logs-delayed \
pause \
pull \
Expand All @@ -191,6 +195,7 @@ endef
stop \
terminate \
test \
test-setup \
top \
unpause

Expand Down Expand Up @@ -365,9 +370,17 @@ _require-package-path:
exit 1; \
fi

_require-root:
@ if [[ $${EUID} -ne 0 ]]; \
then \
>&2 printf -- '%sMust be run as root\n' \
"$(PREFIX_STEP_NEGATIVE)"; \
exit 1; \
fi

_test-prerequisites:
ifeq ($(shpec),)
$(error "Please install shpec.")
$(error "Please install shpec. Try: DOCKER_NAME=$(DOCKER_NAME) make test-setup")
endif

_usage:
Expand Down Expand Up @@ -581,14 +594,20 @@ install: | \
logs: \
_prerequisites \
_require-docker-container
@ $(docker) logs $(DOCKER_NAME)
@ $(docker) logs \
$(filter-out $@, $(MAKECMDGOALS)) \
$(DOCKER_NAME)
%:; @:

logs-delayed: \
logsdef: \
_prerequisites \
_require-docker-container
@ sleep $(STARTUP_TIME)
@ $(MAKE) logs

logs-delayed: \
logsdef

load: \
_prerequisites \
_require-docker-release-tag \
Expand Down Expand Up @@ -980,6 +999,18 @@ test: \
"Functional test"
@ SHPEC_ROOT=$(SHPEC_ROOT) $(shpec)

test-setup: \
_require-root
@ printf -- '%s%s\n' \
"$(PREFIX_STEP)" \
"Installing shpec"
@ bash -c "$$(curl -LSs \
https://raw.githubusercontent.com/rylnd/shpec/master/install.sh \
)"
@ ln -sf \
/usr/local/bin/shpec \
/usr/bin/shpec

unpause: \
_prerequisites \
_require-docker-container \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Tags and respective `Dockerfile` links

- `centos-7-mysql57-community`, [`2.3.1`](https://github.com/jdeathe/centos-ssh-mysql/tree/2.3.1) [(centos-7-mysql57-community/Dockerfile)](https://github.com/jdeathe/centos-ssh-mysql/blob/centos-7-mysql57-community/Dockerfile)
- `centos-6`, [`1.11.1`](https://github.com/jdeathe/centos-ssh-mysql/tree/1.11.1) [(centos-6/Dockerfile)](https://github.com/jdeathe/centos-ssh-mysql/blob/centos-6/Dockerfile)
- [`2.3.1`](https://github.com/jdeathe/centos-ssh-mysql/tree/2.3.1), `centos-7-mysql57-community` [(centos-7-mysql57-community/Dockerfile)](https://github.com/jdeathe/centos-ssh-mysql/blob/centos-7-mysql57-community/Dockerfile)
- [`1.11.1`](https://github.com/jdeathe/centos-ssh-mysql/tree/1.11.1), `centos-6` [(centos-6/Dockerfile)](https://github.com/jdeathe/centos-ssh-mysql/blob/centos-6/Dockerfile)

## Overview

Expand Down
13 changes: 13 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Testing

## Functional

The functional test cases are written in [shpec](https://github.com/rylnd/shpec).

To run the tests use the `test` Makefile target after building.

> *Note:* You might need to run via sudo if your environment requires root privileges to run docker.

```
$ make build test
```
78 changes: 17 additions & 61 deletions src/usr/bin/healthcheck
Original file line number Diff line number Diff line change
Expand Up @@ -130,45 +130,6 @@ function __mysql_get_option ()
"${value:-$3}"
}

function __print_message ()
{
local -r quiet="${quiet:-false}"
local -r type="${1:-}"

local message="${2:-}"
local prefix

case "${type}" in
error)
prefix="ERROR: "
;;
info)
prefix="INFO: "
;;
*)
message="${type}"
;;
esac

if [[ ${quiet} == true ]] \
&& [[ ${type} != error ]]
then
return 0
elif [[ ${quiet} == true ]] \
&& [[ ${type} == error ]]
then
>&2 printf -- \
'%s%s\n' \
"${prefix}" \
"${message}"
else
printf -- \
'%s%s\n' \
"${prefix}" \
"${message}"
fi
}

function __record_exit_status ()
{
local -r status_directory="${status_path%/*}"
Expand Down Expand Up @@ -255,14 +216,14 @@ function main ()
__usage
break
;;
-i)
interval="${2}"
shift 2 || break
;;
--interval=*)
interval="${1#*=}"
shift 1
;;
-i|--interval)
interval="${2}"
shift 2 || break
;;
-q|--quiet)
quiet="true"
shift 1
Expand All @@ -275,26 +236,24 @@ function main ()

if [[ ! ${interval} =~ ${pattern_seconds_in_minute} ]]
then
__print_message \
"error" \
"Invalid interval."
>&2 printf -- \
'ERROR: %s invalid interval' \
"${0##*/}"
exit 1
fi

if ! ps axo command \
| grep -qE '^/usr/bin/python /usr/bin/supervisord'
then
__print_message \
"error" \
"supervisord not running."
>&2 printf -- \
"supervisord not running"
exit 1
fi

if [[ ${system_timezone} != "${zone}" ]]
then
__print_message \
"error" \
"system-timezone zone mismatch."
>&2 printf -- \
"system-timezone zone mismatch"
exit 1
fi

Expand All @@ -303,9 +262,8 @@ function main ()
if [[ -f /var/lock/subsys/mysqld-bootstrap ]] \
|| ! __is_mysql_data_directory_populated
then
__print_message \
"error" \
"Bootstrap failed to complete."
>&2 printf -- \
"bootstrap failed to complete"
exit 1
fi
fi
Expand All @@ -315,9 +273,8 @@ function main ()
if ! ps axo command \
| grep -qE "^${mysqld} "
then
__print_message \
"error" \
"Service process not running."
>&2 printf -- \
"service process not running"
exit 1
fi

Expand All @@ -337,9 +294,8 @@ function main ()

if ! __have_mysql_access
then
__print_message \
"error" \
"root@localhost access failed."
>&2 printf -- \
"root@localhost access failed"
exit 1
fi
fi
Expand Down
3 changes: 2 additions & 1 deletion src/usr/sbin/mysqld-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ function main ()
__get_proxy
)"

if [[ ${verbose} == true ]]
if [[ ${verbose} == true ]] \
&& [[ ! -f ${bootstrap_state_file} ]]
then
printf -- \
'INFO: %s waiting on %s\n' \
Expand Down
Loading