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

Remove multiTestContext #59670

Merged
merged 1 commit into from
Feb 8, 2021

Conversation

lunevalex
Copy link
Collaborator

@lunevalex lunevalex commented Feb 1, 2021

This pull request is broken up into two commits:

Makes progress on #8299

This change converts the last set of tests in client_metrics_test,
client_raft_test, client_raft_log_queue_test to use TestCluster instead
of multiTestContext.

Closes #8299

With all the tests converted to use TestCluster/TestServer,
we can finally remove multiTestContext and all of the dependent
code.

Release Note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@lunevalex lunevalex force-pushed the alex/remove-the-last-mtc-tests branch 3 times, most recently from c5fe105 to 51c8a96 Compare February 2, 2021 05:14
@lunevalex lunevalex requested review from tbg and andreimatei February 2, 2021 05:54
Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Fantastic. I truly didn't think it was going to happen.
Let me know if there are areas of the rewritten tests that you want scrutinized.

Reviewed 6 of 6 files at r1, 3 of 3 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @lunevalex)


pkg/kv/kvserver/client_metrics_test.go, line 81 at r1 (raw file):

	}

	wg.Add(numStores)

Did you determine that stopping the stores wasn't necessary?


pkg/kv/kvserver/client_metrics_test.go, line 241 at r1 (raw file):

					{
						InMemory: true,
						Size: base.SizeSpec{

Can you add a comment here? Right now this looks like you're setting this up manually when the defaults would serve you just as well, which I assume is false.


pkg/kv/kvserver/client_metrics_test.go, line 264 at r1 (raw file):

	}

	// We skip verifying stats on Server[0] because there is no reliable way to

I might be missing something but where are you actually skipping it?


pkg/kv/kvserver/client_metrics_test.go, line 265 at r1 (raw file):

	// We skip verifying stats on Server[0] because there is no reliable way to
	// do that given all oif the system table activity generated by the TestCluster.

oif


pkg/kv/kvserver/client_raft_test.go, line 470 at r1 (raw file):

	// The filter is very aggressive, so we need to turn it on after the cluster
	// starts up.

The filter avoids all commits? That seems over the top. Just check et.InternalCommitTrigger != nil && et.InternalCommitTrigger.ChangeReplicasTrigger != nil in addition to what's there.


pkg/kv/kvserver/client_test.go, line 1653 at r1 (raw file):

}

// This test is here to please the unused code linter, and will be removed in

FYI the usual way we do this is

var _ = (*unusedStruct)(nil)
var _ = (&someStruct{}).unusedMethod

etc (no need to change things here, this works)

Copy link
Collaborator Author

@lunevalex lunevalex left a comment

Choose a reason for hiding this comment

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

The two tests that gave me problems were TestStoreMetrics and TestSnapshotAfterTruncationWithUncommittedTail

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei, @lunevalex, and @tbg)


pkg/kv/kvserver/client_metrics_test.go, line 81 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

Did you determine that stopping the stores wasn't necessary?

The original comments, claimed it was to reduce the possibility that something would update the metrics while the measurements were being taken. With TestCluster I am mitigating this by only measuring s2 and s3, which dont have any system tables/ranges on them. The other issues is TestCluster.Restart() completely rebuilds the whole store, so metrics are wiped between restarts, which seems problematic for this test.


pkg/kv/kvserver/client_metrics_test.go, line 241 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

Can you add a comment here? Right now this looks like you're setting this up manually when the defaults would serve you just as well, which I assume is false.

Good catch, it is needed to enable the BlockCache in Pebble


pkg/kv/kvserver/client_metrics_test.go, line 264 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

I might be missing something but where are you actually skipping it?

it's the verifyStats() methods bellow, I moved the comment closer to that code


pkg/kv/kvserver/client_raft_test.go, line 470 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

The filter avoids all commits? That seems over the top. Just check et.InternalCommitTrigger != nil && et.InternalCommitTrigger.ChangeReplicasTrigger != nil in addition to what's there.

Ack

@lunevalex lunevalex force-pushed the alex/remove-the-last-mtc-tests branch 3 times, most recently from ca6f7da to dfd9c60 Compare February 3, 2021 05:23
Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 6 files at r3, 3 of 3 files at r4.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @lunevalex)


pkg/kv/kvserver/client_metrics_test.go, line 54 at r4 (raw file):

	t.Helper()
	var stores []*kvserver.Store
	// We need to stop the stores at the given indexes, while keeping the reference to the

Stale comment, and while you're here also give verifyStats a comment about the pitfalls of using it on a general running server.

@lunevalex lunevalex force-pushed the alex/remove-the-last-mtc-tests branch 6 times, most recently from 1844842 to fbdade8 Compare February 5, 2021 23:10
…luster

Makes progress on cockroachdb#8299

This change converts the last set of tests in client_metrics_test,
client_raft_test, client_raft_log_queue_test to use TestCluster instead
of multiTestContext.

Release note: None
@lunevalex lunevalex force-pushed the alex/remove-the-last-mtc-tests branch from fbdade8 to dd8197f Compare February 6, 2021 00:15
@lunevalex
Copy link
Collaborator Author

bors r=tbg

@craig
Copy link
Contributor

craig bot commented Feb 8, 2021

Build succeeded:

@craig craig bot merged commit 04428fc into cockroachdb:master Feb 8, 2021
lunevalex added a commit to lunevalex/cockroach that referenced this pull request Mar 26, 2021
Fixes cockroachdb#60146

When TestStoreMetrics was converted to use TestCluster in cockroachdb#59670.
The verifyStats method was changed to not stop the stores anymore
that was a mistake that caused this flake. This change adds back the
stopping and fixes a race with lease transfers.

Release note: None
craig bot pushed a commit that referenced this pull request Mar 30, 2021
62660: kvserver: fix flake in TestStoreMetrics r=lunevalex a=lunevalex

Fixes #60146

When TestStoreMetrics was converted to use TestCluster in #59670.
The verifyStats method was changed to not stop the stores anymore
that was a mistake that caused this flake. This change adds back the
stopping and fixes a race with lease transfers.

Release note: None

Co-authored-by: Alex Lunev <[email protected]>
lunevalex added a commit to lunevalex/cockroach that referenced this pull request May 17, 2021
Fixes cockroachdb#60146

When TestStoreMetrics was converted to use TestCluster in cockroachdb#59670.
The verifyStats method was changed to not stop the stores anymore
that was a mistake that caused this flake. This change adds back the
stopping and fixes a race with lease transfers.

Release note: None
Copy link
Contributor

@andreimatei andreimatei 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


pkg/util/leaktest/leaktest.go line 97 at r5 (raw file):

// goroutines leaked.
func AfterTest(t testing.TB) func() {
	// Try a best effort GC to help the race tests move along.

Do you remember why this was necessary?

@tbg
Copy link
Member

tbg commented Dec 2, 2022

@andreimatei if memory serves correctly this was all band-aid to try to make #61120 better, but we fixed this properly in the end so hopefully (read: I'm confident that) this runtime.GC() can just be removed.

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.

kvserver: migrate multiTestContext to TestCluster
4 participants