Skip to content

Commit c0aabf1

Browse files
craig[bot]annrpomknztbgwenyihu6
committed
107391: roachtest: include link to testeng grafana in issue posts r=smg260,tbg a=annrpom This adds a link, populated with relevant cluster name and test timeframe, to the testeng grafana instance for failed roachtests. Fixes: cockroachdb#105894 Release note: None 107659: serverutils: provide SQLConn/SQLConnE in ApplicationLayerInterface r=stevendanna a=knz Fixes cockroachdb#107672. Part of solving cockroachdb#107058. Informs cockroachdb#106772. Epic: CRDB-18499 107697: rpc: avoid crash in newPeer r=erikgrinaker a=tbg It was previously possible to make a new peer while the old one was in the middle of being deleted, which caused a crash due to to acquiring child metrics when they still existed. Luckily, this is easy enough to fix: just remove some premature optimization where I had tried to be too clever. Fixes cockroachdb#105335. Epic: CRDB-21710 Release note: None (bug never released) 107721: asim: skip TestAllocatorSimulatorDeterministic and example_fulldisk r=wenyihu6 a=wenyihu6 We found some non-deterministic behavior in the allocator simulator (see cockroachdb#105904 for more details). For now, we are skipping these potentially flaky tests. Release Note: None Epic: None 107728: persistedsqlstats: specify background qos for compaction job r=xinhaoz a=xinhaoz The compaction job can be an expensive operation so we should de-prioritize it with the `UserLow` qos setting. Fixes: cockroachdb#99949 Release note: None 107750: ui: fix app = empty string filter on stmts page r=xinhaoz a=xinhaoz The filter on app name = empty string was not working on the stmts page. This was due to the fact that we use (unset) as the option in the filter to represent selecting the empty string app name. However when filtering statements, the empty string app name on the stmt was not changed accordingly. this commit fixes this and also adds testing for the unset case. Epic: none Fixes: cockroachdb#107748 Release note (bug fix): Filter on stmts page works for app name = empty string (represented as 'unset'). https://www.loom.com/share/2fee4f0fb7b04208803e0dac1d9694ab?sid=5cabecf9-1c2a-406b-89a8-b378ed07d329 107753: backupccl: deflake TestBackupAndRestoreJobDescription r=stevendanna a=adityamaru This change sorts the jobs based on when they were created to ensure we get a stable sort of job descriptions. Fixes: cockroachdb#107684 Release note: None Co-authored-by: Annie Pompa <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Tobias Grieger <[email protected]> Co-authored-by: wenyihu6 <[email protected]> Co-authored-by: Xin Hao Zhang <[email protected]> Co-authored-by: adityamaru <[email protected]>
8 parents 8beed2d + c885ab1 + 57b77ac + b26eef1 + 2aa1e61 + 21163ac + 32cea10 + bd690b4 commit c0aabf1

File tree

90 files changed

+835
-1020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+835
-1020
lines changed

pkg/ccl/auditloggingccl/audit_logging_test.go

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ package auditloggingccl
1010

