Browse Source

e2e: test 'physical' flag in compact cmd

Gyu-Ho Lee 9 years ago
parent
commit
f63e6875bd
3 changed files with 18 additions and 6 deletions
  1. 10 5
      e2e/ctl_v3_compact_test.go
  2. 1 1
      e2e/ctl_v3_defrag_test.go
  3. 7 0
      e2e/ctl_v3_test.go

+ 10 - 5
e2e/ctl_v3_compact_test.go

@@ -20,10 +20,12 @@ import (
 	"testing"
 )
 
-func TestCtlV3Compact(t *testing.T) { testCtl(t, compactTest) }
+func TestCtlV3Compact(t *testing.T)         { testCtl(t, compactTest) }
+func TestCtlV3CompactPhysical(t *testing.T) { testCtl(t, compactTest, withCompactPhysical()) }
 
 func compactTest(cx ctlCtx) {
-	if err := ctlV3Compact(cx, 2); err != nil {
+	compactPhysical := cx.compactPhysical
+	if err := ctlV3Compact(cx, 2, compactPhysical); err != nil {
 		if !strings.Contains(err.Error(), "required revision is a future revision") {
 			cx.t.Fatal(err)
 		}
@@ -42,7 +44,7 @@ func compactTest(cx ctlCtx) {
 		cx.t.Errorf("compactTest: ctlV3Get error (%v)", err)
 	}
 
-	if err := ctlV3Compact(cx, 4); err != nil {
+	if err := ctlV3Compact(cx, 4, compactPhysical); err != nil {
 		cx.t.Fatal(err)
 	}
 
@@ -54,7 +56,7 @@ func compactTest(cx ctlCtx) {
 		cx.t.Fatalf("expected '...has been compacted' error, got <nil>")
 	}
 
-	if err := ctlV3Compact(cx, 2); err != nil {
+	if err := ctlV3Compact(cx, 2, compactPhysical); err != nil {
 		if !strings.Contains(err.Error(), "required revision has been compacted") {
 			cx.t.Fatal(err)
 		}
@@ -63,8 +65,11 @@ func compactTest(cx ctlCtx) {
 	}
 }
 
-func ctlV3Compact(cx ctlCtx, rev int64) error {
+func ctlV3Compact(cx ctlCtx, rev int64, physical bool) error {
 	rs := strconv.FormatInt(rev, 10)
 	cmdArgs := append(cx.PrefixArgs(), "compact", rs)
+	if physical {
+		cmdArgs = append(cmdArgs, "--physical")
+	}
 	return spawnWithExpect(cmdArgs, "compacted revision "+rs)
 }

+ 1 - 1
e2e/ctl_v3_defrag_test.go

@@ -26,7 +26,7 @@ func defragTest(cx ctlCtx) {
 		}
 	}
 
-	if err := ctlV3Compact(cx, 4); err != nil {
+	if err := ctlV3Compact(cx, 4, cx.compactPhysical); err != nil {
 		cx.t.Fatal(err)
 	}
 

+ 7 - 0
e2e/ctl_v3_test.go

@@ -51,6 +51,9 @@ type ctlCtx struct {
 
 	user string
 	pass string
+
+	// for compaction
+	compactPhysical bool
 }
 
 type ctlOption func(*ctlCtx)
@@ -81,6 +84,10 @@ func withQuota(b int64) ctlOption {
 	return func(cx *ctlCtx) { cx.quotaBackendBytes = b }
 }
 
+func withCompactPhysical() ctlOption {
+	return func(cx *ctlCtx) { cx.compactPhysical = true }
+}
+
 func testCtl(t *testing.T, testFunc func(ctlCtx), opts ...ctlOption) {
 	defer testutil.AfterTest(t)