Skip to content

Commit d7b3994

Browse files
committed
Add a test for PMA_HOST
1 parent d91c4ba commit d7b3994

File tree

4 files changed

+83
-15
lines changed

4 files changed

+83
-15
lines changed

.github/workflows/run-tests.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
- uses: actions/checkout@v2
1717
- name: Build images
1818
run: docker-compose -f docker-compose.testing.yml build
19-
- name: Run tests
19+
- name: Run normal tests
2020
run: docker-compose -f docker-compose.testing.yml up --build --abort-on-container-exit --exit-code-from=sut
2121
env:
2222
DB: ${{ matrix.database-image }}
23+
- name: Run one host tests
24+
run: docker-compose -f docker-compose.testing-one-host.yml up --build --abort-on-container-exit --exit-code-from=sut
25+
env:
26+
DB: ${{ matrix.database-image }}

docker-compose.testing-one-host.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
version: "3.1"
2+
3+
services:
4+
db_server:
5+
image: ${DB:-mariadb:10.3}
6+
container_name: phpmyadmin_testing_db
7+
environment:
8+
MYSQL_ROOT_PASSWORD: "${TESTSUITE_PASSWORD:-my-secret-pw}"
9+
healthcheck:
10+
test: ["CMD", "mysqladmin", "ping", "-uroot", "-p${TESTSUITE_PASSWORD:-my-secret-pw}"]
11+
start_period: 5s
12+
interval: 5s
13+
timeout: 60s
14+
retries: 10
15+
networks:
16+
testing:
17+
volumes:
18+
- ./testing/testing.cnf:/etc/mysql/conf.d/testing.cnf:ro
19+
tmpfs:
20+
- /var/lib/mysql:rw,noexec,nosuid,size=300m
21+
22+
phpmyadmin:
23+
build:
24+
context: apache
25+
container_name: phpmyadmin_testing_apache
26+
environment:
27+
PMA_HOST: db_server
28+
UPLOAD_LIMIT: 123M
29+
MAX_EXECUTION_TIME: 125
30+
HIDE_PHP_VERSION: 1
31+
volumes:
32+
- ./testing/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
33+
healthcheck:
34+
test: ["CMD", "curl", "-Ss", "http://localhost/robots.txt"]
35+
start_period: 5s
36+
interval: 3s
37+
timeout: 60s
38+
retries: 10
39+
networks:
40+
testing:
41+
depends_on:
42+
db_server:
43+
condition: service_healthy
44+
45+
sut:
46+
depends_on:
47+
phpmyadmin:
48+
condition: service_healthy
49+
db_server:
50+
condition: service_healthy
51+
build:
52+
context: testing
53+
command: "/tests/testing/test-docker.sh"
54+
networks:
55+
testing:
56+
environment:
57+
TESTSUITE_HOSTNAME: phpmyadmin_testing_apache
58+
TESTSUITE_PORT: 80
59+
TESTSUITE_PASSWORD: "${TESTSUITE_PASSWORD:-my-secret-pw}"
60+
PMA_HOST: phpmyadmin_testing_db
61+
PMA_PORT: 3306
62+
volumes:
63+
- ./:/tests:ro
64+
- /var/run/docker.sock:/var/run/docker.sock
65+
working_dir: /tests
66+
67+
networks:
68+
testing:
69+
driver: bridge

docker-compose.testing.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ services:
5050
condition: service_healthy
5151
build:
5252
context: testing
53-
command: "/tests/testing/test-docker.sh 80 phpmyadmin_testing_db"
53+
command: "/tests/testing/test-docker.sh"
5454
networks:
5555
testing:
5656
environment:
57+
TESTSUITE_HOSTNAME_ARBITRARY: 1
5758
TESTSUITE_HOSTNAME: phpmyadmin_testing_apache
59+
PMA_HOST: phpmyadmin_testing_db
5860
TESTSUITE_PORT: 80
5961
TESTSUITE_PASSWORD: "${TESTSUITE_PASSWORD:-my-secret-pw}"
6062
volumes:

testing/test-docker.sh

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
#!/bin/sh
22

3-
if [ -n "$1" ] ; then
4-
TESTSUITE_PORT=$1
5-
fi
6-
7-
if [ -n "$2" ] ; then
8-
SERVER="--server $2"
9-
PMA_HOST=$2
10-
else
11-
SERVER=''
12-
fi
13-
14-
# Set PHPMyAdmin environment
3+
# Set phpMyAdmin environment
154
PHPMYADMIN_HOSTNAME=${TESTSUITE_HOSTNAME:=localhost}
165
PHPMYADMIN_PORT=${TESTSUITE_PORT:=80}
176
PHPMYADMIN_URL=http://${PHPMYADMIN_HOSTNAME}:${PHPMYADMIN_PORT}/
@@ -20,6 +9,10 @@ PHPMYADMIN_URL=http://${PHPMYADMIN_HOSTNAME}:${PHPMYADMIN_PORT}/
209
PHPMYADMIN_DB_HOSTNAME=${PMA_HOST:=localhost}
2110
PHPMYADMIN_DB_PORT=${PMA_PORT:=3306}
2211

12+
if [ ! -z "${TESTSUITE_HOSTNAME_ARBITRARY}" ]; then
13+
SERVER="--server ${PHPMYADMIN_DB_HOSTNAME}"
14+
fi
15+
2316
# Find test script
2417
if [ -f ./phpmyadmin_test.py ] ; then
2518
FILENAME=./phpmyadmin_test.py
@@ -31,7 +24,7 @@ mysql -h "${PHPMYADMIN_DB_HOSTNAME}" -P"${PHPMYADMIN_DB_PORT}" -u"${TESTSUITE_US
3124
ret=$?
3225

3326
if [ $ret -ne 0 ] ; then
34-
echo "Could not connect to ${PHPMYADMIN_DB_HOSTNAME}"
27+
echo "Could not connect to ${PHPMYADMIN_DB_HOSTNAME} on port ${PHPMYADMIN_DB_PORT}"
3528
exit $ret
3629
fi
3730

0 commit comments

Comments
 (0)