From 2c3155b1c7c03ed23ac703af0c20a2a98eaefe99 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 17 Jul 2021 02:30:58 +0600 Subject: [PATCH] use local ip address for tests Signed-off-by: Vasiliy Tolstov --- api/router/router_test.go | 1 + client/grpc/grpc_pool_test.go | 2 +- codec/segmentio/grpc_test.go | 3 ++- go.mod | 9 ++++----- go.sum | 20 ++++--------------- server/grpc/grpc_test.go | 7 +++++-- server/http/http_test.go | 6 ++++++ wrapper/trace/opentracing/opentracing_test.go | 1 + 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/api/router/router_test.go b/api/router/router_test.go index ebf8720..2b51f8c 100644 --- a/api/router/router_test.go +++ b/api/router/router_test.go @@ -63,6 +63,7 @@ func initial(t *testing.T) (server.Server, client.Client) { server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Codec("application/grpc+json", protocodec.NewCodec()), server.Codec("application/json", jsoncodec.NewCodec()), + server.Address("127.0.0.1:0"), server.Name("foo"), server.Broker(b), server.Register(r), diff --git a/client/grpc/grpc_pool_test.go b/client/grpc/grpc_pool_test.go index c45606c..e7c7d34 100644 --- a/client/grpc/grpc_pool_test.go +++ b/client/grpc/grpc_pool_test.go @@ -15,7 +15,7 @@ import ( func testPool(t *testing.T, size int, ttl time.Duration, idle int, ms int) { // setup server - l, err := net.Listen("tcp", ":0") + l, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { t.Fatalf("failed to listen: %v", err) } diff --git a/codec/segmentio/grpc_test.go b/codec/segmentio/grpc_test.go index 32d1f4d..e4b41ab 100644 --- a/codec/segmentio/grpc_test.go +++ b/codec/segmentio/grpc_test.go @@ -36,7 +36,8 @@ func TestGRPCServer(t *testing.T) { r := register.NewRegister() b := broker.NewBroker(broker.Register(r)) - s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Address(":12345"), server.Register(r), server.Name("helloworld"), gserver.Reflection(true)) + s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), + server.Address("127.0.0.1:0"), server.Register(r), server.Name("helloworld"), gserver.Reflection(true)) // create router rtr := regRouter.NewRouter(router.Register(r)) diff --git a/go.mod b/go.mod index b829b9e..93b38c2 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,16 @@ module github.com/unistack-org/micro-tests go 1.16 require ( + github.com/frankban/quicktest v1.11.3 // indirect github.com/google/uuid v1.3.0 github.com/opentracing/opentracing-go v1.2.0 github.com/prometheus/client_golang v1.10.0 github.com/prometheus/client_model v0.2.0 - github.com/segmentio/kafka-go v0.4.16 github.com/stretchr/testify v1.7.0 github.com/unistack-org/micro-api-handler-rpc/v3 v3.3.0 github.com/unistack-org/micro-api-router-register/v3 v3.2.2 github.com/unistack-org/micro-api-router-static/v3 v3.2.1 github.com/unistack-org/micro-broker-http/v3 v3.3.1 - github.com/unistack-org/micro-broker-segmentio/v3 v3.0.0-00010101000000-000000000000 //github.com/unistack-org/micro-client-drpc/v3 v3.0.0-00010101000000-000000000000 github.com/unistack-org/micro-client-grpc/v3 v3.3.3 github.com/unistack-org/micro-client-http/v3 v3.4.5 @@ -36,10 +35,10 @@ require ( github.com/unistack-org/micro-wrapper-trace-opentracing/v3 v3.2.0 github.com/unistack-org/micro/v3 v3.4.9 golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect - google.golang.org/genproto v0.0.0-20210630183607-d20f26d13c79 + google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea google.golang.org/grpc v1.39.0 google.golang.org/protobuf v1.27.1 - storj.io/drpc v0.0.23 + storj.io/drpc v0.0.24 ) //replace github.com/unistack-org/micro-wrapper-trace-opentracing/v3 => ../micro-wrapper-trace-opentracing @@ -48,7 +47,7 @@ require ( //replace github.com/unistack-org/micro-server-http/v3 => ../micro-server-http //replace github.com/unistack-org/micro-client-http/v3 => ../micro-client-http //replace github.com/unistack-org/micro-client-drpc/v3 => ../micro-client-drpc -replace github.com/unistack-org/micro-broker-segmentio/v3 => ../micro-broker-segmentio +//replace github.com/unistack-org/micro-broker-segmentio/v3 => ../micro-broker-segmentio //replace github.com/unistack-org/micro/v3 => ../micro diff --git a/go.sum b/go.sum index 6a40eee..8c3fd7a 100644 --- a/go.sum +++ b/go.sum @@ -119,7 +119,6 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= @@ -329,8 +328,6 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.9.8 h1:VMAMUUOh+gaxKTMk+zqbjsSjsIcUcL/LF4o63i82QyA= -github.com/klauspost/compress v1.9.8/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/cpuid v1.2.3 h1:CCtW0xUnWGVINKvE/WWOYKdsPV6mawAtvQuSl8guwQs= github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.5 h1:qnfhwbFriwDIX51QncuNU5mEMf+6KE3t7O8V2KQl3Dg= @@ -455,7 +452,6 @@ github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9 github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -519,8 +515,6 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/encoding v0.2.17 h1:cgfmPc44u1po1lz5bSgF00gLCROBjDNc7h+H7I20zpc= github.com/segmentio/encoding v0.2.17/go.mod h1:7E68jTSWMnNoYhHi1JbLd7NBSB6XfE4vzqhR88hDBQc= -github.com/segmentio/kafka-go v0.4.16 h1:9dt78ehM9qzAkekA60D6A96RlqDzC3hnYYa8y5Szd+U= -github.com/segmentio/kafka-go v0.4.16/go.mod h1:19+Eg7KwrNKy/PFhiIthEPkO8k+ac7/ZYXwYM9Df10w= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/silas/dag v0.0.0-20210121180416-41cf55125c34 h1:vBfVmA5mZhsQa2jr1FOL9nfA37N/jnbBmi5XUfviVTI= github.com/silas/dag v0.0.0-20210121180416-41cf55125c34/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I= @@ -624,10 +618,6 @@ github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002 github.com/valyala/histogram v1.1.2 h1:vOk5VrGjMBIoPR5k6wA8vBaC8toeJ8XO0yfRjFEc1h8= github.com/valyala/histogram v1.1.2/go.mod h1:CZAr6gK9dbD7hYx2s8WSPh0p5x5wETjC+2b3PJVtEdg= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= -github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0= -github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= @@ -660,7 +650,6 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -867,8 +856,8 @@ google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210630183607-d20f26d13c79 h1:s1jFTXJryg4a1mew7xv03VZD8N9XjxFhk1o4Js4WvPQ= -google.golang.org/genproto v0.0.0-20210630183607-d20f26d13c79/go.mod h1:yiaVoXHpRzHGyxV3o4DktVWY4mSUErTKaeEOq6C3t3U= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea h1:8ZyCcgugUqamxp/vZSEJw9CMy7VZlSWYJLLJPi/dSDA= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -888,7 +877,6 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI= google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -952,5 +940,5 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= -storj.io/drpc v0.0.23 h1:MHVOMVoBbQkPuL17GerlGTA9PLwE1HF6zAOYFvWwYG4= -storj.io/drpc v0.0.23/go.mod h1:OSJH7wvH3yKlhnMHwblKJioaaeyI6X8xbXT1SG9woe8= +storj.io/drpc v0.0.24 h1:9WgD+q8WWDIz7XCMib+U6xX9SjblMqOz9R6sU7rJnS8= +storj.io/drpc v0.0.24/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko= diff --git a/server/grpc/grpc_test.go b/server/grpc/grpc_test.go index 063d215..b26acb3 100644 --- a/server/grpc/grpc_test.go +++ b/server/grpc/grpc_test.go @@ -57,7 +57,10 @@ func TestGRPCServer(t *testing.T) { b := broker.NewBroker(broker.Register(r)) s := gserver.NewServer( server.Codec("application/grpc+proto", protocodec.NewCodec()), - server.Address(":0"), server.Register(r), server.Name("helloworld"), gserver.Reflection(true), + server.Address("127.0.0.1:0"), + server.Register(r), + server.Name("helloworld"), + gserver.Reflection(true), server.WrapHandler(NewServerHandlerWrapper()), ) // create router @@ -69,7 +72,7 @@ func TestGRPCServer(t *testing.T) { } srv := httpsrv.NewServer( - server.Address(":0"), + server.Address("127.0.0.1:0"), server.Codec("text/plain", codec.NewCodec()), ) if err = health.RegisterHealthServer(srv, health.NewHandler(health.Version("0.0.1"))); err != nil { diff --git a/server/http/http_test.go b/server/http/http_test.go index 41a767c..7001b2d 100644 --- a/server/http/http_test.go +++ b/server/http/http_test.go @@ -88,6 +88,7 @@ func TestMultipart(t *testing.T) { // create server srv := httpsrv.NewServer( + server.Address("127.0.0.1:0"), server.Name("helloworld"), server.Register(reg), server.Codec("application/json", jsoncodec.NewCodec()), @@ -221,6 +222,7 @@ func TestNativeFormUrlencoded(t *testing.T) { // create server srv := httpsrv.NewServer( + server.Address("127.0.0.1:0"), server.Name("helloworld"), server.Register(reg), server.Codec("application/json", jsoncodec.NewCodec()), @@ -338,6 +340,7 @@ func TestNativeClientServer(t *testing.T) { m := vmeter.NewMeter() // create server srv := httpsrv.NewServer( + server.Address("127.0.0.1:0"), server.Meter(m), server.Name("helloworld"), server.Register(reg), @@ -478,6 +481,7 @@ func TestNativeServer(t *testing.T) { // create server srv := httpsrv.NewServer( + server.Address("127.0.0.1:0"), server.Name("helloworld"), server.Register(reg), server.Codec("text/xml", xmlcodec.NewCodec()), @@ -620,6 +624,7 @@ func TestHTTPHandler(t *testing.T) { // create server srv := httpsrv.NewServer( + server.Address("127.0.0.1:0"), server.Register(reg), server.Codec("application/json", jsoncodec.NewCodec()), server.Codec("application/x-www-form-urlencoded", urlencodecodec.NewCodec()), @@ -692,6 +697,7 @@ func TestHTTPServer(t *testing.T) { // create server srv := httpsrv.NewServer( + server.Address("127.0.0.1:0"), server.Register(reg), httpsrv.Server(&http.Server{Handler: mux}), server.Codec("application/json", jsoncodec.NewCodec()), diff --git a/wrapper/trace/opentracing/opentracing_test.go b/wrapper/trace/opentracing/opentracing_test.go index fa06fa2..7fd988e 100644 --- a/wrapper/trace/opentracing/opentracing_test.go +++ b/wrapper/trace/opentracing/opentracing_test.go @@ -94,6 +94,7 @@ func TestClient(t *testing.T) { server.Broker(brk), server.WrapSubscriber(otwrapper.NewServerSubscriberWrapper(otwrapper.WithTracer(tracer))), server.WrapHandler(otwrapper.NewServerHandlerWrapper(otwrapper.WithTracer(tracer))), + server.Address("127.0.0.1:0"), ) if err := s.Init(); err != nil { t.Fatal(err)