@@ -18,6 +18,7 @@ import (
1818 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/storepool"
1919 "github.com/cockroachdb/cockroach/pkg/roachpb"
2020 "github.com/cockroachdb/cockroach/pkg/settings/cluster"
21+ "github.com/cockroachdb/cockroach/pkg/util/grunning"
2122 "github.com/cockroachdb/cockroach/pkg/util/leaktest"
2223 "github.com/cockroachdb/cockroach/pkg/util/log"
2324 "github.com/stretchr/testify/require"
@@ -82,6 +83,29 @@ func TestLoadBasedRebalancingObjective(t *testing.T) {
8283 defer log .Scope (t ).Close (t )
8384 ctx := context .Background ()
8485
86+ // On ARM MacOS and other architectures, grunning isn't supported so
87+ // changing the objective to CPU should never work. If this test is run on
88+ // one of these unsupported aarch, test this behavior only.
89+ if ! grunning .Supported () {
90+ st := cluster .MakeTestingClusterSettings ()
91+
92+ gossipStoreDescProvider := testMakeProviderNotifier (allPositiveCPUMap )
93+ LoadBasedRebalancingObjective .Override (ctx , & st .SV , int64 (LBRebalancingQueries ))
94+ require .Equal (t ,
95+ LBRebalancingQueries ,
96+ ResolveLBRebalancingObjective (ctx , st , gossipStoreDescProvider .GetStores ()),
97+ )
98+
99+ // Despite setting to CPU, only QPS should be returned since this aarch
100+ // doesn't support grunning.
101+ LoadBasedRebalancingObjective .Override (ctx , & st .SV , int64 (LBRebalancingCPU ))
102+ require .Equal (t ,
103+ LBRebalancingQueries ,
104+ ResolveLBRebalancingObjective (ctx , st , gossipStoreDescProvider .GetStores ()),
105+ )
106+ return
107+ }
108+
85109 t .Run ("latest version supports all rebalance objectives" , func (t * testing.T ) {
86110 st := cluster .MakeTestingClusterSettings ()
87111 gossipStoreDescProvider := testMakeProviderNotifier (allPositiveCPUMap )
@@ -168,6 +192,26 @@ func TestRebalanceObjectiveManager(t *testing.T) {
168192 ), & callbacks
169193 }
170194
195+ // On ARM MacOS and other architectures, grunning isn't supported so
196+ // changing the objective to CPU should never work. If this test is run on
197+ // one of these unsupported aarch, test this behavior only.
198+ if ! grunning .Supported () {
199+ st := cluster .MakeTestingClusterSettings ()
200+ LoadBasedRebalancingObjective .Override (ctx , & st .SV , int64 (LBRebalancingQueries ))
201+ providerNotifier := testMakeProviderNotifier (allPositiveCPUMap )
202+ manager , callbacks := makeTestManager (st , providerNotifier )
203+
204+ require .Equal (t , LBRebalancingQueries , manager .Objective ())
205+
206+ // Changing the objective to CPU should not work since it isn't
207+ // supported on this aarch.
208+ LoadBasedRebalancingObjective .Override (ctx , & st .SV , int64 (LBRebalancingCPU ))
209+ require .Equal (t , LBRebalancingCPU , manager .Objective ())
210+ require .Len (t , * callbacks , 0 )
211+
212+ return
213+ }
214+
171215 t .Run ("latest version" , func (t * testing.T ) {
172216 st := cluster .MakeTestingClusterSettings ()
173217 LoadBasedRebalancingObjective .Override (ctx , & st .SV , int64 (LBRebalancingCPU ))
0 commit comments