Skip to content

Commit 542dd15

Browse files
committed
Add valkey8-bundle to search index tests
1 parent 12c6285 commit 542dd15

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test:
3737
TEST_REDIS_URI="redis://localhost:6379" \
3838
TEST_VALKEY7_URI="valkey://localhost:16384" \
3939
TEST_VALKEY8_URI="valkey://localhost:16382" \
40+
TEST_VALKEY8_BUNDLE_URI="valkey://localhost:16389" \
4041
TEST_VALKEY8_TLS_URI="valkeys://localhost:16386" \
4142
TEST_REDIS7_TLS_URI="rediss://localhost:16387" \
4243
TEST_REDIS8_URI="redis://localhost:16388" \

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ services:
2020
ports:
2121
- "16386:6379"
2222

23+
valkey8-bundle:
24+
image: valkey/valkey-bundle:8
25+
command: "valkey-server --enable-debug-command yes --protected-mode no"
26+
ports:
27+
- "16389:6379"
28+
2329
valkey7:
2430
image: valkey/valkey:7
2531
command: "valkey-server --enable-debug-command yes --protected-mode no"

exporter/modules_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func TestModulesv74(t *testing.T) {
7474
}
7575

7676
func TestModulesv80(t *testing.T) {
77-
if os.Getenv("TEST_REDIS8_URI") == "" {
78-
t.Skipf("TEST_REDIS8_URI not set - skipping")
77+
if os.Getenv("TEST_REDIS8_URI") == "" || os.Getenv("TEST_REDIS_URI") == "" {
78+
t.Skipf("TEST_REDIS8_URI / TEST_REDIS_URI aren't set - skipping")
7979
}
8080

8181
tsts := []struct {

exporter/search_indexes_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,36 @@ func setupSearchIndex(t *testing.T, addr string) error {
1818
}
1919
defer c.Close()
2020

21-
// create search index, based on https://redis.io/docs/latest/develop/get-started/document-database/
22-
if _, err := doRedisCmd(c, "FT.CREATE", "idx:bicycle", "ON", "JSON", "PREFIX", "1", "bicycle:", "SCORE", "1.0", "SCHEMA", "$.brand", "AS", "brand", "TEXT", "WEIGHT", "1.0", "$.model", "AS", "model", "TEXT", "WEIGHT", "1.0", "$.description", "AS", "description", "TEXT", "WEIGHT", "1.0", "$.price", "AS", "price", "NUMERIC", "$.condition", "AS", "condition", "TAG", "SEPARATOR", ","); err != nil {
21+
// create search index, based on https://redis.io/docs/latest/commands/ft.create and https://valkey.io/commands/ft.create
22+
if _, err := doRedisCmd(c, "FT.CREATE", "test_index", "SCHEMA", "my_hash_field_key", "VECTOR", "HNSW", "10", "TYPE", "FLOAT32", "DIM", "20", "DISTANCE_METRIC", "COSINE", "M", "4", "EF_CONSTRUCTION", "100"); err != nil {
2323
log.Printf("setupSearchIndex() - couldn't create search index, err: %s ", err)
2424
return err
2525
}
2626
return nil
2727
}
2828

2929
func TestExtractSearchIndexesMetrics(t *testing.T) {
30-
if os.Getenv("TEST_REDIS8_URI") == "" {
31-
t.Skipf("TEST_REDIS8_URI not set - skipping")
30+
test_redis8_uri := os.Getenv("TEST_REDIS8_URI")
31+
test_valkey8_bundle_uri := os.Getenv("TEST_VALKEY8_BUNDLE_URI")
32+
if test_redis8_uri == "" || test_valkey8_bundle_uri == "" {
33+
t.Skipf("TEST_REDIS8_URI or TEST_VALKEY8_BUNDLE_URI aren't set - skipping")
3234
}
33-
if err := setupSearchIndex(t, os.Getenv("TEST_REDIS8_URI")); err != nil {
34-
t.Fatalf("couldn't create search index, err: %s ", err)
35+
if err := setupSearchIndex(t, test_redis8_uri); err != nil {
36+
t.Fatalf("couldn't create search index in TEST_REDIS8_URI (%s), err: %s ", test_redis8_uri, err)
37+
}
38+
if err := setupSearchIndex(t, test_valkey8_bundle_uri); err != nil {
39+
t.Fatalf("couldn't create search index in TEST_VALKEY8_BUNDLE_URI (%s), err: %s ", test_valkey8_bundle_uri, err)
3540
}
3641

3742
tsts := []struct {
3843
addr string
3944
inclSearchIndexesMetrics bool
4045
wantSearchIndexesMetrics bool
4146
}{
42-
{addr: os.Getenv("TEST_REDIS8_URI"), inclSearchIndexesMetrics: true, wantSearchIndexesMetrics: true},
43-
{addr: os.Getenv("TEST_REDIS8_URI"), inclSearchIndexesMetrics: false, wantSearchIndexesMetrics: false},
47+
{addr: test_redis8_uri, inclSearchIndexesMetrics: true, wantSearchIndexesMetrics: true},
48+
{addr: test_redis8_uri, inclSearchIndexesMetrics: false, wantSearchIndexesMetrics: false},
49+
{addr: test_valkey8_bundle_uri, inclSearchIndexesMetrics: true, wantSearchIndexesMetrics: true},
50+
{addr: test_valkey8_bundle_uri, inclSearchIndexesMetrics: false, wantSearchIndexesMetrics: false},
4451
}
4552

4653
for _, tst := range tsts {

0 commit comments

Comments
 (0)