Skip to content

Commit

Permalink
test valkey 8
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver006 committed Oct 14, 2024
1 parent 4d260d8 commit c72f959
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test:
TEST_VALKEY7_URI="valkey://localhost:16384" \
TEST_VALKEY8_URI="valkey://localhost:16382" \
TEST_VALKEY8_TLS_URI="valkeys://localhost:16386" \
TEST_REDIS7_TLS_URI="rediss://localhost:16386" \
TEST_REDIS7_TLS_URI="rediss://localhost:16387" \
TEST_REDIS_URI="redis://localhost:16385" \
TEST_REDIS7_URI="redis://localhost:16385" \
TEST_REDIS5_URI="redis://localhost:16383" \
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
services:

redis74:
redis7:
image: redis:7.4
command: "redis-server --enable-debug-command yes --protected-mode no"
ports:
- "16385:6379"
- "6379:6379"

redis74-tls:
redis7-tls:
image: redis:7.4
volumes:
- ./contrib/tls:/tls
command: |
valkey-server --enable-debug-command yes --protected-mode no
redis-server --enable-debug-command yes --protected-mode no
--tls-port 6379 --port 0
--tls-cert-file /tls/redis.crt
--tls-key-file /tls/redis.key
Expand Down
2 changes: 1 addition & 1 deletion exporter/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ func TestSimultaneousMetricsHttpRequests(t *testing.T) {
os.Getenv("TEST_REDIS_2_8_URI"),

os.Getenv("TEST_REDIS7_URI"),
os.Getenv("TEST_REDIS7_TLS_URI"),

os.Getenv("TEST_VALKEY7_URI"),
os.Getenv("TEST_VALKEY8_URI"),

os.Getenv("TEST_KEYDB01_URI"),
Expand Down
4 changes: 2 additions & 2 deletions exporter/streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestStreamsGetStreamInfoUsingValKey7(t *testing.T) {
t.Skipf("TEST_VALKEY7_URI not set - skipping")
}

addr := os.Getenv("TEST_VALKEY7_URI")
addr := strings.Replace(os.Getenv("TEST_VALKEY7_URI"), "valkey://", "redis://", 1)
c, err := redis.DialURL(addr)
if err != nil {
t.Fatalf("Couldn't connect to %#v: %#v", addr, err)
Expand Down Expand Up @@ -285,7 +285,7 @@ func TestStreamsScanStreamGroupsUsingValKey7(t *testing.T) {
if os.Getenv("TEST_VALKEY7_URI") == "" {
t.Skipf("TEST_VALKEY7_URI not set - skipping")
}
addr := os.Getenv("TEST_VALKEY7_URI")
addr := strings.Replace(os.Getenv("TEST_VALKEY7_URI"), "valkey://", "redis://", 1)
db := dbNumStr

c, err := redis.DialURL(addr)
Expand Down
82 changes: 42 additions & 40 deletions exporter/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,53 +45,55 @@ func TestCreateClientTLSConfig(t *testing.T) {
}

func TestValkeyTLSScheme(t *testing.T) {

for _, host := range []string{
os.Getenv("TEST_REDIS7_TLS_URI"),
os.Getenv("TEST_VALKEY8_TLS_URI"),
} {
t.Run(host, func(t *testing.T) {

e, _ := NewRedisExporter(host,
Options{
SkipTLSVerification: true,
ClientCertFile: "../contrib/tls/redis.crt",
ClientKeyFile: "../contrib/tls/redis.key",
},
)
c, err := e.connectToRedis()
if err != nil {
t.Fatalf("connectToRedis() err: %s", err)
}

if _, err := c.Do("PING", ""); err != nil {
t.Errorf("PING err: %s", err)
}

e, _ := NewRedisExporter(host,
Options{
SkipTLSVerification: true,
ClientCertFile: "../contrib/tls/redis.crt",
ClientKeyFile: "../contrib/tls/redis.key",
},
)
c, err := e.connectToRedis()
if err != nil {
t.Fatalf("connectToRedis() err: %s", err)
}

if _, err := c.Do("PING", ""); err != nil {
t.Errorf("PING err: %s", err)
}

c.Close()

chM := make(chan prometheus.Metric)
go func() {
e.Collect(chM)
close(chM)
}()

tsts := []struct {
in string
found bool
}{
{in: "db_keys"},
{in: "commands_total"},
{in: "total_connections_received"},
{in: "used_memory"},
}
for m := range chM {
desc := m.Desc().String()
for i := range tsts {
if strings.Contains(desc, tsts[i].in) {
tsts[i].found = true
c.Close()

chM := make(chan prometheus.Metric)
go func() {
e.Collect(chM)
close(chM)
}()

tsts := []struct {
in string
found bool
}{
{in: "db_keys"},
{in: "commands_total"},
{in: "total_connections_received"},
{in: "used_memory"},
}
for m := range chM {
desc := m.Desc().String()
for i := range tsts {
if strings.Contains(desc, tsts[i].in) {
tsts[i].found = true
}
}
}
}

})
}
}

Expand Down

0 comments on commit c72f959

Please sign in to comment.