Running the Test Suite under Docker - bschmalhofer/otobo-ideas GitHub Wiki

How to Run the Test Suite including the Selenium Tests

This page should give people that want to run the OTOBO test suite some pointers. Everything runs in on a single machine in Docker containers. The tests should run on a local build of the Docker images.

The special case of running with S3 backend is also covered here.

Here is a list of what we need to set up:

  • a Linux machine with Docker installed
  • an OTOBO installation, including
    • the database service
    • the web server
    • the OTOBO daemon
    • ElasticSearch
    • MinIO for testing the S3 backend
  • the test scripts themselves
  • a browser that is remote controllable for the Selenium tests, here we use a Chrome browser
  • one or two consoles where we can start the scripts and inspect the progress
  • Self signed certificates:
    • otobo_nginx-selfsigned.crt
    • otobo_nginx-selfsigned.key

First let's check our requirements. We need Git, Docker and Docker Compose. The minimal versions are documented in https://doc.otobo.org/manual/installation/stable/en/content/installation-docker.html#requirements. Furthermore install Remina on your machine for watching the Chrome browser via VNC.

Now let's create an installation with the current development version of OTOBO.

Creating local Docker images

  • mkdir ~/devel/OTOBO
  • cd ~/devel/OTOBO
  • git clone https://github.com/RotherOSS/otobo
  • cd ~/devel/OTOBO/otobo
  • git checkout rel-10_1
  • S3: activate S3 in Kernel/Config.pm.docker.dist
  • ./bin/docker/build_docker_images.sh # this takes a while, created images are tagged as local-10.1.x
  • docker images | grep local-10.1.x # verify that we have actually built the images
    • otobo-selenium-chrome local-10.1.x 7aca398f12ca 3 seconds ago 1.07GB
    • otobo-elasticsearch local-10.1.x 268b78510dae 6 seconds ago 720MB
    • otobo-nginx-kerberos-webproxy local-10.1.x 4f7bad32119e 7 seconds ago 248MB
    • otobo-nginx-webproxy local-10.1.x 08fbf647cc35 9 seconds ago 220MB
    • otobo-kerberos local-10.1.x 80c42c0ac8d6 11 seconds ago 1.8GB
    • otobo local-10.1.x a28138b89d62 55 seconds ago 1.79GB

Setting up and Starting Docker-Compose

Some extra flexibility can be earned by creating .env from a customized template. The code for the Docker setup changes only slowly, so we get away with fetching a single branch. See https://doc.otobo.org/manual/installation/stable/en/content/installation-docker.html .

  • cd ~/devel/OTOBO
  • git clone https://github.com/RotherOSS/otobo-docker.git --branch rel-10_1 --single-branch
  • cd ~/devel/OTOBO/otobo-docker
  • cp .docker_compose_env_https_selenium dot_env.m4
  • In dot_env.m4:
    • comment out the line: COMPOSE_PROJECT_NAME=otobo
    • uncomments the line: COMPOSE_PROJECT_NAME=otovar_PROJECT
    • For S3: add docker-compose/otobo-minio.yml to COMPOSE_FILE
    • set COMPOSE_PROJECT_NAME=otovar_PROJECTS
    • set OTOBO_WEB_PORT=81, as port 80 is often taken
    • set OTOBO_NGINX_SSL_CERTIFICATE=/etc/nginx/ssl/otobo_nginx-selfsigned.crt
    • set OTOBO_NGINX_SSL_CERTIFICATE_KEY=/etc/nginx/ssl/otobo_nginx-selfsigned.key
    • uncomment the remaining lines that contain the string otovar_
  • ./scripts/devel/generate_dot_env.sh --template dot_env.m4 --project=ototest --repository "" --tag local-10.1.x
    • This creates the .env file which holds the setup for Docker Compose
    • ignore the potential warning about .env not existing, the warning is emitted only the first time
  • Shut down old containers
    • otobo_show_project
    • ATTENTION: this deletes the database and the previous OTOBO installation
    • docker-compose down -v only when $COMPOSE_PROJECT_NAME is not set
    • shut down old ototest container
    • just to make sure that no old services are running
  • docker ps
    • check whether there other possibly conflicting container running
  • non-S3:
    • docker compose up -d
  • S3:
    • remove the opt_otobo volume from docker-compose/otobo-base.yml
    • docker compose up -d --scale web=4
  • docker-compose ps
    • ototest_daemon_1 /opt/otobo_install/entrypo ... Up (health: starting)
    • ototest_db_1 docker-entrypoint.sh --max ... Up (health: starting) 0.0.0.0:3307->3306/tcp,:::3307->3306/tcp
    • ototest_elastic_1 /bin/tini -- /usr/local/bi ... Up (health: starting) 9200/tcp, 9300/tcp
    • ototest_minio_1 /usr/bin/docker-entrypoint ... Up 0.0.0.0:9000->9000/tcp,:::9000->9000/tcp, 0.0.0.0:9001->9001/tcp,:::9001->9001/tcp
    • ototest_nginx_1 /docker-entrypoint.sh ngin ... Up (health: starting) 80/tcp, 0.0.0.0:81->8080/tcp, 0.0.0.0:443->8443/tcp
    • ototest_redis_1 docker-entrypoint.sh redis ... Up (health: starting) 6379/tcp
    • ototest_selenium-chrome_1 /opt/bin/entry_point.sh Up 4444/tcp, 0.0.0.0:5900->5900/tcp,:::5900->5900/tcp
    • ototest_web_1 /opt/otobo_install/entrypo ... Up (health: starting)

