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

testserver: remove direct casts to *server.TestServer #107866

Merged
merged 4 commits into from
Aug 2, 2023

Conversation

knz
Copy link
Contributor

@knz knz commented Jul 30, 2023

First 3 commits from #107868.

In a later stage we would like the result of StartServer to return different concrete types depending on parameters. Before we can do that however, we need to remove direct casts of that return value to *server.TestServer.

Incidentally, this patch improves the APIs as follows:

  • the health probe for secondary tenant servers now properly
    includes the draining state of the RPC interface (previously,
    only the SQL draining state was included).

  • ApplicationLayerInterface now includes Readiness() and
    DefaultZoneConfig().

  • StorageLayerInterface now includes
    ScratchRangeWithExpirationLease(), GetRangeLease(), TsDB(),
    Locality() and DefaultSystemZoneConfig().

Epic: CRDB-18499

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz knz force-pushed the 20230729-avoid-ts-cast branch from 8517275 to 31f98a0 Compare July 31, 2023 03:04
@knz knz marked this pull request as ready for review July 31, 2023 03:05
@knz knz requested a review from a team July 31, 2023 03:05
@knz knz requested review from a team as code owners July 31, 2023 03:05
@knz knz requested a review from a team July 31, 2023 03:05
@knz knz requested review from a team as code owners July 31, 2023 03:05
@knz knz requested a review from a team July 31, 2023 03:05
@knz knz requested review from a team as code owners July 31, 2023 03:05
@knz knz requested review from nkodali, adityamaru, samiskin, herkolategan and smg260 and removed request for a team July 31, 2023 03:05
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

Last two commits :lgtm:

Reviewed 10 of 10 files at r4, 19 of 99 files at r5, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @herkolategan, @knz, and @stevendanna)


-- commits line 44 at r4:
Is it because GossipI is part of the storage layer interface?


pkg/cli/testutils.go line 52 at r5 (raw file):

// TestCLI wraps a test server and is used by tests to make assertions about the output of CLI commands.
type TestCLI struct {
	// a copy of the insecure mode parameter.

nit: should start with the capital letter.

Copy link
Contributor Author

@knz knz 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! 1 of 0 LGTMs obtained (waiting on @herkolategan and @yuzefovich)


-- commits line 44 at r4:

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Is it because GossipI is part of the storage layer interface?

It's more because GossipI is an interface method, and .Gossip is not (because of package dependency cycle).
Same about .Stores vs .GetStores which the next commit also simplifies.


pkg/cli/testutils.go line 52 at r5 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: should start with the capital letter.

Done.

@knz knz force-pushed the 20230729-avoid-ts-cast branch from 50e86f3 to 6f29b21 Compare August 2, 2023 01:54
craig bot pushed a commit that referenced this pull request Aug 2, 2023
107868: rpc,*: sanitize the configuration of rpc.Context r=yuzefovich,stevendanna a=knz

The main goal of this change is to offer a `.RPCClientConn()` method
on test servers.

To achieve this, it was necessary to lift the code previously in
`cli.getClientGRPCConn` into a more reusable version of it,
now hosted in `rpc.NewClientContext()`.

I also took the opportunity to remove the dependency of `rpc.Context`
on `base.Config`, by spelling out precisely which fields are necessary
to RPC connections.

Numerous tests could be simplified as a result.

Needed for  #107866.
Epic: CRDB-18499

Co-authored-by: Raphael 'kena' Poss <[email protected]>
Tests should use `.GossipI()`

Release note: None
knz added 3 commits August 2, 2023 14:10
We want to keep tests using go interfaces, to ensure the test server
APIs can be mocked if needed.

Incidentally, this patch improves the APIs as follows:

- the health probe for secondary tenant servers now properly
  includes the draining state of the RPC interface (previously,
  only the SQL draining state was included).

- `ApplicationLayerInterface` now includes `Readiness()` and
  `DefaultZoneConfig()`.

- `StorageLayerInterface` now includes
  `ScratchRangeWithExpirationLease()`, `GetRangeLease()`, `TsDB()`,
  `Locality()` and `DefaultSystemZoneConfig()`.

Release note: None
Release note: None
Release note: None
@knz knz force-pushed the 20230729-avoid-ts-cast branch from 6f29b21 to eaf0f22 Compare August 2, 2023 12:15
@knz
Copy link
Contributor Author

knz commented Aug 2, 2023

bors r=yuzefovich,stevendanna

@craig
Copy link
Contributor

craig bot commented Aug 2, 2023

Canceled.

@knz
Copy link
Contributor Author

knz commented Aug 2, 2023

bors r=yuzefovich,stevendanna

@knz knz force-pushed the 20230729-avoid-ts-cast branch from 2b29313 to eaf0f22 Compare August 2, 2023 12:27
@craig
Copy link
Contributor

craig bot commented Aug 2, 2023

Canceled.

@knz
Copy link
Contributor Author

knz commented Aug 2, 2023

bors r=yuzefovich,stevendanna

@knz knz mentioned this pull request Aug 2, 2023
@craig
Copy link
Contributor

craig bot commented Aug 2, 2023

Build succeeded:

@craig craig bot merged commit a462321 into cockroachdb:master Aug 2, 2023
@knz knz deleted the 20230729-avoid-ts-cast branch August 2, 2023 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants