Skip to content

Commit c551d8d

Browse files
committed
fix tests
1 parent 6a7187e commit c551d8d

File tree

5 files changed

+104
-46
lines changed

5 files changed

+104
-46
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ jobs:
154154
runs-on: ubuntu-latest
155155
steps:
156156
- uses: actions/checkout@v4
157-
158157
- name: Set up Rust cache
159158
uses: Swatinem/rust-cache@v2
160159
with:

sdk/ahnlich-client-go/Makefile

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ JUNIT_VERSION := 2.1.0
1313
STATICCHECK_VERSION := 2025.1
1414
OUT_DIR := grpc
1515
TEST_DIR := $(shell realpath .)
16+
TEST_NUM_MODULE_BUILDS := 1
17+
TEST_NUM_PARALLEL := 20
18+
AHNLICH_DIR := $(shell realpath ../../ahnlich)
1619

1720
.PHONY: all \
1821
install-go-junit install-go-test-sum install-gofmt install-goimports \
@@ -164,13 +167,12 @@ pre-commit-check: format-check lint-check
164167

165168
.PHONY: help-bins
166169
help-bins:
167-
@echo "→ ahnlich-db help"
168-
@toml=$$(realpath ../../ahnlich/Cargo.toml) && \
169-
cargo run --manifest-path $$toml --bin ahnlich-db --help
170+
@echo "→ ahnlich build"
171+
pushd "$(AHNLICH_DIR)" && \
172+
cargo build && \
173+
echo "→ ahnlich build complete" && \
174+
popd
170175
@echo
171-
@echo "→ ahnlich-ai help"
172-
@toml=$$(realpath ../../ahnlich/Cargo.toml) && \
173-
cargo run --manifest-path $$toml --bin ahnlich-ai --help
174176

175177
test-sequential:
176178
make help-bins
@@ -179,18 +181,38 @@ ifeq ($(CI),1)
179181
endif
180182
ifneq ($(CACHE),1)
181183
ifeq ($(REPORT),1)
182-
CGO_ENABLED=0 go test -count=1 -p 1 -failfast -v $$(go list $(TEST_DIR)/...) && gotestsum --junitfile go.xml
184+
CGO_ENABLED=0 go test -count=1 -p $(TEST_NUM_MODULE_BUILDS) -failfast -v $$(go list $(TEST_DIR)/...) && gotestsum --junitfile go.xml
183185
else
184-
CGO_ENABLED=0 go test -count=1 -p 1 -failfast -v $$(go list $(TEST_DIR)/...)
186+
CGO_ENABLED=0 go test -count=1 -p $(TEST_NUM_MODULE_BUILDS) -failfast -v $$(go list $(TEST_DIR)/...)
185187
endif
186188
else
187189
ifeq ($(REPORT),1)
188-
CGO_ENABLED=0 go test -p 1 -failfast -v $$(go list $(TEST_DIR)/...) && gotestsum --junitfile go.xml
190+
CGO_ENABLED=0 go test -p $(TEST_NUM_MODULE_BUILDS) -failfast -v $$(go list $(TEST_DIR)/...) && gotestsum --junitfile go.xml
189191
else
190-
CGO_ENABLED=0 go test -p 1 -failfast -v $$(go list $(TEST_DIR)/...)
192+
CGO_ENABLED=0 go test -p $(TEST_NUM_MODULE_BUILDS) -failfast -v $$(go list $(TEST_DIR)/...)
191193
endif
192194
endif
193195

196+
test-parallel:
197+
make help-bins
198+
ifeq ($(CI),1)
199+
@export PATH=$$PATH:/usr/local/go/bin:$(shell go env GOPATH)/bin;
200+
endif
201+
ifneq ($(CACHE),1)
202+
ifeq ($(REPORT),1)
203+
CGO_ENABLED=0 go test -count=1 -parallel $(TEST_NUM_PARALLEL) -p $(TEST_NUM_MODULE_BUILDS) -failfast -v $$(go list $(TEST_DIR)/...) && gotestsum --junitfile go.xml
204+
else
205+
CGO_ENABLED=0 go test -count=1 -parallel $(TEST_NUM_PARALLEL) -p $(TEST_NUM_MODULE_BUILDS) -failfast -v $$(go list $(TEST_DIR)/...)
206+
endif
207+
else
208+
ifeq ($(REPORT),1)
209+
CGO_ENABLED=0 go test -p $(TEST_NUM_MODULE_BUILDS) -parallel $(TEST_NUM_PARALLEL) -failfast -v $$(go list $(TEST_DIR)/...) && gotestsum --junitfile go.xml
210+
else
211+
CGO_ENABLED=0 go test -p $(TEST_NUM_MODULE_BUILDS) -parallel $(TEST_NUM_PARALLEL) -failfast -v $$(go list $(TEST_DIR)/...)
212+
endif
213+
endif
214+
215+
194216
test-race:
195217
ifeq ($(CI),1)
196218
@export PATH=$$PATH:/usr/local/go/bin:$(shell go env GOPATH)/bin;
@@ -239,4 +261,4 @@ clean:
239261
rm -f $(PB_FILES) $(PBW_FILES) $(GRPC_PB_FILES)
240262
@echo "✅ Clean complete."
241263

