MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / TestBasicOperations

Function TestBasicOperations

store/engine/postgresql/postgresql_test.go:40–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38)
39
40func TestBasicOperations(t *testing.T) {
41 id := util.RandString(40)
42 testElectPath := util.RandString(32)
43 persist, err := New(id, &Config{
44 Username: username,
45 Password: password,
46 DBName: dbName,
47 NotifyChannel: notifyChannel,
48 ElectPath: testElectPath,
49 Addrs: []string{addr},
50 })
51 require.NoError(t, err)
52 defer persist.Close()
53 go func() {
54 for range persist.LeaderChange() {
55 // do nothing
56 }
57 }()
58
59 ctx := context.Background()
60 keys := []string{"/a/b/c0", "/a/b/c1", "/a/b/c2"}
61 value := []byte("v")
62 for _, key := range keys {
63 require.NoError(t, persist.Set(ctx, key, value))
64 gotValue, err := persist.Get(ctx, key)
65 require.NoError(t, err)
66 require.Equal(t, value, gotValue)
67 }
68 entries, err := persist.List(ctx, "/a/b")
69 require.NoError(t, err)
70 require.Equal(t, len(keys), len(entries))
71 for _, key := range keys {
72 require.NoError(t, persist.Delete(ctx, key))
73 }
74}
75
76func TestElect(t *testing.T) {
77 endpoints := []string{addr}

Callers

nothing calls this directly

Calls 9

RandStringFunction · 0.92
EqualMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65
LeaderChangeMethod · 0.65
SetMethod · 0.65
GetMethod · 0.65
ListMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected