MCPcopy
hub / github.com/etcd-io/etcd / TestVerifyHashKVAfterCompact

Function TestVerifyHashKVAfterCompact

tests/e2e/hashkv_test.go:32–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestVerifyHashKVAfterCompact(t *testing.T) {
33 scenarios := []struct {
34 clusterVersion e2e.ClusterVersion
35 keys []string // used for data generators
36 }{
37 {
38 clusterVersion: e2e.CurrentVersion,
39 keys: []string{"key0"},
40 },
41 {
42 clusterVersion: e2e.CurrentVersion,
43 keys: []string{"key0", "key1"},
44 },
45 {
46 clusterVersion: e2e.QuorumLastVersion,
47 keys: []string{"key0"},
48 },
49 {
50 clusterVersion: e2e.QuorumLastVersion,
51 keys: []string{"key0", "key1"},
52 },
53 }
54
55 for _, compactedOnTombstoneRev := range []bool{false, true} {
56 for _, scenario := range scenarios {
57 t.Run(fmt.Sprintf("compactedOnTombstone=%v - %s - Keys=%v", compactedOnTombstoneRev, scenario.clusterVersion, scenario.keys), func(t *testing.T) {
58 e2e.BeforeTest(t)
59
60 if scenario.clusterVersion != e2e.CurrentVersion {
61 if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
62 t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
63 }
64 }
65
66 ctx := context.Background()
67
68 cfg := e2e.NewConfigClientTLS()
69 clus, err := e2e.NewEtcdProcessCluster(ctx, t,
70 e2e.WithConfig(cfg),
71 e2e.WithClusterSize(3),
72 e2e.WithVersion(scenario.clusterVersion))
73 require.NoError(t, err)
74
75 t.Cleanup(func() { clus.Close() })
76
77 tombstoneRevs, lastestRev := populateDataForHashKV(t, clus, cfg.Client, scenario.keys)
78
79 compactedOnRev := tombstoneRevs[0]
80
81 // If compaction revision isn't a tombstone, select a revision in the middle of two tombstones.
82 if !compactedOnTombstoneRev {
83 compactedOnRev = (tombstoneRevs[0] + tombstoneRevs[1]) / 2
84 require.Greater(t, compactedOnRev, tombstoneRevs[0])
85 require.Greater(t, tombstoneRevs[1], compactedOnRev)
86 }
87
88 cli, err := e2e.NewEtcdctl(cfg.Client, clus.EndpointsGRPC())
89 require.NoError(t, err)

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
EndpointsGRPCMethod · 0.95
populateDataForHashKVFunction · 0.85
RunMethod · 0.65
BeforeTestMethod · 0.65
CleanupMethod · 0.65
LogfMethod · 0.65
CompactMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…