242-
test: test-sequential
264+
test: test-parallel

sdk/ahnlich-client-go/tests/ai/ai_test.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ func startAI(t *testing.T) *utils.AhnlichProcess {
3232
}
3333

3434
// Helper to dial the AI gRPC server
35-
func dialAI(t *testing.T, addr string) *grpc.ClientConn {
36-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
37-
t.Cleanup(cancel)
35+
func dialAI(t *testing.T, addr string) (*grpc.ClientConn, context.CancelFunc) {
36+
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
3837
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithBlock())
3938
require.NoError(t, err)
40-
return conn
39+
return conn, cancel
4140
}
4241

4342
// Shared test data
@@ -62,7 +61,8 @@ var (
6261
func TestCreateStoreOK(t *testing.T) {
6362
proc := startAI(t)
6463
defer proc.Kill()
65-
conn := dialAI(t, proc.ServerAddr)
64+
conn, cancel := dialAI(t, proc.ServerAddr)
65+
defer cancel()
6666
defer conn.Close()
6767

6868
client := aisvc.NewAIServiceClient(conn)
@@ -73,7 +73,8 @@ func TestCreateStoreOK(t *testing.T) {
7373
func TestCreateStoreAlreadyExists(t *testing.T) {
7474
proc := startAI(t)
7575
defer proc.Kill()
76-
conn := dialAI(t, proc.ServerAddr)
76+
conn, cancel := dialAI(t, proc.ServerAddr)
77+
defer cancel()
7778
defer conn.Close()
7879
client := aisvc.NewAIServiceClient(conn)
7980

@@ -88,7 +89,8 @@ func TestCreateStoreAlreadyExists(t *testing.T) {
8889
func TestGetPredicates(t *testing.T) {
8990
proc := startAI(t)
9091
defer proc.Kill()
91-
conn := dialAI(t, proc.ServerAddr)
92+
conn, cancel := dialAI(t, proc.ServerAddr)
93+
defer cancel()
9294
defer conn.Close()
9395
client := aisvc.NewAIServiceClient(conn)
9496
_, _ = client.CreateStore(context.Background(), storeWithPred)
@@ -141,7 +143,8 @@ func TestGetPredicates(t *testing.T) {
141143
func TestCreateAndDropPredIndex(t *testing.T) {
142144
proc := startAI(t)
143145
defer proc.Kill()
144-
conn := dialAI(t, proc.ServerAddr)
146+
conn, cancel := dialAI(t, proc.ServerAddr)
147+
defer cancel()
145148
defer conn.Close()
146149
client := aisvc.NewAIServiceClient(conn)
147150

@@ -172,7 +175,8 @@ func TestCreateAndDropPredIndex(t *testing.T) {
172175
func TestDeleteAndGetKey(t *testing.T) {
173176
proc := startAI(t)
174177
defer proc.Kill()
175-
conn := dialAI(t, proc.ServerAddr)
178+
conn, cancel := dialAI(t, proc.ServerAddr)
179+
defer cancel()
176180
defer conn.Close()
177181
client := aisvc.NewAIServiceClient(conn)
178182

@@ -200,7 +204,8 @@ func TestDeleteAndGetKey(t *testing.T) {
200204
func TestListClients(t *testing.T) {
201205
proc := startAI(t)
202206
defer proc.Kill()
203-
conn := dialAI(t, proc.ServerAddr)
207+
conn, cancel := dialAI(t, proc.ServerAddr)
208+
defer cancel()
204209
defer conn.Close()
205210
client := aisvc.NewAIServiceClient(conn)
206211

@@ -212,7 +217,8 @@ func TestListClients(t *testing.T) {
212217
func TestPipelineSuccess(t *testing.T) {
213218
proc := startAI(t)
214219
defer proc.Kill()
215-
conn := dialAI(t, proc.ServerAddr)
220+
conn, cancel := dialAI(t, proc.ServerAddr)
221+
defer cancel()
216222
defer conn.Close()
217223
client := aisvc.NewAIServiceClient(conn)
218224

@@ -249,7 +255,8 @@ func TestPipelineSuccess(t *testing.T) {
249255
func TestPipelineError(t *testing.T) {
250256
proc := startAI(t)
251257
defer proc.Kill()
252-
conn := dialAI(t, proc.ServerAddr)
258+
conn, cancel := dialAI(t, proc.ServerAddr)
259+
defer cancel()
253260
defer conn.Close()
254261
client := aisvc.NewAIServiceClient(conn)
255262

sdk/ahnlich-client-go/tests/db/db_test.go

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ func startDB(t *testing.T) *utils.AhnlichProcess {
2727
}
2828

2929
// Helper to dial the DB gRPC server
30-
func dialDB(t *testing.T, addr string) *grpc.ClientConn {
31-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
32-
t.Cleanup(cancel)
30+
func dialDB(t *testing.T, addr string) (*grpc.ClientConn, context.CancelFunc) {
31+
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
3332
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithBlock())
3433
require.NoError(t, err)
35-
return conn
34+
return conn, cancel
3635
}
3736

3837
// Shared test data
@@ -51,9 +50,11 @@ var (
5150
)
5251

5352
func TestCreateStore_Succeeds(t *testing.T) {
53+
t.Parallel()
5454
proc := startDB(t)
5555
defer proc.Kill()
56-
conn := dialDB(t, proc.ServerAddr)
56+
conn, cancel := dialDB(t, proc.ServerAddr)
57+
defer cancel()
5758
defer conn.Close()
5859
client := dbsvc.NewDBServiceClient(conn)
5960

@@ -63,9 +64,11 @@ func TestCreateStore_Succeeds(t *testing.T) {
6364
}
6465

6566
func TestCreateStoreWithPredicates_Succeeds(t *testing.T) {
67+
t.Parallel()
6668
proc := startDB(t)
6769
defer proc.Kill()
68-
conn := dialDB(t, proc.ServerAddr)
70+
conn, cancel := dialDB(t, proc.ServerAddr)
71+
defer cancel()
6972
defer conn.Close()
7073
client := dbsvc.NewDBServiceClient(conn)
7174

@@ -75,9 +78,11 @@ func TestCreateStoreWithPredicates_Succeeds(t *testing.T) {
7578
}
7679

7780
func TestListStores_FindsCreatedStore(t *testing.T) {
81+
t.Parallel()
7882
proc := startDB(t)
7983
defer proc.Kill()
80-
conn := dialDB(t, proc.ServerAddr)
84+
conn, cancel := dialDB(t, proc.ServerAddr)
85+
defer cancel()
8186
defer conn.Close()
8287
client := dbsvc.NewDBServiceClient(conn)
8388

@@ -95,9 +100,11 @@ func TestListStores_FindsCreatedStore(t *testing.T) {
95100
}
96101

97102
func TestSetInStore_Succeeds(t *testing.T) {
103+
t.Parallel()
98104
proc := startDB(t)
99105
defer proc.Kill()
100-
conn := dialDB(t, proc.ServerAddr)
106+
conn, cancel := dialDB(t, proc.ServerAddr)
107+
defer cancel()
101108
defer conn.Close()
102109
client := dbsvc.NewDBServiceClient(conn)
103110

@@ -128,9 +135,11 @@ func TestSetInStore_Succeeds(t *testing.T) {
128135
}
129136

130137
func TestSetInStore_SucceedsWithBinary(t *testing.T) {
138+
t.Parallel()
131139
proc := startDB(t)
132140
defer proc.Kill()
133-
conn := dialDB(t, proc.ServerAddr)
141+
conn, cancel := dialDB(t, proc.ServerAddr)
142+
defer cancel()
134143
defer conn.Close()
135144
client := dbsvc.NewDBServiceClient(conn)
136145

@@ -152,9 +161,11 @@ func TestSetInStore_SucceedsWithBinary(t *testing.T) {
152161
}
153162

154163
func TestCreatePredicateIndex_Succeeds(t *testing.T) {
164+
t.Parallel()
155165
proc := startDB(t)
156166
defer proc.Kill()
157-
conn := dialDB(t, proc.ServerAddr)
167+
conn, cancel := dialDB(t, proc.ServerAddr)
168+
defer cancel()
158169
defer conn.Close()
159170
client := dbsvc.NewDBServiceClient(conn)
160171
_, _ = client.CreateStore(context.Background(), storeWithPred)
@@ -168,9 +179,11 @@ func TestCreatePredicateIndex_Succeeds(t *testing.T) {
168179
}
169180

170181
func TestGetByPredicate_Succeeds(t *testing.T) {
182+
t.Parallel()
171183
proc := startDB(t)
172184
defer proc.Kill()
173-
conn := dialDB(t, proc.ServerAddr)
185+
conn, cancel := dialDB(t, proc.ServerAddr)
186+
defer cancel()
174187
defer conn.Close()
175188
client := dbsvc.NewDBServiceClient(conn)
176189
_, _ = client.CreateStore(context.Background(), storeWithPred)
@@ -216,9 +229,11 @@ func TestGetByPredicate_Succeeds(t *testing.T) {
216229
}
217230

218231
func TestGetSimN_Succeeds(t *testing.T) {
232+
t.Parallel()
219233
proc := startDB(t)
220234
defer proc.Kill()
221-
conn := dialDB(t, proc.ServerAddr)
235+
conn, cancel := dialDB(t, proc.ServerAddr)
236+
defer cancel()
222237
defer conn.Close()
223238
client := dbsvc.NewDBServiceClient(conn)
224239
_, _ = client.CreateStore(context.Background(), storeNoPred)
@@ -254,9 +269,11 @@ func TestGetSimN_Succeeds(t *testing.T) {
254269
}
255270

256271
func TestDropPredicateIndex_Succeeds(t *testing.T) {
272+
t.Parallel()
257273
proc := startDB(t)
258274
defer proc.Kill()
259-
conn := dialDB(t, proc.ServerAddr)
275+
conn, cancel := dialDB(t, proc.ServerAddr)
276+
defer cancel()
260277
defer conn.Close()
261278
client := dbsvc.NewDBServiceClient(conn)
262279
_, _ = client.CreateStore(context.Background(), storeWithPred)
@@ -271,9 +288,11 @@ func TestDropPredicateIndex_Succeeds(t *testing.T) {
271288
}
272289

273290
func TestDeletePredicate_Succeeds(t *testing.T) {
291+
t.Parallel()
274292
proc := startDB(t)
275293
defer proc.Kill()
276-
conn := dialDB(t, proc.ServerAddr)
294+
conn, cancel := dialDB(t, proc.ServerAddr)
295+
defer cancel()
277296
defer conn.Close()
278297
client := dbsvc.NewDBServiceClient(conn)
279298
_, _ = client.CreateStore(context.Background(), storeWithPred)
@@ -309,9 +328,11 @@ func TestDeletePredicate_Succeeds(t *testing.T) {
309328
}
310329

311330
func TestDeleteKey_Succeeds(t *testing.T) {
331+
t.Parallel()
312332
proc := startDB(t)
313333
defer proc.Kill()
314-
conn := dialDB(t, proc.ServerAddr)
334+
conn, cancel := dialDB(t, proc.ServerAddr)
335+
defer cancel()
315336
defer conn.Close()
316337
client := dbsvc.NewDBServiceClient(conn)
317338
_, _ = client.CreateStore(context.Background(), storeNoPred)
@@ -338,9 +359,11 @@ func TestDeleteKey_Succeeds(t *testing.T) {
338359
}
339360

340361
func TestDropStore_Succeeds(t *testing.T) {
362+
t.Parallel()
341363
proc := startDB(t)
342364
defer proc.Kill()
343-
conn := dialDB(t, proc.ServerAddr)
365+
conn, cancel := dialDB(t, proc.ServerAddr)
366+
defer cancel()
344367
defer conn.Close()
345368
client := dbsvc.NewDBServiceClient(conn)
346369
_, _ = client.CreateStore(context.Background(), storeNoPred)
@@ -351,9 +374,11 @@ func TestDropStore_Succeeds(t *testing.T) {
351374
}
352375

353376
func TestListStores_ReflectsDroppedStore(t *testing.T) {
377+
t.Parallel()
354378
proc := startDB(t)
355379
defer proc.Kill()
356-
conn := dialDB(t, proc.ServerAddr)
380+
conn, cancel := dialDB(t, proc.ServerAddr)
381+
defer cancel()
357382
defer conn.Close()
358383
client := dbsvc.NewDBServiceClient(conn)
359384
_, _ = client.CreateStore(context.Background(), storeNoPred)
@@ -367,9 +392,11 @@ func TestListStores_ReflectsDroppedStore(t *testing.T) {
367392
}
368393

369394
func TestPipeline_BulkSetAndGet(t *testing.T) {
395+
t.Parallel()
370396
proc := startDB(t)
371397
defer proc.Kill()
372-
conn := dialDB(t, proc.ServerAddr)
398+
conn, cancel := dialDB(t, proc.ServerAddr)
399+
defer cancel()
373400
defer conn.Close()
374401
client := dbsvc.NewDBServiceClient(conn)
375402
_, _ = client.CreateStore(context.Background(), storeNoPred)

0 commit comments

Comments
 (0)