increase the size of txn to support vault (#14599)

* increase the size of txn to support vault

* add test, revert change to acl endpoint

* add changelog

* update test, add passing test case

* Update .changelog/14599.txt

Co-authored-by: Freddy <freddygv@users.noreply.github.com>

Co-authored-by: Freddy <freddygv@users.noreply.github.com>
This commit is contained in:
malizz 2022-09-19 09:07:19 -07:00 committed by GitHub
parent 3f19b1235d
commit a3fc665eef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 1 deletions

3
.changelog/14599.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
api: Increase max number of operations inside a transaction for requests to /v1/txn (128)
```

View File

@ -17,7 +17,7 @@ const (
// maxTxnOps is used to set an upper limit on the number of operations
// inside a transaction. If there are more operations than this, then the
// client is likely abusing transactions.
maxTxnOps = 64
maxTxnOps = 128
)
// decodeValue decodes the value member of the given operation.

View File

@ -798,3 +798,54 @@ func TestTxnEndpoint_NodeService(t *testing.T) {
}
assert.Equal(t, expected, txnResp)
}
func TestTxnEndpoint_OperationsSize(t *testing.T) {
if testing.Short() {
t.Skip("too slow for testing.Short")
}
t.Run("too-many-operations", func(t *testing.T) {
var ops []api.TxnOp
agent := NewTestAgent(t, "limits = { txn_max_req_len = 700000 }")
for i := 0; i < 130; i++ {
ops = append(ops, api.TxnOp{
KV: &api.KVTxnOp{
Verb: api.KVSet,
Key: "key",
Value: []byte("test"),
},
})
}
req, _ := http.NewRequest("PUT", "/v1/txn", jsonBody(ops))
resp := httptest.NewRecorder()
raw, err := agent.srv.Txn(resp, req)
require.Error(t, err)
require.Contains(t, err.Error(), "Transaction contains too many operations")
require.Nil(t, raw)
agent.Shutdown()
})
t.Run("allowed", func(t *testing.T) {
var ops []api.TxnOp
agent := NewTestAgent(t, "limits = { txn_max_req_len = 700000 }")
for i := 0; i < 128; i++ {
ops = append(ops, api.TxnOp{
KV: &api.KVTxnOp{
Verb: api.KVSet,
Key: "key",
Value: []byte("test"),
},
})
}
req, _ := http.NewRequest("PUT", "/v1/txn", jsonBody(ops))
resp := httptest.NewRecorder()
raw, err := agent.srv.Txn(resp, req)
require.NoError(t, err)
require.NotNil(t, raw)
agent.Shutdown()
})
}