-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Description
Beekeeper's orchestration layer currently includes logic for selecting random nodes, such as the ShuffledFullNodeClients method in the cluster interface (see cluster.go#L37-L38). This is used in various checks and tests to retrieve shuffled lists of full node clients for randomized operations. However, similar random node selection logic is duplicated or implemented ad-hoc across different checks, leading to inconsistency and maintenance challenges.
To improve modularity and reusability, I propose extracting this randomization logic into a dedicated package or client within Beekeeper. This "orchestration randomizer" would handle all aspects of random node retrievability, such as shuffling nodes, selecting subsets, and ensuring balanced distribution across node groups or clusters. It should support the current logic in all checks, unifying the randomization orchestration.
Additionally, there is an existing github.com/ethersphere/beekeeper/pkg/test package that contains some related testing utilities, which could be refactored or integrated into this new package to avoid redundancy.
Proposed Functionality
- Create a new package, e.g.,
pkg/orchestration/randomizer, or extend an existing one likepkg/orchestration. - Expose methods for random node selection, building on
ShuffledFullNodeClients:GetShuffledNodes(n int) []NodeClient: Return a shuffled list of n nodes.GetRandomNode() NodeClient: Select a single random node.
- Refactor existing checks (e.g., in
cmd/beekeeper/checkor integration tests) to use this package, replacing any duplicated randomization code.
This would centralize the logic, making it easier to maintain and extend.
Benefits
- Unifies randomization logic across all checks, reducing code duplication and bugs.
- Improves test reliability and orchestration consistency.
- Facilitates refactoring of the existing
pkg/testpackage, potentially merging utilities into the new randomizer.