mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
e2e: add getCountOnlyTest testcase
(cherry picked from commit 3594ab94cfefa7488993ac14e7b410ee63b25d3d) Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
00a005c300
commit
2070f55aab
@ -41,9 +41,10 @@ func TestCtlV3GetPeerTLS(t *testing.T) { testCtl(t, getTest, withCfg(confi
|
|||||||
func TestCtlV3GetTimeout(t *testing.T) { testCtl(t, getTest, withDialTimeout(0)) }
|
func TestCtlV3GetTimeout(t *testing.T) { testCtl(t, getTest, withDialTimeout(0)) }
|
||||||
func TestCtlV3GetQuorum(t *testing.T) { testCtl(t, getTest, withQuorum()) }
|
func TestCtlV3GetQuorum(t *testing.T) { testCtl(t, getTest, withQuorum()) }
|
||||||
|
|
||||||
func TestCtlV3GetFormat(t *testing.T) { testCtl(t, getFormatTest) }
|
func TestCtlV3GetFormat(t *testing.T) { testCtl(t, getFormatTest) }
|
||||||
func TestCtlV3GetRev(t *testing.T) { testCtl(t, getRevTest) }
|
func TestCtlV3GetRev(t *testing.T) { testCtl(t, getRevTest) }
|
||||||
func TestCtlV3GetKeysOnly(t *testing.T) { testCtl(t, getKeysOnlyTest) }
|
func TestCtlV3GetKeysOnly(t *testing.T) { testCtl(t, getKeysOnlyTest) }
|
||||||
|
func TestCtlV3GetCountOnly(t *testing.T) { testCtl(t, getCountOnlyTest) }
|
||||||
|
|
||||||
func TestCtlV3Del(t *testing.T) { testCtl(t, delTest) }
|
func TestCtlV3Del(t *testing.T) { testCtl(t, delTest) }
|
||||||
func TestCtlV3DelNoTLS(t *testing.T) { testCtl(t, delTest, withCfg(configNoTLS)) }
|
func TestCtlV3DelNoTLS(t *testing.T) { testCtl(t, delTest, withCfg(configNoTLS)) }
|
||||||
@ -235,6 +236,44 @@ func getKeysOnlyTest(cx ctlCtx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCountOnlyTest(cx ctlCtx) {
|
||||||
|
cmdArgs := append(cx.PrefixArgs(), []string{"get", "--count-only", "key", "--prefix", "--write-out=fields"}...)
|
||||||
|
if err := spawnWithExpects(cmdArgs, "\"Count\" : 0"); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ctlV3Put(cx, "key", "val", ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
cmdArgs = append(cx.PrefixArgs(), []string{"get", "--count-only", "key", "--prefix", "--write-out=fields"}...)
|
||||||
|
if err := spawnWithExpects(cmdArgs, "\"Count\" : 1"); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ctlV3Put(cx, "key1", "val", ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ctlV3Put(cx, "key1", "val", ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
cmdArgs = append(cx.PrefixArgs(), []string{"get", "--count-only", "key", "--prefix", "--write-out=fields"}...)
|
||||||
|
if err := spawnWithExpects(cmdArgs, "\"Count\" : 2"); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ctlV3Put(cx, "key2", "val", ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
cmdArgs = append(cx.PrefixArgs(), []string{"get", "--count-only", "key", "--prefix", "--write-out=fields"}...)
|
||||||
|
if err := spawnWithExpects(cmdArgs, "\"Count\" : 3"); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
expected := []string{
|
||||||
|
"\"Count\" : 3",
|
||||||
|
}
|
||||||
|
cmdArgs = append(cx.PrefixArgs(), []string{"get", "--count-only", "key3", "--prefix", "--write-out=fields"}...)
|
||||||
|
if err := spawnWithExpects(cmdArgs, expected...); err == nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func delTest(cx ctlCtx) {
|
func delTest(cx ctlCtx) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
puts []kv
|
puts []kv
|
||||||
|
Loading…
x
Reference in New Issue
Block a user