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