-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (104 loc) · 3.36 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
OVAL := ./oval
IMAGE_NAME ?= ghcr.io/peng225/oval
BINDIR := bin
GO_FILES := $(shell find . -path './test' -prune -o -type f -name '*.go' -print)
MINIO_DATADIR := $(shell git rev-parse --show-toplevel)/test/data
MINIO_CERTDIR := $(shell git rev-parse --show-toplevel)/test/certs
CERTGEN_VERSION := v1.2.1
CERTGEN := $(BINDIR)/certgen-$(CERTGEN_VERSION)
GOLANGCI_LINT_VERSION := v1.56.2
GOLANGCI_LINT := $(BINDIR)/golangci-lint-$(GOLANGCI_LINT_VERSION)
S3_ENDPOINT ?= http://localhost:9000
CERT_CONFIG ?=
EXEC_TIME ?= 5s
COMMON_OPTIONS := --size 4k-12m --time $(EXEC_TIME) --num_obj 1024 --num_worker 4 --bucket "test-bucket,test-bucket2" --ope_ratio 8,8,8,1 --endpoint $(S3_ENDPOINT) --multipart_thresh 5m
$(OVAL): $(GO_FILES)
CGO_ENABLED=0 go build -o $@ -v
$(BINDIR):
mkdir -p $@
$(MINIO_DATADIR):
mkdir -p $@
$(MINIO_CERTDIR):
mkdir -p $@
.PHONY: image
image:
docker build . --file Dockerfile --tag $(IMAGE_NAME)
$(GOLANGCI_LINT): | $(BINDIR)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b . $(GOLANGCI_LINT_VERSION)
mv golangci-lint $(GOLANGCI_LINT)
.PHONY: lint
lint: | $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run
.PHONY: test
test: $(OVAL)
go test -v ./...
.PHONY: run
run: $(OVAL)
$(OVAL) $(COMMON_OPTIONS) $(CERT_CONFIG) --save test.json
$(OVAL) --time 3s --multipart_thresh 6m --log json --load test.json $(CERT_CONFIG)
.PHONY: run-multi-process
run-multi-process: $(OVAL)
make run-followers
sleep 1
make run-leader
.PHONY: run-leader
run-leader: $(OVAL)
$(OVAL) leader --follower_list "http://localhost:8080,http://localhost:8081,http://localhost:8082"\
$(COMMON_OPTIONS)
.PHONY: run-leader-with-config
run-leader-with-config: $(OVAL)
$(OVAL) leader --config test_config.json $(COMMON_OPTIONS)
.PHONY: run-followers
run-followers: $(OVAL)
$(OVAL) follower --follower_port 8080 $(CERT_CONFIG) &
$(OVAL) follower --follower_port 8081 $(CERT_CONFIG) &
$(OVAL) follower --follower_port 8082 $(CERT_CONFIG) &
.PHONY: run-and-signal
run-and-signal: $(OVAL)
$(OVAL) $(COMMON_OPTIONS) $(CERT_CONFIG) &
sleep 2
kill -2 $$(pidof $(OVAL))
wait
.PHONY: run-leader-and-signal-follower
run-leader-and-signal-follower: $(OVAL)
$(OVAL) leader --follower_list "http://localhost:8080,http://localhost:8081,http://localhost:8082"\
$(COMMON_OPTIONS) &
sleep 2
FOLLOWER_PID=$$(ps aux | grep oval | grep follower_port | awk '{print $$2}' | head -n 1); \
kill $${FOLLOWER_PID}
wait
$(CERTGEN): | $(BINDIR)
wget https://github.com/minio/certgen/releases/download/$(CERTGEN_VERSION)/certgen-linux-amd64
mv certgen-linux-amd64 $@
chmod +x $@
.PHONY: keypair
keypair: $(CERTGEN) $(MINIO_CERTDIR)
$(CERTGEN) -host "127.0.0.1,localhost"
mv public.crt $(MINIO_CERTDIR)
mv private.key $(MINIO_CERTDIR)
.PHONY: start-minio
start-minio: | $(MINIO_DATADIR)
docker run \
--user $$(id -u):$$(id -g) \
-p 9000:9000 \
-p 9090:9090 \
--name minio \
-v $(MINIO_DATADIR):/data \
--rm -d \
minio/minio server /data --console-address ":9090"
.PHONY: start-minio-https
start-minio-https: keypair | $(MINIO_DATADIR)
docker run \
-p 9000:9000 \
-p 9090:9090 \
--name minio \
-v $(MINIO_DATADIR):/data \
-v $(MINIO_CERTDIR):/certs \
--rm -d \
minio/minio server /data --console-address ":9090" --certs-dir /certs
.PHONY: stop-minio
stop-minio:
docker stop minio
.PHONY: clean
clean:
rm -f $(OVAL) test.json