-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rafttest: support multi-command statements #141
Draft
pav-kv
wants to merge
27
commits into
etcd-io:main
Choose a base branch
from
pav-kv:revamp-testdriven
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0fd7150
rafttest: support multi-command statements
pav-kv b716493
testdata: compress async_storage_writes
pav-kv ba5768e
testdata: compress async_storage_writes_append_aba_race
pav-kv 25b2f62
testdata: compress campaign_learner_must_vote
pav-kv 23d40b5
testdata: compress checkquorum
pav-kv 6312ada
testdata: compress confchange_disable_validation
pav-kv 8c1d187
testdata: compress confchange_v1_add_single
pav-kv 002a762
testdata: compress confchange_v1_remove_leader
pav-kv 2c9f0da
testdata: compress confchange_v1_remove_leader_stepdown
pav-kv 91a4fb5
testdata: compress confchange_v2_add_double_auto
pav-kv 1c2c831
testdata: compress confchange_v2_add_double_implicit
pav-kv 1ccfbde
testdata: compress confchange_v2_add_single_auto
pav-kv cdb9c8f
testdata: compress confchange_v2_add_single_explicit
pav-kv 2df089f
testdata: compress confchange_v2_replace_leader
pav-kv 9171140
testdata: compress confchange_v2_replace_leader_stepdown
pav-kv 2cdae74
testdata: compress forget_leader
pav-kv d79825b
testdata: compress forget_leader_prevote_checkquorum
pav-kv e6cf75f
testdata: compress forget_leader_read_only_lease_based
pav-kv 96d5a0a
testdata: compress heartbeat_resp_recovers_from_probing
pav-kv 9f87dee
testdata: compress prevote
pav-kv d10f9f0
testdata: compress prevote_checkquorum
pav-kv c674bec
testdata: compress probe_and_replicate
pav-kv 1b0951e
testdata: compress replicate_pause
pav-kv 2942896
testdata: compress single_node
pav-kv 88680ed
testdata: compress slow_follower_after_compaction
pav-kv 2d04ec7
testdata: compress snapshot_succeed_via_app_resp
pav-kv 11c763f
testdata: compress snapshot_succeed_via_app_resp_behind
pav-kv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package rafttest | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/cockroachdb/datadriven" | ||
) | ||
|
||
// scanArgs is a copy-paste from datadriven. TODO | ||
func scanArgs(args []datadriven.CmdArg, key string, dests ...interface{}) error { | ||
var arg datadriven.CmdArg | ||
for i := range args { | ||
if args[i].Key == key { | ||
arg = args[i] | ||
break | ||
} | ||
} | ||
if arg.Key == "" { | ||
return fmt.Errorf("missing argument: %s", key) | ||
} | ||
if len(dests) != len(arg.Vals) { | ||
return fmt.Errorf("%s: got %d destinations, but %d values", arg.Key, len(dests), len(arg.Vals)) | ||
} | ||
|
||
for i := range dests { | ||
if err := scanErr(arg, i, dests[i]); err != nil { | ||
return fmt.Errorf("%s: failed to scan argument %d: %v", arg.Key, i, err) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// scanErr is like Scan but returns an error rather than taking a testing.T to fatal. | ||
func scanErr(arg datadriven.CmdArg, i int, dest interface{}) error { | ||
if i < 0 || i >= len(arg.Vals) { | ||
return fmt.Errorf("cannot scan index %d of key %s", i, arg.Key) | ||
} | ||
val := arg.Vals[i] | ||
switch dest := dest.(type) { | ||
case *string: | ||
*dest = val | ||
case *int: | ||
n, err := strconv.ParseInt(val, 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
*dest = int(n) // assume 64bit ints | ||
case *int64: | ||
n, err := strconv.ParseInt(val, 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
*dest = n | ||
case *uint64: | ||
n, err := strconv.ParseUint(val, 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
*dest = n | ||
case *bool: | ||
b, err := strconv.ParseBool(val) | ||
if err != nil { | ||
return err | ||
} | ||
*dest = b | ||
default: | ||
return fmt.Errorf("unsupported type %T for destination #%d (might be easy to add it)", dest, i+1) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High