Skip to content

Commit fc7895b

Browse files
authored
Fix test suite issues (#65)
* use latest requests module instead of a pinned version * Fix compose file * use correct default verion * provide container_names for better handling in later steps * Fix test environment setup * remove sleep from make target `setup-phpipam` as database setup script waits on it's own * fix recognition of podman * Change run-on image for CI pipeline As `ubuntu-20.04` was deprecated and already removed we switched to `ubuntu-latest` instead. * Update python versions We removed python 3.7 and 3.8 from testing scope, as these versions are not supported by github actions. * Switch to setup-python@v3 * We need to upgrade docker-compose before every other step * Add latest phpipam version to matrix
1 parent 4467e52 commit fc7895b

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ on:
77
jobs:
88
e2e_tests:
99
name: end to end tests
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
phpipam-version: ['v1.4x', 'v1.5x']
14-
python-version: ['3.7.x', '3.8.x', '3.9.x', '3.10.x']
13+
phpipam-version: ['v1.4x', 'v1.5x', 'v1.6x', 'v1.7x']
14+
python-version: ['3.9.x', '3.10.x', '3.11.x', '3.12.0', '3.13.0']
1515
steps:
16+
- name: Upgrade docker-compose
17+
run: sudo apt-get install --upgrade docker-compose
1618
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
19+
- uses: actions/setup-python@v3
1820
with:
1921
python-version: ${{ matrix.python-version }}
2022
- name: setup phpipam

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ changelog-cli
33
flake8
44
flake8-colors
55
flake8-docstrings
6-
requests >=2.31,<3.0
6+
requests
77
inflection
88
twine
99
setuptools

tests/docker/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
IPAM_DATABASE_NAME: "phpipam"
1212
depends_on:
1313
- database
14+
container_name: phpipam_test_webserver
1415
database:
1516
image: mariadb:10.3.18
1617
ports:
@@ -20,3 +21,4 @@ services:
2021
MYSQL_USER: "phpipam"
2122
MYSQL_PASSWORD: "phpipamadmin"
2223
MYSQL_DATABASE: "phpipam"
24+
container_name: phpipam_test_db

tests/docker/setup_database.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ function info() {
99

1010
MYSQL_PING="mysqladmin ping -h ${DB_HOST:-127.0.0.1} -P ${DB_PORT:-3306} -u ${MYSQL_ROOT_USER:-root} -p${MYSQL_ROOT_PASSWORD:-rootpw}"
1111

12-
if grep -q podman <<< $(docker --version 2> /dev/null) ; then
12+
if grep -qi podman <<< $(docker version 2> /dev/null) ; then
1313
info "Podman is installed"
1414
DOCKER_CMD=$(which podman)
1515
fi
1616

17-
if "${DOCKER_CMD}" ps | grep -q docker_phpipam_1 && ! eval "${MYSQL_PING}" ; then
17+
if "${DOCKER_CMD}" ps | grep -q phpipam_test_webserver && ! eval "${MYSQL_PING}" ; then
1818

1919
info -n "Waiting for database connection "
2020
while ! eval "${MYSQL_PING}" ; do
@@ -26,10 +26,10 @@ fi
2626

2727
info "Database is up"
2828

29-
if [[ $(mysqlshow -u root -prootpw -h 127.0.0.1 -P 3306 phpipam | wc -l) -eq 5 ]] ; then
29+
if [[ $(mysqlshow -u root -prootpw -h 127.0.0.1 -P 3306 phpipam 2>/dev/null | wc -l) -eq 5 ]] ; then
3030

3131
info "Creating database ${DB_NAME:-phpipam}"
32-
${DOCKER_CMD} exec -ti docker_phpipam_1 sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' && ((init_result++))
32+
${DOCKER_CMD} exec -t phpipam_test_webserver sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' && ((init_result++))
3333

3434
info "Activating API"
3535
mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE settings SET api=1 WHERE id=1;" && ((init_result++))

0 commit comments

Comments
 (0)