From 1d55e671a2657fe058a44e87711b8c98a79f1efa Mon Sep 17 00:00:00 2001 From: Travis Date: Fri, 15 Jan 2021 14:53:36 -0600 Subject: [PATCH] go mod tidy and linter fix race cleanup --- cluster_internal_test.go | 4 ---- cmd/pilosa-fsck/fsck_test.go | 3 --- cmd/server_test.go | 5 ++--- etcd/embed.go | 1 - executor.go | 2 +- go.sum | 2 -- http/client.go | 2 +- server.go | 1 - server/server_test.go | 2 +- test/cluster.go | 2 -- test/pilosa.go | 27 +-------------------------- util.go | 15 --------------- 12 files changed, 6 insertions(+), 60 deletions(-) diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 062b7a806..ea391b52d 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -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"} diff --git a/cmd/pilosa-fsck/fsck_test.go b/cmd/pilosa-fsck/fsck_test.go index bb6f6ff7f..41e0d7a8c 100644 --- a/cmd/pilosa-fsck/fsck_test.go +++ b/cmd/pilosa-fsck/fsck_test.go @@ -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") } diff --git a/cmd/server_test.go b/cmd/server_test.go index 847228a86..ff19458a2 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -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("", "") diff --git a/etcd/embed.go b/etcd/embed.go index 23b6cc8cb..2cbcce20f 100644 --- a/etcd/embed.go +++ b/etcd/embed.go @@ -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 diff --git a/executor.go b/executor.go index 59fd6b62a..b85f688e0 100644 --- a/executor.go +++ b/executor.go @@ -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)} } diff --git a/go.sum b/go.sum index dfa823f3b..f5021bc1b 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/http/client.go b/http/client.go index 9361d68ad..7eb5d025f 100644 --- a/http/client.go +++ b/http/client.go @@ -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, } diff --git a/server.go b/server.go index 519cfa56e..5a775d61d 100644 --- a/server.go +++ b/server.go @@ -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 } diff --git a/server/server_test.go b/server/server_test.go index f21059e9c..3e44e0c89 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -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) } } diff --git a/test/cluster.go b/test/cluster.go index e9635ad9e..41f6d0aad 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -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") } diff --git a/test/pilosa.go b/test/pilosa.go index 15fa72998..e999a3cd3 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -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 diff --git a/util.go b/util.go index af459a46a..720a1ddf2 100644 --- a/util.go +++ b/util.go @@ -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