go mod tidy and linter

fix race

cleanup
This commit is contained in:
Travis 2021-01-15 14:53:36 -06:00
parent 9855f4d0a0
commit 1d55e671a2
No known key found for this signature in database
GPG key ID: 37080CC2042BA34E
12 changed files with 6 additions and 60 deletions

View file

@ -628,10 +628,6 @@ func TestCluster_Coordinator(t *testing.T) {
})
}
func getport() uint16 {
return uint16(globalPortMap.MustGetPort())
}
func TestCluster_Topology(t *testing.T) {
c1 := NewTestCluster(t, 1) // automatically creates Node{ID: "node0"}

View file

@ -78,8 +78,6 @@ func Test_Repair(t *testing.T) {
)
// note: do not defer c.Close() here. We manually close below.
vv("MustRunCluster done.\n")
var nodes []*test.Command
var dirs []string
for i := 0; i < nNodes; i++ {
@ -102,7 +100,6 @@ func Test_Repair(t *testing.T) {
if err != nil {
t.Fatalf("creating index: %v", err)
}
vv("past create index")
if idx[i].CreatedAt() == 0 {
t.Fatal("index createdAt is empty")
}

View file

@ -35,12 +35,11 @@ func TestServerHelp(t *testing.T) {
}
}
func nextPort() string {
// I have no idea why the linter in ci is complaining about this being unused.
func nextPort() string { //nolint:unused
return fmt.Sprintf(`"localhost:%d"`, 0)
}
var _ = nextPort // happy linter
func TestServerConfig(t *testing.T) {
t.Skip("pilosa hosts config (cmd.Server.Config.Cluster.Hosts and brethren) is test only and will go away with high probability. skip for now.")
actualDataDir, err := ioutil.TempDir("", "")

View file

@ -106,7 +106,6 @@ func (e *Etcd) Close() error {
e.e.Server.Stop()
e.e.Close()
<-e.e.Server.StopNotify()
// os.RemoveAll(e.options.Dir)
}
return nil

View file

@ -5359,7 +5359,7 @@ func (e *executor) mapReduce(ctx context.Context, index string, shards []uint64,
// processing should be done locally so we start with just the local node.
var nodes []*topology.Node
if !opt.Remote {
nodes = topology.Nodes(e.Cluster.nodes).Clone()
nodes = topology.Nodes(e.Cluster.Nodes()).Clone()
} else {
nodes = []*topology.Node{e.Cluster.nodeByID(e.Node.ID)}
}

2
go.sum
View file

@ -371,8 +371,6 @@ go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/etcd v0.0.0-20201125193152-8a03d2e9614b h1:5makfKENOTVu2bNoHzSqwwz+g70ivWLSnExzd33/2bI=
go.etcd.io/etcd v0.0.0-20201125193152-8a03d2e9614b/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=

View file

@ -1926,7 +1926,7 @@ func pos(rowID, columnID uint64) uint64 {
func uriPathToURL(uri *pnet.URI, path string) url.URL {
return url.URL{
Scheme: uri.Scheme, // race read
Scheme: uri.Scheme,
Host: uri.HostPort(),
Path: path,
}

View file

@ -336,7 +336,6 @@ func OptServerClusterHasher(h topology.Hasher) ServerOption {
// used to specify the translation data store type.
func OptServerOpenTranslateStore(fn OpenTranslateStoreFunc) ServerOption {
return func(s *Server) error {
//fmt.Printf("OptServerOpenTranslateStore calling fn = %p; boltdb.OpenTranslateStore= %p; pilosa.OpenInMemTranslateStore = %p", fn, boltdb.OpenTranslateStore, OpenInMemTranslateStore)
s.holderConfig.OpenTranslateStore = fn
return nil
}

View file

@ -838,7 +838,7 @@ func TestRemoveConcurrentIndexCreation(t *testing.T) {
t.Fatalf("unexpected hosts: %v", hosts)
}
if err := <-errc; err != nil {
t.Fatalf("error from index creation: %v", err) // server_test.go:834: error from index creation: validating api method: api method apiCreateIndex not allowed in state RESIZING
t.Fatalf("error from index creation: %v", err)
}
}

View file

@ -408,8 +408,6 @@ func newCluster(tb testing.TB, size int, opts ...[]server.CommandOption) (*Clust
return nil, errors.New("cluster must contain at least one node")
}
//opts = appendOpts(opts, GenDisCoConfig(size))
if len(opts) != size && len(opts) != 0 && len(opts) != 1 {
return nil, errors.New("Slice of CommandOptions must be of length 0, 1, or equal to the number of cluster nodes")
}

View file

@ -43,7 +43,6 @@ type Command struct {
func OptAllowedOrigins(origins []string) server.CommandOption {
return func(m *server.Command) error {
fmt.Printf("OptAllowedOrigins called with origins = '%#v'", origins)
m.Config.Handler.AllowedOrigins = origins
return nil
}
@ -79,21 +78,6 @@ func newCommand(tb testing.TB, opts ...server.CommandOption) *Command {
m.Config.BindGRPC = "http://localhost:0"
}
/*
if err := port.GetPorts(func(ports []int) error {
if m.Config.Bind == defaultConf.Bind {
m.Config.Bind = fmt.Sprintf("http://localhost:%d", ports[0])
}
if m.Config.BindGRPC == defaultConf.BindGRPC {
m.Config.BindGRPC = fmt.Sprintf("http://localhost:%d", ports[1])
}
return nil
}, 2, 10); err != nil {
panic(err)
}
*/
m.Config.Translation.MapSize = 140000
m.Config.WorkerPoolSize = 2
@ -122,17 +106,8 @@ func RunCommand(t *testing.T) *Command {
t.Helper()
// prefer MustRunCluster since it sets up for using etcd using
// the GenDisCoConfig(size) option.
// the GenDisCoConfig(size) option.
return MustRunCluster(t, 1).GetNode(0)
/*
m := newCommand(t, server.OptCommandServerOptions(pilosa.OptServerOpenTranslateStore(pilosa.OpenInMemTranslateStore)))
m.Config.Metric.Diagnostics = false // Disable diagnostics.
m.Config.Gossip.Port = "0"
if err := m.Start(); err != nil {
t.Fatal(err)
}
return m
*/
}
// GossipAddress returns the address on which gossip is listening after a Main

15
util.go
View file

@ -55,21 +55,6 @@ func NilInside(iface interface{}) bool {
return false
}
// GetAvailPort asks the OS for an unused port.
// There's a race here, where the port could be grabbed by someone else
// before the caller gets to Listen on it, but we are only using
// it to find a random port for the test hang debugging.
// Moreover, in practice such races are rare. Just ask for
// it again if the port is taken.
// Uses net.Listen("tcp", ":0") to determine a free port, then
// releases it back to the OS with Listener.Close().
/*func GetAvailPort() int {
l, _ := net.Listen("tcp", ":0")
r := l.Addr()
l.Close()
return r.(*net.TCPAddr).Port
}*/
//////////////////////////////////
// helper utility functions