code.gitea.io/gitea@v1.21.7/tests/integration/README.md (about) 1 # Integration tests 2 3 Integration tests can be run with make commands for the 4 appropriate backends, namely: 5 ```shell 6 make test-sqlite 7 make test-pgsql 8 make test-mysql 9 make test-mysql8 10 make test-mssql 11 ``` 12 13 Make sure to perform a clean build before running tests: 14 ``` 15 make clean build 16 ``` 17 18 ## Run tests via local act_runner 19 20 ### Run all jobs 21 22 ``` 23 act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest 24 ``` 25 26 Warning: This file defines many jobs, so it will be resource-intensive and therefor not recommended. 27 28 ### Run single job 29 30 ```SHELL 31 act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest -j <job_name> 32 ``` 33 34 You can list all job names via: 35 36 ```SHELL 37 act_runner exec -W ./.github/workflows/pull-db-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest -l 38 ``` 39 40 ## Run sqlite integration tests 41 Start tests 42 ``` 43 make test-sqlite 44 ``` 45 46 ## Run MySQL integration tests 47 Setup a MySQL database inside docker 48 ``` 49 docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest #(just ctrl-c to stop db and clean the container) 50 docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --rm --name elasticsearch elasticsearch:7.6.0 #(in a second terminal, just ctrl-c to stop db and clean the container) 51 ``` 52 Start tests based on the database container 53 ``` 54 TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql 55 ``` 56 57 ## Run pgsql integration tests 58 Setup a pgsql database inside docker 59 ``` 60 docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container) 61 ``` 62 Start tests based on the database container 63 ``` 64 TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql 65 ``` 66 67 ## Run mssql integration tests 68 Setup a mssql database inside docker 69 ``` 70 docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container) 71 ``` 72 Start tests based on the database container 73 ``` 74 TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql 75 ``` 76 77 ## Running individual tests 78 79 Example command to run GPG test: 80 81 For SQLite: 82 83 ``` 84 make test-sqlite#GPG 85 ``` 86 87 For other databases(replace `mssql` to `mysql`, `mysql8` or `pgsql`): 88 89 ``` 90 TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql#GPG 91 ``` 92 93 ## Setting timeouts for declaring long-tests and long-flushes 94 95 We appreciate that some testing machines may not be very powerful and 96 the default timeouts for declaring a slow test or a slow clean-up flush 97 may not be appropriate. 98 99 You can either: 100 101 * Within the test ini file set the following section: 102 103 ```ini 104 [integration-tests] 105 SLOW_TEST = 10s ; 10s is the default value 106 SLOW_FLUSH = 5S ; 5s is the default value 107 ``` 108 109 * Set the following environment variables: 110 111 ```bash 112 GITEA_SLOW_TEST_TIME="10s" GITEA_SLOW_FLUSH_TIME="5s" make test-sqlite 113 ```