ADAPT-Chase commited on
Commit
1c79be5
·
verified ·
1 Parent(s): 55fff8b

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. platform/dbops/archive/databases_old/data/workspace/elizabeth_xet_ready/elizabeth_data_20250824_011825/config/.env +42 -0
  2. platform/dbops/binaries/weaviate-src/test/acceptance/graphql_resolvers/fixtures/actions_schema.json +99 -0
  3. platform/dbops/binaries/weaviate-src/test/acceptance/graphql_resolvers/fixtures/data.json +495 -0
  4. platform/dbops/binaries/weaviate-src/test/acceptance/graphql_resolvers/fixtures/things_schema.json +177 -0
  5. platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_deletes_test.go +120 -0
  6. platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_insertions_test.go +109 -0
  7. platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_multi_tenancy_test.go +141 -0
  8. platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_test.go +241 -0
  9. platform/dbops/binaries/weaviate-src/test/acceptance/stress_tests/tenants_test.go +112 -0
  10. platform/dbops/binaries/weaviate-src/test/acceptance/telemetry/logging_test.go +130 -0
  11. platform/dbops/binaries/weaviate-src/test/acceptance/telemetry/setup_test.go +70 -0
  12. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/cosine_test.go +559 -0
  13. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/data_test.go +98 -0
  14. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/dot_test.go +217 -0
  15. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/explore_test.go +128 -0
  16. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/graphql_helper_test.go +107 -0
  17. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/hamming_test.go +185 -0
  18. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/l2_test.go +206 -0
  19. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/manhattan_test.go +206 -0
  20. platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/setup_test.go +72 -0
