Skip to content

Commit

Permalink
debug: debug
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Dec 20, 2017
1 parent bb04bc3 commit 2cf2808
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
35 changes: 34 additions & 1 deletion clientv3/integration/leasing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"github.com/coreos/etcd/clientv3/leasing"
"github.com/coreos/etcd/integration"
"github.com/coreos/etcd/pkg/testutil"

"github.com/coreos/pkg/capnslog"
)

func TestLeasingPutGet(t *testing.T) {
Expand Down Expand Up @@ -1359,56 +1361,87 @@ func TestLeasingPutGetDeleteConcurrent(t *testing.T) {
// TestLeasingReconnectOwnerRevoke checks that revocation works if
// disconnected when trying to submit revoke txn.
func TestLeasingReconnectOwnerRevoke(t *testing.T) {
fmt.Println("[DEBUG] TestLeasingReconnectOwnerRevoke starts!")
capnslog.SetGlobalLogLevel(capnslog.INFO)

defer testutil.AfterTest(t)
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
defer clus.Terminate(t)
defer func() {
fmt.Println("[DEBUG] TestLeasingReconnectOwnerRevoke DONE!")
capnslog.SetGlobalLogLevel(capnslog.CRITICAL)
clus.Terminate(t)
}()
fmt.Println("clus.Members:", clus.Members[0].GRPCAddr(), clus.Members[1].GRPCAddr(), clus.Members[2].GRPCAddr())

fmt.Println("[DEBUG] leasing.NewKV 1")
lkv1, closeLKV1, err1 := leasing.NewKV(clus.Client(0), "foo/")
testutil.AssertNil(t, err1)
defer closeLKV1()
fmt.Println("[DEBUG] leasing.NewKV 2")

fmt.Println("[DEBUG] leasing.NewKV 3")
lkv2, closeLKV2, err2 := leasing.NewKV(clus.Client(1), "foo/")
testutil.AssertNil(t, err2)
defer closeLKV2()
fmt.Println("[DEBUG] leasing.NewKV 4")

fmt.Println("[DEBUG] lkv1.Get 1")
if _, err := lkv1.Get(context.TODO(), "k"); err != nil {
t.Fatal(err)
}
fmt.Println("[DEBUG] lkv1.Get 2")

// force leader away from member 0
fmt.Println("[DEBUG] clus.Members[0].Stop 1", clus.Members[0].GRPCAddr())
clus.Members[0].Stop(t)
fmt.Println("[DEBUG] clus.Members[0].Stop 2", clus.Members[0].GRPCAddr())
fmt.Println("[DEBUG] WaitLeader 1")
clus.WaitLeader(t)
fmt.Println("[DEBUG] WaitLeader 2")
fmt.Println("[DEBUG] clus.Members[0].Restart 1", clus.Members[0].GRPCAddr())
clus.Members[0].Restart(t)
fmt.Println("[DEBUG] clus.Members[0].Restart 2", clus.Members[0].GRPCAddr())

cctx, cancel := context.WithCancel(context.TODO())
sdonec, pdonec := make(chan struct{}), make(chan struct{})
// make lkv1 connection choppy so Txn fails
go func() {
defer close(sdonec)
for i := 0; i < 10 && cctx.Err() == nil; i++ {
fmt.Println("[DEBUG] clus.Members[0].Stop 2-1", clus.Members[0].GRPCAddr())
clus.Members[0].Stop(t)
fmt.Println("[DEBUG] clus.Members[0].Stop 2-2", clus.Members[0].GRPCAddr())
time.Sleep(10 * time.Millisecond)
fmt.Println("[DEBUG] clus.Members[0].Restart 2-1", clus.Members[0].GRPCAddr())
clus.Members[0].Restart(t)
fmt.Println("[DEBUG] clus.Members[0].Restart 2-2", clus.Members[0].GRPCAddr())
}
}()
go func() {
defer close(pdonec)
fmt.Println("[DEBUG] lkv2.Put 1")
if _, err := lkv2.Put(cctx, "k", "v"); err != nil {
t.Log(err)
}
fmt.Println("[DEBUG] lkv2.Put 2")
fmt.Println("[DEBUG] lkv1.Get 1")
resp, err := lkv1.Get(cctx, "k")
if err != nil {
t.Fatal(err)
}
fmt.Println("[DEBUG] lkv1.Get 2")
if string(resp.Kvs[0].Value) != "v" {
t.Fatalf(`expected "v" value, got %+v`, resp)
}
}()
fmt.Println("[DEBUG] start waiting...")
select {
case <-pdonec:
fmt.Println("[DEBUG] pdonec")
cancel()
<-sdonec
case <-time.After(10 * time.Second):
fmt.Println("[DEBUG] time.After")
cancel()
<-sdonec
<-pdonec
Expand Down
10 changes: 0 additions & 10 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ function integration_pass {
}

function integration_extra {
go test -timeout 1m -v ${RACE} -cpu 1,2,4 "$@" "${REPO_PATH}/client/integration"
go test -timeout 20m -v ${RACE} -cpu 1,2,4 "$@" "${REPO_PATH}/clientv3/integration"
go test -timeout 1m -v -cpu 1,2,4 "$@" "${REPO_PATH}/contrib/raftexample"
go test -timeout 5m -v ${RACE} -tags v2v3 "$@" "${REPO_PATH}/store"
go test -timeout 1m -v ${RACE} -cpu 1,2,4 -run=Example "$@" "${TEST[@]}"
}

function functional_pass {
Expand Down Expand Up @@ -228,12 +224,6 @@ function e2e_pass {
function integration_e2e_pass {
echo "Running integration and e2e tests..."

go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/e2e" &
e2epid="$!"
go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/integration" &
intpid="$!"
wait $e2epid
wait $intpid
integration_extra "$@"
}

Expand Down

0 comments on commit 2cf2808

Please sign in to comment.