Skip to content

Commit

Permalink
kvserver: rename the test-only replica loading func
Browse files Browse the repository at this point in the history
Release note: none
Epic: none
  • Loading branch information
pav-kv committed Feb 6, 2023
1 parent 57ee90b commit 5e241b4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/kv/kvserver/replica_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const (
mergeQueueThrottleDuration = 5 * time.Second
)

// loadInitializedReplica loads and constructs an initialized Replica, after
// checking its invariants.
func loadInitializedReplica(
// loadInitializedReplicaForTesting loads and constructs an initialized Replica,
// after checking its invariants.
func loadInitializedReplicaForTesting(
ctx context.Context, store *Store, desc *roachpb.RangeDescriptor, replicaID roachpb.ReplicaID,
) (*Replica, error) {
if !desc.IsInitialized() {
Expand Down Expand Up @@ -180,7 +180,7 @@ func (r *Replica) setStartKeyLocked(startKey roachpb.RKey) {
// loaded from storage. Must not be called more than once on a Replica.
//
// This method is called in:
// - loadInitializedReplica, to finalize creating an initialized replica;
// - loadInitializedReplicaForTesting, to finalize creating an initialized replica;
// - splitPostApply, to initialize a previously uninitialized replica.
func (r *Replica) initRaftMuLockedReplicaMuLocked(s kvstorage.LoadedReplicaState) error {
if err := s.Check(r.StoreID()); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/split_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestSplitQueueShouldQueue(t *testing.T) {
replicaID := cpy.Replicas().VoterDescriptors()[0].ReplicaID
require.NoError(t,
logstore.NewStateLoader(cpy.RangeID).SetRaftReplicaID(ctx, tc.store.engine, replicaID))
repl, err := loadInitializedReplica(ctx, tc.store, &cpy, replicaID)
repl, err := loadInitializedReplicaForTesting(ctx, tc.store, &cpy, replicaID)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/store_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestStorePoolUpdateLocalStoreBeforeGossip(t *testing.T) {
const replicaID = 1
require.NoError(t,
logstore.NewStateLoader(rg.RangeID).SetRaftReplicaID(ctx, store.engine, replicaID))
replica, err := loadInitializedReplica(ctx, store, &rg, replicaID)
replica, err := loadInitializedReplicaForTesting(ctx, store, &rg, replicaID)
if err != nil {
t.Fatalf("make replica error : %+v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func createReplica(s *Store, rangeID roachpb.RangeID, start, end roachpb.RKey) *
); err != nil {
panic(err)
}
r, err := loadInitializedReplica(ctx, s, desc, replicaID)
r, err := loadInitializedReplicaForTesting(ctx, s, desc, replicaID)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/stores_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestStoresGetReplicaForRangeID(t *testing.T) {

require.NoError(t,
logstore.NewStateLoader(desc.RangeID).SetRaftReplicaID(ctx, store.engine, replicaID))
replica, err := loadInitializedReplica(ctx, store, desc, replicaID)
replica, err := loadInitializedReplicaForTesting(ctx, store, desc, replicaID)
if err != nil {
t.Fatalf("unexpected error when creating replica: %+v", err)
}
Expand Down

0 comments on commit 5e241b4

Please sign in to comment.