forked from topfreegames/pitaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (108 loc) · 5.11 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
TESTABLE_PACKAGES = `go list ./... | grep -v examples | grep -v constants | grep -v mocks | grep -v helpers | grep -v interfaces | grep -v protos | grep -v e2e | grep -v benchmark`
setup: init-submodules
@go get ./...
init-submodules:
@git submodule init
setup-ci:
@go get github.com/mattn/goveralls
@go get -u github.com/wadey/gocovmerge
setup-protobuf-macos:
@brew install protobuf
@go get github.com/golang/protobuf/protoc-gen-go
run-chat-example:
@cd examples/testing && docker-compose up -d etcd nats && cd ../demo/chat/ && go run main.go
run-cluster-example-frontend:
@PITAYA_METRICS_PROMETHEUS_PORT=9090 go run examples/demo/cluster/main.go
run-cluster-protobuf-frontend-example:
@cd examples/demo/cluster_protobuf && go run main.go
run-cluster-protobuf-backend-example:
@cd examples/demo/cluster_protobuf && go run main.go --port 3251 --type room --frontend=false
run-cluster-example-backend:
@PITAYA_METRICS_PROMETHEUS_PORT=9091 go run examples/demo/cluster/main.go --port 3251 --type room --frontend=false
run-cluster-grpc-example-connector:
@cd examples/demo/cluster_grpc && go run main.go
run-cluster-grpc-example-room:
@cd examples/demo/cluster_grpc && go run main.go --port 3251 --rpcsvport 3435 --type room --frontend=false
run-cluster-worker-example-room:
@cd examples/demo/worker && go run main.go --type room --frontend=true
run-cluster-worker-example-metagame:
@cd examples/demo/worker && go run main.go --type metagame --frontend=false
run-cluster-worker-example-worker:
@cd examples/demo/worker && go run main.go --type worker --frontend=false
run-custom-metrics-example:
@cd examples/demo/custom_metrics && go run main.go --port 3250
run-rate-limiting-example:
@go run examples/demo/rate_limiting/main.go
protos-compile:
@cd benchmark/testdata && ./gen_proto.sh
@protoc -I pitaya-protos/ pitaya-protos/*.proto --go_out=plugins=grpc:protos
@protoc -I pitaya-protos/test pitaya-protos/test/*.proto --go_out=protos/test
rm-test-temp-files:
@rm -f cluster/127.0.0.1* 127.0.0.1*
@rm -f cluster/localhost* localhost*
ensure-testing-bin:
@[ -f ./examples/testing/server ] || go build -o ./examples/testing/server ./examples/testing/main.go
ensure-testing-deps:
@cd ./examples/testing && docker-compose up -d
ensure-e2e-deps-grpc:
@cd ./examples/testing && docker-compose up -d etcd
kill-testing-deps:
@cd ./examples/testing && docker-compose down; true
e2e-test: e2e-test-nats e2e-test-grpc
e2e-test-nats: ensure-testing-deps ensure-testing-bin
@echo "===============RUNNING E2E NATS TESTS==============="
@go test ./e2e/e2e_test.go -update
e2e-test-grpc: ensure-testing-deps ensure-testing-bin
@echo "===============RUNNING E2E GRPC TESTS==============="
@go test ./e2e/e2e_test.go -update -grpc
bench-nats-sv:
@PITAYA_METRICS_PROMETHEUS_PORT=9098 ./examples/testing/server -type game -frontend=false > /dev/null 2>&1 & echo $$! > back.PID
@PITAYA_METRICS_PROMETHEUS_PORT=9099 ./examples/testing/server -type connector -frontend=true > /dev/null 2>&1 & echo $$! > front.PID
bench-grpc-sv:
@PITAYA_METRICS_PROMETHEUS_PORT=9098 ./examples/testing/server -grpc -grpcport=3435 -type game -frontend=false > /dev/null 2>&1 & echo $$! > back.PID
@PITAYA_METRICS_PROMETHEUS_PORT=9099 ./examples/testing/server -grpc -grpcport=3436 -type connector -frontend=true > /dev/null 2>&1 & echo $$! > front.PID
benchmark-test-nats: ensure-testing-deps ensure-testing-bin
@echo "===============RUNNING BENCHMARK TESTS WITH NATS==============="
@echo "--- starting testing servers"
@echo "--- sleeping for 5 seconds"
@make bench-nats-sv
@sleep 5
@go test ./benchmark/benchmark_test.go -bench=.
@echo "--- killing testing servers"
@kill `cat back.PID` && rm back.PID
@kill `cat front.PID` && rm front.PID
benchmark-test-grpc: ensure-e2e-deps-grpc ensure-testing-bin
@echo "===============RUNNING BENCHMARK TESTS WITH GRPC==============="
@echo "--- starting testing servers"
@echo "--- sleeping for 5 seconds"
@make bench-grpc-sv
@sleep 5
@go test ./benchmark/benchmark_test.go -bench=.
@echo "--- killing testing servers"
@kill `cat back.PID` && rm back.PID
@kill `cat front.PID` && rm front.PID
unit-test-coverage: kill-testing-deps
@echo "===============RUNNING UNIT TESTS==============="
@go test $(TESTABLE_PACKAGES) -coverprofile coverprofile.out
test: kill-testing-deps test-coverage
@make rm-test-temp-files
@make ensure-testing-deps
@sleep 10
@make e2e-test
test-coverage: unit-test-coverage
@make rm-test-temp-files
test-coverage-html: test-coverage
@go tool cover -html=coverprofile.out
merge-profiles:
@rm -f coverage-all.out
@gocovmerge *.out > coverage-all.out
test-coverage-func coverage-func: test-coverage merge-profiles
@echo
@echo "\033[1;34m=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\033[0m"
@echo "\033[1;34mFunctions NOT COVERED by Tests\033[0m"
@echo "\033[1;34m=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\033[0m"
@go tool cover -func=coverage-all.out | egrep -v "100.0[%]"
serializer-mock:
@mockgen github.com/tutumagi/pitaya/serialize Serializer | sed 's/mock_serialize/mocks/' > serialize/mocks/serializer.go
acceptor-mock:
@mockgen github.com/tutumagi/pitaya/acceptor Acceptor | sed 's/mock_acceptor/mocks/' > mocks/acceptor.go