Aliases

alias otobo_docker_quick_setup='docker compose exec web bash -c "date ; hostname ; rm -f Kernel/Config/Files/ZZZAAuto.pm ; bin/docker/quick_setup.pl --db-password otobo_root --http-port 81 --activate-elasticsearch --add-user --add-admin-user --add-customer-user --add-calendar"'
alias otobo_docker_quick_setup_S3='PATH=$PATH:~/devel/OTOBO/minio ../../otobo/bin/docker/set_up_minio.sh ; docker compose exec web bash -c "date ; hostname ; rm -f Kernel/Config/Files/ZZZAAuto.pm ; bin/docker/quick_setup.pl --db-password otobo_root --http-port 81 --activate-elasticsearch --add-user --add-admin-user --add-customer-user --add-calendar --activate-sync-with-S3 "'
alias otobo_docker_test_suite="docker-compose stop daemon ; docker-compose exec web bash -c \" date ; hostname ; bin/docker/run_test_suite.sh\" ; date ; docker-compose start daemon"
alias otobo_docker_test_progress="docker-compose exec web bash -c \"stat -c 'created:  %w' prove_*.out ; stat -c 'modified: %y' prove_*.out ; wc -l prove_*.out ; grep '^not ok ' prove_*.out | grep -v -c '# TODO'\" ; ps waux | grep perl"

setting up OTOBO

The services should be running now, but we still need to do some setup before the test scripts can run. See the aliases above.

  • S3: otobo_docker_quick_setup_S3 this also creates the MinIO bucket and the MinIO user
  • no S3: otobo_docker_quick_setup_10_1
    • docker-compose exec: take COMPOSE_PROJECT_NAME either from the environment or from the default in .env
    • port is 81 because that value was set in .env
    • replace the DB password with the value from .env
    • quick_setup.pl is quicker than running the installer manually
    • activating Elasticsearch
    • adding a customer (tina/tina) and a calendar is useful during development
    • Finished running bin/docker/quick_setup.pl indicates success
    • S3: activate S3 related SysConfig settings

running the test suite

  • otobo_docker_test_suite
    • The daemon should not be running during the test suite, but test scripts might start it indepently
    • takes about 1.5 h on my notebook

tracking progress

Switch to another console or to another screen.

  • cd ~/devel/OTOBO/otobo-docker
  • otobo_docker_test_progress
  • Use Remina for watching Chrome. The host is localhost and the password is secret.
  • After the run docker cp ototest_web_1:/opt/otobo/prove_10.0.x_2021-06-02-140536.out .
    • use the file name from the command before

Cleaning up

  • docker-compose down -v

Getting out of a mess

Sometimes everything becomes messed up. Services don't shut down or start up properly. docker-proxy processes still run even if all containers are stopped. In this case try:

  • sudo service docker stop
  • sudo rm -f /var/lib/docker/network/files/local-kv.db
  • sudo service docker start

See https://stackoverflow.com/questions/39130263/docker-proxy-using-port-when-no-containers-are-running?utm_source=pocket_mylist

TODO:

  • copy the test report in a subfolder, this simplifies the docker cp command