Skip to content

Commit 1f99589

Browse files
committed
Update tests for apache conatiner
1 parent 4f8be73 commit 1f99589

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ python:
1212
env:
1313
matrix:
1414
- DB=mysql:latest
15-
- DB=mariadb:10.2
15+
- DB=mariadb:latest
1616

1717
before_install:
1818
- export TESTSUITE_PASSWORD=`openssl rand -base64 30`
@@ -42,4 +42,5 @@ script:
4242
- docker-compose stop
4343
# Run tests in testing container
4444
- docker-compose -f docker-compose.testing.yml up -d phpmyadmin
45+
- docker-compose exec phpmyadmin /test-docker.sh test 80 db_server
4546
- ./testing/wait-for-testing.sh

docker-compose.testing.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@ version: '2'
33
services:
44
db_server:
55
image: ${DB}
6-
container_name: phpmyadmin_testing_mariadb
6+
container_name: phpmyadmin_testing_${DB}
77
environment:
8-
- MYSQL_ROOT_PASSWORD=test123
8+
- MYSQL_ROOT_PASSWORD=${TESTSUITE_PASSWORD}
99
volumes:
1010
- ./testing/testing.cnf:/etc/mysql/conf.d/testing.cnf:ro
1111

1212
phpmyadmin:
1313
build:
1414
context: testing/
15+
links:
16+
- db_server:db_server
1517
container_name: phpmyadmin_testing
1618
volumes:
1719
- /sessions
1820
ports:
1921
- 8090:80
2022
environment:
2123
- PMA_ARBITRARY=1
22-
- TESTSUITE_PASSWORD=test123
24+
- TESTSUITE_PASSWORD=${TESTSUITE_PASSWORD}
2325
depends_on:
2426
- db_server

testing/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
FROM phpmyadmin/phpmyadmin
44

55
# Install test dependencies
6-
RUN apk add --no-cache curl py2-pip
7-
RUN pip install mechanize html5lib
6+
RUN set -ex; \
7+
\
8+
apt-get update; \
9+
apt-get install -y --no-install-recommends \
10+
curl \
11+
python-pip \
12+
; \
13+
pip install mechanize html5lib; \
14+
rm -rf /var/lib/apt/lists/*
815

9-
COPY test.ini /etc/supervisor.d/
1016
COPY phpmyadmin_test.py test-docker.sh world.sql /

testing/phpmyadmin_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python2
22
import argparse
33
import os
44
import re

testing/test-docker.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if [ -f /.dockerenv ] ; then
3636

3737
# Wait for database to start
3838
TIMEOUT=0
39-
while ! curl "$PHPMYADMIN_DB_URL" &>/dev/null; do
39+
while [ $(docker logs db_server 2>&1 | fgrep -c "mysqld: ready for connections.") -le 0 ] ; do
4040
echo "Waiting for ${PHPMYADMIN_DB_HOSTNAME} database start..."
4141
sleep 10
4242
TIMEOUT=$((TIMEOUT + 1))
@@ -55,7 +55,7 @@ fi
5555

5656
# Wait for container to start
5757
TIMEOUT=0
58-
while ! $COMMAND_HOST ps aux | grep -q nginx ; do
58+
while [ $(docker logs ${NAME} 2>&1 | fgrep -c "Command line: 'apache2 -D FOREGROUND'") -le 0 ] ; do
5959
echo "Waiting for PHPMyAdmin start..."
6060
sleep 1
6161
TIMEOUT=$((TIMEOUT + 1))
@@ -76,17 +76,15 @@ if [ $ret -eq 0 ] ; then
7676
else
7777
FILENAME=./testing/phpmyadmin_test.py
7878
fi
79-
python $FILENAME --url "$PHPMYADMIN_URL" --username root --password $TESTSUITE_PASSWORD $SERVER
79+
python2 $FILENAME --url "$PHPMYADMIN_URL" --username root --password $TESTSUITE_PASSWORD $SERVER
8080
ret=$?
8181
fi
8282

8383
# Show debug output in case of failure
8484
if [ $ret -ne 0 ] ; then
8585
curl "$PHPMYADMIN_URL"
8686
$COMMAND_HOST ps faux
87-
$COMMAND_HOST cat /var/log/php-fpm.log
88-
$COMMAND_HOST cat /var/log/nginx-error.log
89-
$COMMAND_HOST cat /var/log/supervisord.log
87+
docker logs ${NAME}
9088
echo "Result of ${PHPMYADMIN_DB_HOSTNAME} tests: ${RED}FAILED${NC}"
9189
exit $ret
9290
fi

0 commit comments

Comments
 (0)