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

roachtest: improvements to mixedversion package #96989

Merged

Conversation

renatolabs
Copy link
Contributor

This commit introduces a few improvements to the mixedversion package, the recently introduced framework for mixed-version (and mixed-binary) roachtests.

Specifically, the following improvements are made:

  • Removal of DBNode() function: having the planner pick a database that the individual steps will connect to is insufficient in many cases and could be misleading. The idea was that the user would be able to see, from the test plan itself, what node a certain step would be interacting with. However, the reality is that steps often need to run statements on multiple different nodes, or perhaps they need to pick one node specifically (e.g., the statement needs to run on a node in the old version). For that reason, the DBNode() function was dropped. Instead, steps have access to a random number generator that they can use to pick an arbitrary node themselves. The random number generators are unique to each user function, meaning each test run will see the same numbers being generated even if other steps are scheduled concurrently. The numbers observed by a user function will also be the same if the seed passed to mixedversion.Test is the same.

  • Definition of a "test context" that is available to mixed-version tests. For now, the test context includes things like which version we are upgrading (or downgrading) to and from and which nodes are running which version. This allows tests to take actions based on, for example, the number of nodes upgraded. It also allows them to run certain operations on nodes that are known to be in a specific version.

  • Introduction of a helper struct that is passed to user-functions. For now, the helper includes functions to connect to a specific node and get the current test context. The struct will help us provide common functionality to tests so that they don't have to duplicate code.

  • Log cached binary and cluster versions before executing a step. This makes it easier to understand the state of the cluster when looking at the logs of one specific step.

  • Internal improvement to the test runner: instead of assuming the first step of a mixed-version test plan will start the the cockroach nodes, we now check that that is the case, providing a clear error message if/when that assumption doesn't hold anymore (instead of a cryptic connection failure error).

Epic: CRDB-19321

Release note: None

@renatolabs renatolabs requested a review from a team as a code owner February 10, 2023 23:16
@renatolabs renatolabs requested review from herkolategan and smg260 and removed request for a team February 10, 2023 23:16
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@renatolabs
Copy link
Contributor Author

Copy link
Collaborator

@herkolategan herkolategan left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @renatolabs and @smg260)


pkg/cmd/roachtest/roachtestutil/mixedversion/runner.go line 39 at r1 (raw file):

	Helper struct {
		ctx       context.Context
		context   *Context

Nit: ctx vs. context might be a little confusing here, could help to make the field naming a little more descriptive.

Copy link
Collaborator

@herkolategan herkolategan left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @renatolabs and @smg260)

Copy link
Collaborator

@herkolategan herkolategan left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 5 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @renatolabs and @smg260)

This commit introduces a few improvements to the `mixedversion`
package, the recently introduced framework for mixed-version (and
mixed-binary) roachtests.

Specifically, the following improvements are made:

* Removal of `DBNode()` function: having the planner pick a database
that the individual steps will connect to is insufficient in many
cases and could be misleading. The idea was that the user would be
able to see, from the test plan itself, what node a certain step would
be interacting with. However, the reality is that steps often need to
run statements on multiple different nodes, or perhaps they need to
pick one node specifically (e.g., the statement needs to run on a node
in the old version). For that reason, the `DBNode()` function was
dropped. Instead, steps have access to a random number generator that
they can use to pick an arbitrary node themselves. The random number
generators are unique to each user function, meaning each test run
will see the same numbers being generated even if other steps are
scheduled concurrently. The numbers observed by a user function will
also be the same if the seed passed to `mixedversion.Test` is the
same.

* Definition of a "test context" that is available to mixed-version
tests. For now, the test context includes things like which version we
are upgrading (or downgrading) to and from and which nodes are running
which version. This allows tests to take actions based on, for
example, the number of nodes upgraded. It also allows them to run
certain operations on nodes that are known to be in a specific
version.

* Introduction of a `helper` struct that is passed to user-functions.
For now, the helper includes functions to connect to a specific node
and get the current test context. The struct will help us provide
common functionality to tests so that they don't have to duplicate
code.

* Log cached binary and cluster versions before executing a step. This
makes it easier to understand the state of the cluster when looking at
the logs of one specific step.

* Internal improvement to the test runner: instead of assuming the
first step of a mixed-version test plan will start the the cockroach
nodes, we now check that that is the case, providing a clear error
message if/when that assumption doesn't hold anymore (instead of a
cryptic connection failure error).

Epic: CRDB-19321

Release note: None
@renatolabs renatolabs force-pushed the rc/1-mixed-version-roachtest-improvements branch from ac248b6 to 304e0b4 Compare February 24, 2023 14:56
Copy link
Contributor Author

@renatolabs renatolabs left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @herkolategan and @smg260)


pkg/cmd/roachtest/roachtestutil/mixedversion/runner.go line 39 at r1 (raw file):

Previously, herkolategan (Herko Lategan) wrote…

Nit: ctx vs. context might be a little confusing here, could help to make the field naming a little more descriptive.

Good point, renamed to testContext.

@renatolabs
Copy link
Contributor Author

bors r=herkolategan

TFTR!

@craig
Copy link
Contributor

craig bot commented Feb 24, 2023

Build succeeded:

@craig craig bot merged commit 4eb5451 into cockroachdb:master Feb 24, 2023
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