github.com/devwanda/aphelion-staking@v0.33.9/tests.mk (about)

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