Skip to content

Commit

Permalink
integration: creation of cluster now takes maxTxnOps
Browse files Browse the repository at this point in the history
  • Loading branch information
fanminshi committed May 24, 2017
1 parent ae7ddfb commit 34b8bad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions clientv3/integration/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"time"

"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/etcdserver/api/v3rpc"
"github.com/coreos/etcd/embed"
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
"github.com/coreos/etcd/integration"
"github.com/coreos/etcd/pkg/testutil"
Expand All @@ -41,7 +41,7 @@ func TestTxnError(t *testing.T) {
t.Fatalf("expected %v, got %v", rpctypes.ErrDuplicateKey, err)
}

ops := make([]clientv3.Op, v3rpc.MaxTxnOps+10)
ops := make([]clientv3.Op, int(embed.DefaultMaxTxnOps+10))
for i := range ops {
ops[i] = clientv3.OpPut(fmt.Sprintf("foo%d", i), "")
}
Expand Down
8 changes: 8 additions & 0 deletions integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

"github.com/coreos/etcd/client"
"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/embed"
"github.com/coreos/etcd/etcdserver"
"github.com/coreos/etcd/etcdserver/api/v2http"
"github.com/coreos/etcd/etcdserver/api/v3client"
Expand Down Expand Up @@ -93,6 +94,7 @@ type ClusterConfig struct {
DiscoveryURL string
UseGRPC bool
QuotaBackendBytes int64
MaxTxnOps uint
}

type cluster struct {
Expand Down Expand Up @@ -224,6 +226,7 @@ func (c *cluster) mustNewMember(t *testing.T) *member {
peerTLS: c.cfg.PeerTLS,
clientTLS: c.cfg.ClientTLS,
quotaBackendBytes: c.cfg.QuotaBackendBytes,
maxTxnOps: c.cfg.MaxTxnOps,
})
m.DiscoveryURL = c.cfg.DiscoveryURL
if c.cfg.UseGRPC {
Expand Down Expand Up @@ -490,6 +493,7 @@ type memberConfig struct {
peerTLS *transport.TLSInfo
clientTLS *transport.TLSInfo
quotaBackendBytes int64
maxTxnOps uint
}

// mustNewMember return an inited member with the given name. If peerTLS is
Expand Down Expand Up @@ -537,6 +541,10 @@ func mustNewMember(t *testing.T, mcfg memberConfig) *member {
m.ElectionTicks = electionTicks
m.TickMs = uint(tickDuration / time.Millisecond)
m.QuotaBackendBytes = mcfg.quotaBackendBytes
m.MaxTxnOps = mcfg.maxTxnOps
if m.MaxTxnOps == 0 {
m.MaxTxnOps = embed.DefaultMaxTxnOps
}
m.AuthToken = "simple" // for the purpose of integration testing, simple token is enough
return m
}
Expand Down
6 changes: 3 additions & 3 deletions integration/v3_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"time"

"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/etcdserver/api/v3rpc"
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/coreos/etcd/pkg/testutil"
Expand Down Expand Up @@ -150,7 +149,8 @@ func TestV3CompactCurrentRev(t *testing.T) {

func TestV3TxnTooManyOps(t *testing.T) {
defer testutil.AfterTest(t)
clus := NewClusterV3(t, &ClusterConfig{Size: 3})
maxTxnOps := uint(128)
clus := NewClusterV3(t, &ClusterConfig{Size: 3, MaxTxnOps: maxTxnOps})
defer clus.Terminate(t)

kvc := toGRPC(clus.RandClient()).KV
Expand Down Expand Up @@ -201,7 +201,7 @@ func TestV3TxnTooManyOps(t *testing.T) {

for i, tt := range tests {
txn := &pb.TxnRequest{}
for j := 0; j < v3rpc.MaxTxnOps+1; j++ {
for j := 0; j < int(maxTxnOps+1); j++ {
tt(txn)
}

Expand Down

0 comments on commit 34b8bad

Please sign in to comment.