mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Merge pull request #475 from nats-io/updates
Fixes for staticcheck tests, added misspell check and fixes.
This commit is contained in:
10
.travis.yml
10
.travis.yml
@@ -2,20 +2,22 @@ language: go
|
||||
go:
|
||||
- 1.6.4
|
||||
- 1.7.5
|
||||
- 1.8
|
||||
- 1.8.1
|
||||
install:
|
||||
- go get github.com/nats-io/go-nats
|
||||
- go get github.com/mattn/goveralls
|
||||
- go get github.com/wadey/gocovmerge
|
||||
- go get honnef.co/go/tools/cmd/staticcheck
|
||||
- go get honnef.co/go/tools/cmd/gosimple
|
||||
- go get -u honnef.co/go/tools/cmd/staticcheck
|
||||
- go get -u honnef.co/go/tools/cmd/gosimple
|
||||
- go get -u github.com/client9/misspell/cmd/misspell
|
||||
before_script:
|
||||
- EXCLUDE_VENDOR=$(go list ./... | grep -v "/vendor/")
|
||||
- go build
|
||||
- go fmt ./...
|
||||
- go vet $EXCLUDE_VENDOR
|
||||
- gosimple $EXCLUDE_VENDOR
|
||||
- staticcheck -ignore "$(cat staticcheck.ignore)" $EXCLUDE_VENDOR
|
||||
- misspell -error -locale US .
|
||||
- staticcheck $EXCLUDE_VENDOR
|
||||
script:
|
||||
- go test -i -race $EXCLUDE_VENDOR
|
||||
- go test -v -race $EXCLUDE_VENDOR
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
|
||||
package server
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s *Server) SetLogger(logger Logger, debugFlag, traceFlag bool) {
|
||||
}
|
||||
|
||||
// If the logger is a file based logger, close and re-open the file.
|
||||
// This allows for file rotation by 'mv'ing the file then signalling
|
||||
// This allows for file rotation by 'mv'ing the file then signaling
|
||||
// the process to trigger this function.
|
||||
func (s *Server) ReOpenLogFile() {
|
||||
// Check to make sure this is a file logger.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2013-2015 Apcera Inc. All rights reserved.
|
||||
// Copyright 2013-2017 Apcera Inc. All rights reserved.
|
||||
|
||||
package server
|
||||
|
||||
@@ -240,7 +240,7 @@ func (s *Server) HandleConnz(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
b, err := json.MarshalIndent(c, "", " ")
|
||||
if err != nil {
|
||||
Errorf("Error marshalling response to /connz request: %v", err)
|
||||
Errorf("Error marshaling response to /connz request: %v", err)
|
||||
}
|
||||
|
||||
// Handle response
|
||||
@@ -331,7 +331,7 @@ func (s *Server) HandleRoutez(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
b, err := json.MarshalIndent(rs, "", " ")
|
||||
if err != nil {
|
||||
Errorf("Error marshalling response to /routez request: %v", err)
|
||||
Errorf("Error marshaling response to /routez request: %v", err)
|
||||
}
|
||||
|
||||
// Handle response
|
||||
@@ -347,7 +347,7 @@ func (s *Server) HandleSubsz(w http.ResponseWriter, r *http.Request) {
|
||||
st := &Subsz{s.sl.Stats()}
|
||||
b, err := json.MarshalIndent(st, "", " ")
|
||||
if err != nil {
|
||||
Errorf("Error marshalling response to /subscriptionsz request: %v", err)
|
||||
Errorf("Error marshaling response to /subscriptionsz request: %v", err)
|
||||
}
|
||||
|
||||
// Handle response
|
||||
@@ -484,7 +484,7 @@ func (s *Server) HandleVarz(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
b, err := json.MarshalIndent(v, "", " ")
|
||||
if err != nil {
|
||||
Errorf("Error marshalling response to /varz request: %v", err)
|
||||
Errorf("Error marshaling response to /varz request: %v", err)
|
||||
}
|
||||
|
||||
// Handle response
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2015-2017 Apcera Inc. All rights reserved.
|
||||
|
||||
package server
|
||||
|
||||
@@ -1311,28 +1311,40 @@ func TestConcurrentMonitoring(t *testing.T) {
|
||||
endpoints := []string{"varz", "varz", "varz", "connz", "connz", "subsz", "subsz", "routez", "routez"}
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(len(endpoints))
|
||||
ech := make(chan string, len(endpoints))
|
||||
|
||||
for _, e := range endpoints {
|
||||
go func(endpoint string) {
|
||||
defer wg.Done()
|
||||
for i := 0; i < 150; i++ {
|
||||
resp, err := http.Get(url + endpoint)
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error: Got %v\n", err)
|
||||
ech <- fmt.Sprintf("Expected no error: Got %v\n", err)
|
||||
return
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
t.Fatalf("Expected a 200 response, got %d\n", resp.StatusCode)
|
||||
ech <- fmt.Sprintf("Expected a 200 response, got %d\n", resp.StatusCode)
|
||||
return
|
||||
}
|
||||
ct := resp.Header.Get("Content-Type")
|
||||
if ct != "application/json" {
|
||||
t.Fatalf("Expected application/json content-type, got %s\n", ct)
|
||||
ech <- fmt.Sprintf("Expected application/json content-type, got %s\n", ct)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if _, err := ioutil.ReadAll(resp.Body); err != nil {
|
||||
t.Fatalf("Got an error reading the body: %v\n", err)
|
||||
ech <- fmt.Sprintf("Got an error reading the body: %v\n", err)
|
||||
return
|
||||
}
|
||||
resp.Body.Close()
|
||||
}
|
||||
}(e)
|
||||
}
|
||||
wg.Wait()
|
||||
// Check for any errors
|
||||
select {
|
||||
case err := <-ech:
|
||||
t.Fatal(err)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2012-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2012-2017 Apcera Inc. All rights reserved.
|
||||
|
||||
package server
|
||||
|
||||
@@ -397,7 +397,7 @@ func parseUsers(mv interface{}) ([]*User, error) {
|
||||
user.Username = v.(string)
|
||||
case "pass", "password":
|
||||
user.Password = v.(string)
|
||||
case "permission", "permissions", "authroization":
|
||||
case "permission", "permissions", "authorization":
|
||||
pm, ok := v.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Expected user permissions to be a map/struct, got %+v", v)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2013-2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2013-2017 Apcera Inc. All rights reserved.
|
||||
|
||||
package server
|
||||
|
||||
@@ -72,7 +72,7 @@ func (c *client) sendConnect(tlsRequired bool) {
|
||||
}
|
||||
b, err := json.Marshal(cinfo)
|
||||
if err != nil {
|
||||
c.Errorf("Error marshalling CONNECT to route: %v\n", err)
|
||||
c.Errorf("Error marshaling CONNECT to route: %v\n", err)
|
||||
c.closeConnection()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (s *Server) generateServerInfoJSON() {
|
||||
// Generate the info json
|
||||
b, err := json.Marshal(s.info)
|
||||
if err != nil {
|
||||
Fatalf("Error marshalling INFO JSON: %+v\n", err)
|
||||
Fatalf("Error marshaling INFO JSON: %+v\n", err)
|
||||
return
|
||||
}
|
||||
s.infoJSON = []byte(fmt.Sprintf("INFO %s %s", b, CR_LF))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2016 Apcera Inc. All rights reserved.
|
||||
// Copyright 2016-2017 Apcera Inc. All rights reserved.
|
||||
|
||||
// Package sublist is a routing mechanism to handle subject distribution
|
||||
// and provides a facility to match subjects from published messages to
|
||||
@@ -70,7 +70,7 @@ func newNode() *node {
|
||||
}
|
||||
|
||||
// Create a new default level. We use FNV1A as the hash
|
||||
// algortihm for the tokens, which should be short.
|
||||
// algorithm for the tokens, which should be short.
|
||||
func newLevel() *level {
|
||||
return &level{nodes: make(map[string]*node)}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func TestSublistRemoveCleanupWildcards(t *testing.T) {
|
||||
func TestSublistInvalidSubjectsInsert(t *testing.T) {
|
||||
s := NewSublist()
|
||||
|
||||
// Insert, or subscribtions, can have wildcards, but not empty tokens,
|
||||
// Insert, or subscriptions, can have wildcards, but not empty tokens,
|
||||
// and can not have a FWC that is not the terminal token.
|
||||
|
||||
// beginning empty token
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
github.com/nats-io/gnatsd/*/*_test.go:SA2002
|
||||
|
||||
Reference in New Issue
Block a user