You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: node_test.go
    path of file: ./repos/cockroach/pkg/server
    
    the code of the file until where you have to start completion: // Copyright 2014 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package server

import (
	"bytes"
	"context"
	"fmt"
	"reflect"
	"runtime/pprof"
	"sort"
	"strconv"
	"testing"

	"github.com/cockroachdb/cockroach/pkg/base"
	"github.com/cockroachdb/cockroach/pkg/clusterversion"
	"github.com/cockroachdb/cockroach/pkg/config"
	"github.com/cockroachdb/cockroach/pkg/config/zonepb"
	"github.com/cockroachdb/cockroach/pkg/gossip"
	"github.com/cockroachdb/cockroach/pkg/keys"
	"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
	"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
	"github.com/cockroachdb/cockroach/pkg/roachpb"
	"git
    
func TestRevertToEpochIfTooManyRanges(t *testing.T) {
	defer leaktest.AfterTest(t)()
	defer log.Scope(t).Close(t)

	const expirationThreshold = 100
	ctx := context.Background()
	st := cluster.MakeTestingClusterSettings()
	// Use expiration leases by default, but decrease the limit for the test to
	// avoid having to create too many splits.
	kvserver.ExpirationLeasesOnly.Override(ctx, &st.SV, true)
	kvserver.ExpirationLeasesMaxReplicasPerNode.Override(ctx, &st.SV, expirationThreshold)
	s, _, kvDB := serverutils.StartServer(t, base.TestServerArgs{Settings: st})
	defer s.Stopper().Stop(ctx)

	// Create range and upreplicate.
	key := roachpb.Key("a")
	require.NoError(t, kvDB.AdminSplit(ctx, key, hlc.MaxTimestamp))

	// Make sure the lease is an expiration lease.
	lease, _, err := s.GetRangeLease(ctx, key, roachpb.QueryLocalNodeOnly)
	require.NoError(t, err)
	require.Equal(t, roachpb.LeaseExpiration, lease.Current().Type())

	node := s.Node().(*Node)

	// Force a metrics computation and check the current number of ranges. There
	// are 68 ranges by default in 24.1.
	require.NoError(t, node.computeMetricsPeriodically(ctx, map[*kvserver.Store]*storage.MetricsForInterval{}, 0))
	num := node.storeCfg.RangeCount.Load()
	require.Greaterf(t, num, int64(50), "Expected more than 50 ranges, only found %d", num)

	// Add 50 more ranges to push over the 100 replica expiration limit.
	for i := 0; i < 50; i++ {
		require.NoError(t, kvDB.AdminSplit(ctx, roachpb.Key("a"+strconv.Itoa(i)), hlc.MaxTimestamp))
	}
	// Check metrics again. This has the impact of updating the RangeCount.
	require.NoError(t, node.computeMetricsPeriodically(ctx, map[*kvserver.Store]*storage.MetricsForInterval{}, 0))
	num = node.storeCfg.RangeCount.Load()
	require.Greaterf(t, num, int64(expirationThreshold), "Expected more than 100 ranges, only found %d", num)

	// Verify the lease switched back to Epoch automatically.
	testutils.SucceedsSoon(t, func() error {
		lease, _, err = s.GetRangeLease(ctx, key, roachpb.QueryLocalNodeOnly)
		require.NoError(t, err)
		if lease.Current().Type() != roachpb.LeaseEpoch {
			return errors.New("Lease is still expiration")
		}
		return nil
	})
}