Skip to content

Commit

Permalink
Merge pull request #527 from nats-io/release_1_9_0
Browse files Browse the repository at this point in the history
Release v1.9.0
  • Loading branch information
kozlovic authored Oct 30, 2019
2 parents fec076f + 6635d2e commit 41e7eae
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 70 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ When using or transitioning to Go modules support:
```bash
# Go client latest or explicit version
go get github.com/nats-io/nats.go/@latest
go get github.com/nats-io/nats.go/@v1.8.1
go get github.com/nats-io/nats.go/@v1.9.0

# For latest NATS Server, add /v2 at the end
go get github.com/nats-io/nats-server/v2
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ github.com/nats-io/nkeys v0.1.0 h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4=
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2 changes: 1 addition & 1 deletion nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (

// Default Constants
const (
Version = "1.8.1"
Version = "1.9.0"
DefaultURL = "nats://127.0.0.1:4222"
DefaultPort = 4222
DefaultMaxReconnect = 60
Expand Down
35 changes: 24 additions & 11 deletions nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ func stackFatalf(t *testing.T, f string, args ...interface{}) {
t.Fatalf("%s", strings.Join(lines, "\n"))
}

// Check the error channel for an error and if one is present,
// calls t.Fatal(e.Error()). Note that this supports tests that
// send nil to the error channel and so report error only if
// e is != nil.
func checkErrChannel(t *testing.T, errCh chan error) {
t.Helper()
select {
case e := <-errCh:
if e != nil {
t.Fatal(e.Error())
}
default:
}
}

func TestVersionMatchesTag(t *testing.T) {
tag := os.Getenv("TRAVIS_TAG")
if tag == "" {
Expand Down Expand Up @@ -1871,15 +1886,13 @@ func TestNKeyOptionFromSeed(t *testing.T) {

addr := tl.Addr().(*net.TCPAddr)

wg := sync.WaitGroup{}
wg.Add(1)

ch := make(chan bool, 1)
errCh := make(chan error, 1)
rs := func(ch chan bool) {
defer wg.Done()
conn, err := l.Accept()
if err != nil {
t.Fatalf("Error accepting client connection: %v\n", err)
errCh <- fmt.Errorf("error accepting client connection: %v", err)
return
}
defer conn.Close()
info := "INFO {\"server_id\":\"foobar\",\"nonce\":\"anonce\"}\r\n"
Expand All @@ -1889,7 +1902,8 @@ func TestNKeyOptionFromSeed(t *testing.T) {
br := bufio.NewReaderSize(conn, 10*1024)
line, _, _ := br.ReadLine()
if err != nil {
t.Fatalf("Expected CONNECT and PING from client, got: %s", err)
errCh <- fmt.Errorf("expected CONNECT and PING from client, got: %s", err)
return
}
// If client got an error reading the seed, it will not send it
if bytes.Contains(line, []byte(`"sig":`)) {
Expand All @@ -1900,8 +1914,8 @@ func TestNKeyOptionFromSeed(t *testing.T) {
}
// Now wait to be notified that we can finish
<-ch
errCh <- nil
}
//lint:ignore SA2002 t.Fatalf in go routine will happen only if test fails
go rs(ch)

nc, err := Connect(fmt.Sprintf("nats://127.0.0.1:%d", addr.Port), opt)
Expand All @@ -1910,20 +1924,19 @@ func TestNKeyOptionFromSeed(t *testing.T) {
}
nc.Close()
close(ch)
wg.Wait()

checkErrChannel(t, errCh)

// Now that option is already created, change content of file
ioutil.WriteFile(seedFile, []byte(`xxxxx`), 0666)
ch = make(chan bool, 1)
wg.Add(1)
//lint:ignore SA2002 t.Fatalf in go routine will happen only if test fails
go rs(ch)

if _, err := Connect(fmt.Sprintf("nats://127.0.0.1:%d", addr.Port), opt); err == nil {
t.Fatal("Expected error, got none")
}
close(ch)
wg.Wait()
checkErrChannel(t, errCh)
}

func TestLookupHostResultIsRandomized(t *testing.T) {
Expand Down
27 changes: 21 additions & 6 deletions test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ func getStableNumGoroutine(t *testing.T) int {
return 0
}

// Check the error channel for an error and if one is present,
// calls t.Fatal(e.Error()). Note that this supports tests that
// send nil to the error channel and so report error only if
// e is != nil.
func checkErrChannel(t *testing.T, errCh chan error) {
t.Helper()
select {
case e := <-errCh:
if e != nil {
t.Fatal(e.Error())
}
default:
}
}

func TestCloseLeakingGoRoutines(t *testing.T) {
s := RunDefaultServer()
defer s.Shutdown()
Expand Down Expand Up @@ -636,19 +651,19 @@ func TestSimultaneousRequests(t *testing.T) {
nc.Publish(m.Reply, response)
})

var wg sync.WaitGroup
wg := sync.WaitGroup{}
wg.Add(50)
errCh := make(chan error, 50)
for i := 0; i < 50; i++ {
wg.Add(1)
//lint:ignore SA2002 t.Fatalf in go routine will happen only if test fails
go func() {
defer wg.Done()
if _, err := nc.Request("foo", nil, 2*time.Second); err != nil {
t.Fatalf("Expected to receive a timeout error")
} else {
wg.Done()
errCh <- fmt.Errorf("expected to receive a timeout error")
}
}()
}
wg.Wait()
checkErrChannel(t, errCh)
}

func TestRequestClose(t *testing.T) {
Expand Down
Loading

0 comments on commit 41e7eae

Please sign in to comment.