Skip to content
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

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

siyuanfoundation
Copy link
Contributor

{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},
Copy link
Member

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.

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:

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},
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@siyuanfoundation siyuanfoundation changed the title robustness: add function to configure WeightedClusterOptionGroups robustness: change mixedVersionOption to use ChoiceWeight. Jun 17, 2024
Signed-off-by: Siyuan Zhang <sizhang@google.com>
@siyuanfoundation
Copy link
Contributor Author

/retest

@serathius serathius merged commit 2deefb0 into etcd-io:main Jun 18, 2024
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants