Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…db#99660

99509: bazci: protect against `nil` target r=healthy-pod a=rickystewart

Closes cockroachdb#98861.

Epic: none

Release note: None

99532: sql: inject stats into TestExecBuild_sql_statistics_persisted testdata r=ericharmeling a=ericharmeling

Background thread: cockroachdb#99240 (comment)

Part of cockroachdb#99399.

This commit replaces the `CREATE STATISTICS` statements in the `TestExecBuild_sql_statistics_persisted` testdata with `ALTER TABLE ... INJECT STATISTICS` and removes the retry directives added to deflake the test in cockroachdb#99447.

Epic: none

Release note: None

99642: serverccl: skip TestServerControllerHTTP under deadlock r=dhartunian a=knz

Fixes cockroachdb#98046.
Release note: None

99660: workload/tpcc: disable check 3.3.2.11 after workload r=renatolabs a=nvanbenschoten

Fixes cockroachdb#99619.
Fixes cockroachdb#99594.
Fixes cockroachdb#99603.
Fixes cockroachdb#99604.
Fixes cockroachdb#99617.
Fixes cockroachdb#99616.
Fixes cockroachdb#99613.
Fixes cockroachdb#99611.
Fixes cockroachdb#99604.
Fixes cockroachdb#99603.
Fixes cockroachdb#99600.
Fixes cockroachdb#99599.
Fixes cockroachdb#99598.
Fixes cockroachdb#99596.
Fixes cockroachdb#99595.
Fixes cockroachdb#99594.

This commit disables TPC-C's consistency check 3.3.2.11 (added in cockroachdb#99542) after the workload has run. The check asserts a relationship between the number of rows in the "order" table and rows in the "new_order" table. Rows are inserted into these tables transactional by the NewOrder transaction. However, only rows in the "new_order" table are deleted by the Delivery transaction. Consequently, the consistency condition will fail after the first Delivery transaction is run by the workload.

See cockroachdb#99542 (comment) for more details.

Release note: None

Co-authored-by: Ricky Stewart <[email protected]>
Co-authored-by: Eric Harmeling <[email protected]>
Co-authored-by: Raphael 'kena' Poss <[email protected]>
Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
5 people committed Mar 27, 2023
5 parents b4f3ae3 + 92efe7d + 4ae429f + 2133e67 + 70b1be2 commit b1a20ba
Show file tree
Hide file tree
Showing 7 changed files with 766 additions and 109 deletions.
1 change: 1 addition & 0 deletions pkg/ccl/serverccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ go_test(
"//pkg/sql/tests",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
"//pkg/testutils/sqlutils",
"//pkg/testutils/testcluster",
"//pkg/ts/catalog",
Expand Down
27 changes: 27 additions & 0 deletions pkg/ccl/serverccl/server_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/util/httputil"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand All @@ -38,19 +39,25 @@ func TestServerControllerHTTP(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

skip.UnderDeadlock(t, "test triggers many goroutines, which results in conn timeouts and test failures under deadlock")

ctx := context.Background()

s, db, _ := serverutils.StartServer(t, base.TestServerArgs{
DisableDefaultTestTenant: true,
})
defer s.Stopper().Stop(ctx)

t.Logf("waking up HTTP server")

// Retrieve a privileged HTTP client. NB: this also populates
// system.web_sessions.
aurl := s.AdminURL()
client, err := s.GetAdminHTTPClient()
require.NoError(t, err)

t.Logf("retrieving web session details")

// Now retrieve the entry in the system tenant's web sessions.
row := db.QueryRow(`SELECT id,"hashedSecret",username,"createdAt","expiresAt" FROM system.web_sessions`)
var id int64
Expand All @@ -59,13 +66,17 @@ func TestServerControllerHTTP(t *testing.T) {
var created, expires time.Time
require.NoError(t, row.Scan(&id, &secret, &username, &created, &expires))

t.Logf("waking up a test tenant")

// Create our own test tenant with a known name.
_, _, err = s.(*server.TestServer).StartSharedProcessTenant(ctx,
base.TestSharedProcessTenantArgs{
TenantName: "hello",
})
require.NoError(t, err)

t.Logf("connecting to the test tenant")

// Get a SQL connection to the test tenant.
sqlAddr := s.ServingSQLAddr()
db2, err := serverutils.OpenDBConnE(sqlAddr, "cluster:hello/defaultdb", false, s.Stopper())
Expand All @@ -76,6 +87,8 @@ func TestServerControllerHTTP(t *testing.T) {
// This actually uses the connection.
require.NoError(t, db2.Ping())

t.Logf("creating a test user and session")

// Instantiate the HTTP test username and privileges into the test tenant.
_, err = db2.Exec(fmt.Sprintf(`CREATE USER %s`, lexbase.EscapeSQLIdent(username)))
require.NoError(t, err)
Expand All @@ -88,6 +101,8 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
id, secret, username, created, expires)
require.NoError(t, err)

t.Logf("configuring the test connections")

// From this point, we are expecting the ability to access both tenants using
// the same cookie jar.
// Let's assert this is true by retrieving session lists, asserting
Expand Down Expand Up @@ -128,6 +143,8 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
return req
}

t.Logf("retrieving session list from system tenant")

// Retrieve the session list for the system tenant.
req := newreq()
req.Header.Set(server.TenantSelectHeader, catconstants.SystemTenantName)
Expand All @@ -137,6 +154,8 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
require.Equal(t, len(body.Sessions), 1)
require.Equal(t, body.Sessions[0].ApplicationName, "hello system")

t.Logf("retrieving session list from test tenant")

// Ditto for the test tenant.
req = newreq()
req.Header.Set(server.TenantSelectHeader, "hello")
Expand All @@ -146,6 +165,8 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
require.Equal(t, len(body.Sessions), 1)
require.Equal(t, body.Sessions[0].ApplicationName, "hello hello")

t.Logf("retrieving session list from system tenant via cookie")

c := &http.Cookie{
Name: server.TenantSelectCookieName,
Value: catconstants.SystemTenantName,
Expand All @@ -164,6 +185,8 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
require.Equal(t, len(body.Sessions), 1)
require.Equal(t, body.Sessions[0].ApplicationName, "hello system")

t.Logf("retrieving session list from test tenant via cookie")

c.Value = "hello"
client.Jar.SetCookies(purl, []*http.Cookie{c})
req = newreq()
Expand All @@ -173,6 +196,8 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
require.Equal(t, len(body.Sessions), 1)
require.Equal(t, body.Sessions[0].ApplicationName, "hello hello")

t.Logf("retrieving session list from test tenant via cookie and header")

// Finally, do it again with both cookie and header. Verify
// that the header wins.
req = newreq()
Expand All @@ -182,6 +207,8 @@ VALUES($1, $2, $3, $4, $5, (SELECT user_id FROM system.users WHERE username = $3
t.Logf("response 5:\n%#v", body)
require.Equal(t, len(body.Sessions), 1)
require.Equal(t, body.Sessions[0].ApplicationName, "hello system")

t.Logf("end of test")
}

// TestServerControllerBadHTTPCookies tests the controller's proxy
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/bazci/bazci.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ func (s *monitorBuildServer) handleBuildEvent(
func (s *monitorBuildServer) Finalize() error {
if s.action == "build" {
for _, target := range s.builtTargets {
if target == nil {
continue
}
for _, outputGroup := range target.OutputGroup {
if outputGroup == nil || outputGroup.Incomplete {
continue
Expand Down
Loading

0 comments on commit b1a20ba

Please sign in to comment.