Skip to content

Commit

Permalink
Tidy up end-to-end tests
Browse files Browse the repository at this point in the history
* Only use a production installation of the plugin when using within WordPress to have tests of compose changes.
* Rename files for consistency.
* Tag the PHP image and name the container to avoid nameless resources, also make sure the image is deleted after each run.
  • Loading branch information
Jack-Dane committed Jun 15, 2024
1 parent c2ae161 commit 5a2b7af
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
27 changes: 11 additions & 16 deletions runE2ETests.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
#!/bin/bash

docker compose -f tests/end_to_end_tests/compose.yaml rm -f --volumes --stop
docker compose -f tests/end_to_end_tests/compose.yaml up --force-recreate --build --wait
docker compose -f tests/end_to_end_tests/wordpress-compose.yaml rm -f --volumes --stop
docker compose -f tests/end_to_end_tests/wordpress-compose.yaml up --force-recreate --build --wait

echo "Waiting for WP containers to start"
sleep 30

echo "Starting PHP container"
dockerPHPImageId=$(docker build -f tests/end_to_end_tests/php-composer-dockerfile . -q)
dockerPHPImageId=$(docker build -t cf7-odoo-connector-php -f tests/end_to_end_tests/php-composer-dockerfile . -q)
dockerPHPContainerId=$(docker container run -d --network=host ${dockerPHPImageId} tail -f /dev/null)

echo "Installing Vendor"
# no-cache because the container fails to create directories when cloning
# from git eg:
# could not create leading directories of
# '/.composer/cache/vcs/https ---github.com-bovigo-vfsStream.git'
docker exec $dockerPHPContainerId /bin/sh -c 'cd /opt/odoo_conn; composer install --no-cache'

echo "Running Endpoint Tests"
docker exec $dockerPHPContainerId /bin/sh -c 'cd /opt/odoo_conn; vendor/bin/phpunit tests/end_to_end_tests/tests/endpoint_tests'

echo "Running Selenium Tests"
dockerSeleniumContainerId=$(docker run -d --rm -it --network host --shm-size 2g selenium/standalone-chrome)
docker compose -f tests/end_to_end_tests/odoo_compose.yaml rm -f --volumes --stop
docker compose -f tests/end_to_end_tests/odoo_compose.yaml up --force-recreate --build --wait
docker compose -f tests/end_to_end_tests/odoo-compose.yaml rm -f --volumes --stop
docker compose -f tests/end_to_end_tests/odoo-compose.yaml up --force-recreate --build --wait

echo "Waiting for Odoo"
sleep 20
Expand All @@ -35,8 +28,10 @@ docker exec $dockerPHPContainerId /bin/sh -c 'cd /opt/odoo_conn; vendor/bin/phpu
docker exec $dockerPHPContainerId /bin/sh -c 'cd /opt/odoo_conn; vendor/bin/phpunit tests/end_to_end_tests/tests/selenium_tests/Delete_Test.php'

# cleanup the containers
docker compose -f tests/end_to_end_tests/odoo_compose.yaml rm -f --volumes --stop
docker compose --project-directory tests/end_to_end_tests rm -f --volumes --stop
docker compose -f tests/end_to_end_tests/odoo-compose.yaml rm -f --volumes --stop
docker compose -f tests/end_to_end_tests/wordpress-compose.yaml rm -f --volumes --stop

docker container rm -f $dockerPHPContainerId
docker container rm -f $dockerSeleniumContainerId

docker container rm --force $dockerPHPContainerId
docker container rm --force $dockerSeleniumContainerId
docker image rm $dockerPHPImageId
File renamed without changes.
13 changes: 10 additions & 3 deletions tests/end_to_end_tests/php-composer-dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Container with PHP + Composer
# syntax=docker/dockerfile:1.7-labs
FROM php:7.4-cli

RUN apt-get update
RUN apt-get -y install git unzip libzip-dev
RUN docker-php-ext-install zip

COPY . /opt/odoo_conn
COPY --exclude=vendor/ . /opt/odoo_conn
WORKDIR /opt/odoo_conn

COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=composer /usr/bin/composer /usr/bin/composer

# no-cache because the container fails to create directories when cloning
# from git eg:
# could not create leading directories of
# '/.composer/cache/vcs/https ---github.com-bovigo-vfsStream.git'
RUN composer install --no-cache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
restart: always
build:
context: .
dockerfile: wordpress_dockerfile
dockerfile: wordpress-dockerfile
ports:
- 8000:80
environment:
Expand All @@ -20,7 +20,7 @@ services:
source: ../../
target: /var/www/html/wp-content/plugins/odoo
# install composer before starting the apache server
command: '/bin/sh -c "cd /var/www/html/wp-content/plugins/odoo; composer install --no-cache; cd /var/www/html/; docker-entrypoint.sh apache2-foreground"'
command: '/bin/sh -c "cd /var/www/html/wp-content/plugins/odoo; composer install --no-cache --no-dev; cd /var/www/html/; docker-entrypoint.sh apache2-foreground"'

test_db:
restart: always
Expand Down
File renamed without changes.

0 comments on commit 5a2b7af

Please sign in to comment.