From 8ce1a7e801422bb7e333b3cf36e639f2e9e621a5 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Fri, 31 May 2019 10:59:32 -0600 Subject: [PATCH] Prepare for release 0.14.3 - update tests based on staticcheck reports - update version info in README outputs Signed-off-by: Ivan Kozlovic --- README.md | 62 +++++++++++++++++------------------ server/raft_log_test.go | 19 +++++++++-- server/server.go | 2 +- server/server_durable_test.go | 14 ++++++-- server/server_limits_test.go | 19 +++++++++-- util/lockfile_test.go | 11 +++++-- 6 files changed, 87 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 1bb663e1..0c6dc4cd 100644 --- a/README.md +++ b/README.md @@ -825,13 +825,13 @@ various general statistics. ``` { "cluster_id": "test-cluster", - "server_id": "JEzjfVQS4JIEzM7lZmWHm9", - "version": "0.14.2", + "server_id": "xMp6S8ujCdq1f6K1zLQ7Jx", + "version": "0.14.3", "go": "go1.11.10", "state": "STANDALONE", - "now": "2019-05-21T11:09:35.364637-06:00", - "start_time": "2019-05-21T11:09:24.204869-06:00", - "uptime": "11s", + "now": "2019-05-31T10:40:20.103701-06:00", + "start_time": "2019-05-31T10:40:17.72128-06:00", + "uptime": "2s", "clients": 0, "subscriptions": 0, "channels": 0, @@ -845,13 +845,13 @@ Here is an example: ``` { "cluster_id": "test-cluster", - "server_id": "t9W9zbOIIi5Y9Guppxl0lF", - "version": "0.14.2", + "server_id": "tD1uT9RDU117EnhbjfYiWy", + "version": "0.14.3", "go": "go1.11.10", "state": "CLUSTERED", "role": "Follower", - "now": "2019-05-21T11:10:15.765261-06:00", - "start_time": "2019-05-21T11:10:12.21284-06:00", + "now": "2019-05-31T10:40:46.762166-06:00", + "start_time": "2019-05-31T10:40:43.690739-06:00", "uptime": "3s", "clients": 0, "subscriptions": 0, @@ -1174,26 +1174,26 @@ The NATS Streaming Server embeds a NATS Server. Starting the server with no argu ``` > ./nats-streaming-server -[78166] 2019/05/21 11:11:55.176519 [INF] STREAM: Starting nats-streaming-server[test-cluster] version 0.14.2 -[78166] 2019/05/21 11:11:55.176607 [INF] STREAM: ServerID: Zea1oL1PCvdcPAjWYYI65l -[78166] 2019/05/21 11:11:55.176610 [INF] STREAM: Go version: go1.11.10 -[78166] 2019/05/21 11:11:55.176612 [INF] STREAM: Git commit: [not set] -[78166] 2019/05/21 11:11:55.177090 [INF] Starting nats-server version 1.4.1 -[78166] 2019/05/21 11:11:55.177096 [INF] Git commit [not set] -[78166] 2019/05/21 11:11:55.177274 [INF] Listening for client connections on 0.0.0.0:4222 -[78166] 2019/05/21 11:11:55.177278 [INF] Server is ready -[78166] 2019/05/21 11:11:55.205993 [INF] STREAM: Recovering the state... -[78166] 2019/05/21 11:11:55.206010 [INF] STREAM: No recovered state -[78166] 2019/05/21 11:11:55.457928 [INF] STREAM: Message store is MEMORY -[78166] 2019/05/21 11:11:55.457987 [INF] STREAM: ---------- Store Limits ---------- -[78166] 2019/05/21 11:11:55.457990 [INF] STREAM: Channels: 100 * -[78166] 2019/05/21 11:11:55.457992 [INF] STREAM: --------- Channels Limits -------- -[78166] 2019/05/21 11:11:55.458008 [INF] STREAM: Subscriptions: 1000 * -[78166] 2019/05/21 11:11:55.458010 [INF] STREAM: Messages : 1000000 * -[78166] 2019/05/21 11:11:55.458012 [INF] STREAM: Bytes : 976.56 MB * -[78166] 2019/05/21 11:11:55.458014 [INF] STREAM: Age : unlimited * -[78166] 2019/05/21 11:11:55.458016 [INF] STREAM: Inactivity : unlimited * -[78166] 2019/05/21 11:11:55.458034 [INF] STREAM: ---------------------------------- +[45214] 2019/05/31 10:58:21.697786 [INF] STREAM: Starting nats-streaming-server[test-cluster] version 0.14.3 +[45214] 2019/05/31 10:58:21.697835 [INF] STREAM: ServerID: pshy3fbo9AuEtXcLvjwfQQ +[45214] 2019/05/31 10:58:21.697837 [INF] STREAM: Go version: go1.11.10 +[45214] 2019/05/31 10:58:21.697839 [INF] STREAM: Git commit: [not set] +[45214] 2019/05/31 10:58:21.698338 [INF] Starting nats-server version 1.4.1 +[45214] 2019/05/31 10:58:21.698345 [INF] Git commit [not set] +[45214] 2019/05/31 10:58:21.698520 [INF] Listening for client connections on 0.0.0.0:4222 +[45214] 2019/05/31 10:58:21.698525 [INF] Server is ready +[45214] 2019/05/31 10:58:21.726481 [INF] STREAM: Recovering the state... +[45214] 2019/05/31 10:58:21.726495 [INF] STREAM: No recovered state +[45214] 2019/05/31 10:58:21.982074 [INF] STREAM: Message store is MEMORY +[45214] 2019/05/31 10:58:21.982110 [INF] STREAM: ---------- Store Limits ---------- +[45214] 2019/05/31 10:58:21.982113 [INF] STREAM: Channels: 100 * +[45214] 2019/05/31 10:58:21.982115 [INF] STREAM: --------- Channels Limits -------- +[45214] 2019/05/31 10:58:21.982117 [INF] STREAM: Subscriptions: 1000 * +[45214] 2019/05/31 10:58:21.982119 [INF] STREAM: Messages : 1000000 * +[45214] 2019/05/31 10:58:21.982121 [INF] STREAM: Bytes : 976.56 MB * +[45214] 2019/05/31 10:58:21.982123 [INF] STREAM: Age : unlimited * +[45214] 2019/05/31 10:58:21.982125 [INF] STREAM: Inactivity : unlimited * +[45214] 2019/05/31 10:58:21.982126 [INF] STREAM: ---------------------------------- ``` The server will be started and listening for client connections on port 4222 (the default) from all available interfaces. The logs will be displayed to stderr as shown above. @@ -1770,8 +1770,8 @@ Below is what would be displayed with the above store limits configuration. Noti how `foo.bar.>` is indented compared to `foo.>` to show the inheritance. ``` -[INF] STREAM: Starting nats-streaming-server[test-cluster] version 0.14.2 -[INF] STREAM: ServerID: XStGXeAQhMgPpp4kXg5HNO +[INF] STREAM: Starting nats-streaming-server[test-cluster] version 0.14.3 +[INF] STREAM: ServerID: GTYa5pcjZnQ6aSoO1PWMmT [INF] STREAM: Go version: go1.11.10 [INF] STREAM: Git commit: [not set] [INF] Starting nats-server version 1.4.1 diff --git a/server/raft_log_test.go b/server/raft_log_test.go index bcb8822a..92842022 100644 --- a/server/raft_log_test.go +++ b/server/raft_log_test.go @@ -180,6 +180,7 @@ func TestRaftLogEncodeDecodeLogs(t *testing.T) { } } + errCh := make(chan error, 1) // Perform concurrent encoding... wg := sync.WaitGroup{} encode := func(wg *sync.WaitGroup, min, max int) { @@ -187,7 +188,11 @@ func TestRaftLogEncodeDecodeLogs(t *testing.T) { for i := min; i < max; i++ { l := logs[i] if _, err := store.encodeRaftLog(l); err != nil { - t.Fatalf("Error during encoding") + select { + case errCh <- fmt.Errorf("Error during encoding: %v", err): + return + default: + } } } } @@ -205,7 +210,11 @@ func TestRaftLogEncodeDecodeLogs(t *testing.T) { e := encoded[i] var l raft.Log if err := store.decodeRaftLog(e, &l); err != nil { - t.Fatalf("Error during encoding") + select { + case errCh <- fmt.Errorf("Error during decoding: %v", err): + return + default: + } } } } @@ -215,6 +224,12 @@ func TestRaftLogEncodeDecodeLogs(t *testing.T) { go decode(&wg, 2*(total/4), 3*(total/4)) go decode(&wg, 3*(total/4), total) wg.Wait() + + select { + case e := <-errCh: + t.Fatal(e.Error()) + default: + } } func TestRaftLogWithEncryption(t *testing.T) { diff --git a/server/server.go b/server/server.go index 30a51d7a..25d91229 100644 --- a/server/server.go +++ b/server/server.go @@ -47,7 +47,7 @@ import ( // Server defaults. const ( // VERSION is the current version for the NATS Streaming server. - VERSION = "0.14.2" + VERSION = "0.14.3" DefaultClusterID = "test-cluster" DefaultDiscoverPrefix = "_STAN.discover" diff --git a/server/server_durable_test.go b/server/server_durable_test.go index 805b6656..a5adec33 100644 --- a/server/server_durable_test.go +++ b/server/server_durable_test.go @@ -1,4 +1,4 @@ -// Copyright 2016-2018 The NATS Authors +// Copyright 2016-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -822,6 +822,7 @@ func TestNewOnHoldSetOnDurableRestart(t *testing.T) { stop := make(chan struct{}) wg := sync.WaitGroup{} wg.Add(1) + errCh := make(chan error, 1) go func() { defer wg.Done() for { @@ -830,7 +831,11 @@ func TestNewOnHoldSetOnDurableRestart(t *testing.T) { return default: if err := sc.Publish("foo", []byte("hello")); err != nil { - t.Fatalf("Unexpected error on publish: %v", err) + select { + case errCh <- fmt.Errorf("Unexpected error on publish: %v", err): + return + default: + } } } } @@ -853,6 +858,11 @@ func TestNewOnHoldSetOnDurableRestart(t *testing.T) { if failed { t.Fatal("Did not receive the redelivered messages first") } + select { + case e := <-errCh: + t.Fatal(e.Error()) + default: + } } func TestPersistentStoreDurableClosedStatusOnRestart(t *testing.T) { diff --git a/server/server_limits_test.go b/server/server_limits_test.go index c8b91203..154f325c 100644 --- a/server/server_limits_test.go +++ b/server/server_limits_test.go @@ -1,4 +1,4 @@ -// Copyright 2016-2018 The NATS Authors +// Copyright 2016-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -21,6 +21,7 @@ import ( "testing" "time" + natsdTest "github.com/nats-io/gnatsd/test" "github.com/nats-io/go-nats-streaming" "github.com/nats-io/go-nats-streaming/pb" "github.com/nats-io/nats-streaming-server/stores" @@ -531,7 +532,11 @@ func TestMaxInactivity(t *testing.T) { cleanupDatastore(t) defer cleanupDatastore(t) + ns := natsdTest.RunDefaultServer() + defer ns.Shutdown() + opts := getTestDefaultOptsForPersistentStore() + opts.NATSServerURL = "nats://127.0.0.1:4222" opts.MaxInactivity = 100 * time.Millisecond fooStarLimits := &stores.ChannelLimits{MaxInactivity: 500 * time.Millisecond} opts.AddPerChannel("foo.*", fooStarLimits) @@ -547,6 +552,7 @@ func TestMaxInactivity(t *testing.T) { defer sc.Close() wg := sync.WaitGroup{} + errCh := make(chan error, 1) // If a subscription exists, channel should not be removed. checkChannelNotDeletedDueToSub := func(channel, queue, dur string) { defer wg.Done() @@ -560,7 +566,11 @@ func TestMaxInactivity(t *testing.T) { sub, err = sc.QueueSubscribe(channel, queue, func(_ *stan.Msg) {}) } if err != nil { - t.Fatalf("Error on subscribe: %v", err) + select { + case errCh <- fmt.Errorf("Error on subscribe: %v", err): + return + default: + } } defer sub.Unsubscribe() time.Sleep(opts.MaxInactivity + 50*time.Millisecond) @@ -572,6 +582,11 @@ func TestMaxInactivity(t *testing.T) { go checkChannelNotDeletedDueToSub("c3", "", "dur") go checkChannelNotDeletedDueToSub("c4", "queue", "dur") wg.Wait() + select { + case e := <-errCh: + t.Fatal(e.Error()) + default: + } // Since last subscription is closed, wait more than // MaxInactivity, all those channels should have been deleted time.Sleep(opts.MaxInactivity + 50*time.Millisecond) diff --git a/util/lockfile_test.go b/util/lockfile_test.go index 4b1dbe9a..bbff33f5 100644 --- a/util/lockfile_test.go +++ b/util/lockfile_test.go @@ -1,4 +1,4 @@ -// Copyright 2017-2018 The NATS Authors +// Copyright 2017-2019 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,6 +15,7 @@ package util import ( "flag" + "fmt" "os" "os/exec" "strings" @@ -99,12 +100,13 @@ func TestLockFile(t *testing.T) { // Try again with different process, it should work now. wg := sync.WaitGroup{} wg.Add(1) + errCh := make(chan error, 1) go func() { defer wg.Done() out, err := exec.Command(os.Args[0], "-lockFile", fname, "-test.v", "-test.run=TestLockFile$").CombinedOutput() if err != nil { - t.Fatalf("Other process should have been able to get the lock, got %v - %v", + errCh <- fmt.Errorf("Other process should have been able to get the lock, got %v - %v", err, out) } }() @@ -130,6 +132,11 @@ func TestLockFile(t *testing.T) { wf.Close() defer os.Remove(wf.Name()) wg.Wait() + select { + case e := <-errCh: + t.Fatal(e.Error()) + default: + } } }