integration: creation of cluster now takes maxTxnOps
This commit is contained in:
@ -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"
|
||||
@ -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), "")
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ func newConfig() *config {
|
||||
fs.UintVar(&cfg.TickMs, "heartbeat-interval", cfg.TickMs, "Time (in milliseconds) of a heartbeat interval.")
|
||||
fs.UintVar(&cfg.ElectionMs, "election-timeout", cfg.ElectionMs, "Time (in milliseconds) for an election to timeout.")
|
||||
fs.Int64Var(&cfg.QuotaBackendBytes, "quota-backend-bytes", cfg.QuotaBackendBytes, "Raise alarms when backend size exceeds the given quota. 0 means use the default quota.")
|
||||
fs.UintVar(&cfg.MaxTxnOps, "max-txn-ops", cfg.MaxTxnOps, "Maximum operations per txn that etcd server allows; defaults to 128.")
|
||||
fs.UintVar(&cfg.MaxTxnOps, "max-txn-ops", cfg.MaxTxnOps, "Maximum number of operations permitted in a transaction.")
|
||||
|
||||
// clustering
|
||||
fs.Var(flags.NewURLsValue(embed.DefaultInitialAdvertisePeerURLs), "initial-advertise-peer-urls", "List of this member's peer URLs to advertise to the rest of the cluster.")
|
||||
|
@ -67,7 +67,7 @@ member flags:
|
||||
--quota-backend-bytes '0'
|
||||
raise alarms when backend size exceeds the given quota (0 defaults to low space quota).
|
||||
--max-txn-ops '128'
|
||||
maximum operations per txn that etcd server allows; defaults to 128.
|
||||
maximum number of operations permitted in a transaction.
|
||||
|
||||
clustering flags:
|
||||
|
||||
|
@ -152,7 +152,6 @@ func checkDeleteRequest(r *pb.DeleteRangeRequest) error {
|
||||
}
|
||||
|
||||
func checkTxnRequest(r *pb.TxnRequest, maxTxnOps int) error {
|
||||
plog.Infof("maxTxnOps %v", maxTxnOps)
|
||||
if len(r.Compare) > maxTxnOps || len(r.Success) > maxTxnOps || len(r.Failure) > maxTxnOps {
|
||||
return rpctypes.ErrGRPCTooManyOps
|
||||
}
|
||||
|
@ -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"
|
||||
@ -93,6 +94,7 @@ type ClusterConfig struct {
|
||||
DiscoveryURL string
|
||||
UseGRPC bool
|
||||
QuotaBackendBytes int64
|
||||
MaxTxnOps uint
|
||||
}
|
||||
|
||||
type cluster struct {
|
||||
@ -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 {
|
||||
@ -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
|
||||
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
@ -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
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user