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

server: split test code into sub-packages and files #107135

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ ALL_TESTS = [
"//pkg/security/username:username_disallowed_imports_test",
"//pkg/security/username:username_test",
"//pkg/security:security_test",
"//pkg/server/application_api:application_api_test",
"//pkg/server/authserver:authserver_test",
"//pkg/server/autoconfig:autoconfig_test",
"//pkg/server/debug/goroutineui:goroutineui_test",
"//pkg/server/debug/pprofui:pprofui_test",
Expand All @@ -294,11 +296,14 @@ ALL_TESTS = [
"//pkg/server/dumpstore:dumpstore_test",
"//pkg/server/goroutinedumper:goroutinedumper_test",
"//pkg/server/pgurl:pgurl_test",
"//pkg/server/privchecker:privchecker_test",
"//pkg/server/profiler:profiler_test",
"//pkg/server/serverpb:serverpb_test",
"//pkg/server/serverrules:serverrules_test",
"//pkg/server/settingswatcher:settingswatcher_test",
"//pkg/server/srverrors:srverrors_test",
"//pkg/server/status:status_test",
"//pkg/server/storage_api:storage_api_test",
"//pkg/server/structlogging:structlogging_test",
"//pkg/server/systemconfigwatcher:systemconfigwatcher_test",
"//pkg/server/telemetry:telemetry_test",
Expand Down Expand Up @@ -1503,6 +1508,12 @@ GO_TARGETS = [
"//pkg/security/username:username_test",
"//pkg/security:security",
"//pkg/security:security_test",
"//pkg/server/apiconstants:apiconstants",
"//pkg/server/apiutil:apiutil",
"//pkg/server/application_api:application_api",
"//pkg/server/application_api:application_api_test",
"//pkg/server/authserver:authserver",
"//pkg/server/authserver:authserver_test",
"//pkg/server/autoconfig/acprovider:acprovider",
"//pkg/server/autoconfig/autoconfigpb:autoconfigpb",
"//pkg/server/autoconfig:autoconfig",
Expand All @@ -1523,17 +1534,25 @@ GO_TARGETS = [
"//pkg/server/goroutinedumper:goroutinedumper_test",
"//pkg/server/pgurl:pgurl",
"//pkg/server/pgurl:pgurl_test",
"//pkg/server/privchecker:privchecker",
"//pkg/server/privchecker:privchecker_test",
"//pkg/server/profiler:profiler",
"//pkg/server/profiler:profiler_test",
"//pkg/server/rangetestutils:rangetestutils",
"//pkg/server/serverpb:serverpb",
"//pkg/server/serverpb:serverpb_test",
"//pkg/server/serverrules:serverrules",
"//pkg/server/serverrules:serverrules_test",
"//pkg/server/settingswatcher:settingswatcher",
"//pkg/server/settingswatcher:settingswatcher_test",
"//pkg/server/srverrors:srverrors",
"//pkg/server/srverrors:srverrors_test",
"//pkg/server/srvtestutils:srvtestutils",
"//pkg/server/status/statuspb:statuspb",
"//pkg/server/status:status",
"//pkg/server/status:status_test",
"//pkg/server/storage_api:storage_api",
"//pkg/server/storage_api:storage_api_test",
"//pkg/server/structlogging:structlogging",
"//pkg/server/structlogging:structlogging_test",
"//pkg/server/systemconfigwatcher/systemconfigwatchertest:systemconfigwatchertest",
Expand Down Expand Up @@ -2343,6 +2362,7 @@ GO_TARGETS = [
"//pkg/util/retry:retry_test",
"//pkg/util/ring:ring",
"//pkg/util/ring:ring_test",
"//pkg/util/safesql:safesql",
"//pkg/util/schedulerlatency:schedulerlatency",
"//pkg/util/schedulerlatency:schedulerlatency_test",
"//pkg/util/sdnotify:sdnotify",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/oidcccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ go_library(
"//pkg/ccl/utilccl",
"//pkg/roachpb",
"//pkg/security/username",
"//pkg/server",
"//pkg/server/authserver",
"//pkg/server/serverpb",
"//pkg/server/telemetry",
"//pkg/settings",
Expand Down
6 changes: 3 additions & 3 deletions pkg/ccl/oidcccl/authentication_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/ccl/utilccl"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/server/authserver"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/server/telemetry"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
Expand Down Expand Up @@ -293,7 +293,7 @@ var ConfigureOIDC = func(
userLoginFromSSO func(ctx context.Context, username string) (*http.Cookie, error),
ambientCtx log.AmbientContext,
cluster uuid.UUID,
) (server.OIDC, error) {
) (authserver.OIDC, error) {
oidcAuthentication := &oidcAuthenticationServer{}

// Don't want to use GRPC here since these endpoints require HTTP-Redirect behaviors and the
Expand Down Expand Up @@ -719,5 +719,5 @@ var ConfigureOIDC = func(
}

func init() {
server.ConfigureOIDC = ConfigureOIDC
authserver.ConfigureOIDC = ConfigureOIDC
}
1 change: 1 addition & 0 deletions pkg/ccl/serverccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ go_test(
"//pkg/security/securitytest",
"//pkg/security/username",
"//pkg/server",
"//pkg/server/authserver",
"//pkg/server/serverpb",
"//pkg/server/systemconfigwatcher/systemconfigwatchertest",
"//pkg/settings/cluster",
Expand Down
7 changes: 4 additions & 3 deletions pkg/ccl/serverccl/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/server/authserver"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql/lexbase"
Expand Down Expand Up @@ -285,7 +286,7 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
t.Logf("retrieving session list from system tenant via cookie")

c := &http.Cookie{
Name: server.TenantSelectCookieName,
Name: authserver.TenantSelectCookieName,
Value: catconstants.SystemTenantName,
Path: "/",
HttpOnly: true,
Expand Down Expand Up @@ -362,7 +363,7 @@ func TestServerControllerDefaultHTTPTenant(t *testing.T) {

tenantCookie := ""
for _, c := range resp.Cookies() {
if c.Name == server.TenantSelectCookieName {
if c.Name == authserver.TenantSelectCookieName {
tenantCookie = c.Value
}
}
Expand All @@ -387,7 +388,7 @@ func TestServerControllerBadHTTPCookies(t *testing.T) {
require.NoError(t, err)

c := &http.Cookie{
Name: server.TenantSelectCookieName,
Name: authserver.TenantSelectCookieName,
Value: "some-nonexistent-tenant",
Path: "/",
HttpOnly: true,
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ go_library(
"//pkg/security/securitytest",
"//pkg/security/username",
"//pkg/server",
"//pkg/server/authserver",
"//pkg/server/autoconfig/acprovider",
"//pkg/server/pgurl",
"//pkg/server/profiler",
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/cli/clisqlclient"
"github.com/cockroachdb/cockroach/pkg/cli/clisqlexec"
"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/server/authserver"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
Expand Down Expand Up @@ -117,7 +117,7 @@ func createAuthSessionToken(
}

// Make a secret.
secret, hashedSecret, err := server.CreateAuthSecret()
secret, hashedSecret, err := authserver.CreateAuthSecret()
if err != nil {
return -1, nil, err
}
Expand Down Expand Up @@ -185,7 +185,7 @@ RETURNING id

// Spell out the cookie.
sCookie := &serverpb.SessionCookie{ID: id, Secret: secret}
httpCookie, err = server.EncodeSessionCookie(sCookie, false /* forHTTPSOnly */)
httpCookie, err = authserver.EncodeSessionCookie(sCookie, false /* forHTTPSOnly */)
return id, httpCookie, err
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cli/democluster/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ go_library(
"//pkg/security/certnames",
"//pkg/security/username",
"//pkg/server",
"//pkg/server/authserver",
"//pkg/server/autoconfig/acprovider",
"//pkg/server/pgurl",
"//pkg/server/serverpb",
Expand Down
3 changes: 2 additions & 1 deletion pkg/cli/democluster/demo_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/security/certnames"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/server/authserver"
"github.com/cockroachdb/cockroach/pkg/server/pgurl"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/server/status"
Expand Down Expand Up @@ -2002,7 +2003,7 @@ func (c *transientCluster) addDemoLoginToURL(uiURL *url.URL, includeTenantName b
// in that case.
q.Add("username", c.adminUser.Normalized())
q.Add("password", c.adminPassword)
uiURL.Path = server.DemoLoginPath
uiURL.Path = authserver.DemoLoginPath
}

if !includeTenantName {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ go_library(
"//pkg/roachprod/logger",
"//pkg/roachprod/prometheus",
"//pkg/roachprod/vm",
"//pkg/server",
"//pkg/server/authserver",
"//pkg/server/serverpb",
"//pkg/sql",
"//pkg/sql/pgwire/pgcode",
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/roachtest/tests/cluster_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
"github.com/cockroachdb/cockroach/pkg/server"
"github.com/cockroachdb/cockroach/pkg/server/authserver"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/util/httputil"
"github.com/cockroachdb/cockroach/pkg/util/retry"
Expand Down Expand Up @@ -138,7 +138,7 @@ func runClusterInit(ctx context.Context, t test.Test, c cluster.Cluster) {
// Prevent regression of #25771 by also sending authenticated
// requests, like would be sent if an admin UI were open against
// this node while it booted.
cookie, err := server.EncodeSessionCookie(&serverpb.SessionCookie{
cookie, err := authserver.EncodeSessionCookie(&serverpb.SessionCookie{
// The actual contents of the cookie don't matter; the presence of
// a valid encoded cookie is enough to trigger the authentication
// code paths.
Expand Down
Loading