github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/testutils/physicalplanutils/fake_resolver.go (about) 1 // Copyright 2016 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package physicalplanutils 12 13 import ( 14 "github.com/cockroachdb/cockroach/pkg/roachpb" 15 "github.com/cockroachdb/cockroach/pkg/sql/physicalplan" 16 "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" 17 "github.com/cockroachdb/cockroach/pkg/util" 18 ) 19 20 // FakeResolverForTestCluster creates a fake span resolver for the nodes in a 21 // test cluster. 22 func FakeResolverForTestCluster(tc serverutils.TestClusterInterface) physicalplan.SpanResolver { 23 nodeDescs := make([]*roachpb.NodeDescriptor, tc.NumServers()) 24 for i := range nodeDescs { 25 s := tc.Server(i) 26 nodeDescs[i] = &roachpb.NodeDescriptor{ 27 NodeID: s.NodeID(), 28 Address: util.UnresolvedAddr{AddressField: s.ServingRPCAddr()}, 29 } 30 } 31 32 return physicalplan.NewFakeSpanResolver(nodeDescs) 33 }