1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

update v3 plugins (#2105)

This commit is contained in:
Asim Aslam
2021-01-20 21:01:10 +00:00
committed by GitHub
parent d94936f6c9
commit dc8236ec05
534 changed files with 11293 additions and 5806 deletions

View File

@ -9,11 +9,10 @@ import (
"testing"
"time"
log "github.com/micro/go-micro/v2/logger"
"github.com/micro/go-micro/v2/registry"
"github.com/micro/go-micro/v2/router"
"github.com/micro/go-micro/plugins/registry/kubernetes/v2/client"
"github.com/micro/go-micro/plugins/registry/kubernetes/v2/client/mock"
log "github.com/asim/go-micro/v3/logger"
"github.com/asim/go-micro/v3/registry"
"github.com/asim/go-micro/plugins/registry/kubernetes/v3/client"
"github.com/asim/go-micro/plugins/registry/kubernetes/v3/client/mock"
)
var (
@ -425,18 +424,17 @@ func TestListServices(t *testing.T) {
func TestWatcher(t *testing.T) {
r := setupRegistry()
rtr := router.NewRouter(router.Registry(r))
// check that service is blank
if _, err := rtr.Lookup(router.QueryService("foo.service")); err != router.ErrRouteNotFound {
log.Fatal("expected selector.ErrNotFound")
if _, err := r.GetService("foo.service"); err != registry.ErrNotFound {
log.Fatal("expected ErrNotFound")
}
// setup svc
svc1 := &registry.Service{Name: "foo.service", Version: "1"}
register(r, "pod-1", svc1)
if routes, err := rtr.Lookup(router.QueryService("foo.service")); err != nil {
if routes, err := r.GetService("foo.service"); err != nil {
t.Fatalf("Querying service returned an error: %v", err)
} else if len(routes) != 1 {
t.Fatalf("Expected one route, found %v", len(routes))
@ -447,19 +445,16 @@ func TestWatcher(t *testing.T) {
register(r, "pod-2", svc2)
time.Sleep(time.Millisecond * 100)
if routes, err := rtr.Lookup(router.QueryService("foo.service")); err != nil {
if routes, err := r.GetService("foo.service"); err != nil {
t.Fatalf("Querying service returned an error: %v", err)
} else if len(routes) != 2 {
t.Fatalf("Expected two routes, found %v", len(routes))
} else if len(routes) != 1 {
t.Fatalf("Expected one service, found %v", len(routes))
}
// remove pods
teardownRegistry()
time.Sleep(time.Millisecond * 100)
if _, err := rtr.Lookup(router.QueryService("foo.service")); err != router.ErrRouteNotFound {
log.Fatal("expected selector.ErrNotFound")
}
}
func hasNodes(a, b []*registry.Node) bool {