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

Restructure E2Es to setup chain in SetupSuite and create channel in SetupTest #1 #6629

Merged

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Jun 18, 2024

Description

This PR addresses the first step of the overall restructuring of E2Es to allow for multiple tests running on an individual host.

The main differences introduced in this PR are.

  • the SetupChainsRelayerAndChannel function has been removed. Instead, the chains get created in SetupSuite and the channels get created in SetupTest.
  • If any test needs to provide additional configuration options, they can override the SetupTest or SetupSuite functions as required.

Follow up PRs will handle.

shout out to @anhductn2001 for the work on the first iteration of this.

ref: #5317


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@chatton chatton changed the title Restructure E2Es to setup chain in SetupSuite and create channel in SetupTest [WIP] Restructure E2Es to setup chain in SetupSuite and create channel in SetupTest Jun 18, 2024
@chatton chatton marked this pull request as ready for review June 18, 2024 12:33
@chatton chatton marked this pull request as draft June 18, 2024 12:33
@chatton chatton marked this pull request as ready for review June 18, 2024 14:01
@chatton chatton changed the title [WIP] Restructure E2Es to setup chain in SetupSuite and create channel in SetupTest Restructure E2Es to setup chain in SetupSuite and create channel in SetupTest Jun 18, 2024
@@ -0,0 +1,356 @@
//go:build !test_e2e
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created a new file for these tests since the original channel creation options were all a v1 transfer. This was more straightforward than adding conditional logic based on which test was running in the SetupTest

