Skip to content

Commit

Permalink
Merge pull request #657 from cytopia/release/v1.5.0
Browse files Browse the repository at this point in the history
Release v1.5.0
  • Loading branch information
cytopia authored Jan 4, 2020
2 parents 7d1d3ad + 75b6db7 commit dada924
Show file tree
Hide file tree
Showing 11 changed files with 619 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .devilbox/www/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');


$DEVILBOX_VERSION = 'v1.4.0';
$DEVILBOX_DATE = '2020-01-02';
$DEVILBOX_VERSION = 'v1.5.0';
$DEVILBOX_DATE = '2020-01-03';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';

//
Expand Down
391 changes: 391 additions & 0 deletions .devilbox/www/htdocs/vendor/ocp.php

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .devilbox/www/include/lib/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class Html
array(
'name' => 'Opcache GUI',
'path' => '/opcache.php'
),
array(
'name' => 'Opcache Control Panel',
'path' => '/vendor/ocp.php'
)
)
)
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci-smoke-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ jobs:
make test-smoke-framework-wordpress
if: success() || failure()

- name: "Test Container"
shell: bash
run: |
cd .tests/
make test-smoke-container
if: success() || failure()

# ------------------------------------------------------------
# Finish
# ------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ jobs:
make test-smoke-framework-wordpress
if: success() || failure()

- name: "Test Container"
shell: bash
run: |
cd .tests/
make test-smoke-container
if: success() || failure()

# ------------------------------------------------------------
# Finish
# ------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ jobs:
make test-smoke-framework-wordpress
if: success() || failure()

- name: "Test Container"
shell: bash
run: |
cd .tests/
make test-smoke-container
if: success() || failure()

# ------------------------------------------------------------
# Finish
# ------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions .tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ test-smoke-vendors:
$(PWD)/tests/vendor-phpmyadmin.sh
$(PWD)/tests/vendor-phppgadmin.sh
$(PWD)/tests/vendor-phpredmin.sh
$(PWD)/tests/vendor-ocp.sh


###
Expand Down Expand Up @@ -160,6 +161,13 @@ test-smoke-framework-wordpress:
$(PWD)/tests/framework-wordpress.sh


###
### Container
###
test-smoke-container:
$(PWD)/tests/container-mysql.sh


# -------------------------------------------------------------------------------------------------
# Helper Targets
# -------------------------------------------------------------------------------------------------
Expand Down
103 changes: 103 additions & 0 deletions .tests/tests/container-mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env bash

# NOTE: Parsing curl to tac to circumnvent "failed writing body"
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body

set -e
set -u
set -o pipefail

SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
# shellcheck disable=SC1090
. "${SCRIPT_PATH}/../scripts/.lib.sh"

RETRIES=10
DISABLED_VERSIONS=("")


echo
echo "# --------------------------------------------------------------------------------------------------"
echo "# [Container] MySQL"
echo "# --------------------------------------------------------------------------------------------------"
echo


# -------------------------------------------------------------------------------------------------
# Pre-check
# -------------------------------------------------------------------------------------------------

PHP_VERSION="$( get_php_version "${DVLBOX_PATH}" )"
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_VERSION} ]]; then
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_VERSION}"
exit 0
fi


# -------------------------------------------------------------------------------------------------
# ENTRYPOINT
# -------------------------------------------------------------------------------------------------

###
### Get required env values
###
MYSQL_ROOT_PASSWORD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "MYSQL_ROOT_PASSWORD" )"

DB_NAME="my_db"
TBL_NAME="my_table"

ROWS=2000 # how many insert statements
GROUPED=1000 # how many grouped inserts: INSERT INTO tbl VALUES ('1') ('2') ('3');
DATALEN=200 # Length of the data per value


# Install pipe viewer
run "docker-compose exec --user root -T php bash -c 'apt update && apt install -y pv'" "${RETRIES}" "${DVLBOX_PATH}"

# Drop database
run "docker-compose exec --user devilbox -T php bash -c 'mysql --host=mysql --user=root --password='\\''${MYSQL_ROOT_PASSWORD}'\\'' -e '\\''DROP DATABASE IF EXISTS ${DB_NAME};'\\'''" "${RETRIES}" "${DVLBOX_PATH}"

# Delete mysql.sql file
run "docker-compose exec --user devilbox -T php bash -c 'rm -f /home/devilbox/mysql.sql'" "${RETRIES}" "${DVLBOX_PATH}"

# Create SQL File
run "docker-compose exec --user devilbox -T php bash -c '
(
echo \"CREATE DATABASE ${DB_NAME} COLLATE '\\''utf8mb4_bin'\\'';\";
echo \"USE ${DB_NAME};\";
echo \"CREATE TABLE ${TBL_NAME} (
id int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
dt varchar(256) COLLATE '\\''utf8mb4_bin'\\'' NOT NULL
);\";
>&2 printf \"Creating random mysql.sql file: \";
for i in \$(seq ${ROWS}); do
MY_VAL=\$(openssl rand -hex ${DATALEN});
MY_VAL=\${MY_VAL:$((DATALEN-1))};
echo \"INSERT INTO ${TBL_NAME} (dt) VALUES\";
for num in \$( seq $((GROUPED-1)) ); do
echo \" ('\\''\${i}-\${num} \${MY_VAL}'\\''), \";
done
echo \" ('\\''\${i}-\${GROUPED} \${MY_VAL}'\\''); \";
>&2 printf \".\";
done;
) > /home/devilbox/mysql.sql
'" "${RETRIES}" "${DVLBOX_PATH}"
printf "\\n"
run "docker-compose exec --user devilbox -T php bash -c 'ls -lap /home/devilbox/mysql.sql'" "${RETRIES}" "${DVLBOX_PATH}"

# Import SQL file
run "docker-compose exec --user devilbox -T php bash -c 'pv -f -i 1 -p -t -e /home/devilbox/mysql.sql | mysql --host=mysql --user=root --password='\\''${MYSQL_ROOT_PASSWORD}'\\'''" "${RETRIES}" "${DVLBOX_PATH}"

# Compare inserted rows
COUNT="$( run "docker-compose exec --user devilbox -T php bash -c 'mysql --host=mysql --user=root --password='\\''${MYSQL_ROOT_PASSWORD}'\\'' -e '\\''SELECT COUNT(*) AS cnt FROM ${DB_NAME}.${TBL_NAME};'\\''' | grep -Ei '[0-9]+'" "1" "${DVLBOX_PATH}" )"
COUNT="$( echo "${COUNT}" | grep -Eo '[0-9]+' )"

if [ "${COUNT}" -ne "$(( ROWS * GROUPED ))" ]; then
>&2 echo "Error, Expected rows $(( ROWS * GROUPED )), found rows: ${COUNT}"
exit 1
fi
echo "Success, Expected rows $(( ROWS * GROUPED )), found rows: ${COUNT}"
81 changes: 81 additions & 0 deletions .tests/tests/vendor-ocp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

# NOTE: Parsing curl to tac to circumnvent "failed writing body"
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body

set -e
set -u
set -o pipefail

SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
# shellcheck disable=SC1090
. "${SCRIPT_PATH}/../scripts/.lib.sh"

RETRIES=10
DISABLED_VERSIONS=()


echo
echo "# --------------------------------------------------------------------------------------------------"
echo "# [Vendor] Opcache Control Panel"
echo "# --------------------------------------------------------------------------------------------------"
echo


# -------------------------------------------------------------------------------------------------
# Pre-check
# -------------------------------------------------------------------------------------------------

PHP_VERSION="$( get_php_version "${DVLBOX_PATH}" )"
if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_VERSION} ]]; then
printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_VERSION}"
exit 0
fi


# -------------------------------------------------------------------------------------------------
# ENTRYPOINT
# -------------------------------------------------------------------------------------------------

###
### Get required env values
###
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"


###
### Ensure Opcache Control Panel works
###
URL="/vendor/ocp.php"
printf "[TEST] Fetch %s" "${URL}"
if [ "$( run "\
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}${URL}' \
| tac \
| tac \
| grep -Ec 'Used Memory'" \
"${RETRIES}" "" "0" )" != "1" ]; then
printf "\\r[FAIL] Fetch %s\\n" "${URL}"
run "curl -sS 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
run "curl -sS -I 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
exit 1
else
printf "\\r[OK] Fetch %s\\n" "${URL}"
fi


URL="/vendor/ocp.php?FILES=1&GROUP=2&SORT=3"
printf "[TEST] Fetch %s" "${URL}"
if [ "$( run "\
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}${URL}' \
| tac \
| tac \
| grep -Ec 'files cached'" \
"${RETRIES}" "" "0" )" != "1" ]; then
printf "\\r[FAIL] Fetch %s\\n" "${URL}"
run "curl -sS 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
run "curl -sS -I 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
exit 1
else
printf "\\r[OK] Fetch %s\\n" "${URL}"
fi
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,6 @@ script:
retry make test-smoke-autostart &&
retry make test-smoke-framework-cakephp &&
retry make test-smoke-framework-drupal &&
retry make test-smoke-framework-wordpress;
retry make test-smoke-framework-wordpress &&
retry make test-smoke-container;
fi
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ major versions.
## Unreleased


## Release v1.5.0 (2020-01-03)

#### Added
- [#654](https://github.com/cytopia/devilbox/issues/654) Added Opcache Control Panel
- Integration tests for MySQL Docker image


## Release v1.4.0 (2020-01-02)

#### Fixed
Expand Down

0 comments on commit dada924

Please sign in to comment.