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

feat: Testground tooling #2456

Merged
merged 90 commits into from
Dec 8, 2023
Merged

feat: Testground tooling #2456

merged 90 commits into from
Dec 8, 2023

Conversation

evan-forbes
Copy link
Member

@evan-forbes evan-forbes commented Sep 11, 2023

Overview

This is a refactor of the celestia-app tests in test-infra. The refactor focuses on further removing boiler plate and using our existing testing utilities for devUX, but also allows for more elaborate test scenarios and data collection.

Testground requires that each node is responsible for intializing, operating, performing tests, and collecting data on itself. To do this this refactor adds a new Role interface, where we define specific roles that Plan, Execute, and Retro. The first test case makes use of the interface to define a Leader and Follower, where we can have the Leader generate all the keys, configs, genesis, etc during Plan and then publishes that data to all Followers, which use their respective configuration to start their node. After execution of the test, each Role can run arbitrary Retro logic over the data produced or collected during the test run.

The first experiment is mean to add as similar environment to mainnet as possible. We will use this as a base control case for an upcoming PR that adds the unbounded blocksize test

Please see the README for more info and diagrams

closes #2033 blocking celestiaorg/celestia-core#945

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@evan-forbes evan-forbes added testing items that are strictly related to adding or extending test coverage refactor optional label for items that are related to implementation work and do not change functionality testground directly relevant to testground usage labels Sep 11, 2023
@evan-forbes evan-forbes self-assigned this Sep 11, 2023
@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2023

Codecov Report

Merging #2456 (0b4bf7a) into evan/multi-validator-genesis-creation (a383494) will increase coverage by 0.15%.
Report is 3 commits behind head on evan/multi-validator-genesis-creation.
The diff coverage is 100.00%.

@@                            Coverage Diff                            @@
##           evan/multi-validator-genesis-creation    #2456      +/-   ##
=========================================================================
+ Coverage                                  20.61%   20.76%   +0.15%     
=========================================================================
  Files                                        131      136       +5     
  Lines                                      15270    15624     +354     
=========================================================================
+ Hits                                        3148     3245      +97     
- Misses                                     11820    12055     +235     
- Partials                                     302      324      +22     
Files Changed Coverage Δ
test/genesis/accounts.go 56.66% <ø> (ø)
test/genesis/files.go 0.00% <ø> (ø)
test/genesis/genesis.go 24.22% <100.00%> (ø)
test/genesis/util.go 77.77% <100.00%> (ø)

... and 1 file with indirect coverage changes

@evan-forbes
Copy link
Member Author

the test can run a 3 validator network atm, but there are still a few minor but blocking bugs left. I'll add a way to sync before the "planning" stage to handle those bugs, then we should be good write the larger tests 🤞


var _ = Configurator(ConnectRandom(1))

func ConnectRandom(numPeers int) Configurator {
Copy link
Member Author

Choose a reason for hiding this comment

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

these are deleted in the ubounded block size iirc, but current tests support them

@evan-forbes
Copy link
Member Author

@rootulp do you have any clue why the ledger test is breaking? its breaking locally as well, but wasn't breaking a few commits ago

rootulp
rootulp previously approved these changes Dec 6, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

:shipit: I skipped reviewing the code in test/testground/* and instead focused on the celestia-app portions

package testground

const (
Version uint64 = 420420420
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Version could use a GoDoc that explains why this number looks crazy

Copy link
Member Author

Choose a reason for hiding this comment

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

resolved in 93cb5d4

Comment on lines +31 to +33
default:
return v1.SquareSizeUpperBound
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO this thread shouldn't block this PR and instead we should create a new issue for this.

Go doesn't have exhaustive checking (like Rust) but I don't understand why silently defaulting to an old version is preferable over a panic. I see the options as:

Current

func SquareSizeUpperBound(v uint64) int {
	switch v {
	case testground.Version:
		return testground.SquareSizeUpperBound
	// There is currently only a single square size upper bound.
	default:
		return v1.SquareSizeUpperBound
	}

Proposal

func SquareSizeUpperBound(v uint64) int {
	switch v {
	case testground.Version:
		return testground.SquareSizeUpperBound
	case v1.Version:
		return v1.SquareSizeUpperBound
	case v2.Version:
		return v2.SquareSizeUpperBound
	default:
		panic(fmt.Sprintf("unsupported version %v", v))
	}
}

ref: https://rustc-dev-guide.rust-lang.org/pat-exhaustive-checking.html#pattern-and-exhaustiveness-checking

const (
Version uint64 = 420420420
SquareSizeUpperBound int = 512
SubtreeRootThreshold int = 64
Copy link
Collaborator

Choose a reason for hiding this comment

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

[question] related to https://github.com/celestiaorg/celestia-app/pull/2456/files#r1417502424

why define this constant if it is never used?

Copy link
Member Author

Choose a reason for hiding this comment

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

resolved in 93cb5d4

we should probably do the same for v2

Comment on lines 6 to 28
// Role is the interface between a testground test entrypoint and the actual
// test logic. Testground creates many instances and passes each instance a
// configuration from the plan and manifest toml files. From those
// configurations a Role is created for each node, and the three methods below
// are ran in order.
type Role interface {
// Plan is the first function called in a test by each node. It is
// responsible for creating the genesis block, configuring nodes, and
// starting the network.
Plan(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
// Execute is the second function called in a test by each node. It is
// responsible for running any experiments. This is phase where commands are
// sent and received.
Execute(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
// Retro is the last function called in a test by each node. It is
// responsible for collecting any data from the node and/or running any
// retrospective tests or benchmarks.
Retro(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) error
}

var _ Role = (*Leader)(nil)

var _ Role = (*Follower)(nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[optional] This Go code may become stale with respect to the Role interface defined in test/testground/network.go. We may remove the code and replace with a permalink.

Copy link
Member Author

Choose a reason for hiding this comment

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

resolved in 93cb5d4

test/util/testnode/rpc_client.go Show resolved Hide resolved
@evan-forbes
Copy link
Member Author

There's a weird bug where this test is failing consistently in ci bug not locally. It also doesn't make any sense, since it was just passing and the commit that broke it only added docs and removed an usused var

rootulp
rootulp previously approved these changes Dec 8, 2023
staheri14
staheri14 previously approved these changes Dec 8, 2023
@evan-forbes evan-forbes dismissed stale reviews from staheri14 and rootulp via 50bc61e December 8, 2023 19:46
@celestia-bot celestia-bot requested a review from a team December 8, 2023 19:46
@@ -119,7 +124,8 @@ func DefaultConfig() *Config {
WithAppConfig(DefaultAppConfig()).
WithAppOptions(DefaultAppOptions()).
WithAppCreator(cmd.NewAppServer).
WithSupressLogs(true)
WithSuppressLogs(true).
WithConsensusParams(DefaultConsensusParams())
Copy link
Member Author

Choose a reason for hiding this comment

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

setting the default consensus params here fixes the failing test, which apparently we aren't doing doing on main! This doesn't fail on main, because we don't actually have a test that checks that the version is updated but now we do here

@evan-forbes evan-forbes enabled auto-merge (squash) December 8, 2023 19:50
@evan-forbes evan-forbes merged commit ce1c6cd into main Dec 8, 2023
28 checks passed
@evan-forbes evan-forbes deleted the evan/testground-test branch December 8, 2023 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor optional label for items that are related to implementation work and do not change functionality testground directly relevant to testground usage testing items that are strictly related to adding or extending test coverage
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

EPIC: core/app testground tooling
5 participants