From f25ad35f0a6a15566759517bed338a4532f4c2fb Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Mon, 9 Dec 2019 09:28:42 -0800 Subject: [PATCH 1/4] web: fix test goroutine in TestTLS() --- web/service_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/web/service_test.go b/web/service_test.go index 588531b8..a4447174 100644 --- a/web/service_test.go +++ b/web/service_test.go @@ -221,10 +221,10 @@ func TestTLS(t *testing.T) { service.HandleFunc("/", fn) + errCh := make(chan error, 1) go func() { - if err := service.Run(); err != nil { - t.Fatal(err) - } + errCh <- service.Run() + close(errCh) }() var s []*registry.Service @@ -257,4 +257,13 @@ func TestTLS(t *testing.T) { if string(b) != str { t.Errorf("Expected %s got %s", str, string(b)) } + + select { + case err := <-errCh: + if err != nil { + t.Fatalf("Run():%v", err) + } + case <-time.After(time.Duration(time.Second)): + t.Logf("service.Run() survived a client request without an error") + } } From c9af88184bd0d55c39bee202de84a487e30c3dcc Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Mon, 9 Dec 2019 09:44:14 -0800 Subject: [PATCH 2/4] web: fix test goroutine in TestService() --- web/service_test.go | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/web/service_test.go b/web/service_test.go index a4447174..33365535 100644 --- a/web/service_test.go +++ b/web/service_test.go @@ -57,10 +57,10 @@ func TestService(t *testing.T) { service.HandleFunc("/", fn) + errCh := make(chan error, 1) go func() { - if err := service.Run(); err != nil { - t.Fatal(err) - } + errCh <- service.Run() + close(errCh) }() var s []*registry.Service @@ -104,12 +104,32 @@ func TestService(t *testing.T) { } } + select { + case err := <-errCh: + if err != nil { + t.Fatalf("service.Run():%v", err) + } + case <-time.After(time.Duration(time.Second)): + t.Logf("service.Run() survived a client request without an error") + } + ch := make(chan os.Signal, 1) signal.Notify(ch, syscall.SIGTERM) syscall.Kill(syscall.Getpid(), syscall.SIGTERM) <-ch + select { + case err := <-errCh: + if err != nil { + t.Fatalf("service.Run():%v", err) + } else { + t.Log("service.Run() nil return on syscall.SIGTERM") + } + case <-time.After(time.Duration(time.Second)): + t.Logf("service.Run() survived a client request without an error") + } + eventually(func() bool { _, err := reg.GetService("go.micro.web.test") return err == registry.ErrNotFound @@ -128,6 +148,7 @@ func TestService(t *testing.T) { t.Errorf("unexpected %s: want true, have false", tt.subject) } } + } func TestOptions(t *testing.T) { @@ -261,9 +282,10 @@ func TestTLS(t *testing.T) { select { case err := <-errCh: if err != nil { - t.Fatalf("Run():%v", err) + t.Fatalf("service.Run():%v", err) } case <-time.After(time.Duration(time.Second)): t.Logf("service.Run() survived a client request without an error") } + } From 5352d5334657342922da5554b1b37f4b9420cda6 Mon Sep 17 00:00:00 2001 From: Jan Kremlacek Date: Mon, 9 Dec 2019 21:52:28 +0100 Subject: [PATCH 3/4] nlopes/slack dep update to fix broken unmarshal About a month ago Slack introduced the updated structure of RTM messages which resulted in an inability to unmarshal received msg (original issue: https://github.com/nlopes/slack/issues/630). It's not an issue of micro itself, but of the github.com/nlopes/slack lib. The fix was already merged into master (https://github.com/nlopes/slack/pull/618), but the lib has not been released in any new version. Thus so I propose to update directly to the commit: go get github.com/nlopes/slack@d06c2a2b3249b44a9c5dee8485f5a87497beb9ea The MicroBot does now work now with any Slack client newer than around a month old. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0812f043..3cbfcc37 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/miekg/dns v1.1.22 github.com/mitchellh/hashstructure v1.0.0 github.com/nats-io/nats.go v1.9.1 - github.com/nlopes/slack v0.6.0 + github.com/nlopes/slack@d06c2a2b3249b44a9c5dee8485f5a87497beb9ea github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c github.com/pkg/errors v0.8.1 github.com/stretchr/testify v1.4.0 From 1582aa1572b5a9a3144adebfb5a635523a2ec18b Mon Sep 17 00:00:00 2001 From: Jan Kremlacek Date: Mon, 9 Dec 2019 22:08:57 +0100 Subject: [PATCH 4/4] proper go.mod, go.sum --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3cbfcc37..47c95a32 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( github.com/miekg/dns v1.1.22 github.com/mitchellh/hashstructure v1.0.0 github.com/nats-io/nats.go v1.9.1 - github.com/nlopes/slack@d06c2a2b3249b44a9c5dee8485f5a87497beb9ea + github.com/nlopes/slack v0.6.1-0.20191106133607-d06c2a2b3249 // indirect github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c github.com/pkg/errors v0.8.1 github.com/stretchr/testify v1.4.0 diff --git a/go.sum b/go.sum index 113e6bd2..8a137787 100644 --- a/go.sum +++ b/go.sum @@ -294,6 +294,8 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nlopes/slack v0.6.0 h1:jt0jxVQGhssx1Ib7naAOZEZcGdtIhTzkP0nopK0AsRA= github.com/nlopes/slack v0.6.0/go.mod h1:JzQ9m3PMAqcpeCam7UaHSuBuupz7CmpjehYMayT6YOk= +github.com/nlopes/slack v0.6.1-0.20191106133607-d06c2a2b3249 h1:Pr5gZa2VcmktVwq0lyC39MsN5tz356vC/pQHKvq+QBo= +github.com/nlopes/slack v0.6.1-0.20191106133607-d06c2a2b3249/go.mod h1:JzQ9m3PMAqcpeCam7UaHSuBuupz7CmpjehYMayT6YOk= github.com/nrdcg/auroradns v1.0.0/go.mod h1:6JPXKzIRzZzMqtTDgueIhTi6rFf1QvYE/HzqidhOhjw= github.com/nrdcg/goinwx v0.6.1/go.mod h1:XPiut7enlbEdntAqalBIqcYcTEVhpv/dKWgDCX2SwKQ= github.com/nrdcg/namesilo v0.2.1/go.mod h1:lwMvfQTyYq+BbjJd30ylEG4GPSS6PII0Tia4rRpRiyw=