-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
robustness: change mixedVersionOption to use ChoiceWeight. #18060
Conversation
tests/robustness/scenarios.go
Outdated
{options.WithVersion(e2e.QuorumLastVersion), options.WithInitialLeaderIndex(0)}, | ||
// 10% with 2 members of last version, 1 member current version, leader is current version | ||
{options.WithVersion(e2e.QuorumLastVersion), options.WithInitialLeaderIndex(2)}}, | ||
[]float64{0.6, 0.1, 0.1, 0.1, 0.1}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's less readable than previous solution, by weight options like traffic, I literally meant the weighted choice from robustness traffic.
etcd/tests/robustness/traffic/random.go
Lines 31 to 49 in 7a3ca53
type choiceWeight[T any] struct { | |
choice T | |
weight int | |
} | |
func pickRandom[T any](choices []choiceWeight[T]) T { | |
sum := 0 | |
for _, op := range choices { | |
sum += op.weight | |
} | |
roll := rand.Int() % sum | |
for _, op := range choices { | |
if roll < op.weight { | |
return op.choice | |
} | |
roll -= op.weight | |
} | |
panic("unexpected") | |
} |
Example of usage:
etcd/tests/robustness/traffic/etcd.go
Lines 36 to 48 in 7a3ca53
requests: []choiceWeight[etcdRequestType]{ | |
{choice: Get, weight: 15}, | |
{choice: List, weight: 15}, | |
{choice: StaleGet, weight: 10}, | |
{choice: StaleList, weight: 10}, | |
{choice: Put, weight: 23}, | |
{choice: LargePut, weight: 2}, | |
{choice: Delete, weight: 5}, | |
{choice: MultiOpTxn, weight: 5}, | |
{choice: PutWithLease, weight: 5}, | |
{choice: LeaseRevoke, weight: 5}, | |
{choice: CompareAndSet, weight: 5}, | |
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: Siyuan Zhang <sizhang@google.com>
/retest |
followup of #17923
Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.