forked from dmwm/dbs2go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
233 lines (212 loc) · 8.85 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
VERSION=`git describe --tags`
flags=-ldflags="-s -w -X main.gitVersion=${VERSION}"
debug_flags=-ldflags="-X main.gitVersion=${VERSION}"
# we'll acquire architecture of the node and disable ORACLE libs for arm so far
# as there is no official ORACLE build on that architecture
arch:=$(shell uname -p)
ifeq ($(arch),arm)
odir=""
else
odir=`cat ${PKG_CONFIG_PATH}/oci8.pc | grep "libdir=" | sed -e "s,libdir=,,"`
endif
ifeq ($(arch),arm)
.IGNORE:
all: strip_oracle build restore_oracle
else
all: build
endif
vet:
go vet .
ORAFILES = web/server.go test/merge/main.go test/seq/seq.go test/http_test.go test/writer_test.go
strip_oracle:
$(info ### on $(arch) platform there is no ORALCE libs, we will disable their drivers from the build)
for f in $(ORAFILES); do \
sed -i -e "s,_ \"github.com/mattn/go-oci8\",//_ \"github.com/mattn/go-oci8\",g" $$f; \
sed -i -e "s,_ \"gopkg.in/rana/ora.v4\",//_ \"gopkg.in/rana/ora.v4\",g" $$f; \
rm $$f-e; \
done
restore_oracle: $(ORAFILES)
$(info ### on $(arch) platform there is no ORALCE libs, we will restore them after the build)
for f in $(ORAFILES); do \
sed -i -e "s,//_ \"github.com/mattn/go-oci8\",_ \"github.com/mattn/go-oci8\",g" $$f; \
sed -i -e "s,//_ \"gopkg.in/rana/ora.v4\",_ \"gopkg.in/rana/ora.v4\",g" $$f; \
rm $$f-e; \
done
build:
$(info ### building dbs2go executable on $(arch))
go clean; rm -rf pkg dbs2go*; go build ${flags}
@echo
.IGNORE:
build_no_oracle: strip_oracle build restore_oracle
build_debug:
go clean; rm -rf pkg dbs2go*; go build -gcflags=all="-N -l" ${debug_flags}
build_all: build build_osx build_osx_arm64 build_linux build_power8 build_arm64
build_osx:
go clean; rm -rf pkg dbs2go_osx; GOOS=darwin go build ${flags}
mv dbs2go dbs2go_osx_x86
build_osx_arm64:
go clean; rm -rf pkg dbs2go_osx; GOARCH=arm64 GOOS=darwin go build ${flags}
mv dbs2go dbs2go_osx_arm64
build_linux:
go clean; rm -rf pkg dbs2go_linux; GOOS=linux go build ${flags}
mv dbs2go dbs2go_linux
build_power8:
go clean; rm -rf pkg dbs2go_power8; GOARCH=ppc64le GOOS=linux go build ${flags}
mv dbs2go dbs2go_power8
build_arm64:
go clean; rm -rf pkg dbs2go_arm64; GOARCH=arm64 GOOS=linux go build ${flags}
mv dbs2go dbs2go_arm64
install:
go install
clean:
go clean; rm -rf pkg
ifeq ($(arch),arm)
test_all: test-dbs test-sql test-errors test-validator test-bulk test-http test-utils test-migrate test-writer test-integration test-lexicon bench
.IGNORE:
test: strip_oracle test_all restore_oracle
else
test: test-dbs test-sql test-errors test-validator test-bulk test-http test-utils test-migrate test-writer test-integration test-lexicon bench
endif
test-github: test-dbs test-sql test-errors test-validator test-bulk test-http test-utils test-writer test-lexicon test-integration test-migration-requests test-migration bench
test-lexicon: test-lexicon-writer-pos test-lexicon-writer-neg test-lexicon-reader-pos test-lexicon-reader-neg
test-errors:
cd test && LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} go test -v -run TestDBSError
test-dbs:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_DB_FILE=/tmp/dbs-test.db \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run TestDBS
test-bulk:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_DB_FILE=/tmp/dbs-test.db \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run Bulk
test-sql:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
DBS_DB_FILE=/tmp/dbs-test.db \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run SQL
test-validator:
cd test && LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
DBS_DB_FILE=/tmp/dbs-test.db \
go test -v -run Validator
test-http:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
DBS_DB_FILE=/tmp/dbs-test.db \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run HTTP
test-writer:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
DBS_DB_FILE=/tmp/dbs-test.db \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run DBSWriter
test-utils:
cd test && LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run Utils
test-migrate:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
DBS_DB_FILE=/tmp/dbs-test.db \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run Migrate
test-filelumis:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
DBS_DB_FILE=/tmp/dbs-test.db \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -v -run FileLumisInjection
test-lexicon-writer-pos:
cd test && LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_DB_FILE=/tmp/dbs-test.db \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
DBS_LEXICON_SAMPLE_FILE=../static/lexicon_writer_positive.json \
go test -v -run LexiconPositive
test-lexicon-writer-neg:
cd test && LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_DB_FILE=/tmp/dbs-test.db \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
DBS_LEXICON_SAMPLE_FILE=../static/lexicon_writer_negative.json \
go test -v -run LexiconNegative
test-lexicon-reader-pos:
cd test && LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_DB_FILE=/tmp/dbs-test.db \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_reader.json \
DBS_LEXICON_SAMPLE_FILE=../static/lexicon_reader_positive.json \
go test -v -run LexiconPositive
test-lexicon-reader-neg:
cd test && LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_DB_FILE=/tmp/dbs-test.db \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_reader.json \
DBS_LEXICON_SAMPLE_FILE=../static/lexicon_reader_negative.json \
go test -v -run LexiconNegative
test-integration:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
echo "\"sqlite3 /tmp/dbs-test.db sqlite\"" > ./dbfile && \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_READER_LEXICON_FILE=../static/lexicon_reader.json \
DBS_WRITER_LEXICON_FILE=../static/lexicon_writer.json \
DBS_DB_FILE=/tmp/dbs-test.db \
INTEGRATION_DATA_FILE=./data/integration/integration_data.json \
BULKBLOCKS_DATA_FILE=./data/integration/bulkblocks_data.json \
LARGE_BULKBLOCKS_DATA_FILE=./data/integration/largebulkblocks_data.json \
FILE_LUMI_LIST_LENGTH=30 \
go test -v -failfast -run Integration
test-migration:
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
./bin/start_test_migration && \
cd test && \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
BULKBLOCKS_DATA_FILE=./data/migration/bulkblocks_data.json \
go test -v -failfast -timeout 10m -run IntMigration
test-migration-requests:
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
./bin/start_test_migration && \
cd test && \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
MIGRATION_REQUESTS_PATH=./data/migration/requests \
go test -v -failfast -timeout 10m -run MigrationRequests
bench:
cd test && rm -f /tmp/dbs-test.db && \
sqlite3 /tmp/dbs-test.db < ../static/schema/sqlite-schema.sql && \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
DBS_DB_FILE=/tmp/dbs-test.db \
DBS_API_PARAMETERS_FILE=../static/parameters.json \
DBS_LEXICON_FILE=../static/lexicon_writer.json \
go test -run Benchmark -bench=.
test-race:
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
./bin/start_write_servers && \
cd test && \
LD_LIBRARY_PATH=${odir} DYLD_LIBRARY_PATH=${odir} \
MIGRATION_REQUESTS_PATH=./data/migration/requests \
INTEGRATION_DATA_FILE=./data/integration/integration_data.json \
go test -v -failfast -timeout 10m -run RaceConditions