@@ -17,6 +17,7 @@ import (
1717
1818 "github.com/cockroachdb/cockroach/pkg/base"
1919 "github.com/cockroachdb/cockroach/pkg/build"
20+ "github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities"
2021 "github.com/cockroachdb/cockroach/pkg/roachpb"
2122 "github.com/cockroachdb/cockroach/pkg/server"
2223 "github.com/cockroachdb/cockroach/pkg/server/apiconstants"
@@ -29,6 +30,7 @@ import (
2930 "github.com/cockroachdb/cockroach/pkg/util/leaktest"
3031 "github.com/cockroachdb/cockroach/pkg/util/log"
3132 "github.com/pkg/errors"
33+ "github.com/stretchr/testify/require"
3234)
3335
3436// TestStatusJson verifies that status endpoints return expected Json results.
@@ -86,9 +88,25 @@ func TestStatusJson(t *testing.T) {
8688func TestNodeStatusResponse (t * testing.T ) {
8789 defer leaktest .AfterTest (t )()
8890 defer log .Scope (t ).Close (t )
89- s := serverutils .StartServerOnly (t , base.TestServerArgs {})
90- defer s .Stopper ().Stop (context .Background ())
91- node := s .Node ().(* server.Node )
91+ srv := serverutils .StartServerOnly (t , base.TestServerArgs {
92+ DefaultTestTenant : base .TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet (110023 ),
93+ })
94+ defer srv .Stopper ().Stop (context .Background ())
95+
96+ if srv .TenantController ().StartedDefaultTestTenant () {
97+ // Enable access to the nodes endpoint for the test tenant.
98+ _ , err := srv .SystemLayer ().SQLConn (t , "" ).Exec (
99+ `ALTER TENANT [$1] GRANT CAPABILITY can_view_node_info=true` , serverutils .TestTenantID ().ToUint64 ())
100+ require .NoError (t , err )
101+
102+ serverutils .WaitForTenantCapabilities (t , srv , serverutils .TestTenantID (), map [tenantcapabilities.ID ]string {
103+ tenantcapabilities .CanViewNodeInfo : "true" ,
104+ }, "" )
105+ }
106+
107+ s := srv .ApplicationLayer ()
108+
109+ node := srv .StorageLayer ().Node ().(* server.Node )
92110
93111 wrapper := serverpb.NodesResponse {}
94112
@@ -187,11 +205,25 @@ func TestNodesGRPCResponse(t *testing.T) {
187205
188206 ctx := context .Background ()
189207
190- s := serverutils .StartServerOnly (t , base.TestServerArgs {})
191- defer s .Stopper ().Stop (ctx )
208+ srv := serverutils .StartServerOnly (t , base.TestServerArgs {
209+ DefaultTestTenant : base .TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet (110023 ),
210+ })
211+ defer srv .Stopper ().Stop (ctx )
212+
213+ if srv .TenantController ().StartedDefaultTestTenant () {
214+ // Enable access to the nodes endpoint for the test tenant.
215+ _ , err := srv .SystemLayer ().SQLConn (t , "" ).Exec (
216+ `ALTER TENANT [$1] GRANT CAPABILITY can_view_node_info=true` , serverutils .TestTenantID ().ToUint64 ())
217+ require .NoError (t , err )
218+
219+ serverutils .WaitForTenantCapabilities (t , srv , serverutils .TestTenantID (), map [tenantcapabilities.ID ]string {
220+ tenantcapabilities .CanViewNodeInfo : "true" ,
221+ }, "" )
222+ }
192223
193224 var request serverpb.NodesRequest
194225
226+ s := srv .ApplicationLayer ()
195227 client := s .GetStatusClient (t )
196228
197229 response , err := client .Nodes (ctx , & request )
0 commit comments