1111
import (
1212
"context"
13-
gosql "database/sql"
1413
"fmt"
1514
"math"
16-
"net/url"
1715
"regexp"
1816
"strings"
1917
"testing"
@@ -121,13 +119,7 @@ func TestSingleRoleAuditLogging(t *testing.T) {
121119
rootRunner := sqlutils.MakeSQLRunner(sqlDB)
122120
defer s.Stopper().Stop(context.Background())
123121

124-
testUserURL, cleanupFn := sqlutils.PGUrl(t,
125-
s.ApplicationLayer().AdvSQLAddr(), t.Name(), url.User(username.TestUser))
126-
defer cleanupFn()
127-
128-
testUserDb, err := gosql.Open("postgres", testUserURL.String())
129-
require.NoError(t, err)
130-
defer testUserDb.Close()
122+
testUserDb := s.ApplicationLayer().SQLConnForUser(t, username.TestUser, "")
131123
testRunner := sqlutils.MakeSQLRunner(testUserDb)
132124

133125
// Dummy table/user used by tests.
@@ -250,16 +242,10 @@ func TestMultiRoleAuditLogging(t *testing.T) {
250242
defer cleanup()
251243

252244
s, sqlDB, _ := serverutils.StartServer(t, base.TestServerArgs{})
253-
rootRunner := sqlutils.MakeSQLRunner(sqlDB)
254245
defer s.Stopper().Stop(context.Background())
246+
rootRunner := sqlutils.MakeSQLRunner(sqlDB)
255247

256-
testUserURL, cleanupFn := sqlutils.PGUrl(t,
257-
s.ApplicationLayer().AdvSQLAddr(), t.Name(), url.User(username.TestUser))
258-
defer cleanupFn()
259-
260-
testUserDb, err := gosql.Open("postgres", testUserURL.String())
261-
require.NoError(t, err)
262-
defer testUserDb.Close()
248+
testUserDb := s.ApplicationLayer().SQLConnForUser(t, username.TestUser, "")
263249
testRunner := sqlutils.MakeSQLRunner(testUserDb)
264250

265251
// Dummy table/user used by tests.
@@ -374,13 +360,7 @@ func TestReducedAuditConfig(t *testing.T) {
374360
return nil
375361
})
376362

377-
testUserURL, cleanupFn := sqlutils.PGUrl(t,
378-
s.ApplicationLayer().AdvSQLAddr(), t.Name(), url.User(username.TestUser))
379-
defer cleanupFn()
380-
381-
testUserDb, err := gosql.Open("postgres", testUserURL.String())
382-
require.NoError(t, err)
383-
defer testUserDb.Close()
363+
testUserDb := s.ApplicationLayer().SQLConnForUser(t, username.TestUser, "")
384364
testRunner := sqlutils.MakeSQLRunner(testUserDb)
385365

386366
// Set a cluster configuration.
@@ -436,9 +416,7 @@ func TestReducedAuditConfig(t *testing.T) {
436416
}
437417

438418
// Open 2nd connection for the test user.
439-
testUserDb2, err := gosql.Open("postgres", testUserURL.String())
440-
require.NoError(t, err)
441-
defer testUserDb2.Close()
419+
testUserDb2 := s.ApplicationLayer().SQLConnForUser(t, username.TestUser, "")
442420
testRunner2 := sqlutils.MakeSQLRunner(testUserDb2)
443421

444422
// Run a query on the new connection. The new connection will cause the reduced audit config to be re-computed.

pkg/ccl/backupccl/backup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ func TestBackupAndRestoreJobDescription(t *testing.T) {
897897
resolvedAsOfCollectionURIs := getResolvedCollectionURIs(collections, asOf1)
898898

899899
sqlDB.CheckQueryResults(
900-
t, "SELECT description FROM [SHOW JOBS] WHERE job_type='RESTORE'",
900+
t, "SELECT description FROM [SHOW JOBS] WHERE job_type='RESTORE' ORDER BY created",
901901
[][]string{
902902
{fmt.Sprintf("RESTORE DATABASE data FROM ('%s', '%s', '%s')",
903903
backups[0].(string), backups[1].(string), backups[2].(string))},
@@ -1006,7 +1006,7 @@ func backupAndRestore(
10061006
) {
10071007
conn := tc.Conns[0]
10081008
sqlDB := sqlutils.MakeSQLRunner(conn)
1009-
storageConn := tc.StorageClusterConn()
1009+
storageConn := tc.SystemLayer(0).SQLConn(t, "")
10101010
storageSQLDB := sqlutils.MakeSQLRunner(storageConn)
10111011
storageSQLDB.Exec(t, "SET DATABASE=defaultdb")
10121012
{

pkg/ccl/backupccl/create_scheduled_backup_test.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ package backupccl
1010

1111
import (
1212
"context"
13-
gosql "database/sql"
1413
"fmt"
15-
"net/url"
1614
"regexp"
1715
"sort"
1816
"strconv"
@@ -970,18 +968,9 @@ func TestCreateBackupScheduleRequiresAdminRole(t *testing.T) {
970968
defer cleanup()
971969

972970
th.sqlDB.Exec(t, `CREATE USER testuser`)
973-
pgURL, cleanupFunc := sqlutils.PGUrl(
974-
t, th.server.ApplicationLayer().AdvSQLAddr(),
975-
"TestCreateSchedule-testuser", url.User("testuser"),
976-
)
977-
defer cleanupFunc()
978-
testuser, err := gosql.Open("postgres", pgURL.String())
979-
require.NoError(t, err)
980-
defer func() {
981-
require.NoError(t, testuser.Close())
982-
}()
971+
testuser := th.server.ApplicationLayer().SQLConnForUser(t, "testuser", "")
983972

984-
_, err = testuser.Exec("CREATE SCHEDULE FOR BACKUP INTO 'somewhere' RECURRING '@daily'")
973+
_, err := testuser.Exec("CREATE SCHEDULE FOR BACKUP INTO 'somewhere' RECURRING '@daily'")
985974
require.Error(t, err)
986975
}
987976

pkg/ccl/backupccl/show_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ package backupccl
1010

1111
import (
1212
"context"
13-
gosql "database/sql"
1413
"fmt"
1514
"net/url"
1615
"os"
@@ -681,14 +680,7 @@ func TestShowBackupPrivileges(t *testing.T) {
681680
sqlDB.Exec(t, `CREATE USER testuser`)
682681
sqlDB.Exec(t, `CREATE TABLE privs (a INT)`)
683682

684-
pgURL, cleanup := sqlutils.PGUrl(t, srv.ApplicationLayer().AdvSQLAddr(),
685-
"TestShowBackupPrivileges-testuser", url.User("testuser"))
686-
defer cleanup()
687-
testuser, err := gosql.Open("postgres", pgURL.String())
688-
require.NoError(t, err)
689-
defer func() {
690-
require.NoError(t, testuser.Close())
691-
}()
683+
testuser := srv.ApplicationLayer().SQLConnForUser(t, "testuser", "")
692684

693685
// Make an initial backup.
694686
const full = localFoo + "/full"
@@ -698,7 +690,7 @@ func TestShowBackupPrivileges(t *testing.T) {
698690
// Make a second full backup using non into syntax.
699691
sqlDB.Exec(t, `BACKUP TO $1;`, full)
700692

701-
_, err = testuser.Exec(`SHOW BACKUPS IN $1`, full)
693+
_, err := testuser.Exec(`SHOW BACKUPS IN $1`, full)
702694
require.True(t, testutils.IsError(err,
703695
"only users with the admin role or the EXTERNALIOIMPLICITACCESS system privilege are allowed to access the specified nodelocal URI"))
704696

pkg/ccl/backupccl/tenant_backup_nemesis_test.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/roachpb"
2323
"github.com/cockroachdb/cockroach/pkg/security/username"
2424
"github.com/cockroachdb/cockroach/pkg/testutils"
25-
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
2625
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
2726
"github.com/cockroachdb/cockroach/pkg/util"
2827
"github.com/cockroachdb/cockroach/pkg/util/ctxgroup"
@@ -81,8 +80,7 @@ func TestTenantBackupWithCanceledImport(t *testing.T) {
8180
},
8281
})
8382
require.NoError(t, err)
84-
tenant10Conn, err := serverutils.OpenDBConnE(tenant10.SQLAddr(), "defaultdb", false, tenant10.Stopper())
85-
require.NoError(t, err)
83+
tenant10Conn := tenant10.SQLConn(t, "defaultdb")
8684
tenant10DB := sqlutils.MakeSQLRunner(tenant10Conn)
8785

8886
tenant10DB.Exec(t, "CREATE DATABASE bank")
@@ -110,8 +108,7 @@ func TestTenantBackupWithCanceledImport(t *testing.T) {
110108
})
111109
require.NoError(t, err)
112110

113-
tenant11Conn, err := serverutils.OpenDBConnE(tenant11.SQLAddr(), "bank", false, tenant11.Stopper())
114-
require.NoError(t, err)
111+
tenant11Conn := tenant11.SQLConn(t, "bank")
115112
tenant11DB := sqlutils.MakeSQLRunner(tenant11Conn)
116113
countQuery := fmt.Sprintf(`SELECT count(1) FROM bank."%s"`, tableName)
117114
assertEqualQueries(t, tenant10DB, tenant11DB, countQuery)
@@ -157,9 +154,7 @@ func TestTenantBackupNemesis(t *testing.T) {
157154
},
158155
})
159156
require.NoError(t, err)
160-
tenant10Conn, err := serverutils.OpenDBConnE(
161-
tenant10.SQLAddr(), "defaultdb", false, tenant10.Stopper())
162-
require.NoError(t, err)
157+
tenant10Conn := tenant10.SQLConn(t, "defaultdb")
163158
_, err = tenant10Conn.Exec("CREATE DATABASE bank")
164159
require.NoError(t, err)
165160
_, err = tenant10Conn.Exec("USE bank")
@@ -184,7 +179,7 @@ func TestTenantBackupNemesis(t *testing.T) {
184179
g := ctxgroup.WithContext(ctx)
185180
g.GoCtx(func(ctx context.Context) error {
186181
pgURL, cleanupGoDB, err := sqlutils.PGUrlE(
187-
tenant10.SQLAddr(), "workload-worker" /* prefix */, url.User(username.RootUser))
182+
tenant10.AdvSQLAddr(), "workload-worker" /* prefix */, url.User(username.RootUser))
188183
if err != nil {
189184
return err
190185
}
@@ -259,9 +254,7 @@ func TestTenantBackupNemesis(t *testing.T) {
259254
})
260255
require.NoError(t, err)
261256

262-
tenant11Conn, err := serverutils.OpenDBConnE(
263-
tenant11.SQLAddr(), "bank", false, tenant11.Stopper())
264-
require.NoError(t, err)
257+
tenant11Conn := tenant11.SQLConn(t, "bank")
265258

266259
tenant10SQLDB := sqlutils.MakeSQLRunner(tenant10Conn)
267260
tenant11SQLDB := sqlutils.MakeSQLRunner(tenant11Conn)

pkg/ccl/cloudccl/cloudprivilege/privileges_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ package cloudprivilege
1010

1111
import (
1212
"context"
13-
gosql "database/sql"
1413
"fmt"
15-
"net/url"
1614
"testing"
1715

1816
"github.com/cockroachdb/cockroach/pkg/base"
@@ -44,14 +42,7 @@ func TestURIRequiresAdminOrPrivilege(t *testing.T) {
4442
rootDB := sqlutils.MakeSQLRunner(conn)
4543

4644
rootDB.Exec(t, `CREATE USER testuser`)
47-
pgURL, cleanupFunc := sqlutils.PGUrl(
48-
t, tc.ApplicationLayer(0).AdvSQLAddr(), "TestURIRequiresAdminRole-testuser",
49-
url.User("testuser"),
50-
)
51-
defer cleanupFunc()
52-
testuser, err := gosql.Open("postgres", pgURL.String())
53-
require.NoError(t, err)
54-
defer testuser.Close()
45+
testuser := tc.ApplicationLayer(0).SQLConnForUser(t, username.TestUser, "")
5546
rootDB.Exec(t, `CREATE TABLE foo (id INT)`)
5647

5748
// Grant SELECT so that EXPORT fails when checking URI privileges.

pkg/ccl/kvccl/kvfollowerreadsccl/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ go_test(
6262
"//pkg/rpc",
6363
"//pkg/security/securityassets",
6464
"//pkg/security/securitytest",
65-
"//pkg/security/username",
6665
"//pkg/server",
6766
"//pkg/settings/cluster",
6867
"//pkg/sql",

pkg/ccl/kvccl/kvfollowerreadsccl/followerreads_test.go

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
gosql "database/sql"
1414
"fmt"
1515
"math"
16-
"net/url"
1716
"strings"
1817
"testing"
1918
"time"
@@ -31,7 +30,6 @@ import (
3130
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/concurrency/lock"
3231
"github.com/cockroachdb/cockroach/pkg/roachpb"
3332
"github.com/cockroachdb/cockroach/pkg/rpc"
34-
"github.com/cockroachdb/cockroach/pkg/security/username"
3533
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
3634
"github.com/cockroachdb/cockroach/pkg/sql"
3735
"github.com/cockroachdb/cockroach/pkg/sql/physicalplan/replicaoracle"
@@ -971,23 +969,22 @@ func TestSecondaryTenantFollowerReadsRouting(t *testing.T) {
971969
// in KV so we must ensure they're not redacted.
972970
systemSQL.Exec(t, `SET CLUSTER SETTING server.secondary_tenants.redact_trace.enabled = 'false'`)
973971

972+
dbs := make([]*gosql.DB, numNodes)
973+
for i := 0; i < numNodes; i++ {
974+
dbs[i] = tenants[i].SQLConn(t, "")
975+
}
976+
974977
// Wait until all tenant servers are aware of the setting override.
975978
testutils.SucceedsSoon(t, func() error {
976979
settingNames := []string{
977980
"kv.closed_timestamp.target_duration", "kv.closed_timestamp.side_transport_interval", "kv.closed_timestamp.propagation_slack",
978981
}
979982
for _, settingName := range settingNames {
980983
for i := 0; i < numNodes; i++ {
981-
pgURL, cleanup := sqlutils.PGUrl(t, tenants[i].SQLAddr(), "Tenant", url.User(username.RootUser))
982-
defer cleanup()
983-
db, err := gosql.Open("postgres", pgURL.String())
984-
if err != nil {
985-
t.Fatal(err)
986-
}
987-
defer db.Close()
984+
db := dbs[i]
988985

989986
var val string
990-
err = db.QueryRow(
987+
err := db.QueryRow(
991988
fmt.Sprintf("SHOW CLUSTER SETTING %s", settingName),
992989
).Scan(&val)
993990
require.NoError(t, err)
@@ -1003,13 +1000,7 @@ func TestSecondaryTenantFollowerReadsRouting(t *testing.T) {
10031000
return nil
10041001
})
10051002

1006-
pgURL, cleanupPGUrl := sqlutils.PGUrl(
1007-
t, tenants[3].SQLAddr(), "Tenant", url.User(username.RootUser),
1008-
)
1009-
defer cleanupPGUrl()
1010-
tenantSQLDB, err := gosql.Open("postgres", pgURL.String())
1011-
require.NoError(t, err)
1012-
defer tenantSQLDB.Close()
1003+
tenantSQLDB := dbs[3]
10131004
tenantSQL := sqlutils.MakeSQLRunner(tenantSQLDB)
10141005

10151006
tenantSQL.Exec(t, `CREATE DATABASE t`)

pkg/ccl/kvccl/kvtenantccl/upgradeccl/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ go_test(
1616
"//pkg/roachpb",
1717
"//pkg/security/securityassets",
1818
"//pkg/security/securitytest",
19-
"//pkg/security/username",
2019
"//pkg/server",
2120
"//pkg/settings/cluster",
2221
"//pkg/spanconfig",

0 commit comments

Comments
 (0)