Comment on lines +33 to +37
func (s *TransferChannelUpgradesV1TestSuite) SetupTest() {
opts := s.TransferChannelOptions()
opts.Version = transfertypes.V1
s.SetupPath(ibc.DefaultClientOpts(), opts)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the main addition

@@ -55,6 +56,15 @@ type UpgradeTestSuite struct {
testsuite.E2ETestSuite
}

func (s *UpgradeTestSuite) SetupTest() {
channelOpts := s.TransferChannelOptions()
// TODO(chatton) hack to handle special case for the v8 to v8.1 upgrade test.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe not the end of the world as it's a once off, I can create an issue for this but it would be nice to have a generalized way of specifying per channel options per test name. Kind of chicken and egg situation as it's happening in SetupTest

@@ -223,7 +233,9 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {
t := s.T()

ctx := context.Background()
chain := s.SetupSingleChain(ctx)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted to remove this fn for now, and more native support for a single chain in a follow up (will create issues soon)

Copy link
Member

Choose a reason for hiding this comment

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

I got you brother! :D #3160

@@ -64,6 +64,61 @@ type GrandpaTestSuite struct {
testsuite.E2ETestSuite
}

func (s *GrandpaTestSuite) SetupSuite() {
s.SetupChains(context.Background(), nil, func(options *testsuite.ChainOptions) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

configuration remained unchanged

channelOpts := defaultChannelOpts(chains)
chain1, chain2 := chains[i], chains[i+1]

if modificationProvider != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

provides a mechanism to selectively modify channels when there are more than 2 chains in a test.

Copy link
Member

Choose a reason for hiding this comment

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

provide me modifications, almighty provider! 🙌🏻

@chatton chatton changed the title Restructure E2Es to setup chain in SetupSuite and create channel in SetupTest Restructure E2Es to setup chain in SetupSuite and create channel in SetupTest #1 Jun 18, 2024
})
}

s.startRelayerFn = func(relayer ibc.Relayer) {
// depending on the test, the path names will be different.
// whenever a relayer is started, it should use the paths associated with the test the relayer is running in.
pathNames, ok := s.testPaths[s.T().Name()]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

path names only needs to be correct for rly, it is a no-op for hermes

func (s *E2ETestSuite) GetPathName(idx int64) string {
pathName := fmt.Sprintf("%s-path-%d", s.T().Name(), idx)
func GetPathName(idx int64) string {
pathName := fmt.Sprintf("path-%d", idx)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing the name from the string as s.T().Name() is different depending on the context of the invocation. using an incrementing int will behave as expected everywhere.

@chatton
Copy link
Contributor Author

chatton commented Jun 18, 2024

looks like there are some client tests failing, definitely related will investigate these

@gjermundgaraba gjermundgaraba added the priority PRs that need prompt reviews label Jun 18, 2024

// SetupSuite will by default create chains with no additional options. If additional options are required,
// the test suite must define the SetupSuite function and provide the required options.
func (s *E2ETestSuite) SetupSuite() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be clear, this means that all tests in one suite will share the same chains, and so we must be careful that accounts are not shared across the tests to avoid account sequence mismatches, resusing balances, etc, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes that's correct! By default we are always generating addresses that won't collide by default, but we need to keep this in mind in case we end up encountering a new category of error

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think that will help a lot with running e2e tests faster, which is a big win!

// GetChannel returns the ibc.ChannelOutput for the current test.
// this defaults to the first entry in the list, and will be what is needed in the case of
// a single channel test.
func (s *E2ETestSuite) GetChannel() ibc.ChannelOutput {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it better to rename this to be more precise? Either something like GetChainAChannel or refactor it to take in chain1 and chain2 to get the channel between them? A bit more verbose, but also potentially useful in more contexts?

I guess my lens is a bit skewed with all the forwarding tests, so feel free to ignore :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a bad idea to be explicit here, I think GetChainAChannel would be better.

e2e/testsuite/testsuite.go Show resolved Hide resolved
Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

LGTM! Really nice improvements made in this PR, love it ❤️

I think we can follow up separately with any of the next steps, would be in favour of merging this sooner than later! 🚢 🚢 🚢

@@ -223,7 +233,9 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {
t := s.T()

ctx := context.Background()
chain := s.SetupSingleChain(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

I got you brother! :D #3160

transferVersion = transfertypes.V2
}

func (s *E2ETestSuite) FeeMiddlewareChannelOptions() ibc.CreateChannelOptions {
Copy link
Member

Choose a reason for hiding this comment

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

mega nit, I see this was actually named this a long time ago, but would be nice if it was FeeTransferChannelOptions imo!

Comment on lines +158 to +159
// TODO: we need to create a relayer for each test that will run
// having a single relayer for all tests will cause issues when running tests in parallel.
Copy link
Member

Choose a reason for hiding this comment

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

Assuming this TODO is directly related to the one onGetRelayer below on this file.

What issues get caused by having a single relayer for tests running in parallel? 🤔 Just curious about the specifics

We can create an issue to follow up on this too ofc! 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In lots of tests we don't have a relayer started at the beginning, e.g. when doing a message transfer. So another test who has started a relayer, will cause that relayer to relay packets on a different test causing assertions to fail.

channelOpts := defaultChannelOpts(chains)
chain1, chain2 := chains[i], chains[i+1]

if modificationProvider != nil {
Copy link
Member

Choose a reason for hiding this comment

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

provide me modifications, almighty provider! 🙌🏻

@damiannolan
Copy link
Member

I think we should do something about the wasm e2e tests which are failing 🤔

Copy link
Contributor

@gjermundgaraba gjermundgaraba left a comment

Choose a reason for hiding this comment

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

I agree that this would be good to get merged sooner rather than later with follow-up issues - as long as the tests run OK :)

@chatton
Copy link
Contributor Author

chatton commented Jun 19, 2024

sorry if I wasn't clear, the plan was already to do those things in follow ups! Will merge as soon as I have passing tests for all non-wasm E2Es!

@chatton chatton force-pushed the cian/issue#5317-e2e-restructure-to-reduce-number-of-runners-used branch from 4084011 to 0af42e9 Compare June 19, 2024 08:58
@chatton chatton enabled auto-merge June 19, 2024 09:49
@chatton chatton added this pull request to the merge queue Jun 19, 2024
Copy link

sonarcloud bot commented Jun 19, 2024

Merged via the queue into main with commit 10aa0ef Jun 19, 2024
138 of 144 checks passed
@chatton chatton deleted the cian/issue#5317-e2e-restructure-to-reduce-number-of-runners-used branch June 19, 2024 10:40
bznein pushed a commit that referenced this pull request Jun 26, 2024
…etupTest #1 (#6629)

* wip: refactoring tests to create chains in SetupSuite

* chore: refactoring memo test to use new setup fns

* chore: replace calls to setup chains and relayer with calls to get relayer and get channel

* chore: fix wiring in ThreeChainSetup

* chore: remove unused fn

* chore: add modification function based on chain inputs

* chore: update grandpa test with new structure

* chore: remove single chain methods

* chore: move upgrade tests into different files

* chore: fixing client tests

* chore: use paths associated with the test

* chore: add getter to fetch paths

* chore: fix client tests

* chore: fix misbehaviour test

* chore: fix misbehaviour test

* chore: mereg main

* chore: pr feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants