Merge master into resover-refactor

This commit is contained in:
Ben Toogood 2020-04-09 12:42:34 +01:00
commit f9cfbe96c0
19 changed files with 140 additions and 63 deletions

View File

@ -18,7 +18,7 @@ import (
func TestCertMagic(t *testing.T) { func TestCertMagic(t *testing.T) {
if len(os.Getenv("IN_TRAVIS_CI")) != 0 { if len(os.Getenv("IN_TRAVIS_CI")) != 0 {
t.Skip("Travis doesn't let us bind :443") t.Skip()
} }
l, err := NewProvider().Listen() l, err := NewProvider().Listen()
if err != nil { if err != nil {
@ -52,6 +52,10 @@ func TestCertMagic(t *testing.T) {
} }
func TestStorageImplementation(t *testing.T) { func TestStorageImplementation(t *testing.T) {
if len(os.Getenv("IN_TRAVIS_CI")) != 0 {
t.Skip()
}
apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID") apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID")
kvID := os.Getenv("KV_NAMESPACE_ID") kvID := os.Getenv("KV_NAMESPACE_ID")
if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 { if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 {
@ -189,6 +193,10 @@ func TestStorageImplementation(t *testing.T) {
// Full test with a real zone, with against LE staging // Full test with a real zone, with against LE staging
func TestE2e(t *testing.T) { func TestE2e(t *testing.T) {
if len(os.Getenv("IN_TRAVIS_CI")) != 0 {
t.Skip()
}
apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID") apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID")
kvID := os.Getenv("KV_NAMESPACE_ID") kvID := os.Getenv("KV_NAMESPACE_ID")
if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 { if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 {

View File

@ -1,6 +1,7 @@
package selector package selector
import ( import (
"os"
"testing" "testing"
"github.com/micro/go-micro/v2/registry/memory" "github.com/micro/go-micro/v2/registry/memory"
@ -25,5 +26,7 @@ func TestRegistrySelector(t *testing.T) {
counts[node.Id]++ counts[node.Id]++
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Selector Counts %v", counts) t.Logf("Selector Counts %v", counts)
}
} }

View File

@ -1,6 +1,7 @@
package selector package selector
import ( import (
"os"
"testing" "testing"
"github.com/micro/go-micro/v2/registry" "github.com/micro/go-micro/v2/registry"
@ -50,6 +51,8 @@ func TestStrategies(t *testing.T) {
counts[node.Id]++ counts[node.Id]++
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("%s: %+v\n", name, counts) t.Logf("%s: %+v\n", name, counts)
} }
}
} }

View File

@ -231,7 +231,7 @@ var (
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "store_table", Name: "store_table",
EnvVars: []string{"MICRO_STORE_Table"}, EnvVars: []string{"MICRO_STORE_TABLE"},
Usage: "Table option for the underlying store", Usage: "Table option for the underlying store",
}, },
&cli.StringFlag{ &cli.StringFlag{

View File

@ -59,8 +59,8 @@ func TestFile(t *testing.T) {
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
t.Logf("%+v", c)
if string(c.Data) != string(data) { if string(c.Data) != string(data) {
t.Logf("%+v", c)
t.Error("data from file does not match") t.Error("data from file does not match")
} }
} }

View File

@ -2,6 +2,7 @@ package memory
import ( import (
"fmt" "fmt"
"os"
"testing" "testing"
"time" "time"
@ -205,7 +206,9 @@ func TestMemoryRegistryTTLConcurrent(t *testing.T) {
} }
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("test will wait %v, then check TTL timeouts", waitTime) t.Logf("test will wait %v, then check TTL timeouts", waitTime)
}
errChan := make(chan error, concurrency) errChan := make(chan error, concurrency)
syncChan := make(chan struct{}) syncChan := make(chan struct{})

View File

@ -1,6 +1,7 @@
package registry package registry
import ( import (
"os"
"testing" "testing"
) )
@ -32,7 +33,9 @@ func TestRemove(t *testing.T) {
if i := len(servs); i > 0 { if i := len(servs); i > 0 {
t.Errorf("Expected 0 nodes, got %d: %+v", i, servs) t.Errorf("Expected 0 nodes, got %d: %+v", i, servs)
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Services %+v", servs) t.Logf("Services %+v", servs)
}
} }
func TestRemoveNodes(t *testing.T) { func TestRemoveNodes(t *testing.T) {
@ -67,5 +70,7 @@ func TestRemoveNodes(t *testing.T) {
if i := len(nodes); i != 1 { if i := len(nodes); i != 1 {
t.Errorf("Expected only 1 node, got %d: %+v", i, nodes) t.Errorf("Expected only 1 node, got %d: %+v", i, nodes)
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Nodes %+v", nodes) t.Logf("Nodes %+v", nodes)
}
} }

View File

@ -2,6 +2,7 @@ package router
import ( import (
"fmt" "fmt"
"os"
"sync" "sync"
"testing" "testing"
"time" "time"
@ -29,7 +30,9 @@ func TestRouterStartStop(t *testing.T) {
if err := r.Stop(); err != nil { if err := r.Stop(); err != nil {
t.Errorf("failed to stop router: %v", err) t.Errorf("failed to stop router: %v", err)
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("TestRouterStartStop STOPPED") t.Logf("TestRouterStartStop STOPPED")
}
} }
func TestRouterAdvertise(t *testing.T) { func TestRouterAdvertise(t *testing.T) {
@ -49,7 +52,9 @@ func TestRouterAdvertise(t *testing.T) {
// receive announce event // receive announce event
ann := <-ch ann := <-ch
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("received announce advert: %v", ann) t.Logf("received announce advert: %v", ann)
}
// Generate random unique routes // Generate random unique routes
nrRoutes := 5 nrRoutes := 5
@ -81,9 +86,13 @@ func TestRouterAdvertise(t *testing.T) {
wg.Done() wg.Done()
defer close(createDone) defer close(createDone)
for _, route := range routes { for _, route := range routes {
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Creating route %v", route) t.Logf("Creating route %v", route)
}
if err := r.Table().Create(route); err != nil { if err := r.Table().Create(route); err != nil {
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Failed to create route: %v", err) t.Logf("Failed to create route: %v", err)
}
errChan <- err errChan <- err
return return
} }
@ -105,7 +114,9 @@ func TestRouterAdvertise(t *testing.T) {
t.Errorf("failed advertising events: %v", advertErr) t.Errorf("failed advertising events: %v", advertErr)
default: default:
// do nothing for now // do nothing for now
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Router advert received: %v", advert) t.Logf("Router advert received: %v", advert)
}
adverts += len(advert.Events) adverts += len(advert.Events)
} }
return return

View File

@ -204,7 +204,6 @@ func (r *runtime) Create(s *Service, opts ...CreateOption) error {
service := newService(s, options) service := newService(s, options)
f, err := os.OpenFile(logFile(service.Name), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) f, err := os.OpenFile(logFile(service.Name), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
logger.Info(f, err)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -713,7 +713,7 @@ func (g *grpcServer) Register() error {
} }
if logger.V(logger.DebugLevel, logger.DefaultLogger) { if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debug("Subscribing to topic: %s", sb.Topic()) logger.Debugf("Subscribing to topic: %s", sb.Topic())
} }
sub, err := config.Broker.Subscribe(sb.Topic(), handler, opts...) sub, err := config.Broker.Subscribe(sb.Topic(), handler, opts...)
if err != nil { if err != nil {

View File

@ -11,6 +11,10 @@ import (
) )
func TestCloudflare(t *testing.T) { func TestCloudflare(t *testing.T) {
if len(os.Getenv("IN_TRAVIS_CI")) != 0 {
t.Skip()
}
apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID") apiToken, accountID := os.Getenv("CF_API_TOKEN"), os.Getenv("CF_ACCOUNT_ID")
kvID := os.Getenv("KV_NAMESPACE_ID") kvID := os.Getenv("KV_NAMESPACE_ID")
if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 { if len(apiToken) == 0 || len(accountID) == 0 || len(kvID) == 0 {
@ -31,8 +35,10 @@ func TestCloudflare(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("List: %s\n", err.Error()) t.Fatalf("List: %s\n", err.Error())
} else { } else {
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Log("Listed " + strconv.Itoa(len(records)) + " records") t.Log("Listed " + strconv.Itoa(len(records)) + " records")
} }
}
err = wkv.Write(&store.Record{ err = wkv.Write(&store.Record{
Key: randomK, Key: randomK,

View File

@ -3,6 +3,7 @@ package cockroach
import ( import (
"database/sql" "database/sql"
"fmt" "fmt"
"os"
"testing" "testing"
"time" "time"
@ -11,6 +12,10 @@ import (
) )
func TestSQL(t *testing.T) { func TestSQL(t *testing.T) {
if len(os.Getenv("IN_TRAVIS_CI")) != 0 {
t.Skip()
}
connection := fmt.Sprintf( connection := fmt.Sprintf(
"host=%s port=%d user=%s sslmode=disable dbname=%s", "host=%s port=%d user=%s sslmode=disable dbname=%s",
"localhost", "localhost",
@ -23,7 +28,7 @@ func TestSQL(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if err := db.Ping(); err != nil { if err := db.Ping(); err != nil {
t.Skip(err) t.Fatal(err)
} }
db.Close() db.Close()

View File

@ -53,8 +53,9 @@ func TestFileStoreDatabaseTable(t *testing.T) {
} }
func fileTest(s store.Store, t *testing.T) { func fileTest(s store.Store, t *testing.T) {
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Options %s %v\n", s.String(), s.Options()) t.Logf("Options %s %v\n", s.String(), s.Options())
}
// Read and Write an expiring Record // Read and Write an expiring Record
if err := s.Write(&store.Record{ if err := s.Write(&store.Record{
Key: "Hello", Key: "Hello",
@ -109,7 +110,7 @@ func fileTest(s store.Store, t *testing.T) {
} else { } else {
if len(results) != 2 { if len(results) != 2 {
t.Errorf("Expected 2 items, got %d", len(results)) t.Errorf("Expected 2 items, got %d", len(results))
t.Logf("Table test: %v\n", spew.Sdump(results)) //t.Logf("Table test: %v\n", spew.Sdump(results))
} }
} }
@ -120,7 +121,7 @@ func fileTest(s store.Store, t *testing.T) {
t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", spew.Sdump(results), err) t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", spew.Sdump(results), err)
} else if len(results) != 1 { } else if len(results) != 1 {
t.Errorf("Expected 1 item, got %d", len(results)) t.Errorf("Expected 1 item, got %d", len(results))
t.Logf("Table test: %v\n", spew.Sdump(results)) //t.Logf("Table test: %v\n", spew.Sdump(results))
} }
if err := s.Delete("foo"); err != nil { if err := s.Delete("foo"); err != nil {
@ -163,7 +164,7 @@ func fileTest(s store.Store, t *testing.T) {
} else { } else {
if len(results) != 3 { if len(results) != 3 {
t.Errorf("Expected 3 items, got %d", len(results)) t.Errorf("Expected 3 items, got %d", len(results))
t.Logf("Table test: %v\n", spew.Sdump(results)) //t.Logf("Table test: %v\n", spew.Sdump(results))
} }
} }
@ -173,7 +174,7 @@ func fileTest(s store.Store, t *testing.T) {
} else { } else {
if len(results) != 2 { if len(results) != 2 {
t.Errorf("Expected 2 items, got %d", len(results)) t.Errorf("Expected 2 items, got %d", len(results))
t.Logf("Table test: %v\n", spew.Sdump(results)) //t.Logf("Table test: %v\n", spew.Sdump(results))
} }
} }
@ -183,7 +184,7 @@ func fileTest(s store.Store, t *testing.T) {
} else { } else {
if len(results) != 1 { if len(results) != 1 {
t.Errorf("Expected 1 item, got %d", len(results)) t.Errorf("Expected 1 item, got %d", len(results))
t.Logf("Table test: %# v\n", spew.Sdump(results)) // t.Logf("Table test: %# v\n", spew.Sdump(results))
} }
} }
if err := s.Delete("foo"); err != nil { if err := s.Delete("foo"); err != nil {

View File

@ -2,6 +2,7 @@ package memory
import ( import (
"fmt" "fmt"
"os"
"testing" "testing"
"time" "time"
@ -42,7 +43,9 @@ func TestMemoryNamespacePrefix(t *testing.T) {
} }
func basictest(s store.Store, t *testing.T) { func basictest(s store.Store, t *testing.T) {
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Testing store %s, with options %# v\n", s.String(), pretty.Formatter(s.Options())) t.Logf("Testing store %s, with options %# v\n", s.String(), pretty.Formatter(s.Options()))
}
// Read and Write an expiring Record // Read and Write an expiring Record
if err := s.Write(&store.Record{ if err := s.Write(&store.Record{
Key: "Hello", Key: "Hello",
@ -97,8 +100,10 @@ func basictest(s store.Store, t *testing.T) {
if len(results) != 3 { if len(results) != 3 {
t.Errorf("Expected 3 items, got %d", len(results)) t.Errorf("Expected 3 items, got %d", len(results))
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Prefix test: %v\n", pretty.Formatter(results)) t.Logf("Prefix test: %v\n", pretty.Formatter(results))
} }
}
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 100)
if results, err := s.Read("foo", store.ReadPrefix()); err != nil { if results, err := s.Read("foo", store.ReadPrefix()); err != nil {
t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err)
@ -106,8 +111,10 @@ func basictest(s store.Store, t *testing.T) {
if len(results) != 2 { if len(results) != 2 {
t.Errorf("Expected 2 items, got %d", len(results)) t.Errorf("Expected 2 items, got %d", len(results))
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Prefix test: %v\n", pretty.Formatter(results)) t.Logf("Prefix test: %v\n", pretty.Formatter(results))
} }
}
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 100)
if results, err := s.Read("foo", store.ReadPrefix()); err != nil { if results, err := s.Read("foo", store.ReadPrefix()); err != nil {
t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err)
@ -115,8 +122,10 @@ func basictest(s store.Store, t *testing.T) {
if len(results) != 1 { if len(results) != 1 {
t.Errorf("Expected 1 item, got %d", len(results)) t.Errorf("Expected 1 item, got %d", len(results))
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Prefix test: %# v\n", pretty.Formatter(results)) t.Logf("Prefix test: %# v\n", pretty.Formatter(results))
} }
}
if err := s.Delete("foo", func(d *store.DeleteOptions) {}); err != nil { if err := s.Delete("foo", func(d *store.DeleteOptions) {}); err != nil {
t.Errorf("Delete failed (%v)", err) t.Errorf("Delete failed (%v)", err)
} }
@ -156,8 +165,10 @@ func basictest(s store.Store, t *testing.T) {
if len(results) != 3 { if len(results) != 3 {
t.Errorf("Expected 3 items, got %d", len(results)) t.Errorf("Expected 3 items, got %d", len(results))
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Prefix test: %v\n", pretty.Formatter(results)) t.Logf("Prefix test: %v\n", pretty.Formatter(results))
} }
}
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 100)
if results, err := s.Read("foo", store.ReadSuffix()); err != nil { if results, err := s.Read("foo", store.ReadSuffix()); err != nil {
t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err)
@ -165,8 +176,10 @@ func basictest(s store.Store, t *testing.T) {
if len(results) != 2 { if len(results) != 2 {
t.Errorf("Expected 2 items, got %d", len(results)) t.Errorf("Expected 2 items, got %d", len(results))
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Prefix test: %v\n", pretty.Formatter(results)) t.Logf("Prefix test: %v\n", pretty.Formatter(results))
} }
}
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 100)
if results, err := s.Read("foo", store.ReadSuffix()); err != nil { if results, err := s.Read("foo", store.ReadSuffix()); err != nil {
t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err) t.Errorf("Couldn't read all \"foo\" keys, got %# v (%s)", pretty.Formatter(results), err)
@ -174,8 +187,10 @@ func basictest(s store.Store, t *testing.T) {
if len(results) != 1 { if len(results) != 1 {
t.Errorf("Expected 1 item, got %d", len(results)) t.Errorf("Expected 1 item, got %d", len(results))
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Prefix test: %# v\n", pretty.Formatter(results)) t.Logf("Prefix test: %# v\n", pretty.Formatter(results))
} }
}
if err := s.Delete("foo"); err != nil { if err := s.Delete("foo"); err != nil {
t.Errorf("Delete failed (%v)", err) t.Errorf("Delete failed (%v)", err)
} }

View File

@ -16,18 +16,15 @@ import (
type serviceStore struct { type serviceStore struct {
options store.Options options store.Options
// Namespace to use // The database to use
Namespace string Database string
// The table to use
Table string
// Addresses of the nodes // Addresses of the nodes
Nodes []string Nodes []string
// Prefix to use
Prefix string
// Suffix to use
Suffix string
// store service client // store service client
Client pb.StoreService Client pb.StoreService
} }
@ -40,8 +37,8 @@ func (s *serviceStore) Init(opts ...store.Option) error {
for _, o := range opts { for _, o := range opts {
o(&s.options) o(&s.options)
} }
s.Namespace = s.options.Database s.Database = s.options.Database
s.Prefix = s.options.Table s.Table = s.options.Table
s.Nodes = s.options.Nodes s.Nodes = s.options.Nodes
return nil return nil
@ -52,12 +49,12 @@ func (s *serviceStore) Context() context.Context {
md := make(metadata.Metadata) md := make(metadata.Metadata)
if len(s.Namespace) > 0 { if len(s.Database) > 0 {
md["Micro-Namespace"] = s.Namespace md["Micro-Database"] = s.Database
} }
if len(s.Prefix) > 0 { if len(s.Table) > 0 {
md["Micro-Prefix"] = s.Prefix md["Micro-Table"] = s.Table
} }
return metadata.NewContext(ctx, md) return metadata.NewContext(ctx, md)
@ -169,8 +166,8 @@ func NewStore(opts ...store.Option) store.Store {
service := &serviceStore{ service := &serviceStore{
options: options, options: options,
Namespace: options.Database, Database: options.Database,
Prefix: options.Table, Table: options.Table,
Nodes: options.Nodes, Nodes: options.Nodes,
Client: pb.NewStoreService("go.micro.store", client.DefaultClient), Client: pb.NewStoreService("go.micro.store", client.DefaultClient),
} }

View File

@ -1,6 +1,7 @@
package memory package memory
import ( import (
"os"
"testing" "testing"
"github.com/micro/go-micro/v2/transport" "github.com/micro/go-micro/v2/transport"
@ -24,7 +25,9 @@ func TestMemoryTransport(t *testing.T) {
if err := sock.Recv(&m); err != nil { if err := sock.Recv(&m); err != nil {
return return
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Server Received %s", string(m.Body)) t.Logf("Server Received %s", string(m.Body))
}
if err := sock.Send(&transport.Message{ if err := sock.Send(&transport.Message{
Body: []byte(`pong`), Body: []byte(`pong`),
}); err != nil { }); err != nil {
@ -54,8 +57,10 @@ func TestMemoryTransport(t *testing.T) {
if err := c.Recv(&m); err != nil { if err := c.Recv(&m); err != nil {
return return
} }
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Client Received %s", string(m.Body)) t.Logf("Client Received %s", string(m.Body))
} }
}
} }

View File

@ -1,6 +1,7 @@
package tunnel package tunnel
import ( import (
"os"
"sync" "sync"
"testing" "testing"
"time" "time"
@ -288,6 +289,8 @@ func TestTunnelRTTRate(t *testing.T) {
// wait until done // wait until done
wg.Wait() wg.Wait()
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
// only needed for debug
for _, link := range tunA.Links() { for _, link := range tunA.Links() {
t.Logf("Link %s length %v rate %v", link.Id(), link.Length(), link.Rate()) t.Logf("Link %s length %v rate %v", link.Id(), link.Length(), link.Rate())
} }
@ -295,6 +298,7 @@ func TestTunnelRTTRate(t *testing.T) {
for _, link := range tunB.Links() { for _, link := range tunB.Links() {
t.Logf("Link %s length %v rate %v", link.Id(), link.Length(), link.Rate()) t.Logf("Link %s length %v rate %v", link.Id(), link.Length(), link.Rate())
} }
}
} }
func TestReconnectTunnel(t *testing.T) { func TestReconnectTunnel(t *testing.T) {

View File

@ -226,8 +226,8 @@ func (s *service) start() error {
ch <- l.Close() ch <- l.Close()
}() }()
if logger.V(logger.InfoLevel, log) { if logger.V(logger.DebugLevel, log) {
log.Infof("Listening on %v", l.Addr().String()) log.Debugf("Listening on %v", l.Addr().String())
} }
return nil return nil
} }
@ -370,6 +370,10 @@ func (s *service) Init(opts ...Option) error {
return nil return nil
})) }))
// pass in own name and version
serviceOpts = append(serviceOpts, micro.Name(s.opts.Name))
serviceOpts = append(serviceOpts, micro.Version(s.opts.Version))
s.opts.Service.Init(serviceOpts...) s.opts.Service.Init(serviceOpts...)
srv := s.genSrv() srv := s.genSrv()
srv.Endpoints = s.srv.Endpoints srv.Endpoints = s.srv.Endpoints

View File

@ -110,8 +110,10 @@ func TestService(t *testing.T) {
t.Fatalf("service.Run():%v", err) t.Fatalf("service.Run():%v", err)
} }
case <-time.After(time.Duration(time.Second)): case <-time.After(time.Duration(time.Second)):
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("service.Run() survived a client request without an error") t.Logf("service.Run() survived a client request without an error")
} }
}
ch := make(chan os.Signal, 1) ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGTERM) signal.Notify(ch, syscall.SIGTERM)
@ -125,11 +127,15 @@ func TestService(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("service.Run():%v", err) t.Fatalf("service.Run():%v", err)
} else { } else {
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Log("service.Run() nil return on syscall.SIGTERM") t.Log("service.Run() nil return on syscall.SIGTERM")
} }
}
case <-time.After(time.Duration(time.Second)): case <-time.After(time.Duration(time.Second)):
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("service.Run() survived a client request without an error") t.Logf("service.Run() survived a client request without an error")
} }
}
eventually(func() bool { eventually(func() bool {
_, err := reg.GetService("go.micro.web.test") _, err := reg.GetService("go.micro.web.test")
@ -286,7 +292,9 @@ func TestTLS(t *testing.T) {
t.Fatalf("service.Run():%v", err) t.Fatalf("service.Run():%v", err)
} }
case <-time.After(time.Duration(time.Second)): case <-time.After(time.Duration(time.Second)):
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("service.Run() survived a client request without an error") t.Logf("service.Run() survived a client request without an error")
} }
}
} }