platform/dbops/archive/databases_old/data/workspace/elizabeth_xet_ready/elizabeth_data_20250824_011825/config/.env ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Elizabeth Environment Variables
2
+ ELIZABETH_VERSION=v0.0.2
3
+ VLLM_BASE_URL=http://localhost:8
4
+ MODEL_PATH=/workspace/models/qwen3-8b
5
+
6
+ # Database Connections
7
+ PG_HOST=localhost
8
+ PG_DATABASE=elizabeth_prod
9
+ PG_USER=elizabeth
10
+ PG_PASSWORD=
11
+
12
+ REDIS_HOST=localhost
13
+ REDIS_PORT=6379
14
+
15
+ MONGO_URI=mongodb://localhost:27017/
16
+
17
+ # HuggingFace API Configuration - #FRESH - 250705
18
+ HUGGING_FACE_API_KEY=
19
+ HF_TOKEN=
20
+ HF_ORG=LevelUp2x
21
+
22
+ # Xet Configuration
23
+ XET_REPO_URL=https://xetbeta.com/adaptnova/elizabeth-data
24
+ XET_LOCAL_PATH=/workspace/xet_data
25
+
26
+ # Search API Keys - Configure for enhanced web search
27
+ FIRECRAWL_API_KEY=fc-94ebc24ae6a4492f9022d6a83001fc54
28
+ TAVILY_API_KEY=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
29
+ SERPER_API_KEY=aace3627d2b7d008f85ce06100984ae7c2a2066f
30
+
31
+ # Search Configuration
32
+ SEARCH_PROVIDER=firecrawl # firecrawl, tavily, serper, duckduckgo, perplexity
33
+ SEARCH_MAX_RESULTS=5
34
+ SEARCH_TIMEOUT=30
35
+
36
+ # Additional Search Services
37
+ PERPLEXITY_API_KEY=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
38
+
39
+ # Algolia Search Configuration
40
+ ALGOLIA_APPLICATION_ID=H23FYV09PA
41
+ ALGOLIA_SEARCH_API_KEY=7d71ebe7bf1f76a6bb14aecfae798372
42
+ ALGOLIA_WRITE_API_KEY=4d8787832cc1a7920f68df7e791e75bb
platform/dbops/binaries/weaviate-src/test/acceptance/graphql_resolvers/fixtures/actions_schema.json ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "0.0.1",
3
+ "type": "action",
4
+ "name": "weaviate demo actions schema",
5
+ "maintainer": "yourfriends@weaviate.com",
6
+ "classes": [
7
+ {
8
+ "class": "Flight",
9
+ "description": "An airline flight",
10
+ "properties": [
11
+ {
12
+ "name": "aircraft",
13
+ "dataType": ["Aircraft"],
14
+ "description": "The kind of aircraft"
15
+ },
16
+ {
17
+ "name": "arrivalAirport",
18
+ "dataType": ["Airport"],
19
+ "description": "The airport where the flight terminates"
20
+ },
21
+ {
22
+ "name": "departureAirport",
23
+ "dataType": ["Airport"],
24
+ "description": "The airport where the flight originates."
25
+ },
26
+ {
27
+ "name": "flightNumber",
28
+ "dataType": ["string"],
29
+ "description": "The unique identifier for a flight"
30
+ },
31
+ {
32
+ "name": "date",
33
+ "dataType": ["date"],
34
+ "description": "The date the person is moving"
35
+ },
36
+ {
37
+ "name": "estimatedFlightDuration",
38
+ "dataType": ["number"],
39
+ "description": "The estimated time in minutes the flight will take"
40
+ },
41
+ {
42
+ "name": "numberOfPassengers",
43
+ "dataType": ["int"],
44
+ "description": "Total number of passengers"
45
+ },
46
+ {
47
+ "name": "isDelayed",
48
+ "dataType": ["boolean"],
49
+ "description": "True if the flight is delayed"
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ "class": "BuyAction",
55
+ "description": "An agent buys an object, product, or service from a seller for a price.",
56
+ "properties": [
57
+ {
58
+ "name": "salesPerson",
59
+ "dataType": ["Airline", "Person"],
60
+ "description": "The seller of the thing",
61
+ "keywords": [
62
+ {"keyword": "sale", "weight": 0.5},
63
+ {"keyword": "person", "weight": 0.5}
64
+ ]
65
+ },
66
+ {
67
+ "name": "price",
68
+ "dataType": ["number"],
69
+ "description": "The offer price of a product"
70
+ },
71
+ {
72
+ "name": "recipient",
73
+ "dataType": ["Person"],
74
+ "description": "The recipient of the good",
75
+ "keywords": [
76
+ {"keyword": "buy", "weight": 0.5},
77
+ {"keyword": "person", "weight": 0.5}
78
+ ]
79
+ }
80
+ ]
81
+ },
82
+ {
83
+ "class": "Event",
84
+ "description": "Event is used to replicate bugs and prevent regressions for the fixes mentioned in gh-824",
85
+ "properties": [
86
+ {
87
+ "name": "name",
88
+ "dataType": ["string"],
89
+ "description": "The name of the event"
90
+ },
91
+ {
92
+ "name": "description",
93
+ "dataType": ["text"],
94
+ "description": "The description of the event"
95
+ }
96
+ ]
97
+ }
98
+ ]
99
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/graphql_resolvers/fixtures/data.json ADDED
@@ -0,0 +1,495 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Objects": [
3
+ {
4
+ "class": "City",
5
+ "uuid": "001",
6
+ "name": "Amsterdam",
7
+ "population": 1800000,
8
+ "isCapital": true,
9
+ "inCountry": [
10
+ {
11
+ "class": "Country",
12
+ "uuid": "005",
13
+ "name": "Netherlands",
14
+ "population": 17000000
15
+ }
16
+ ],
17
+ "reviews": "Great! A perfect city",
18
+ "location": {
19
+ "latitude": 52.366667,
20
+ "longitude": 4.9
21
+ }
22
+ },
23
+ {
24
+ "class": "City",
25
+ "uuid": "002",
26
+ "name": "Rotterdam",
27
+ "population": 1800000,
28
+ "isCapital": false,
29
+ "inCountry": [
30
+ {
31
+ "class": "Country",
32
+ "uuid": "005",
33
+ "name": "Netherlands",
34
+ "population": 17000000
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "class": "City",
40
+ "uuid": "003",
41
+ "name": "Berlin",
42
+ "population": 3470000,
43
+ "isCapital": true,
44
+ "reviews": "I had a bad time here",
45
+ "inCountry": [
46
+ {
47
+ "class": "Country",
48
+ "uuid": "006",
49
+ "name": "Germany",
50
+ "population": 83000000
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "class": "City",
56
+ "uuid": "004",
57
+ "name": "Dusseldorf",
58
+ "population": 600000,
59
+ "isCapital": false,
60
+ "inCountry": [
61
+ {
62
+ "class": "Country",
63
+ "uuid": "006",
64
+ "name": "Germany",
65
+ "population": 83000000
66
+ }
67
+ ],
68
+ "location": {
69
+ "latitude": 51.225556,
70
+ "longitude": 6.782778
71
+ }
72
+ },
73
+ {
74
+ "class": "Country",
75
+ "uuid": "005",
76
+ "name": "Netherlands",
77
+ "population": 17000000
78
+ },
79
+ {
80
+ "class": "Country",
81
+ "uuid": "006",
82
+ "name": "Germany",
83
+ "population": 83000000
84
+ },
85
+ {
86
+ "class": "Person",
87
+ "uuid": "007",
88
+ "livesIn": [
89
+ {
90
+ "class": "City",
91
+ "uuid": "004",
92
+ "name": "Dusseldorf",
93
+ "population": 600000,
94
+ "isCapital": false,
95
+ "inCountry": [
96
+ {
97
+ "class": "Country",
98
+ "uuid": "006",
99
+ "name": "Germany",
100
+ "population": 83000000
101
+ }
102
+ ]
103
+ }
104
+ ],
105
+ "ofNation": [
106
+ {
107
+ "class": "Country",
108
+ "uuid": "006",
109
+ "name": "Germany",
110
+ "population": 83000000
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ "class": "Person",
116
+ "uuid": "008",
117
+ "livesIn": [
118
+ {
119
+ "class": "City",
120
+ "uuid": "001",
121
+ "name": "Amsterdam",
122
+ "population": 1800000,
123
+ "isCapital": true,
124
+ "inCountry": {
125
+ "class": "Country",
126
+ "uuid": "005",
127
+ "name": "Netherlands",
128
+ "population": 17000000
129
+ }
130
+ }
131
+ ],
132
+ "ofNation": [
133
+ {
134
+ "class": "Country",
135
+ "uuid": "005",
136
+ "name": "Netherlands",
137
+ "population": 17000000
138
+ }
139
+ ]
140
+ },
141
+ {
142
+ "class": "Airport",
143
+ "uuid": "009",
144
+ "inCity": [
145
+ {
146
+ "class": "City",
147
+ "uuid": "001",
148
+ "name": "Amsterdam",
149
+ "population": 1800000,
150
+ "isCapital": true,
151
+ "inCountry": [
152
+ {
153
+ "class": "Country",
154
+ "uuid": "005",
155
+ "name": "Netherlands",
156
+ "population": 17000000
157
+ }
158
+ ]
159
+ }
160
+ ],
161
+ "code": "10000"
162
+ },
163
+ {
164
+ "class": "Airport",
165
+ "uuid": "010",
166
+ "inCity": [
167
+ {
168
+ "class": "City",
169
+ "uuid": "002",
170
+ "name": "Rotterdam",
171
+ "population": 1800000,
172
+ "isCapital": false,
173
+ "inCountry": {
174
+ "class": "Country",
175
+ "uuid": "005",
176
+ "name": "Netherlands",
177
+ "population": 17000000
178
+ }
179
+ }
180
+ ],
181
+ "code": "20000"
182
+ },
183
+ {
184
+ "class": "Airport",
185
+ "uuid": "011",
186
+ "inCity": [
187
+ {
188
+ "class": "City",
189
+ "uuid": "004",
190
+ "name": "Dusseldorf",
191
+ "population": 600000,
192
+ "isCapital": false,
193
+ "inCountry": {
194
+ "class": "Country",
195
+ "uuid": "006",
196
+ "name": "Germany",
197
+ "population": 83000000
198
+ }
199
+ }
200
+ ],
201
+ "code": "30000"
202
+ },
203
+ {
204
+ "class": "Airport",
205
+ "uuid": "012",
206
+ "inCity": [
207
+ {
208
+ "class": "City",
209
+ "uuid": "003",
210
+ "name": "Berlin",
211
+ "population": 3470000,
212
+ "isCapital": true,
213
+ "inCountry": {
214
+ "class": "Country",
215
+ "uuid": "006",
216
+ "name": "Germany",
217
+ "population": 83000000
218
+ }
219
+ }
220
+ ],
221
+ "code": "40000"
222
+ },
223
+ {
224
+ "class": "Airline",
225
+ "uuid": "013",
226
+ "name": "Lufthansa",
227
+ "basedIn": [
228
+ {
229
+ "class": "City",
230
+ "uuid": "003",
231
+ "name": "Berlin",
232
+ "population": 3470000,
233
+ "isCapital": true,
234
+ "inCountry": {
235
+ "class": "Country",
236
+ "uuid": "006",
237
+ "name": "Germany",
238
+ "population": 83000000
239
+ }
240
+ }
241
+ ],
242
+ "code": "123"
243
+ },
244
+ {
245
+ "class": "Airline",
246
+ "uuid": "014",
247
+ "name": "KLM",
248
+ "basedIn": [
249
+ {
250
+ "class": "City",
251
+ "uuid": "001",
252
+ "name": "Amsterdam",
253
+ "population": 1800000,
254
+ "isCapital": true,
255
+ "inCountry": {
256
+ "class": "Country",
257
+ "uuid": "005",
258
+ "name": "Netherlands",
259
+ "population": 17000000
260
+ }
261
+ }
262
+ ],
263
+ "code": "321"
264
+ },
265
+ {
266
+ "class": "Aircraft",
267
+ "uuid": "015",
268
+ "name": "Boeing 747",
269
+ "numberOfSeats": 366
270
+ },
271
+ {
272
+ "class": "Aircraft",
273
+ "uuid": "016",
274
+ "name": "Airbus A380",
275
+ "numberOfSeats": 853
276
+ },
277
+ {
278
+ "class": "Plane",
279
+ "uuid": "017",
280
+ "code": "AB123",
281
+ "aircraft": [
282
+ {
283
+ "class": "Aircraft",
284
+ "uuid": "015",
285
+ "name": "Boeing 747",
286
+ "numberOfSeats": 366
287
+ }
288
+ ],
289
+ "ofAirline": [
290
+ {
291
+ "class": "Airline",
292
+ "uuid": "013",
293
+ "name": "Lufthansa",
294
+ "basedIn": {
295
+ "class": "City",
296
+ "uuid": "003",
297
+ "name": "Berlin",
298
+ "population": 3470000,
299
+ "isCapital": true,
300
+ "inCountry": {
301
+ "class": "Country",
302
+ "uuid": "006",
303
+ "name": "Germany",
304
+ "population": 83000000
305
+ }
306
+ },
307
+ "code": "123"
308
+ }
309
+ ]
310
+ },
311
+ {
312
+ "class": "Plane",
313
+ "uuid": "018",
314
+ "code": "AB456",
315
+ "aircraft": [
316
+ {
317
+ "class": "Aircraft",
318
+ "uuid": "016",
319
+ "name": "Airbus A380",
320
+ "numberOfSeats": 853
321
+ }
322
+ ],
323
+ "ofAirline": [
324
+ {
325
+ "class": "Airline",
326
+ "uuid": "014",
327
+ "name": "KLM",
328
+ "basedIn": {
329
+ "class": "City",
330
+ "uuid": "001",
331
+ "name": "Amsterdam",
332
+ "population": 1800000,
333
+ "isCapital": true,
334
+ "inCountry": {
335
+ "class": "Country",
336
+ "uuid": "005",
337
+ "name": "Netherlands",
338
+ "population": 17000000
339
+ }
340
+ },
341
+ "code": "321"
342
+ }
343
+ ]
344
+ },
345
+ {
346
+ "class": "Plane",
347
+ "uuid": "019",
348
+ "code": "AB457",
349
+ "aircraft": [
350
+ {
351
+ "class": "Aircraft",
352
+ "uuid": "015",
353
+ "name": "Boeing 747",
354
+ "numberOfSeats": 366
355
+ }
356
+ ],
357
+ "ofAirline": [
358
+ {
359
+ "class": "Airline",
360
+ "uuid": "014",
361
+ "name": "KLM",
362
+ "basedIn": [
363
+ {
364
+ "class": "City",
365
+ "uuid": "001",
366
+ "name": "Amsterdam",
367
+ "population": 1800000,
368
+ "isCapital": true,
369
+ "inCountry": [
370
+ {
371
+ "class": "Country",
372
+ "uuid": "005",
373
+ "name": "Netherlands",
374
+ "population": 17000000
375
+ }
376
+ ]
377
+ }
378
+ ],
379
+ "code": "321"
380
+ }
381
+ ]
382
+ },
383
+ {
384
+ "class": "Plane",
385
+ "uuid": "020",
386
+ "code": "AB456",
387
+ "aircraft": [
388
+ {
389
+ "class": "Aircraft",
390
+ "uuid": "016",
391
+ "name": "Airbus A380",
392
+ "numberOfSeats": 853
393
+ }
394
+ ],
395
+ "ofAirline": [
396
+ {
397
+ "class": "Airline",
398
+ "uuid": "013",
399
+ "name": "Lufthansa",
400
+ "basedIn": [
401
+ {
402
+ "class": "City",
403
+ "uuid": "003",
404
+ "name": "Berlin",
405
+ "population": 3470000,
406
+ "isCapital": true,
407
+ "inCountry": [
408
+ {
409
+ "class": "Country",
410
+ "uuid": "006",
411
+ "name": "Germany",
412
+ "population": 83000000
413
+ }
414
+ ]
415
+ }
416
+ ],
417
+ "code": "123"
418
+ }
419
+ ]
420
+ }
421
+ ],
422
+ "Actions": [
423
+ {
424
+ "class": "Event",
425
+ "uuid": "021",
426
+ "name": "A name"
427
+ },
428
+ {
429
+ "class": "Event",
430
+ "uuid": "022",
431
+ "description": "A desricption"
432
+ },
433
+ {
434
+ "class": "Flight",
435
+ "uuid": "100",
436
+ "aircraft": [
437
+ {
438
+ "class": "Aircraft",
439
+ "uuid": "016",
440
+ "name": "Airbus A380",
441
+ "numberOfSeats": 853
442
+ }
443
+ ],
444
+ "arrivalAirport": [
445
+ {
446
+ "class": "Airport",
447
+ "uuid": "011",
448
+ "inCity": [
449
+ {
450
+ "class": "City",
451
+ "uuid": "004",
452
+ "name": "Dusseldorf",
453
+ "population": 600000,
454
+ "isCapital": false,
455
+ "inCountry": {
456
+ "class": "Country",
457
+ "uuid": "006",
458
+ "name": "Germany",
459
+ "population": 83000000
460
+ }
461
+ }
462
+ ],
463
+ "code": "30000"
464
+ }
465
+ ],
466
+ "departureAirport": [
467
+ {
468
+ "class": "Airport",
469
+ "uuid": "012",
470
+ "inCity": [
471
+ {
472
+ "class": "City",
473
+ "uuid": "003",
474
+ "name": "Berlin",
475
+ "population": 3470000,
476
+ "isCapital": true,
477
+ "inCountry": {
478
+ "class": "Country",
479
+ "uuid": "006",
480
+ "name": "Germany",
481
+ "population": 83000000
482
+ }
483
+ }
484
+ ],
485
+ "code": "40000"
486
+ }
487
+ ],
488
+ "flightNumber": "LH987",
489
+ "date": "2017-08-17T12:47:00+02:00",
490
+ "estimatedFlightDuration": 50,
491
+ "numberOfPassengers": 300,
492
+ "isDelayed": false
493
+ }
494
+ ]
495
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/graphql_resolvers/fixtures/things_schema.json ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "@context": "",
3
+ "version": "0.0.1",
4
+ "type": "object",
5
+ "name": "weaviate demo objects schema",
6
+ "maintainer": "yourfriends@weaviate.com",
7
+ "classes": [
8
+ {
9
+ "class": "City",
10
+ "description": "A city, place or town",
11
+ "properties": [
12
+ {
13
+ "name": "name",
14
+ "dataType": ["string"],
15
+ "description": "Official name of the city."
16
+ },
17
+ {
18
+ "name": "inCountry",
19
+ "dataType": ["Country"],
20
+ "description": "The country the city lies in"
21
+ },
22
+ {
23
+ "name": "population",
24
+ "dataType": ["int"],
25
+ "description": "Number of inhabitants of the city"
26
+ },
27
+ {
28
+ "name": "isCapital",
29
+ "dataType": ["boolean"],
30
+ "description": "True if the city is a capital"
31
+ },
32
+ {
33
+ "name": "reviews",
34
+ "dataType": ["string"],
35
+ "description": "Visitors opinions about the city"
36
+ },
37
+ {
38
+ "name": "location",
39
+ "dataType": ["geoCoordinates"],
40
+ "description": "The city's longitude and latitude",
41
+ "keywords": [{"keyword": "location", "weight": 1.0}]
42
+ }
43
+ ]
44
+ },
45
+ {
46
+ "class": "Person",
47
+ "description": "Person",
48
+ "properties": [
49
+ {
50
+ "name": "livesIn",
51
+ "dataType": ["City"],
52
+ "description": "The place where the person lives in."
53
+ },
54
+ {
55
+ "name": "birthday",
56
+ "dataType": ["date"],
57
+ "description": "Birthday of the person"
58
+ },
59
+ {
60
+ "name": "name",
61
+ "dataType": ["string"],
62
+ "description": "Name of the person"
63
+ },
64
+ {
65
+ "name": "ofNation",
66
+ "dataType": ["Country"],
67
+ "description": "Nationality of the person",
68
+ "keywords": [
69
+ {"keyword": "nation", "weight": 1.0},
70
+ {"keyword": "country", "weight": 1.0},
71
+ {"keyword": "person", "weight": 1.0}
72
+ ]
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ "class": "Country",
78
+ "description": "Country",
79
+ "properties": [
80
+ {
81
+ "name": "name",
82
+ "dataType": ["string"],
83
+ "description": "Official name of the country"
84
+ },
85
+ {
86
+ "name": "population",
87
+ "dataType": ["int"],
88
+ "description": "Amount of people living in the country"
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "class": "Airport",
94
+ "description": "An airport",
95
+ "properties": [
96
+ {
97
+ "name": "code",
98
+ "dataType": ["string"],
99
+ "description": "identifier for an airport"
100
+ },
101
+ {
102
+ "name": "inCity",
103
+ "dataType": ["City"],
104
+ "description": "City where the airport lies."
105
+ },
106
+ {
107
+ "name": "name",
108
+ "dataType": ["string"],
109
+ "description": "Official name of the airport"
110
+ }
111
+ ]
112
+ },
113
+ {
114
+ "class": "Airline",
115
+ "description": "An organization that provides flights for passengers",
116
+ "properties": [
117
+ {
118
+ "name": "code",
119
+ "dataType": ["string"],
120
+ "description": "identifier for an airport"
121
+ },
122
+ {
123
+ "name": "basedIn",
124
+ "dataType": ["City", "Country"],
125
+ "description": "City or country where the airline is based."
126
+ },
127
+ {
128
+ "name": "name",
129
+ "dataType": ["string"],
130
+ "description": "Official name of the airline"
131
+ },
132
+ {
133
+ "name": "hasNumberOfPlanes",
134
+ "dataType": ["int"],
135
+ "description": "Number of airplanes the airline owns"
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "class": "Plane",
141
+ "description": "An airplane",
142
+ "properties": [
143
+ {
144
+ "name": "code",
145
+ "dataType": ["string"],
146
+ "description": "identifier for the plane"
147
+ },
148
+ {
149
+ "name": "aircraft",
150
+ "dataType": ["Aircraft"],
151
+ "description": "the kind of aircraft"
152
+ },
153
+ {
154
+ "name": "ofAirline",
155
+ "dataType": ["Airline"],
156
+ "description": "Airline the plane is owned by"
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ "class": "Aircraft",
162
+ "description": "The kind of aircraft (e.g., \"Boeing 747\")",
163
+ "properties": [
164
+ {
165
+ "name": "name",
166
+ "dataType": ["string"],
167
+ "description": "name of the aircraft"
168
+ },
169
+ {
170
+ "name": "numberOfSeats",
171
+ "dataType": ["number"],
172
+ "description": "number of seats available in the aircraft."
173
+ }
174
+ ]
175
+ }
176
+ ]
177
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_deletes_test.go ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package replication
13
+
14
+ import (
15
+ "context"
16
+ "fmt"
17
+ "testing"
18
+ "time"
19
+
20
+ "github.com/stretchr/testify/assert"
21
+ "github.com/stretchr/testify/require"
22
+ "github.com/weaviate/weaviate/client/nodes"
23
+ "github.com/weaviate/weaviate/cluster/router/types"
24
+ "github.com/weaviate/weaviate/entities/models"
25
+ "github.com/weaviate/weaviate/entities/verbosity"
26
+ "github.com/weaviate/weaviate/test/acceptance/replication/common"
27
+ "github.com/weaviate/weaviate/test/docker"
28
+ "github.com/weaviate/weaviate/test/helper"
29
+ "github.com/weaviate/weaviate/test/helper/sample-schema/articles"
30
+ )
31
+
32
+ func (suite *AsyncReplicationTestSuite) TestAsyncRepairObjectDeleteScenario() {
33
+ t := suite.T()
34
+ mainCtx := context.Background()
35
+
36
+ clusterSize := 3
37
+
38
+ compose, err := docker.New().
39
+ WithWeaviateCluster(clusterSize).
40
+ WithText2VecContextionary().
41
+ Start(mainCtx)
42
+ require.Nil(t, err)
43
+ defer func() {
44
+ if err := compose.Terminate(mainCtx); err != nil {
45
+ t.Fatalf("failed to terminate test containers: %s", err.Error())
46
+ }
47
+ }()
48
+
49
+ ctx, cancel := context.WithTimeout(mainCtx, 15*time.Minute)
50
+ defer cancel()
51
+
52
+ paragraphClass := articles.ParagraphsClass()
53
+
54
+ t.Run("create schema", func(t *testing.T) {
55
+ paragraphClass.ReplicationConfig = &models.ReplicationConfig{
56
+ Factor: int64(clusterSize),
57
+ DeletionStrategy: models.ReplicationConfigDeletionStrategyTimeBasedResolution,
58
+ AsyncEnabled: true,
59
+ }
60
+ paragraphClass.Vectorizer = "text2vec-contextionary"
61
+
62
+ helper.SetupClient(compose.GetWeaviate().URI())
63
+ helper.CreateClass(t, paragraphClass)
64
+ })
65
+
66
+ paragraphCount := len(paragraphIDs)
67
+
68
+ t.Run("insert paragraphs", func(t *testing.T) {
69
+ batch := make([]*models.Object, paragraphCount)
70
+ for i, id := range paragraphIDs {
71
+ batch[i] = articles.NewParagraph().
72
+ WithID(id).
73
+ WithContents(fmt.Sprintf("paragraph#%d", i)).
74
+ Object()
75
+ }
76
+
77
+ common.CreateObjectsCL(t, compose.GetWeaviate().URI(), batch, types.ConsistencyLevelAll)
78
+ })
79
+
80
+ node := 2
81
+
82
+ t.Run(fmt.Sprintf("stop node %d", node), func(t *testing.T) {
83
+ common.StopNodeAt(ctx, t, compose, node)
84
+ })
85
+
86
+ host := compose.GetWeaviate().URI()
87
+ helper.SetupClient(host)
88
+
89
+ for _, id := range paragraphIDs {
90
+ helper.DeleteObjectCL(t, paragraphClass.Class, id, types.ConsistencyLevelQuorum)
91
+ }
92
+
93
+ t.Run(fmt.Sprintf("restart node %d", node), func(t *testing.T) {
94
+ common.StartNodeAt(ctx, t, compose, node)
95
+ })
96
+
97
+ t.Run("verify that all nodes are running", func(t *testing.T) {
98
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
99
+ verbose := verbosity.OutputVerbose
100
+ params := nodes.NewNodesGetClassParams().WithOutput(&verbose)
101
+ body, clientErr := helper.Client(t).Nodes.NodesGetClass(params, nil)
102
+ require.NoError(ct, clientErr)
103
+ require.NotNil(ct, body.Payload)
104
+
105
+ resp := body.Payload
106
+ require.Len(ct, resp.Nodes, clusterSize)
107
+ for _, n := range resp.Nodes {
108
+ require.NotNil(ct, n.Status)
109
+ require.Equal(ct, "HEALTHY", *n.Status)
110
+ }
111
+ }, 15*time.Second, 500*time.Millisecond)
112
+ })
113
+
114
+ t.Run(fmt.Sprintf("all the objects should have been deleted from node %d", node), func(t *testing.T) {
115
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
116
+ resp := common.GQLGet(t, compose.ContainerURI(node), "Paragraph", types.ConsistencyLevelOne)
117
+ require.Len(ct, resp, 0)
118
+ }, 120*time.Second, 5*time.Second, "not all the objects have been asynchronously replicated")
119
+ })
120
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_insertions_test.go ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package replication
13
+
14
+ import (
15
+ "context"
16
+ "fmt"
17
+ "testing"
18
+ "time"
19
+
20
+ "github.com/stretchr/testify/assert"
21
+ "github.com/stretchr/testify/require"
22
+ "github.com/weaviate/weaviate/client/nodes"
23
+ "github.com/weaviate/weaviate/cluster/router/types"
24
+ "github.com/weaviate/weaviate/entities/models"
25
+ "github.com/weaviate/weaviate/entities/verbosity"
26
+ "github.com/weaviate/weaviate/test/acceptance/replication/common"
27
+ "github.com/weaviate/weaviate/test/docker"
28
+ "github.com/weaviate/weaviate/test/helper"
29
+ "github.com/weaviate/weaviate/test/helper/sample-schema/articles"
30
+ )
31
+
32
+ func (suite *AsyncReplicationTestSuite) TestAsyncRepairObjectInsertionScenario() {
33
+ t := suite.T()
34
+ mainCtx := context.Background()
35
+
36
+ clusterSize := 3
37
+
38
+ compose, err := docker.New().
39
+ WithWeaviateCluster(clusterSize).
40
+ WithText2VecContextionary().
41
+ Start(mainCtx)
42
+ require.Nil(t, err)
43
+ defer func() {
44
+ if err := compose.Terminate(mainCtx); err != nil {
45
+ t.Fatalf("failed to terminate test containers: %s", err.Error())
46
+ }
47
+ }()
48
+
49
+ ctx, cancel := context.WithTimeout(mainCtx, 15*time.Minute)
50
+ defer cancel()
51
+
52
+ paragraphClass := articles.ParagraphsClass()
53
+
54
+ t.Run("create schema", func(t *testing.T) {
55
+ paragraphClass.ReplicationConfig = &models.ReplicationConfig{
56
+ Factor: int64(clusterSize),
57
+ AsyncEnabled: true,
58
+ }
59
+ paragraphClass.Vectorizer = "text2vec-contextionary"
60
+
61
+ helper.SetupClient(compose.GetWeaviate().URI())
62
+ helper.CreateClass(t, paragraphClass)
63
+ })
64
+
65
+ node := 2
66
+
67
+ t.Run(fmt.Sprintf("stop node %d", node), func(t *testing.T) {
68
+ common.StopNodeAt(ctx, t, compose, node)
69
+ })
70
+
71
+ t.Run("insert paragraphs", func(t *testing.T) {
72
+ batch := make([]*models.Object, len(paragraphIDs))
73
+ for i := range paragraphIDs {
74
+ batch[i] = articles.NewParagraph().
75
+ WithContents(fmt.Sprintf("paragraph#%d", i)).
76
+ Object()
77
+ }
78
+
79
+ common.CreateObjectsCL(t, compose.GetWeaviate().URI(), batch, types.ConsistencyLevelOne)
80
+ })
81
+
82
+ t.Run(fmt.Sprintf("restart node %d", node), func(t *testing.T) {
83
+ common.StartNodeAt(ctx, t, compose, node)
84
+ })
85
+
86
+ t.Run("verify that all nodes are running", func(t *testing.T) {
87
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
88
+ verbose := verbosity.OutputVerbose
89
+ params := nodes.NewNodesGetClassParams().WithOutput(&verbose)
90
+ body, clientErr := helper.Client(t).Nodes.NodesGetClass(params, nil)
91
+ require.NoError(ct, clientErr)
92
+ require.NotNil(ct, body.Payload)
93
+
94
+ resp := body.Payload
95
+ require.Len(ct, resp.Nodes, clusterSize)
96
+ for _, n := range resp.Nodes {
97
+ require.NotNil(ct, n.Status)
98
+ require.Equal(ct, "HEALTHY", *n.Status)
99
+ }
100
+ }, 15*time.Second, 500*time.Millisecond)
101
+ })
102
+
103
+ t.Run(fmt.Sprintf("assert node %d has all the objects", node), func(t *testing.T) {
104
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
105
+ resp := common.GQLGet(t, compose.ContainerURI(node), "Paragraph", types.ConsistencyLevelOne)
106
+ require.Len(ct, resp, len(paragraphIDs))
107
+ }, 120*time.Second, 5*time.Second, "not all the objects have been asynchronously replicated")
108
+ })
109
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_multi_tenancy_test.go ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package replication
13
+
14
+ import (
15
+ "context"
16
+ "fmt"
17
+ "testing"
18
+ "time"
19
+
20
+ "github.com/stretchr/testify/assert"
21
+ "github.com/stretchr/testify/require"
22
+ "github.com/weaviate/weaviate/client/nodes"
23
+ "github.com/weaviate/weaviate/cluster/router/types"
24
+ "github.com/weaviate/weaviate/entities/models"
25
+ "github.com/weaviate/weaviate/entities/verbosity"
26
+ "github.com/weaviate/weaviate/test/acceptance/replication/common"
27
+ "github.com/weaviate/weaviate/test/docker"
28
+ "github.com/weaviate/weaviate/test/helper"
29
+ "github.com/weaviate/weaviate/test/helper/sample-schema/articles"
30
+ )
31
+
32
+ // In this scenario, we are testing two things:
33
+ //
34
+ // 1. The invocation of shard.UpdateAsyncReplication on an index with inactive tenants,
35
+ // using ForEachLoadedShard to avoid force loading shards for the purpose of enabling
36
+ // async replication, ensuring that if it is enabled when some tenants are inactive,
37
+ // that the change is correctly applied to the tenants if they are later activated
38
+ //
39
+ // 2. That once (1) occurs, the hashBeat process is correctly initiated at the time that
40
+ // the tenant is activated, and any missing objects are successfully propagated to the
41
+ // nodes which are missing them.
42
+ //
43
+ // The actual scenario is as follows:
44
+ // - Create a class with multi-tenancy enabled, replicated by a factor of 3
45
+ // - Create a tenant, and set it to inactive
46
+ // - Stop the second node
47
+ // - Activate the tenant, and insert 1000 objects into the 2 surviving nodes
48
+ // - Restart the second node and ensure it has an object count of 0
49
+ // - Update the class to enabled async replication
50
+ // - Wait a few seconds for objects to propagate
51
+ // - Verify that the resurrected node contains all objects
52
+ func (suite *AsyncReplicationTestSuite) TestAsyncRepairMultiTenancyScenario() {
53
+ t := suite.T()
54
+ mainCtx := context.Background()
55
+
56
+ var (
57
+ clusterSize = 3
58
+ tenantName = "tenant-0"
59
+ objectCount = 100
60
+ )
61
+
62
+ compose, err := docker.New().
63
+ WithWeaviateCluster(clusterSize).
64
+ WithText2VecContextionary().
65
+ Start(mainCtx)
66
+ require.Nil(t, err)
67
+ defer func() {
68
+ if err := compose.Terminate(mainCtx); err != nil {
69
+ t.Fatalf("failed to terminate test containers: %s", err.Error())
70
+ }
71
+ }()
72
+
73
+ ctx, cancel := context.WithTimeout(mainCtx, 15*time.Minute)
74
+ defer cancel()
75
+
76
+ paragraphClass := articles.ParagraphsClass()
77
+
78
+ t.Run("create schema", func(t *testing.T) {
79
+ paragraphClass.ReplicationConfig = &models.ReplicationConfig{
80
+ Factor: int64(clusterSize),
81
+ AsyncEnabled: true,
82
+ }
83
+ paragraphClass.Vectorizer = "text2vec-contextionary"
84
+ paragraphClass.MultiTenancyConfig = &models.MultiTenancyConfig{
85
+ AutoTenantActivation: true,
86
+ Enabled: true,
87
+ }
88
+
89
+ helper.SetupClient(compose.GetWeaviate().URI())
90
+ helper.CreateClass(t, paragraphClass)
91
+ })
92
+
93
+ t.Run("add inactive tenant", func(t *testing.T) {
94
+ tenants := []*models.Tenant{{Name: tenantName, ActivityStatus: "COLD"}}
95
+ helper.CreateTenants(t, paragraphClass.Class, tenants)
96
+ })
97
+
98
+ t.Run("stop node 2", func(t *testing.T) {
99
+ common.StopNodeAt(ctx, t, compose, 2)
100
+ })
101
+
102
+ // Activate/insert tenants while node 2 is down
103
+ t.Run("activate tenant and insert paragraphs", func(t *testing.T) {
104
+ batch := make([]*models.Object, objectCount)
105
+ for i := 0; i < objectCount; i++ {
106
+ batch[i] = articles.NewParagraph().
107
+ WithContents(fmt.Sprintf("paragraph#%d", i)).
108
+ WithTenant(tenantName).
109
+ Object()
110
+ }
111
+ common.CreateObjectsCL(t, compose.GetWeaviate().URI(), batch, types.ConsistencyLevelOne)
112
+ })
113
+
114
+ t.Run("start node 2", func(t *testing.T) {
115
+ common.StartNodeAt(ctx, t, compose, 2)
116
+ })
117
+
118
+ t.Run("verify that all nodes are running", func(t *testing.T) {
119
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
120
+ verbose := verbosity.OutputVerbose
121
+ params := nodes.NewNodesGetClassParams().WithOutput(&verbose)
122
+ body, clientErr := helper.Client(t).Nodes.NodesGetClass(params, nil)
123
+ require.NoError(ct, clientErr)
124
+ require.NotNil(ct, body.Payload)
125
+
126
+ resp := body.Payload
127
+ require.Len(ct, resp.Nodes, clusterSize)
128
+ for _, n := range resp.Nodes {
129
+ require.NotNil(ct, n.Status)
130
+ require.Equal(ct, "HEALTHY", *n.Status)
131
+ }
132
+ }, 15*time.Second, 500*time.Millisecond)
133
+ })
134
+
135
+ t.Run("validate async object propagation", func(t *testing.T) {
136
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
137
+ resp := common.GQLTenantGet(t, compose.GetWeaviateNode(2).URI(), paragraphClass.Class, types.ConsistencyLevelOne, tenantName)
138
+ require.Len(ct, resp, objectCount)
139
+ }, 120*time.Second, 5*time.Second, "not all the objects have been asynchronously replicated")
140
+ })
141
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/replication/async_replication/async_repair_test.go ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package replication
13
+
14
+ import (
15
+ "context"
16
+ "fmt"
17
+ "testing"
18
+ "time"
19
+
20
+ "github.com/go-openapi/strfmt"
21
+ "github.com/stretchr/testify/assert"
22
+ "github.com/stretchr/testify/require"
23
+ "github.com/stretchr/testify/suite"
24
+ "github.com/weaviate/weaviate/client/nodes"
25
+ "github.com/weaviate/weaviate/cluster/router/types"
26
+ "github.com/weaviate/weaviate/entities/models"
27
+ "github.com/weaviate/weaviate/entities/verbosity"
28
+ "github.com/weaviate/weaviate/test/acceptance/replication/common"
29
+ "github.com/weaviate/weaviate/test/docker"
30
+ "github.com/weaviate/weaviate/test/helper"
31
+ "github.com/weaviate/weaviate/test/helper/sample-schema/articles"
32
+ )
33
+
34
+ var (
35
+ paragraphIDs = []strfmt.UUID{
36
+ strfmt.UUID("3bf331ac-8c86-4f95-b127-2f8f96bbc093"),
37
+ strfmt.UUID("47b26ba1-6bc9-41f8-a655-8b9a5b60e1a3"),
38
+ strfmt.UUID("5fef6289-28d2-4ea2-82a9-48eb501200cd"),
39
+ strfmt.UUID("34a673b4-8859-4cb4-bb30-27f5622b47e9"),
40
+ strfmt.UUID("9fa362f5-c2dc-4fb8-b5b2-11701adc5f75"),
41
+ strfmt.UUID("63735238-6723-4caf-9eaa-113120968ff4"),
42
+ strfmt.UUID("2236744d-b2d2-40e5-95d8-2574f20a7126"),
43
+ strfmt.UUID("1a54e25d-aaf9-48d2-bc3c-bef00b556297"),
44
+ strfmt.UUID("0b8a0e70-a240-44b2-ac6d-26dda97523b9"),
45
+ strfmt.UUID("50566856-5d0a-4fb1-a390-e099bc236f66"),
46
+ }
47
+
48
+ articleIDs = []strfmt.UUID{
49
+ strfmt.UUID("aeaf8743-5a8f-4149-b960-444181d3131a"),
50
+ strfmt.UUID("2a1e9834-064e-4ca8-9efc-35707c6bae6d"),
51
+ strfmt.UUID("8d101c0c-4deb-48d0-805c-d9c691042a1a"),
52
+ strfmt.UUID("b9715fec-ef6c-4e8d-a89e-55e2eebee3f6"),
53
+ strfmt.UUID("faf520f2-f6c3-4cdf-9c16-0348ffd0f8ac"),
54
+ strfmt.UUID("d4c695dd-4dc7-4e49-bc73-089ef5f90fc8"),
55
+ strfmt.UUID("c7949324-e07f-4ffc-8be0-194f0470d375"),
56
+ strfmt.UUID("9c112e01-7759-43ed-a6e8-5defb267c8ee"),
57
+ strfmt.UUID("9bf847f3-3a1a-45a5-b656-311163e536b5"),
58
+ strfmt.UUID("c1975388-d67c-404a-ae77-5983fbaea4bb"),
59
+ }
60
+ )
61
+
62
+ type AsyncReplicationTestSuite struct {
63
+ suite.Suite
64
+ }
65
+
66
+ func (suite *AsyncReplicationTestSuite) SetupTest() {
67
+ suite.T().Setenv("TEST_WEAVIATE_IMAGE", "weaviate/test-server")
68
+ }
69
+
70
+ func TestAsyncReplicationTestSuite(t *testing.T) {
71
+ suite.Run(t, new(AsyncReplicationTestSuite))
72
+ }
73
+
74
+ func (suite *AsyncReplicationTestSuite) TestAsyncRepairSimpleScenario() {
75
+ t := suite.T()
76
+ mainCtx := context.Background()
77
+
78
+ compose, err := docker.New().
79
+ WithWeaviateCluster(3).
80
+ WithText2VecContextionary().
81
+ Start(mainCtx)
82
+ require.Nil(t, err)
83
+ defer func() {
84
+ if err := compose.Terminate(mainCtx); err != nil {
85
+ t.Fatalf("failed to terminate test containers: %s", err.Error())
86
+ }
87
+ }()
88
+
89
+ ctx, cancel := context.WithTimeout(mainCtx, 10*time.Minute)
90
+ defer cancel()
91
+
92
+ helper.SetupClient(compose.GetWeaviate().URI())
93
+ paragraphClass := articles.ParagraphsClass()
94
+ articleClass := articles.ArticlesClass()
95
+
96
+ t.Run("create schema", func(t *testing.T) {
97
+ paragraphClass.ReplicationConfig = &models.ReplicationConfig{
98
+ Factor: 3,
99
+ AsyncEnabled: true,
100
+ }
101
+ paragraphClass.Vectorizer = "text2vec-contextionary"
102
+ helper.CreateClass(t, paragraphClass)
103
+ articleClass.ReplicationConfig = &models.ReplicationConfig{
104
+ Factor: 3,
105
+ AsyncEnabled: true,
106
+ }
107
+ helper.CreateClass(t, articleClass)
108
+ })
109
+
110
+ t.Run("insert paragraphs", func(t *testing.T) {
111
+ batch := make([]*models.Object, len(paragraphIDs))
112
+ for i, id := range paragraphIDs {
113
+ batch[i] = articles.NewParagraph().
114
+ WithID(id).
115
+ WithContents(fmt.Sprintf("paragraph#%d", i)).
116
+ Object()
117
+ }
118
+ common.CreateObjects(t, compose.GetWeaviate().URI(), batch)
119
+ })
120
+
121
+ t.Run("insert articles", func(t *testing.T) {
122
+ batch := make([]*models.Object, len(articleIDs))
123
+ for i, id := range articleIDs {
124
+ batch[i] = articles.NewArticle().
125
+ WithID(id).
126
+ WithTitle(fmt.Sprintf("Article#%d", i)).
127
+ Object()
128
+ }
129
+ common.CreateObjects(t, compose.GetWeaviateNode(2).URI(), batch)
130
+ })
131
+
132
+ t.Run("stop node 3", func(t *testing.T) {
133
+ common.StopNodeAt(ctx, t, compose, 3)
134
+ })
135
+
136
+ repairObj := models.Object{
137
+ ID: "e5390693-5a22-44b8-997d-2a213aaf5884",
138
+ Class: "Paragraph",
139
+ Properties: map[string]interface{}{
140
+ "contents": "a new paragraph",
141
+ },
142
+ }
143
+
144
+ t.Run("add new object to node one", func(t *testing.T) {
145
+ common.CreateObjectCL(t, compose.GetWeaviate().URI(), &repairObj, types.ConsistencyLevelOne)
146
+ })
147
+
148
+ t.Run("restart node 3", func(t *testing.T) {
149
+ common.StartNodeAt(ctx, t, compose, 3)
150
+ })
151
+
152
+ t.Run("verify that all nodes are running", func(t *testing.T) {
153
+ assert.EventuallyWithT(t, func(ct *assert.CollectT) {
154
+ verbose := verbosity.OutputVerbose
155
+ params := nodes.NewNodesGetClassParams().WithOutput(&verbose)
156
+ body, clientErr := helper.Client(t).Nodes.NodesGetClass(params, nil)
157
+ require.NoError(ct, clientErr)
158
+ require.NotNil(ct, body.Payload)
159
+
160
+ resp := body.Payload
161
+ require.Len(ct, resp.Nodes, 3)
162
+ for _, n := range resp.Nodes {
163
+ require.NotNil(ct, n.Status)
164
+ assert.Equal(ct, "HEALTHY", *n.Status)
165
+ }
166
+ }, 15*time.Second, 500*time.Millisecond)
167
+ })
168
+
169
+ t.Run("assert new object read repair was made", func(t *testing.T) {
170
+ assert.EventuallyWithT(t, func(ct *assert.CollectT) {
171
+ resp, err := common.GetObjectCL(t, compose.GetWeaviateNode(3).URI(),
172
+ repairObj.Class, repairObj.ID, types.ConsistencyLevelOne)
173
+ assert.Nil(ct, err)
174
+ assert.NotNil(ct, resp)
175
+ if resp == nil {
176
+ return
177
+ }
178
+ assert.Equal(ct, repairObj.ID, resp.ID)
179
+ assert.Equal(ct, repairObj.Class, resp.Class)
180
+ assert.EqualValues(ct, repairObj.Properties, resp.Properties)
181
+ assert.EqualValues(ct, repairObj.Vector, resp.Vector)
182
+ }, 60*time.Second, 1*time.Second, "not all the objects have been asynchronously replicated")
183
+ })
184
+
185
+ replaceObj := repairObj
186
+ replaceObj.Properties = map[string]interface{}{
187
+ "contents": "this paragraph was replaced",
188
+ }
189
+
190
+ t.Run("stop node 2", func(t *testing.T) {
191
+ common.StopNodeAt(ctx, t, compose, 2)
192
+ })
193
+
194
+ t.Run("replace object", func(t *testing.T) {
195
+ common.UpdateObjectCL(t, compose.GetWeaviateNode(3).URI(), &replaceObj, types.ConsistencyLevelOne)
196
+ })
197
+
198
+ t.Run("restart node 2", func(t *testing.T) {
199
+ common.StartNodeAt(ctx, t, compose, 2)
200
+ })
201
+
202
+ t.Run("verify that all nodes are running", func(t *testing.T) {
203
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
204
+ verbose := verbosity.OutputVerbose
205
+ params := nodes.NewNodesGetClassParams().WithOutput(&verbose)
206
+ body, clientErr := helper.Client(t).Nodes.NodesGetClass(params, nil)
207
+ require.NoError(ct, clientErr)
208
+ require.NotNil(ct, body.Payload)
209
+
210
+ resp := body.Payload
211
+ require.Len(ct, resp.Nodes, 3)
212
+ for _, n := range resp.Nodes {
213
+ require.NotNil(ct, n.Status)
214
+ require.Equal(ct, "HEALTHY", *n.Status)
215
+ }
216
+ }, 15*time.Second, 500*time.Millisecond)
217
+ })
218
+
219
+ t.Run("assert updated object read repair was made", func(t *testing.T) {
220
+ require.EventuallyWithT(t, func(ct *assert.CollectT) {
221
+ exists, err := common.ObjectExistsCL(t, compose.GetWeaviateNode(2).URI(),
222
+ replaceObj.Class, replaceObj.ID, types.ConsistencyLevelOne)
223
+ require.Nil(ct, err)
224
+ require.True(ct, exists)
225
+
226
+ resp, err := common.GetObjectCL(t, compose.GetWeaviate().URI(),
227
+ repairObj.Class, repairObj.ID, types.ConsistencyLevelOne)
228
+ require.Nil(ct, err)
229
+ require.NotNil(ct, resp)
230
+
231
+ if resp == nil {
232
+ return
233
+ }
234
+
235
+ require.Equal(ct, replaceObj.ID, resp.ID)
236
+ require.Equal(ct, replaceObj.Class, resp.Class)
237
+ require.EqualValues(ct, replaceObj.Properties, resp.Properties)
238
+ require.EqualValues(ct, replaceObj.Vector, resp.Vector)
239
+ }, 120*time.Second, 5*time.Second, "not all the objects have been asynchronously replicated")
240
+ })
241
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/stress_tests/tenants_test.go ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package stress_tests
13
+
14
+ import (
15
+ "encoding/json"
16
+ "fmt"
17
+ "sync"
18
+ "testing"
19
+
20
+ "github.com/stretchr/testify/assert"
21
+ "github.com/weaviate/weaviate/entities/models"
22
+ )
23
+
24
+ func TestConcurrentTenantsAddAndRemove(t *testing.T) {
25
+ url := "http://localhost:8080/v1/"
26
+
27
+ c := createHttpClient()
28
+ clearExistingObjects(c, url)
29
+ requestSchema := createSchemaRequest(url, class, true)
30
+
31
+ performRequest(c, requestSchema)
32
+
33
+ // Add schema and object
34
+ parallelReqs := 50
35
+ wg := sync.WaitGroup{}
36
+ wgStartReqests := sync.WaitGroup{}
37
+ wgStartReqests.Add(parallelReqs)
38
+ wg.Add(parallelReqs)
39
+
40
+ for i := 0; i < parallelReqs; i++ {
41
+ go func(j int) {
42
+ c := createHttpClient()
43
+
44
+ requestAddTenant := createRequest(url+"schema/"+class+"/tenants", "POST", []models.Tenant{{Name: "tenant" + fmt.Sprint(j)}})
45
+ requestDeleteTenant := createRequest(url+"schema/"+class+"/tenants", "DELETE", []string{"tenant" + fmt.Sprint(j)})
46
+
47
+ wgStartReqests.Done()
48
+ wgStartReqests.Wait()
49
+ performRequest(c, requestAddTenant)
50
+ performRequest(c, requestDeleteTenant)
51
+
52
+ wg.Done()
53
+ }(i)
54
+ }
55
+ wg.Wait()
56
+
57
+ requestGetTenants := createRequest(url+"schema/"+class+"/tenants", "GET", nil)
58
+
59
+ _, body, _ := performRequest(c, requestGetTenants)
60
+ var result []*models.Tenant
61
+ json.Unmarshal(body, &result)
62
+ assert.Equal(t, 0, len(result))
63
+ }
64
+
65
+ func TestConcurrentTenantBatchesWithTenantAdd(t *testing.T) {
66
+ url := "http://localhost:8080/v1/"
67
+
68
+ c := createHttpClient()
69
+ clearExistingObjects(c, url)
70
+
71
+ tenants := make([]models.Tenant, 10)
72
+ for i := 0; i < len(tenants); i++ {
73
+ tenants[i] = models.Tenant{Name: "tenant" + fmt.Sprint(i)}
74
+ }
75
+
76
+ nrClasses := 10
77
+ for i := 0; i < nrClasses; i++ {
78
+ performRequest(c, createSchemaRequest(url, class+fmt.Sprint(i), true))
79
+ performRequest(c, createRequest(url+"schema/"+class+fmt.Sprint(i)+"/tenants", "POST", tenants))
80
+ }
81
+
82
+ // Add schema and object
83
+ parallelReqs := 20
84
+ wg := sync.WaitGroup{}
85
+ wgStartReqests := sync.WaitGroup{}
86
+ wgStartReqests.Add(parallelReqs)
87
+ wg.Add(parallelReqs)
88
+
89
+ batchSize := 100
90
+
91
+ for i := 0; i < parallelReqs; i++ {
92
+ go func(j int) {
93
+ c := createHttpClient()
94
+
95
+ requestBatch := createRequest(url+"batch/objects", "POST", batch{createBatch(class+fmt.Sprint(j%nrClasses), batchSize, tenants)})
96
+
97
+ wgStartReqests.Done()
98
+ wgStartReqests.Wait()
99
+ performRequest(c, requestBatch)
100
+ wg.Done()
101
+ }(i)
102
+ }
103
+ wg.Wait()
104
+
105
+ // check for one class that we have the expected nr of objects per tenant
106
+ requestRead := createRequest(url+fmt.Sprintf("objects?limit=%v&class="+class+"%s&tenant=%s", 1000, "4", fmt.Sprint(tenants[0].Name)), "GET", nil)
107
+ _, body, _ := performRequest(c, requestRead)
108
+ var result map[string]interface{}
109
+ json.Unmarshal(body, &result)
110
+ assert.Equal(t, parallelReqs/nrClasses*batchSize/len(tenants), int(result["totalResults"].(float64))) // batches per class, * objects per batch/nr_tenants
111
+ clearExistingObjects(c, url)
112
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/telemetry/logging_test.go ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ // TODO gh-1232 remove
15
+ // // This test covers the Telemetry process. Weaviate should log each time its endpoints are accessed,
16
+ // // and it should send these logs to an endpoint. In the testing config environment this endpoint is
17
+ // // the mock api's address. This test sends a request to Weaviate to ensure at least one log *should*
18
+ // // exist, waits a few seconds to ensure the log *should* be sent to the mock endpoint and then retrieves
19
+ // // the most recently received log from the mock endpoint. The test then decodes the response and
20
+ // // validates its structure.
21
+ // //
22
+ // // controlled by setup_test.go
23
+ // func createActionLogging(t *testing.T) {
24
+ // // send a request
25
+ // sendCreateActionRequest(t)
26
+
27
+ // // wait for the log to be posted
28
+ // time.Sleep(7 * time.Second)
29
+
30
+ // result := retrieveLogFromMockEndpoint(t)
31
+
32
+ // if result != nil {
33
+ // interpretedResult := interpretResult(t, result)
34
+ // if interpretedResult != nil {
35
+ // _, namePresent := interpretedResult["n"]
36
+ // _, typePresent := interpretedResult["t"]
37
+ // _, identifierPresent := interpretedResult["i"]
38
+ // _, amountPresent := interpretedResult["a"]
39
+ // _, whenPresent := interpretedResult["w"]
40
+
41
+ // assert.Equal(t, true, namePresent)
42
+ // assert.Equal(t, true, typePresent)
43
+ // assert.Equal(t, true, identifierPresent)
44
+ // assert.Equal(t, true, amountPresent)
45
+ // assert.Equal(t, true, whenPresent)
46
+
47
+ // }
48
+ // }
49
+ // }
50
+
51
+ // // The sendCreateActionRequest acceptance test is copied here to ensure at least one request should be
52
+ // // logged when we check the mock api's most recently received request. These assertions should pass
53
+ // // regardless of the rest of the Telemetry test passing.
54
+ // func sendCreateActionRequest(t *testing.T) {
55
+ // // Set all action values to compare
56
+ // actionTestString := "Test string"
57
+ // actionTestInt := 1
58
+ // actionTestBoolean := true
59
+ // actionTestNumber := 1.337
60
+ // actionTestDate := "2017-10-06T08:15:30+01:00"
61
+
62
+ // params := actions.NewActionsCreateParams().WithBody(
63
+ // &models.Action{
64
+ // Class: "MonitoringTestAction",
65
+ // Schema: map[string]interface{}{
66
+ // "testString": actionTestString,
67
+ // "testWholeNumber": actionTestInt,
68
+ // "testTrueFalse": actionTestBoolean,
69
+ // "testNumber": actionTestNumber,
70
+ // "testDateTime": actionTestDate,
71
+ // },
72
+ // })
73
+
74
+ // resp, err := helper.Client(t).Actions.ActionsCreate(params, nil)
75
+
76
+ // // Ensure that the response is OK.
77
+ // helper.AssertRequestOk(t, resp, err, func() {
78
+ // action := resp.Payload
79
+ // assert.Regexp(t, strfmt.UUIDPattern, action.ID)
80
+
81
+ // schema, ok := action.Schema.(map[string]interface{})
82
+ // if !ok {
83
+ // t.Fatal("The returned schema is not an JSON object")
84
+ // }
85
+
86
+ // testWholeNumber, _ := schema["testWholeNumber"].(json.Number).Int64()
87
+ // testNumber, _ := schema["testNumber"].(json.Number).Float64()
88
+
89
+ // // Check whether the returned information is the same as the data added.
90
+ // assert.Equal(t, actionTestString, schema["testString"])
91
+ // assert.Equal(t, actionTestInt, int(testWholeNumber))
92
+ // assert.Equal(t, actionTestBoolean, schema["testTrueFalse"])
93
+ // assert.Equal(t, actionTestNumber, testNumber)
94
+ // assert.Equal(t, actionTestDate, schema["testDateTime"])
95
+ // })
96
+ // }
97
+
98
+ // // retrieveLogFromMockEndpoint retrieves the most recently received log from the mock api.
99
+ // func retrieveLogFromMockEndpoint(t *testing.T) []byte {
100
+ // req, err := http.NewRequest("GET", "http://localhost:8087/mock/last", nil)
101
+ // req.Close = true
102
+ // assert.Equal(t, nil, err)
103
+
104
+ // client := &http.Client{}
105
+ // resp, err := client.Do(req)
106
+ // if err == nil {
107
+ // body, _ := io.ReadAll(resp.Body)
108
+ // defer resp.Body.Close()
109
+ // return body
110
+ // }
111
+ // if err != nil {
112
+ // urlError, ok := err.(*url.Error)
113
+ // if ok {
114
+ // assert.Equal(t, nil, urlError.Op)
115
+ // }
116
+ // }
117
+
118
+ // return nil
119
+ // }
120
+
121
+ // // interpretResult converts the received cbor-encoded log to a []map[string]interface.
122
+ // func interpretResult(t *testing.T, resultBody []byte) map[string]interface{} {
123
+ // decoded := make([]map[string]interface{}, 1)
124
+ // cborHandle := new(codec.CborHandle)
125
+ // encoder := codec.NewDecoderBytes(resultBody, cborHandle)
126
+ // err := encoder.Decode(&decoded)
127
+
128
+ // require.Equal(t, nil, err)
129
+ // return decoded[0]
130
+ // }
platform/dbops/binaries/weaviate-src/test/acceptance/telemetry/setup_test.go ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ // TODO gh-1232: remove
15
+ // import (
16
+ // "testing"
17
+
18
+ // "github.com/weaviate/weaviate/client/schema"
19
+ // "github.com/weaviate/weaviate/entities/models"
20
+ // "github.com/weaviate/weaviate/test/helper"
21
+ // )
22
+
23
+ // func Test_Actions(t *testing.T) {
24
+ // t.Run("setup", func(t *testing.T) {
25
+ // createActionClass(t, &models.Class{
26
+ // Class: "MonitoringTestAction",
27
+ // Properties: []*models.Property{
28
+ // &models.Property{
29
+ // Name: "testString",
30
+ // DataType: schema.DataTypeText.PropString(),
31
+ // Tokenization: models.PropertyTokenizationWhitespace,
32
+ // },
33
+ // &models.Property{
34
+ // Name: "testWholeNumber",
35
+ // DataType: []string{"int"},
36
+ // },
37
+ // &models.Property{
38
+ // Name: "testNumber",
39
+ // DataType: []string{"number"},
40
+ // },
41
+ // &models.Property{
42
+ // Name: "testDateTime",
43
+ // DataType: []string{"date"},
44
+ // },
45
+ // &models.Property{
46
+ // Name: "testTrueFalse",
47
+ // DataType: []string{"boolean"},
48
+ // },
49
+ // },
50
+ // })
51
+ // })
52
+
53
+ // // tests
54
+ // t.Run("create action logging", createActionLogging)
55
+
56
+ // // tear down
57
+ // deleteActionClass(t, "MonitoringTestAction")
58
+ // }
59
+
60
+ // func createActionClass(t *testing.T, class *models.Class) {
61
+ // params := schema.NewCollectionsActionsCreateParams().WithActionClass(class)
62
+ // resp, err := helper.Client(t).Schema.CollectionsActionsCreate(params, nil)
63
+ // helper.AssertRequestOk(t, resp, err, nil)
64
+ // }
65
+
66
+ // func deleteActionClass(t *testing.T, class string) {
67
+ // delParams := schema.NewCollectionsActionsDeleteParams().WithClassName(class)
68
+ // delRes, err := helper.Client(t).Schema.CollectionsActionsDelete(delParams, nil)
69
+ // helper.AssertRequestOk(t, delRes, err, nil)
70
+ // }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/cosine_test.go ADDED
@@ -0,0 +1,559 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "encoding/json"
16
+ "testing"
17
+
18
+ "github.com/stretchr/testify/assert"
19
+ "github.com/stretchr/testify/require"
20
+ "github.com/weaviate/weaviate/entities/models"
21
+ )
22
+
23
+ func addTestDataCosine(t *testing.T) {
24
+ createObject(t, &models.Object{
25
+ Class: "Cosine_Class",
26
+ Properties: map[string]interface{}{
27
+ "name": "object_1",
28
+ },
29
+ Vector: []float32{
30
+ 0.7, 0.3, // our base object
31
+ },
32
+ })
33
+
34
+ createObject(t, &models.Object{
35
+ Class: "Cosine_Class",
36
+ Properties: map[string]interface{}{
37
+ "name": "object_2",
38
+ },
39
+ Vector: []float32{
40
+ 1.4, 0.6, // identical angle to the base
41
+ },
42
+ })
43
+
44
+ createObject(t, &models.Object{
45
+ Class: "Cosine_Class",
46
+ Properties: map[string]interface{}{
47
+ "name": "object_3",
48
+ },
49
+ Vector: []float32{
50
+ -0.7, -0.3, // perfect opposite of the base
51
+ },
52
+ })
53
+
54
+ createObject(t, &models.Object{
55
+ Class: "Cosine_Class",
56
+ Properties: map[string]interface{}{
57
+ "name": "object_4",
58
+ },
59
+ Vector: []float32{
60
+ 1, 1, // somewhere in between
61
+ },
62
+ })
63
+ }
64
+
65
+ func testCosine(t *testing.T) {
66
+ t.Run("without any limiting parameters", func(t *testing.T) {
67
+ res := AssertGraphQL(t, nil, `
68
+ {
69
+ Get{
70
+ Cosine_Class(nearVector:{vector: [0.7, 0.3]}){
71
+ name
72
+ _additional{distance certainty}
73
+ }
74
+ }
75
+ }
76
+ `)
77
+ results := res.Get("Get", "Cosine_Class").AsSlice()
78
+ expectedDistances := []float32{
79
+ 0, // the same vector as the query
80
+ 0, // the same angle as the query vector,
81
+ 0.0715, // the vector in between,
82
+ 2, // the perfect opposite vector,
83
+ }
84
+
85
+ compareDistances(t, expectedDistances, results)
86
+ })
87
+
88
+ t.Run("limiting by certainty", func(t *testing.T) {
89
+ // cosine is a special case. It still supports certainty for legacy
90
+ // reasons. All other distances do not work with certainty.
91
+
92
+ t.Run("Get: with certainty=0 meaning 'match anything'", func(t *testing.T) {
93
+ res := AssertGraphQL(t, nil, `
94
+ {
95
+ Get{
96
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], certainty: 0}){
97
+ name
98
+ _additional{distance certainty}
99
+ }
100
+ }
101
+ }
102
+ `)
103
+ results := res.Get("Get", "Cosine_Class").AsSlice()
104
+ expectedDistances := []float32{
105
+ 0, // the same vector as the query
106
+ 0, // the same angle as the query vector,
107
+ 0.0715, // the vector in between,
108
+ 2, // the perfect opposite vector,
109
+ }
110
+
111
+ compareDistances(t, expectedDistances, results)
112
+
113
+ expectedCertainties := []float32{
114
+ 1, // the same vector as the query
115
+ 1, // the same angle as the query vector,
116
+ 0.96, // the vector in between,
117
+ 0, // the perfect opposite vector,
118
+ }
119
+
120
+ compareCertainties(t, expectedCertainties, results)
121
+ })
122
+
123
+ t.Run("Explore: with certainty=0 meaning 'match anything'", func(t *testing.T) {
124
+ res := AssertGraphQL(t, nil, `
125
+ {
126
+ Explore(nearVector:{vector: [0.7, 0.3], certainty: 0}){
127
+ distance certainty
128
+ }
129
+ }
130
+ `)
131
+ results := res.Get("Explore").AsSlice()
132
+ expectedDistances := []float32{
133
+ 0, // the same vector as the query
134
+ 0, // the same angle as the query vector,
135
+ 0.0715, // the vector in between,
136
+ 2, // the perfect opposite vector,
137
+ }
138
+
139
+ compareDistancesExplore(t, expectedDistances, results)
140
+
141
+ expectedCertainties := []float32{
142
+ 1, // the same vector as the query
143
+ 1, // the same angle as the query vector,
144
+ 0.96, // the vector in between,
145
+ 0, // the perfect opposite vector,
146
+ }
147
+
148
+ compareCertaintiesExplore(t, expectedCertainties, results)
149
+ })
150
+
151
+ t.Run("Get: with certainty=0.95", func(t *testing.T) {
152
+ res := AssertGraphQL(t, nil, `
153
+ {
154
+ Get{
155
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], certainty: 0.95}){
156
+ name
157
+ _additional{distance certainty}
158
+ }
159
+ }
160
+ }
161
+ `)
162
+ results := res.Get("Get", "Cosine_Class").AsSlice()
163
+ expectedDistances := []float32{
164
+ 0, // the same vector as the query
165
+ 0, // the same angle as the query vector,
166
+ 0.0715, // the vector in between,
167
+ }
168
+
169
+ compareDistances(t, expectedDistances, results)
170
+
171
+ expectedCertainties := []float32{
172
+ 1, // the same vector as the query
173
+ 1, // the same angle as the query vector,
174
+ 0.96, // the vector in between,
175
+ // the last element does not have the required certainty (0<0.95)
176
+ }
177
+
178
+ compareCertainties(t, expectedCertainties, results)
179
+ })
180
+
181
+ t.Run("Explore: with certainty=0.95", func(t *testing.T) {
182
+ res := AssertGraphQL(t, nil, `
183
+ {
184
+ Explore(nearVector:{vector: [0.7, 0.3], certainty: 0.95}){
185
+ distance certainty
186
+ }
187
+ }
188
+ `)
189
+ results := res.Get("Explore").AsSlice()
190
+ expectedDistances := []float32{
191
+ 0, // the same vector as the query
192
+ 0, // the same angle as the query vector,
193
+ 0.0715, // the vector in between,
194
+ }
195
+
196
+ compareDistancesExplore(t, expectedDistances, results)
197
+
198
+ expectedCertainties := []float32{
199
+ 1, // the same vector as the query
200
+ 1, // the same angle as the query vector,
201
+ 0.96, // the vector in between,
202
+ // the last element does not have the required certainty (0<0.95)
203
+ }
204
+
205
+ compareCertaintiesExplore(t, expectedCertainties, results)
206
+ })
207
+
208
+ t.Run("Get: with certainty=0.97", func(t *testing.T) {
209
+ res := AssertGraphQL(t, nil, `
210
+ {
211
+ Get{
212
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], certainty: 0.97}){
213
+ name
214
+ _additional{distance certainty}
215
+ }
216
+ }
217
+ }
218
+ `)
219
+ results := res.Get("Get", "Cosine_Class").AsSlice()
220
+ expectedDistances := []float32{
221
+ 0, // the same vector as the query
222
+ 0, // the same angle as the query vector,
223
+ }
224
+
225
+ compareDistances(t, expectedDistances, results)
226
+
227
+ expectedCertainties := []float32{
228
+ 1, // the same vector as the query
229
+ 1, // the same angle as the query vector,
230
+ // the last two elements would have certainty of 0.96 and 0, so they won't match
231
+ }
232
+
233
+ compareCertainties(t, expectedCertainties, results)
234
+ })
235
+
236
+ t.Run("Explore: with certainty=0.97", func(t *testing.T) {
237
+ res := AssertGraphQL(t, nil, `
238
+ {
239
+ Explore(nearVector:{vector: [0.7, 0.3], certainty: 0.97}){
240
+ distance certainty
241
+ }
242
+ }
243
+ `)
244
+ results := res.Get("Explore").AsSlice()
245
+ expectedDistances := []float32{
246
+ 0, // the same vector as the query
247
+ 0, // the same angle as the query vector,
248
+ }
249
+
250
+ compareDistancesExplore(t, expectedDistances, results)
251
+
252
+ expectedCertainties := []float32{
253
+ 1, // the same vector as the query
254
+ 1, // the same angle as the query vector,
255
+ // the last two elements would have certainty of 0.96 and 0, so they won't match
256
+ }
257
+
258
+ compareCertaintiesExplore(t, expectedCertainties, results)
259
+ })
260
+
261
+ t.Run("Get: with certainty=1", func(t *testing.T) {
262
+ // only perfect matches should be included now (certainty=1, distance=0)
263
+ res := AssertGraphQL(t, nil, `
264
+ {
265
+ Get{
266
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], certainty: 1}){
267
+ name
268
+ _additional{distance certainty}
269
+ }
270
+ }
271
+ }
272
+ `)
273
+ results := res.Get("Get", "Cosine_Class").AsSlice()
274
+ expectedDistances := []float32{
275
+ 0, // the same vector as the query
276
+ 0, // the same angle as the query vector,
277
+ }
278
+
279
+ compareDistances(t, expectedDistances, results)
280
+
281
+ expectedCertainties := []float32{
282
+ 1, // the same vector as the query
283
+ 1, // the same angle as the query vector,
284
+ // the last two elements would have certainty of 0.96 and 0, so they won't match
285
+ }
286
+
287
+ compareCertainties(t, expectedCertainties, results)
288
+ })
289
+
290
+ t.Run("Explore: with certainty=1", func(t *testing.T) {
291
+ // only perfect matches should be included now (certainty=1, distance=0)
292
+ res := AssertGraphQL(t, nil, `
293
+ {
294
+ Explore(nearVector:{vector: [0.7, 0.3], certainty: 1}){
295
+ distance certainty
296
+ }
297
+ }
298
+ `)
299
+ results := res.Get("Explore").AsSlice()
300
+ expectedDistances := []float32{
301
+ 0, // the same vector as the query
302
+ 0, // the same angle as the query vector,
303
+ }
304
+
305
+ compareDistancesExplore(t, expectedDistances, results)
306
+
307
+ expectedCertainties := []float32{
308
+ 1, // the same vector as the query
309
+ 1, // the same angle as the query vector,
310
+ // the last two elements would have certainty of 0.96 and 0, so they won't match
311
+ }
312
+
313
+ compareCertaintiesExplore(t, expectedCertainties, results)
314
+ })
315
+ })
316
+
317
+ t.Run("limiting by distance", func(t *testing.T) {
318
+ t.Run("Get: with distance=2, i.e. max distance, should match all", func(t *testing.T) {
319
+ res := AssertGraphQL(t, nil, `
320
+ {
321
+ Get{
322
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], distance: 2}){
323
+ name
324
+ _additional{distance certainty}
325
+ }
326
+ }
327
+ }
328
+ `)
329
+ results := res.Get("Get", "Cosine_Class").AsSlice()
330
+ expectedDistances := []float32{
331
+ 0, // the same vector as the query
332
+ 0, // the same angle as the query vector,
333
+ 0.0715, // the vector in between,
334
+ 2, // the perfect opposite vector,
335
+ }
336
+
337
+ compareDistances(t, expectedDistances, results)
338
+ })
339
+
340
+ t.Run("Explore: with distance=2, i.e. max distance, should match all", func(t *testing.T) {
341
+ res := AssertGraphQL(t, nil, `
342
+ {
343
+ Explore(nearVector:{vector: [0.7, 0.3], distance: 2}){
344
+ distance certainty
345
+ }
346
+ }
347
+ `)
348
+ results := res.Get("Explore").AsSlice()
349
+ expectedDistances := []float32{
350
+ 0, // the same vector as the query
351
+ 0, // the same angle as the query vector,
352
+ 0.0715, // the vector in between,
353
+ 2, // the perfect opposite vector,
354
+ }
355
+
356
+ compareDistancesExplore(t, expectedDistances, results)
357
+ })
358
+
359
+ t.Run("Get: with distance=1.99, should exclude the last", func(t *testing.T) {
360
+ res := AssertGraphQL(t, nil, `
361
+ {
362
+ Get{
363
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], distance: 1.99}){
364
+ name
365
+ _additional{distance certainty}
366
+ }
367
+ }
368
+ }
369
+ `)
370
+ results := res.Get("Get", "Cosine_Class").AsSlice()
371
+ expectedDistances := []float32{
372
+ 0, // the same vector as the query
373
+ 0, // the same angle as the query vector,
374
+ 0.0715, // the vector in between,
375
+ // the vector with the perfect opposite has a distance of 2.00 which is > 1.99
376
+ }
377
+
378
+ compareDistances(t, expectedDistances, results)
379
+ })
380
+
381
+ t.Run("Explore: with distance=1.99, should exclude the last", func(t *testing.T) {
382
+ res := AssertGraphQL(t, nil, `
383
+ {
384
+ Explore(nearVector:{vector: [0.7, 0.3], distance: 1.99}){
385
+ distance certainty
386
+ }
387
+ }
388
+ `)
389
+ results := res.Get("Explore").AsSlice()
390
+ expectedDistances := []float32{
391
+ 0, // the same vector as the query
392
+ 0, // the same angle as the query vector,
393
+ 0.0715, // the vector in between,
394
+ // the vector with the perfect opposite has a distance of 2.00 which is > 1.99
395
+ }
396
+
397
+ compareDistancesExplore(t, expectedDistances, results)
398
+ })
399
+
400
+ t.Run("Get: with distance=0.08, it should barely still match element 3", func(t *testing.T) {
401
+ res := AssertGraphQL(t, nil, `
402
+ {
403
+ Get{
404
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], distance: 0.08}){
405
+ name
406
+ _additional{distance certainty}
407
+ }
408
+ }
409
+ }
410
+ `)
411
+ results := res.Get("Get", "Cosine_Class").AsSlice()
412
+ expectedDistances := []float32{
413
+ 0, // the same vector as the query
414
+ 0, // the same angle as the query vector,
415
+ 0.0715, // the vector in between, just within the allowed range
416
+ // the vector with the perfect opposite has a distance of 2.00 which is > 0.08
417
+ }
418
+
419
+ compareDistances(t, expectedDistances, results)
420
+ })
421
+
422
+ t.Run("Explore: with distance=0.08, it should barely still match element 3", func(t *testing.T) {
423
+ res := AssertGraphQL(t, nil, `
424
+ {
425
+ Explore(nearVector:{vector: [0.7, 0.3], distance: 0.08}){
426
+ distance certainty
427
+ }
428
+ }
429
+ `)
430
+ results := res.Get("Explore").AsSlice()
431
+ expectedDistances := []float32{
432
+ 0, // the same vector as the query
433
+ 0, // the same angle as the query vector,
434
+ 0.0715, // the vector in between, just within the allowed range
435
+ // the vector with the perfect opposite has a distance of 2.00 which is > 0.08
436
+ }
437
+
438
+ compareDistancesExplore(t, expectedDistances, results)
439
+ })
440
+
441
+ t.Run("Get: with distance=0.01, most vectors are excluded", func(t *testing.T) {
442
+ res := AssertGraphQL(t, nil, `
443
+ {
444
+ Get{
445
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], distance: 0.01}){
446
+ name
447
+ _additional{distance certainty}
448
+ }
449
+ }
450
+ }
451
+ `)
452
+ results := res.Get("Get", "Cosine_Class").AsSlice()
453
+ expectedDistances := []float32{
454
+ 0, // the same vector as the query
455
+ 0, // the same angle as the query vector,
456
+ // the third vector would have had a distance of 0.07... which is more than 0.01
457
+ // the vector with the perfect opposite has a distance of 2.00 which is > 0.08
458
+ }
459
+
460
+ compareDistances(t, expectedDistances, results)
461
+ })
462
+
463
+ t.Run("Explore: with distance=0.01, most vectors are excluded", func(t *testing.T) {
464
+ res := AssertGraphQL(t, nil, `
465
+ {
466
+ Explore(nearVector:{vector: [0.7, 0.3], distance: 0.01}){
467
+ distance certainty
468
+ }
469
+ }
470
+ `)
471
+ results := res.Get("Explore").AsSlice()
472
+ expectedDistances := []float32{
473
+ 0, // the same vector as the query
474
+ 0, // the same angle as the query vector,
475
+ // the third vector would have had a distance of 0.07... which is more than 0.01
476
+ // the vector with the perfect opposite has a distance of 2.00 which is > 0.08
477
+ }
478
+
479
+ compareDistancesExplore(t, expectedDistances, results)
480
+ })
481
+
482
+ t.Run("Get: with distance=0, only perfect matches are allowed", func(t *testing.T) {
483
+ res := AssertGraphQL(t, nil, `
484
+ {
485
+ Get{
486
+ Cosine_Class(nearVector:{vector: [0.7, 0.3], distance: 0}){
487
+ name
488
+ _additional{distance certainty}
489
+ }
490
+ }
491
+ }
492
+ `)
493
+ results := res.Get("Get", "Cosine_Class").AsSlice()
494
+ expectedDistances := []float32{
495
+ 0, // the same vector as the query
496
+ 0, // the same angle as the query vector,
497
+ // only the first two vectors are perfect matches
498
+ }
499
+
500
+ compareDistances(t, expectedDistances, results)
501
+ })
502
+
503
+ t.Run("Explore: with distance=0, only perfect matches are allowed", func(t *testing.T) {
504
+ res := AssertGraphQL(t, nil, `
505
+ {
506
+ Explore(nearVector:{vector: [0.7, 0.3], distance: 0}){
507
+ distance certainty
508
+ }
509
+ }
510
+ `)
511
+ results := res.Get("Explore").AsSlice()
512
+ expectedDistances := []float32{
513
+ 0, // the same vector as the query
514
+ 0, // the same angle as the query vector,
515
+ // only the first two vectors are perfect matches
516
+ }
517
+
518
+ compareDistancesExplore(t, expectedDistances, results)
519
+ })
520
+ })
521
+ }
522
+
523
+ func compareDistances(t *testing.T, expectedDistances []float32, results []interface{}) {
524
+ require.Equal(t, len(expectedDistances), len(results))
525
+ for i, expected := range expectedDistances {
526
+ actual, err := results[i].(map[string]interface{})["_additional"].(map[string]interface{})["distance"].(json.Number).Float64()
527
+ require.Nil(t, err)
528
+ assert.InDelta(t, expected, actual, 0.01)
529
+ }
530
+ }
531
+
532
+ func compareDistancesExplore(t *testing.T, expectedDistances []float32, results []interface{}) {
533
+ require.Equal(t, len(expectedDistances), len(results))
534
+ for i, expected := range expectedDistances {
535
+ actual, err := results[i].(map[string]interface{})["distance"].(json.Number).Float64()
536
+ require.Nil(t, err)
537
+ assert.InDelta(t, expected, actual, 0.01)
538
+ }
539
+ }
540
+
541
+ // unique to cosine for legacy reasons
542
+ func compareCertainties(t *testing.T, expectedDistances []float32, results []interface{}) {
543
+ require.Equal(t, len(expectedDistances), len(results))
544
+ for i, expected := range expectedDistances {
545
+ actual, err := results[i].(map[string]interface{})["_additional"].(map[string]interface{})["certainty"].(json.Number).Float64()
546
+ require.Nil(t, err)
547
+ assert.InDelta(t, expected, actual, 0.01)
548
+ }
549
+ }
550
+
551
+ // unique to cosine for legacy reasons
552
+ func compareCertaintiesExplore(t *testing.T, expectedDistances []float32, results []interface{}) {
553
+ require.Equal(t, len(expectedDistances), len(results))
554
+ for i, expected := range expectedDistances {
555
+ actual, err := results[i].(map[string]interface{})["certainty"].(json.Number).Float64()
556
+ require.Nil(t, err)
557
+ assert.InDelta(t, expected, actual, 0.01)
558
+ }
559
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/data_test.go ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "testing"
16
+
17
+ "github.com/weaviate/weaviate/entities/models"
18
+ "github.com/weaviate/weaviate/entities/schema"
19
+ )
20
+
21
+ func addTestSchemaCosine(t *testing.T) {
22
+ createObjectClass(t, &models.Class{
23
+ Class: "Cosine_Class",
24
+ Vectorizer: "none",
25
+ Properties: []*models.Property{
26
+ {
27
+ Name: "name",
28
+ DataType: schema.DataTypeText.PropString(),
29
+ Tokenization: models.PropertyTokenizationWhitespace,
30
+ },
31
+ },
32
+ VectorIndexConfig: map[string]interface{}{
33
+ "distance": "cosine",
34
+ },
35
+ })
36
+ }
37
+
38
+ func addTestSchemaOther(t *testing.T) {
39
+ createObjectClass(t, &models.Class{
40
+ Class: "Dot_Class",
41
+ Vectorizer: "none",
42
+ Properties: []*models.Property{
43
+ {
44
+ Name: "name",
45
+ DataType: schema.DataTypeText.PropString(),
46
+ Tokenization: models.PropertyTokenizationWhitespace,
47
+ },
48
+ },
49
+ VectorIndexConfig: map[string]interface{}{
50
+ "distance": "dot",
51
+ },
52
+ })
53
+
54
+ createObjectClass(t, &models.Class{
55
+ Class: "L2Squared_Class",
56
+ Vectorizer: "none",
57
+ Properties: []*models.Property{
58
+ {
59
+ Name: "name",
60
+ DataType: schema.DataTypeText.PropString(),
61
+ Tokenization: models.PropertyTokenizationWhitespace,
62
+ },
63
+ },
64
+ VectorIndexConfig: map[string]interface{}{
65
+ "distance": "l2-squared",
66
+ },
67
+ })
68
+
69
+ createObjectClass(t, &models.Class{
70
+ Class: "Manhattan_Class",
71
+ Vectorizer: "none",
72
+ Properties: []*models.Property{
73
+ {
74
+ Name: "name",
75
+ DataType: schema.DataTypeText.PropString(),
76
+ Tokenization: models.PropertyTokenizationWhitespace,
77
+ },
78
+ },
79
+ VectorIndexConfig: map[string]interface{}{
80
+ "distance": "manhattan",
81
+ },
82
+ })
83
+
84
+ createObjectClass(t, &models.Class{
85
+ Class: "Hamming_Class",
86
+ Vectorizer: "none",
87
+ Properties: []*models.Property{
88
+ {
89
+ Name: "name",
90
+ DataType: schema.DataTypeText.PropString(),
91
+ Tokenization: models.PropertyTokenizationWhitespace,
92
+ },
93
+ },
94
+ VectorIndexConfig: map[string]interface{}{
95
+ "distance": "hamming",
96
+ },
97
+ })
98
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/dot_test.go ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "testing"
16
+
17
+ "github.com/weaviate/weaviate/entities/models"
18
+ )
19
+
20
+ func addTestDataDot(t *testing.T) {
21
+ createObject(t, &models.Object{
22
+ Class: "Dot_Class",
23
+ Properties: map[string]interface{}{
24
+ "name": "object_1",
25
+ },
26
+ Vector: []float32{
27
+ 3, 4, 5, // our base object
28
+ },
29
+ })
30
+
31
+ createObject(t, &models.Object{
32
+ Class: "Dot_Class",
33
+ Properties: map[string]interface{}{
34
+ "name": "object_2",
35
+ },
36
+ Vector: []float32{
37
+ 1, 1, 1, // a length-one vector
38
+ },
39
+ })
40
+
41
+ createObject(t, &models.Object{
42
+ Class: "Dot_Class",
43
+ Properties: map[string]interface{}{
44
+ "name": "object_3",
45
+ },
46
+ Vector: []float32{
47
+ 0, 0, 0, // a zero vecto
48
+ },
49
+ })
50
+
51
+ createObject(t, &models.Object{
52
+ Class: "Dot_Class",
53
+ Properties: map[string]interface{}{
54
+ "name": "object_2",
55
+ },
56
+ Vector: []float32{
57
+ -3, -4, -5, // negative of the base vector
58
+ },
59
+ })
60
+ }
61
+
62
+ func testDot(t *testing.T) {
63
+ t.Run("without any limiting distance", func(t *testing.T) {
64
+ res := AssertGraphQL(t, nil, `
65
+ {
66
+ Get{
67
+ Dot_Class(nearVector:{vector: [3,4,5]}){
68
+ name
69
+ _additional{distance}
70
+ }
71
+ }
72
+ }
73
+ `)
74
+ results := res.Get("Get", "Dot_Class").AsSlice()
75
+ expectedDistances := []float32{
76
+ -50, // the same vector as the query
77
+ -12, // the same angle as the query vector,
78
+ 0, // the vector in between,
79
+ 50, // the negative of the query vec
80
+ }
81
+
82
+ compareDistances(t, expectedDistances, results)
83
+ })
84
+
85
+ t.Run("with a specified certainty arg - should error", func(t *testing.T) {
86
+ ErrorGraphQL(t, nil, `
87
+ {
88
+ Get{
89
+ Dot_Class(nearVector:{certainty: 0.7, vector: [3,4,5]}){
90
+ name
91
+ _additional{distance}
92
+ }
93
+ }
94
+ }
95
+ `)
96
+ })
97
+
98
+ t.Run("with a specified certainty prop - should error", func(t *testing.T) {
99
+ ErrorGraphQL(t, nil, `
100
+ {
101
+ Get{
102
+ Dot_Class(nearVector:{distance: 0.7, vector: [3,4,5]}){
103
+ name
104
+ _additional{certainty}
105
+ }
106
+ }
107
+ }
108
+ `)
109
+ })
110
+
111
+ t.Run("with a max distancer higher than all results, should contain all elements", func(t *testing.T) {
112
+ res := AssertGraphQL(t, nil, `
113
+ {
114
+ Get{
115
+ Dot_Class(nearVector:{distance: 50, vector: [3,4,5]}){
116
+ name
117
+ _additional{distance}
118
+ }
119
+ }
120
+ }
121
+ `)
122
+ results := res.Get("Get", "Dot_Class").AsSlice()
123
+ expectedDistances := []float32{
124
+ -50, // the same vector as the query
125
+ -12, // the same angle as the query vector,
126
+ 0, // the vector in between,
127
+ 50, // the negative of the query vec
128
+ }
129
+
130
+ compareDistances(t, expectedDistances, results)
131
+ })
132
+
133
+ t.Run("with a positive max distance that does not match all results, should contain 3 elems", func(t *testing.T) {
134
+ res := AssertGraphQL(t, nil, `
135
+ {
136
+ Get{
137
+ Dot_Class(nearVector:{distance: 30, vector: [3,4,5]}){
138
+ name
139
+ _additional{distance}
140
+ }
141
+ }
142
+ }
143
+ `)
144
+ results := res.Get("Get", "Dot_Class").AsSlice()
145
+ expectedDistances := []float32{
146
+ -50, // the same vector as the query
147
+ -12, // the same angle as the query vector,
148
+ 0, // the vector in between,
149
+ // the last one is not contained as it would have a distance of 50, which is > 30
150
+ }
151
+
152
+ compareDistances(t, expectedDistances, results)
153
+ })
154
+
155
+ t.Run("with distance 0, should contain 3 elems", func(t *testing.T) {
156
+ res := AssertGraphQL(t, nil, `
157
+ {
158
+ Get{
159
+ Dot_Class(nearVector:{distance: 0, vector: [3,4,5]}){
160
+ name
161
+ _additional{distance}
162
+ }
163
+ }
164
+ }
165
+ `)
166
+ results := res.Get("Get", "Dot_Class").AsSlice()
167
+ expectedDistances := []float32{
168
+ -50, // the same vector as the query
169
+ -12, // the same angle as the query vector,
170
+ 0, // the vector in between,
171
+ // the last one is not contained as it would have a distance of 50, which is > 0
172
+ }
173
+
174
+ compareDistances(t, expectedDistances, results)
175
+ })
176
+
177
+ t.Run("with a negative distance that should only leave the first element", func(t *testing.T) {
178
+ res := AssertGraphQL(t, nil, `
179
+ {
180
+ Get{
181
+ Dot_Class(nearVector:{distance: -40, vector: [3,4,5]}){
182
+ name
183
+ _additional{distance}
184
+ }
185
+ }
186
+ }
187
+ `)
188
+ results := res.Get("Get", "Dot_Class").AsSlice()
189
+ expectedDistances := []float32{
190
+ -50, // the same vector as the query
191
+ // the second element's distance would be -12 which is > -40
192
+ // the third element's distance would be 0 which is > -40
193
+ // the last one is not contained as it would have a distance of 50, which is > 0
194
+ }
195
+
196
+ compareDistances(t, expectedDistances, results)
197
+ })
198
+
199
+ t.Run("with a distance so small that no element should be left", func(t *testing.T) {
200
+ res := AssertGraphQL(t, nil, `
201
+ {
202
+ Get{
203
+ Dot_Class(nearVector:{distance: -60, vector: [3,4,5]}){
204
+ name
205
+ _additional{distance}
206
+ }
207
+ }
208
+ }
209
+ `)
210
+ results := res.Get("Get", "Dot_Class").AsSlice()
211
+ expectedDistances := []float32{
212
+ // all elements have a distance > -60, so nothing matches
213
+ }
214
+
215
+ compareDistances(t, expectedDistances, results)
216
+ })
217
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/explore_test.go ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "encoding/json"
16
+ "testing"
17
+
18
+ "github.com/stretchr/testify/assert"
19
+ "github.com/weaviate/weaviate/entities/models"
20
+ "github.com/weaviate/weaviate/entities/schema"
21
+ )
22
+
23
+ func testExplore(t *testing.T) {
24
+ className := "L2Squared_Class_2"
25
+ defer deleteObjectClass(t, className)
26
+
27
+ t.Run("create second L2 class", func(t *testing.T) {
28
+ createObjectClass(t, &models.Class{
29
+ Class: className,
30
+ Vectorizer: "none",
31
+ Properties: []*models.Property{
32
+ {
33
+ Name: "name",
34
+ DataType: schema.DataTypeText.PropString(),
35
+ Tokenization: models.PropertyTokenizationWhitespace,
36
+ },
37
+ },
38
+ VectorIndexConfig: map[string]interface{}{
39
+ "distance": "l2-squared",
40
+ },
41
+ })
42
+ })
43
+
44
+ t.Run("create objects for the new class", func(t *testing.T) {
45
+ createObject(t, &models.Object{
46
+ Class: className,
47
+ Properties: map[string]interface{}{
48
+ "name": "object_1",
49
+ },
50
+ Vector: []float32{
51
+ 6, 7, 8,
52
+ },
53
+ })
54
+
55
+ createObject(t, &models.Object{
56
+ Class: className,
57
+ Properties: map[string]interface{}{
58
+ "name": "object_2",
59
+ },
60
+ Vector: []float32{
61
+ 1, 2, 3,
62
+ },
63
+ })
64
+ })
65
+
66
+ t.Run("run Explore and assert results", func(t *testing.T) {
67
+ res := AssertGraphQL(t, nil, `
68
+ {
69
+ Explore(nearVector: {vector: [3, 4, 5], distance: 365}) {
70
+ distance
71
+ className
72
+ }
73
+ }
74
+ `)
75
+
76
+ explore := res.Get("Explore").AsSlice()
77
+
78
+ expected := []struct {
79
+ className string
80
+ dist json.Number
81
+ }{
82
+ {className: "L2Squared_Class_2", dist: "12"},
83
+ {className: "L2Squared_Class_2", dist: "27"},
84
+ {className: "L2Squared_Class", dist: "50"},
85
+ {className: "L2Squared_Class", dist: "147"},
86
+ {className: "L2Squared_Class", dist: "365"},
87
+ }
88
+
89
+ for i, item := range explore {
90
+ m, ok := item.(map[string]interface{})
91
+ assert.True(t, ok)
92
+ assert.Equal(t, expected[i].dist, m["distance"])
93
+ assert.Equal(t, expected[i].className, m["className"])
94
+ }
95
+ })
96
+
97
+ t.Run("run Explore with certainty arg and expect failure", func(t *testing.T) {
98
+ res := ErrorGraphQL(t, nil, `
99
+ {
100
+ Explore(nearVector: {vector: [3, 4, 5], certainty: 0.4}) {
101
+ distance
102
+ className
103
+ }
104
+ }
105
+ `)
106
+
107
+ assert.Len(t, res, 1)
108
+ expectedErr := "can't compute and return certainty when vector index is configured with l2-squared distance"
109
+ errorMsg := res[0].Message
110
+ assert.Equal(t, expectedErr, errorMsg)
111
+ })
112
+
113
+ t.Run("run Explore with certainty prop and expect failure", func(t *testing.T) {
114
+ res := ErrorGraphQL(t, nil, `
115
+ {
116
+ Explore(nearVector: {vector: [3, 4, 5], distance: 0.4}) {
117
+ certainty
118
+ className
119
+ }
120
+ }
121
+ `)
122
+
123
+ assert.Len(t, res, 1)
124
+ expectedErr := "can't compute and return certainty when vector index is configured with l2-squared distance"
125
+ errorMsg := res[0].Message
126
+ assert.Equal(t, expectedErr, errorMsg)
127
+ })
128
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/graphql_helper_test.go ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "encoding/json"
16
+ "errors"
17
+ "fmt"
18
+ "testing"
19
+
20
+ "github.com/go-openapi/runtime"
21
+
22
+ "github.com/weaviate/weaviate/client/graphql"
23
+ "github.com/weaviate/weaviate/entities/models"
24
+ "github.com/weaviate/weaviate/test/helper"
25
+ )
26
+
27
+ type GraphQLResult struct {
28
+ Result interface{}
29
+ }
30
+
31
+ // Perform a GraphQL request
32
+ func QueryGraphQL(t *testing.T, auth runtime.ClientAuthInfoWriterFunc, operation string, query string, variables map[string]interface{}) (*models.GraphQLResponse, error) {
33
+ var vars interface{} = variables
34
+ params := graphql.NewGraphqlPostParams().WithBody(&models.GraphQLQuery{OperationName: operation, Query: query, Variables: vars})
35
+ response, err := helper.Client(t).Graphql.GraphqlPost(params, nil)
36
+ if err != nil {
37
+ return nil, err
38
+ }
39
+
40
+ return response.Payload, nil
41
+ }
42
+
43
+ // Perform a GraphQL request and call fatal on failure
44
+ func QueryGraphQLOrFatal(t *testing.T, auth runtime.ClientAuthInfoWriterFunc, operation string, query string, variables map[string]interface{}) *models.GraphQLResponse {
45
+ response, err := QueryGraphQL(t, auth, operation, query, variables)
46
+ if err != nil {
47
+ var parsedErr *graphql.GraphqlPostUnprocessableEntity
48
+ if !errors.As(err, &parsedErr) {
49
+ t.Fatalf("Expected the query to succeed, but failed due to: %#v", err)
50
+ }
51
+ t.Fatalf("Expected the query to succeed, but failed with unprocessable entity: %v", parsedErr.Payload.Error[0])
52
+ }
53
+ return response
54
+ }
55
+
56
+ // Perform a query and assert that it is successful
57
+ func AssertGraphQL(t *testing.T, auth runtime.ClientAuthInfoWriterFunc, query string) *GraphQLResult {
58
+ response := QueryGraphQLOrFatal(t, auth, "", query, nil)
59
+
60
+ if len(response.Errors) != 0 {
61
+ j, _ := json.Marshal(response.Errors)
62
+ t.Fatal("GraphQL resolved to an error:", string(j))
63
+ }
64
+
65
+ data := make(map[string]interface{})
66
+
67
+ // get rid of models.JSONData
68
+ for key, value := range response.Data {
69
+ data[key] = value
70
+ }
71
+
72
+ return &GraphQLResult{Result: data}
73
+ }
74
+
75
+ // Perform a query and assert that it has errors
76
+ func ErrorGraphQL(t *testing.T, auth runtime.ClientAuthInfoWriterFunc, query string) []*models.GraphQLError {
77
+ response := QueryGraphQLOrFatal(t, auth, "", query, nil)
78
+
79
+ if len(response.Errors) == 0 {
80
+ j, _ := json.Marshal(response.Errors)
81
+ t.Fatal("GraphQL resolved to data:", string(j))
82
+ }
83
+
84
+ return response.Errors
85
+ }
86
+
87
+ // Drill down in the result
88
+ func (g GraphQLResult) Get(paths ...string) *GraphQLResult {
89
+ current := g.Result
90
+ for _, path := range paths {
91
+ var ok bool
92
+ currentAsMap := (current.(map[string]interface{}))
93
+ current, ok = currentAsMap[path]
94
+ if !ok {
95
+ panic(fmt.Sprintf("Cannot get element %s in %#v; result: %#v", path, paths, g.Result))
96
+ }
97
+ }
98
+
99
+ return &GraphQLResult{
100
+ Result: current,
101
+ }
102
+ }
103
+
104
+ // Cast the result to a slice
105
+ func (g *GraphQLResult) AsSlice() []interface{} {
106
+ return g.Result.([]interface{})
107
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/hamming_test.go ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "testing"
16
+
17
+ "github.com/weaviate/weaviate/entities/models"
18
+ )
19
+
20
+ func addTestDataHamming(t *testing.T) {
21
+ createObject(t, &models.Object{
22
+ Class: "Hamming_Class",
23
+ Properties: map[string]interface{}{
24
+ "name": "object_1",
25
+ },
26
+ Vector: []float32{
27
+ 10, 10, 10,
28
+ },
29
+ })
30
+
31
+ createObject(t, &models.Object{
32
+ Class: "Hamming_Class",
33
+ Properties: map[string]interface{}{
34
+ "name": "object_2",
35
+ },
36
+ Vector: []float32{
37
+ 10, 10, 12,
38
+ },
39
+ })
40
+
41
+ createObject(t, &models.Object{
42
+ Class: "Hamming_Class",
43
+ Properties: map[string]interface{}{
44
+ "name": "object_3",
45
+ },
46
+ Vector: []float32{
47
+ 10, 11, 12,
48
+ },
49
+ })
50
+ }
51
+
52
+ func testHamming(t *testing.T) {
53
+ t.Run("without any limiting parameters", func(t *testing.T) {
54
+ res := AssertGraphQL(t, nil, `
55
+ {
56
+ Get{
57
+ Hamming_Class(nearVector:{vector: [10,10,10]}){
58
+ name
59
+ _additional{distance}
60
+ }
61
+ }
62
+ }
63
+ `)
64
+ results := res.Get("Get", "Hamming_Class").AsSlice()
65
+ expectedDistances := []float32{
66
+ 0, // the same vector as the query
67
+ 1, // hamming distance to object_3 vector
68
+ 2, // hamming distance to object_4 vector
69
+ }
70
+
71
+ compareDistances(t, expectedDistances, results)
72
+ })
73
+
74
+ t.Run("with a certainty arg", func(t *testing.T) {
75
+ // not supported for non-cosine distances
76
+ ErrorGraphQL(t, nil, `
77
+ {
78
+ Get{
79
+ Hamming_Class(nearVector:{vector: [10,11,12], certainty:0.3}){
80
+ name
81
+ _additional{distance}
82
+ }
83
+ }
84
+ }
85
+ `)
86
+ })
87
+
88
+ t.Run("with a certainty prop", func(t *testing.T) {
89
+ // not supported for non-cosine distances
90
+ ErrorGraphQL(t, nil, `
91
+ {
92
+ Get{
93
+ Hamming_Class(nearVector:{vector: [10,11,12], distance:0.3}){
94
+ name
95
+ _additional{certainty}
96
+ }
97
+ }
98
+ }
99
+ `)
100
+ })
101
+
102
+ t.Run("a high distance that includes all elements", func(t *testing.T) {
103
+ res := AssertGraphQL(t, nil, `
104
+ {
105
+ Get{
106
+ Hamming_Class(nearVector:{vector: [10,10,10], distance: 365}){
107
+ name
108
+ _additional{distance}
109
+ }
110
+ }
111
+ }
112
+ `)
113
+ results := res.Get("Get", "Hamming_Class").AsSlice()
114
+ expectedDistances := []float32{
115
+ 0, // the same vector as the query
116
+ 1, // hamming distance to object_3 vector
117
+ 2, // hamming distance to object_4 vector
118
+ }
119
+
120
+ compareDistances(t, expectedDistances, results)
121
+ })
122
+
123
+ t.Run("a distance that is too low for the last element", func(t *testing.T) {
124
+ res := AssertGraphQL(t, nil, `
125
+ {
126
+ Get{
127
+ Hamming_Class(nearVector:{vector: [10,10,10], distance: 1.5}){
128
+ name
129
+ _additional{distance}
130
+ }
131
+ }
132
+ }
133
+ `)
134
+ results := res.Get("Get", "Hamming_Class").AsSlice()
135
+ expectedDistances := []float32{
136
+ 0, // the same vector as the query
137
+ 1, // hamming distance to object_3 vector
138
+ // hamming distance to object_4 vector skipped because 2>1
139
+ }
140
+
141
+ compareDistances(t, expectedDistances, results)
142
+ })
143
+
144
+ t.Run("a distance that is too low for the second element", func(t *testing.T) {
145
+ res := AssertGraphQL(t, nil, `
146
+ {
147
+ Get{
148
+ Hamming_Class(nearVector:{vector: [10,10,10], distance: 0.5}){
149
+ name
150
+ _additional{distance}
151
+ }
152
+ }
153
+ }
154
+ `)
155
+ results := res.Get("Get", "Hamming_Class").AsSlice()
156
+ expectedDistances := []float32{
157
+ 0, // the same vector as the query
158
+ // hamming distance to object_3 vector skipped because 1>0.5
159
+ // hamming distance to object_4 vector skipped because 2>0.5
160
+ }
161
+
162
+ compareDistances(t, expectedDistances, results)
163
+ })
164
+
165
+ t.Run("a distance of 0 only matches exact elements", func(t *testing.T) {
166
+ res := AssertGraphQL(t, nil, `
167
+ {
168
+ Get{
169
+ Hamming_Class(nearVector:{vector: [10,10,10], distance: 0}){
170
+ name
171
+ _additional{distance}
172
+ }
173
+ }
174
+ }
175
+ `)
176
+ results := res.Get("Get", "Hamming_Class").AsSlice()
177
+ expectedDistances := []float32{
178
+ 0, // the same vector as the query
179
+ // second elem skipped, because 1 > 0
180
+ // last eleme skipped, because 2 > 0
181
+ }
182
+
183
+ compareDistances(t, expectedDistances, results)
184
+ })
185
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/l2_test.go ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "testing"
16
+
17
+ "github.com/weaviate/weaviate/entities/models"
18
+ )
19
+
20
+ func addTestDataL2(t *testing.T) {
21
+ createObject(t, &models.Object{
22
+ Class: "L2Squared_Class",
23
+ Properties: map[string]interface{}{
24
+ "name": "object_1",
25
+ },
26
+ Vector: []float32{
27
+ 10, 11, 12,
28
+ },
29
+ })
30
+
31
+ createObject(t, &models.Object{
32
+ Class: "L2Squared_Class",
33
+ Properties: map[string]interface{}{
34
+ "name": "object_2",
35
+ },
36
+ Vector: []float32{
37
+ 13, 15, 17,
38
+ },
39
+ })
40
+
41
+ createObject(t, &models.Object{
42
+ Class: "L2Squared_Class",
43
+ Properties: map[string]interface{}{
44
+ "name": "object_3",
45
+ },
46
+ Vector: []float32{
47
+ 0, 0, 0, // a zero vecto
48
+ },
49
+ })
50
+ }
51
+
52
+ func testL2(t *testing.T) {
53
+ t.Run("without any limiting parameters", func(t *testing.T) {
54
+ res := AssertGraphQL(t, nil, `
55
+ {
56
+ Get{
57
+ L2Squared_Class(nearVector:{vector: [10,11,12]}){
58
+ name
59
+ _additional{distance}
60
+ }
61
+ }
62
+ }
63
+ `)
64
+ results := res.Get("Get", "L2Squared_Class").AsSlice()
65
+ expectedDistances := []float32{
66
+ 0, // the same vector as the query
67
+ 50, // distance to the second vector
68
+ 365, // l2 squared distance to the root
69
+ }
70
+
71
+ compareDistances(t, expectedDistances, results)
72
+ })
73
+
74
+ t.Run("with a certainty arg", func(t *testing.T) {
75
+ // not supported for non-cosine distances
76
+ ErrorGraphQL(t, nil, `
77
+ {
78
+ Get{
79
+ L2Squared_Class(nearVector:{vector: [10,11,12], certainty:0.3}){
80
+ name
81
+ _additional{distance}
82
+ }
83
+ }
84
+ }
85
+ `)
86
+ })
87
+
88
+ t.Run("with a certainty prop", func(t *testing.T) {
89
+ // not supported for non-cosine distances
90
+ ErrorGraphQL(t, nil, `
91
+ {
92
+ Get{
93
+ L2Squared_Class(nearVector:{vector: [10,11,12], distance:0.3}){
94
+ name
95
+ _additional{certainty}
96
+ }
97
+ }
98
+ }
99
+ `)
100
+ })
101
+
102
+ t.Run("a high distance that includes all elements", func(t *testing.T) {
103
+ res := AssertGraphQL(t, nil, `
104
+ {
105
+ Get{
106
+ L2Squared_Class(nearVector:{vector: [10,11,12], distance: 365}){
107
+ name
108
+ _additional{distance}
109
+ }
110
+ }
111
+ }
112
+ `)
113
+ results := res.Get("Get", "L2Squared_Class").AsSlice()
114
+ expectedDistances := []float32{
115
+ 0, // the same vector as the query
116
+ 50, // distance to the second vector
117
+ 365, // l2 squared distance to the root
118
+ }
119
+
120
+ compareDistances(t, expectedDistances, results)
121
+ })
122
+
123
+ t.Run("a distance that is too low for the last element", func(t *testing.T) {
124
+ res := AssertGraphQL(t, nil, `
125
+ {
126
+ Get{
127
+ L2Squared_Class(nearVector:{vector: [10,11,12], distance: 364}){
128
+ name
129
+ _additional{distance}
130
+ }
131
+ }
132
+ }
133
+ `)
134
+ results := res.Get("Get", "L2Squared_Class").AsSlice()
135
+ expectedDistances := []float32{
136
+ 0, // the same vector as the query
137
+ 50, // distance to the second vector
138
+ // last eleme skipped, because 365 > 364
139
+ }
140
+
141
+ compareDistances(t, expectedDistances, results)
142
+ })
143
+
144
+ t.Run("a distance that is too low for the second element", func(t *testing.T) {
145
+ res := AssertGraphQL(t, nil, `
146
+ {
147
+ Get{
148
+ L2Squared_Class(nearVector:{vector: [10,11,12], distance: 49}){
149
+ name
150
+ _additional{distance}
151
+ }
152
+ }
153
+ }
154
+ `)
155
+ results := res.Get("Get", "L2Squared_Class").AsSlice()
156
+ expectedDistances := []float32{
157
+ 0, // the same vector as the query
158
+ // second elem skipped, because 50 > 49
159
+ // last eleme skipped, because 365 > 364
160
+ }
161
+
162
+ compareDistances(t, expectedDistances, results)
163
+ })
164
+
165
+ t.Run("a really low distance that only matches one elem", func(t *testing.T) {
166
+ res := AssertGraphQL(t, nil, `
167
+ {
168
+ Get{
169
+ L2Squared_Class(nearVector:{vector: [10,11,12], distance: 0.001}){
170
+ name
171
+ _additional{distance}
172
+ }
173
+ }
174
+ }
175
+ `)
176
+ results := res.Get("Get", "L2Squared_Class").AsSlice()
177
+ expectedDistances := []float32{
178
+ 0, // the same vector as the query
179
+ // second elem skipped, because 50 > 0.001
180
+ // last eleme skipped, because 365 > 0.001
181
+ }
182
+
183
+ compareDistances(t, expectedDistances, results)
184
+ })
185
+
186
+ t.Run("a distance of 0 only matches exact elements", func(t *testing.T) {
187
+ res := AssertGraphQL(t, nil, `
188
+ {
189
+ Get{
190
+ L2Squared_Class(nearVector:{vector: [10,11,12], distance: 0}){
191
+ name
192
+ _additional{distance}
193
+ }
194
+ }
195
+ }
196
+ `)
197
+ results := res.Get("Get", "L2Squared_Class").AsSlice()
198
+ expectedDistances := []float32{
199
+ 0, // the same vector as the query
200
+ // second elem skipped, because 50 > 0
201
+ // last eleme skipped, because 365 > 0
202
+ }
203
+
204
+ compareDistances(t, expectedDistances, results)
205
+ })
206
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/manhattan_test.go ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "testing"
16
+
17
+ "github.com/weaviate/weaviate/entities/models"
18
+ )
19
+
20
+ func addTestDataManhattan(t *testing.T) {
21
+ createObject(t, &models.Object{
22
+ Class: "Manhattan_Class",
23
+ Properties: map[string]interface{}{
24
+ "name": "object_1",
25
+ },
26
+ Vector: []float32{
27
+ 10, 11, 12,
28
+ },
29
+ })
30
+
31
+ createObject(t, &models.Object{
32
+ Class: "Manhattan_Class",
33
+ Properties: map[string]interface{}{
34
+ "name": "object_2",
35
+ },
36
+ Vector: []float32{
37
+ 13, 15, 17,
38
+ },
39
+ })
40
+
41
+ createObject(t, &models.Object{
42
+ Class: "Manhattan_Class",
43
+ Properties: map[string]interface{}{
44
+ "name": "object_3",
45
+ },
46
+ Vector: []float32{
47
+ 0, 0, 0, // a zero vector
48
+ },
49
+ })
50
+ }
51
+
52
+ func testManhattan(t *testing.T) {
53
+ t.Run("without any limiting parameters", func(t *testing.T) {
54
+ res := AssertGraphQL(t, nil, `
55
+ {
56
+ Get{
57
+ Manhattan_Class(nearVector:{vector: [10,11,12]}){
58
+ name
59
+ _additional{distance}
60
+ }
61
+ }
62
+ }
63
+ `)
64
+ results := res.Get("Get", "Manhattan_Class").AsSlice()
65
+ expectedDistances := []float32{
66
+ 0, // the same vector as the query
67
+ 12, // distance to the second vector -> abs(10-13)+abs(11-15)+abs(12-17) = 3+4+5 = 12
68
+ 33, // manhattan distance to the root -> 10+11+12 = 33
69
+ }
70
+
71
+ compareDistances(t, expectedDistances, results)
72
+ })
73
+
74
+ t.Run("with a certainty arg", func(t *testing.T) {
75
+ // not supported for non-cosine distances
76
+ ErrorGraphQL(t, nil, `
77
+ {
78
+ Get{
79
+ Manhattan_Class(nearVector:{vector: [10,11,12], certainty:0.3}){
80
+ name
81
+ _additional{distance}
82
+ }
83
+ }
84
+ }
85
+ `)
86
+ })
87
+
88
+ t.Run("with a certainty prop", func(t *testing.T) {
89
+ // not supported for non-cosine distances
90
+ ErrorGraphQL(t, nil, `
91
+ {
92
+ Get{
93
+ Manhattan_Class(nearVector:{vector: [10,11,12], distance:0.3}){
94
+ name
95
+ _additional{certainty}
96
+ }
97
+ }
98
+ }
99
+ `)
100
+ })
101
+
102
+ t.Run("a high distance that includes all elements", func(t *testing.T) {
103
+ res := AssertGraphQL(t, nil, `
104
+ {
105
+ Get{
106
+ Manhattan_Class(nearVector:{vector: [10,11,12], distance: 365}){
107
+ name
108
+ _additional{distance}
109
+ }
110
+ }
111
+ }
112
+ `)
113
+ results := res.Get("Get", "Manhattan_Class").AsSlice()
114
+ expectedDistances := []float32{
115
+ 0, // the same vector as the query
116
+ 12, // distance to the second vector -> abs(10-13)+abs(11-15)+abs(12-17) = 3+4+5 = 12
117
+ 33, // manhattan distance to the root -> 10+11+12 = 33
118
+ }
119
+
120
+ compareDistances(t, expectedDistances, results)
121
+ })
122
+
123
+ t.Run("a distance that is too low for the last element", func(t *testing.T) {
124
+ res := AssertGraphQL(t, nil, `
125
+ {
126
+ Get{
127
+ Manhattan_Class(nearVector:{vector: [10,11,12], distance: 30}){
128
+ name
129
+ _additional{distance}
130
+ }
131
+ }
132
+ }
133
+ `)
134
+ results := res.Get("Get", "Manhattan_Class").AsSlice()
135
+ expectedDistances := []float32{
136
+ 0, // the same vector as the query
137
+ 12, // distance to the second vector -> abs(10-13)+abs(11-15)+abs(12-17) = 3+4+5 = 12
138
+ // last skipped, as 33 > 30
139
+ }
140
+
141
+ compareDistances(t, expectedDistances, results)
142
+ })
143
+
144
+ t.Run("a distance that is too low for the second element", func(t *testing.T) {
145
+ res := AssertGraphQL(t, nil, `
146
+ {
147
+ Get{
148
+ Manhattan_Class(nearVector:{vector: [10,11,12], distance: 10}){
149
+ name
150
+ _additional{distance}
151
+ }
152
+ }
153
+ }
154
+ `)
155
+ results := res.Get("Get", "Manhattan_Class").AsSlice()
156
+ expectedDistances := []float32{
157
+ 0, // the same vector as the query
158
+ // second elem skipped, because 12 > 10
159
+ // last eleme skipped, because 33 > 10
160
+ }
161
+
162
+ compareDistances(t, expectedDistances, results)
163
+ })
164
+
165
+ t.Run("a really low distance that only matches one elem", func(t *testing.T) {
166
+ res := AssertGraphQL(t, nil, `
167
+ {
168
+ Get{
169
+ Manhattan_Class(nearVector:{vector: [10,11,12], distance: 0.001}){
170
+ name
171
+ _additional{distance}
172
+ }
173
+ }
174
+ }
175
+ `)
176
+ results := res.Get("Get", "Manhattan_Class").AsSlice()
177
+ expectedDistances := []float32{
178
+ 0, // the same vector as the query
179
+ // second elem skipped, because 12 > 0.001
180
+ // last eleme skipped, because 33 > 0.001
181
+ }
182
+
183
+ compareDistances(t, expectedDistances, results)
184
+ })
185
+
186
+ t.Run("a distance of 0 only matches exact elements", func(t *testing.T) {
187
+ res := AssertGraphQL(t, nil, `
188
+ {
189
+ Get{
190
+ Manhattan_Class(nearVector:{vector: [10,11,12], distance: 0}){
191
+ name
192
+ _additional{distance}
193
+ }
194
+ }
195
+ }
196
+ `)
197
+ results := res.Get("Get", "Manhattan_Class").AsSlice()
198
+ expectedDistances := []float32{
199
+ 0, // the same vector as the query
200
+ // second elem skipped, because 12 > 0
201
+ // last eleme skipped, because 33 > 0
202
+ }
203
+
204
+ compareDistances(t, expectedDistances, results)
205
+ })
206
+ }
platform/dbops/binaries/weaviate-src/test/acceptance/vector_distances/setup_test.go ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // _ _
2
+ // __ _____ __ ___ ___ __ _| |_ ___
3
+ // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
4
+ // \ V V / __/ (_| |\ V /| | (_| | || __/
5
+ // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
6
+ //
7
+ // Copyright © 2016 - 2025 Weaviate B.V. All rights reserved.
8
+ //
9
+ // CONTACT: hello@weaviate.io
10
+ //
11
+
12
+ package test
13
+
14
+ import (
15
+ "testing"
16
+
17
+ "github.com/weaviate/weaviate/client/objects"
18
+ "github.com/weaviate/weaviate/client/schema"
19
+ "github.com/weaviate/weaviate/entities/models"
20
+ "github.com/weaviate/weaviate/test/helper"
21
+ )
22
+
23
+ func Test_GraphQL(t *testing.T) {
24
+ t.Run("setup test schema (cosine only)", addTestSchemaCosine)
25
+ // at this point only cosine is present, so we can evaluate both Get and
26
+ // Explore
27
+ t.Run("import cosine test data ", addTestDataCosine)
28
+ t.Run("test cosine distance", testCosine)
29
+
30
+ // import rest of the schema meaning, we can only test Get, Explore is now
31
+ // impossible
32
+ t.Run("setup test schema (all)", addTestSchemaOther)
33
+ t.Run("import dot test data ", addTestDataDot)
34
+ t.Run("test dot distance", testDot)
35
+ t.Run("import l2 test data ", addTestDataL2)
36
+ t.Run("test l2 distance", testL2)
37
+ t.Run("import manhattan test data", addTestDataManhattan)
38
+ t.Run("test manhattan distance", testManhattan)
39
+ t.Run("import hamming test data", addTestDataHamming)
40
+ t.Run("test hamming distance", testHamming)
41
+
42
+ // tear down what we no longer need
43
+ deleteObjectClass(t, "Cosine_Class")
44
+ deleteObjectClass(t, "Dot_Class")
45
+ deleteObjectClass(t, "Manhattan_Class")
46
+ deleteObjectClass(t, "Hamming_Class")
47
+ deleteObjectClass(t, "C1")
48
+
49
+ // now only l2 is left so we can test explore with L2
50
+ t.Run("explore across multiple non-cosine classes", testExplore)
51
+
52
+ // tear down remaining classes
53
+ deleteObjectClass(t, "L2Squared_Class")
54
+ }
55
+
56
+ func createObjectClass(t *testing.T, class *models.Class) {
57
+ params := schema.NewSchemaObjectsCreateParams().WithObjectClass(class)
58
+ resp, err := helper.Client(t).Schema.SchemaObjectsCreate(params, nil)
59
+ helper.AssertRequestOk(t, resp, err, nil)
60
+ }
61
+
62
+ func createObject(t *testing.T, object *models.Object) {
63
+ params := objects.NewObjectsCreateParams().WithBody(object)
64
+ resp, err := helper.Client(t).Objects.ObjectsCreate(params, nil)
65
+ helper.AssertRequestOk(t, resp, err, nil)
66
+ }
67
+
68
+ func deleteObjectClass(t *testing.T, class string) {
69
+ delParams := schema.NewSchemaObjectsDeleteParams().WithClassName(class)
70
+ delRes, err := helper.Client(t).Schema.SchemaObjectsDelete(delParams, nil)
71
+ helper.AssertRequestOk(t, delRes, err, nil)
72
+ }