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.

138 lines
3.9 KiB

  1. #!/usr/bin/make -f
  2. ########################################
  3. ### Testing
  4. BINDIR ?= $(GOPATH)/bin
  5. ## required to be run first by most tests
  6. build_docker_test_image:
  7. docker build -t tester -f ./test/docker/Dockerfile .
  8. .PHONY: build_docker_test_image
  9. ### coverage, app, persistence, and libs tests
  10. test_cover:
  11. # run the go unit tests with coverage
  12. bash test/test_cover.sh
  13. .PHONY: test_cover
  14. test_apps:
  15. # run the app tests using bash
  16. # requires `abci-cli` and `tendermint` binaries installed
  17. bash test/app/test.sh
  18. .PHONY: test_apps
  19. test_abci_apps:
  20. bash abci/tests/test_app/test.sh
  21. .PHONY: test_abci_apps
  22. test_abci_cli:
  23. # test the cli against the examples in the tutorial at:
  24. # ./docs/abci-cli.md
  25. # if test fails, update the docs ^
  26. @ bash abci/tests/test_cli/test.sh
  27. .PHONY: test_abci_cli
  28. test_persistence:
  29. # run the persistence tests using bash
  30. # requires `abci-cli` installed
  31. docker run --name run_persistence -t tester bash test/persist/test_failure_indices.sh
  32. # TODO undockerize
  33. # bash test/persist/test_failure_indices.sh
  34. .PHONY: test_persistence
  35. test_p2p:
  36. docker rm -f rsyslog || true
  37. rm -rf test/logs && mkdir -p test/logs
  38. docker run -d -v "$(CURDIR)/test/logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog
  39. # requires 'tester' the image from above
  40. bash test/p2p/test.sh tester
  41. # the `docker cp` takes a really long time; uncomment for debugging
  42. #
  43. # mkdir -p test/p2p/logs && docker cp rsyslog:/var/log test/p2p/logs
  44. .PHONY: test_p2p
  45. test_p2p_ipv6:
  46. # IPv6 tests require Docker daemon with IPv6 enabled, e.g. in daemon.json:
  47. #
  48. # {
  49. # "ipv6": true,
  50. # "fixed-cidr-v6": "2001:db8:1::/64"
  51. # }
  52. #
  53. # Docker for Mac can set this via Preferences -> Docker Engine.
  54. docker rm -f rsyslog || true
  55. rm -rf test/logs && mkdir -p test/logs
  56. docker run -d -v "$(CURDIR)/test/logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog
  57. # requires 'tester' the image from above
  58. bash test/p2p/test.sh tester 6
  59. # the `docker cp` takes a really long time; uncomment for debugging
  60. #
  61. # mkdir -p test/p2p/logs && docker cp rsyslog:/var/log test/p2p/logs
  62. .PHONY: test_p2p_ipv6
  63. test_integrations:
  64. make build_docker_test_image
  65. make tools
  66. make install
  67. make test_cover
  68. make test_apps
  69. make test_abci_apps
  70. make test_abci_cli
  71. make test_libs
  72. make test_persistence
  73. make test_p2p
  74. # Disabled by default since it requires Docker daemon with IPv6 enabled
  75. #make test_p2p_ipv6
  76. .PHONY: test_integrations
  77. test_release:
  78. @go test -tags release $(PACKAGES)
  79. .PHONY: test_release
  80. test100:
  81. @for i in {1..100}; do make test; done
  82. .PHONY: test100
  83. vagrant_test:
  84. vagrant up
  85. vagrant ssh -c 'make test_integrations'
  86. .PHONY: vagrant_test
  87. ### go tests
  88. test:
  89. @echo "--> Running go test"
  90. @go test -p 1 $(PACKAGES)
  91. .PHONY: test
  92. test_race:
  93. @echo "--> Running go test --race"
  94. @go test -p 1 -v -race $(PACKAGES)
  95. .PHONY: test_race
  96. # uses https://github.com/sasha-s/go-deadlock/ to detect potential deadlocks
  97. test_with_deadlock:
  98. make set_with_deadlock
  99. make test
  100. make cleanup_after_test_with_deadlock
  101. .PHONY: test_with_deadlock
  102. set_with_deadlock:
  103. @echo "Get Goid"
  104. @go get github.com/petermattis/goid@b0b1615b78e5ee59739545bb38426383b2cda4c9
  105. @echo "Get Go-Deadlock"
  106. @go get github.com/sasha-s/go-deadlock@d68e2bc52ae3291765881b9056f2c1527f245f1e
  107. find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/sync.RWMutex/deadlock.RWMutex/'
  108. find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/sync.Mutex/deadlock.Mutex/'
  109. find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w
  110. .PHONY: set_with_deadlock
  111. # cleanes up after you ran test_with_deadlock
  112. cleanup_after_test_with_deadlock:
  113. find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/deadlock.RWMutex/sync.RWMutex/'
  114. find . -name "*.go" | grep -v "vendor/" | xargs -n 1 sed -i.bak 's/deadlock.Mutex/sync.Mutex/'
  115. find . -name "*.go" | grep -v "vendor/" | xargs -n 1 goimports -w
  116. # cleans up the deps to not include the need libs
  117. go mod tidy
  118. .PHONY: cleanup_after_test_with_deadlock