You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.4KB

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