Skip to content

feat(E2E): Enable e2e tests to run in different networks based on chain spec#2403

Draft
nidhi-singh02 wants to merge 59 commits intomainfrom
e2e-configure
Draft

feat(E2E): Enable e2e tests to run in different networks based on chain spec#2403
nidhi-singh02 wants to merge 59 commits intomainfrom
e2e-configure

Conversation

@nidhi-singh02
Copy link
Copy Markdown
Contributor

@nidhi-singh02 nidhi-singh02 commented Jan 23, 2025

As part of the change set, we will be able to spin up different networks on the basis of chain ID and the chain spec name combination each in its own kurtosis enclave and run the tests.

The instructions to add your tests is given in README.md.

This is the just the foundation of making the e2e tests customizable and being able to run different specs as part of our e2e suite.

Note : Currently only devnet is supported. I see hardcoding of chainspec in few tests, needs to be refactored.

Feb 20 EDIT -- Converting to draft. Still desired but postponed.

nidhi-singh02 and others added 24 commits January 9, 2025 11:01
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: Nidhi Singh <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 23, 2025

Codecov Report

❌ Patch coverage is 0% with 378 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.04%. Comparing base (5476afd) to head (3730fa9).
⚠️ Report is 325 commits behind head on main.

Files with missing lines Patch % Lines
testing/e2e/suite/setup.go 0.00% 302 Missing ⚠️
testing/e2e/suite/suite.go 0.00% 66 Missing ⚠️
testing/e2e/suite/options.go 0.00% 8 Missing ⚠️
testing/e2e/config/defaults.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2403      +/-   ##
==========================================
- Coverage   32.27%   32.04%   -0.24%     
==========================================
  Files         350      351       +1     
  Lines       15636    15752     +116     
  Branches       20       20              
==========================================
  Hits         5047     5047              
- Misses      10226    10342     +116     
  Partials      363      363              
Files with missing lines Coverage Δ
testing/e2e/config/config.go 0.00% <ø> (ø)
testing/e2e/config/defaults.go 0.00% <0.00%> (ø)
testing/e2e/suite/options.go 0.00% <0.00%> (ø)
testing/e2e/suite/suite.go 0.00% <0.00%> (ø)
testing/e2e/suite/setup.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nidhi-singh02 nidhi-singh02 self-assigned this Jan 23, 2025
Nidhi Singh added 4 commits January 24, 2025 13:54
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
nidhi-singh02 added 4 commits January 29, 2025 14:12
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
Signed-off-by: nidhi-singh02 <trippin@berachain.com>
@nidhi-singh02 nidhi-singh02 changed the title feat(E2E): Allow tests to run in different networks - WIP feat(E2E): Enable e2e tests to run in different networks based on chain spec Jan 29, 2025
@nidhi-singh02 nidhi-singh02 marked this pull request as ready for review January 29, 2025 09:47
@nidhi-singh02 nidhi-singh02 requested a review from a team as a code owner January 29, 2025 09:47
Comment thread testing/e2e/README.md
Note: The default chainID for this local network is 80087, which is our dev network configuration. To make changes to the 80087 chain spec used, modify parameters [here](https://github.com/berachain/beacon-kit/blob/main/config/spec/devnet.go#L40).

## Configure the default network configuration
To change the chainID, modify the `ChainID` field in the `NetworkConfiguration` struct in `defaultNetworkConfiguration`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given that we default to mainnet chain spec in beacond - feels unintuitive to have the default for tests be devnet. Perhaps worth renaming

//nolint:gochecknoglobals // it's a default value
var (
// defaultChainID is the default chain ID for the network.
defaultChainID = 80087
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should these be const given that they are not mutated?

// 1) Add staking tests for adding a new validator to the network.
// 2) Add staking tests for hitting the validator set cap and eviction.
func (s *BeaconKitE2ESuite) TestDepositRobustness() {
func (s *BeaconKitE2ESuite) runDepositRobustness() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems unintuitive to have tests not be named as such - affects readability

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also my IDE doesn't let me run this test individually now

networks map[string]*NetworkInstance // maps chainSpec to network
testSpecs map[string]ChainSpec // maps testName to chainSpec
testFuncs map[string]func() // maps test names to test functions
mu sync.RWMutex
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you expand on the reasoning for the mutex? it seems the write lock is only in RegisterTest which doesn't seem to be called concurrently

Comment thread testing/e2e/README.md
To add your tests, you need to do the following:
1. Create a new file in the `testing/e2e/` directory.
2. Add your tests in here like how it is done in `runBasicStartup()`
3. Register your tests in `TestRunE2E()`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any way we can avoid this registration?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@rezzmah rezzmah left a comment

Choose a reason for hiding this comment

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

An approach to avoid explicit registration outside of the test is to have each test be "aware" of the chainspec it supports, so that I can look at a test and immediately know what chain spec it's supposed to run on. It would also allow me to run the test directly, without running the whole suite from my IDE (Goland). A problem with "registration" based approaches is also forgetting to register.

Example

func (s *BeaconKitE2ESuite) TestDepositRobustness() {	
	s.Logger().Info("Running Deposit Robustness on devnet")
	network, chainSpec := s.SetForNetwork("devnet")

SetForNetwork would effectively run t.Skip() if the test harness is attempting to run the test on a chain spec it doesn't support.

I was initially confused about the modularity goals we aimed to achieve but to be explicit, the user story is as follows:

  • I want to be able to run tests that are opinionated for a particular chainspec.

We are NOT trying to do the following:

  • Run the same test against multiple chainspecs.

@calbera
Copy link
Copy Markdown
Contributor

calbera commented Feb 5, 2025

+1 to Rez's comment. Some things we should try fixing:

  • currently broken -- if I try changing just 1 test to run on mainnet (and keep the others on devnet) the mainnet fails to startup.
  • reminder -- we want to ideally run the different chains in parallel
  • let's break up this PR into smaller PRs, something like:
    1. the refactor to just the suite which includes running multiple chains
    2. the setup of each of the e2e tests (as Rez mentioned above)
    3. the ability to run each of those chains in parallel

@nidhi-singh02
Copy link
Copy Markdown
Contributor Author

Will address the review comments/resume here once the node api endpoints for validators is complete, which is priority rn.

@calbera calbera marked this pull request as draft February 20, 2025 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants