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.

94 lines
2.7 KiB

  1. # Integrations tests
  2. Integration tests can be run with make commands for the
  3. appropriate backends, namely:
  4. ```shell
  5. make test-mysql
  6. make test-pgsql
  7. make test-sqlite
  8. ```
  9. Make sure to perform a clean build before running tests:
  10. ```
  11. make clean build
  12. ```
  13. ## Run all tests via local drone
  14. ```
  15. drone exec --local --build-event "pull_request"
  16. ```
  17. ## Run sqlite integrations tests
  18. Start tests
  19. ```
  20. make test-sqlite
  21. ```
  22. ## Run mysql integrations tests
  23. Setup a mysql database inside docker
  24. ```
  25. 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)
  26. docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --rm --name elasticsearch elasticsearch:7.6.0 #(in a secound terminal, just ctrl-c to stop db and clean the container)
  27. ```
  28. Start tests based on the database container
  29. ```
  30. TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql
  31. ```
  32. ## Run pgsql integrations tests
  33. Setup a pgsql database inside docker
  34. ```
  35. docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container)
  36. ```
  37. Start tests based on the database container
  38. ```
  39. TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
  40. ```
  41. ## Run mssql integrations tests
  42. Setup a mssql database inside docker
  43. ```
  44. 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)
  45. ```
  46. Start tests based on the database container
  47. ```
  48. TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql
  49. ```
  50. ## Running individual tests
  51. Example command to run GPG test:
  52. For sqlite:
  53. ```
  54. make test-sqlite#GPG
  55. ```
  56. For other databases(replace MSSQL to MYSQL, MYSQL8, PGSQL):
  57. ```
  58. TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql#GPG
  59. ```
  60. ## Setting timeouts for declaring long-tests and long-flushes
  61. We appreciate that some testing machines may not be very powerful and
  62. the default timeouts for declaring a slow test or a slow clean-up flush
  63. may not be appropriate.
  64. You can either:
  65. * Within the test ini file set the following section:
  66. ```ini
  67. [integration-tests]
  68. SLOW_TEST = 10s ; 10s is the default value
  69. SLOW_FLUSH = 5S ; 5s is the default value
  70. ```
  71. * Set the following environment variables:
  72. ```bash
  73. GITEA_SLOW_TEST_TIME="10s" GITEA_SLOW_FLUSH_TIME="5s" make test-sqlite
  74. ```