Skip to content

Commit

Permalink
chore: 提交无用代码,跑gitci的单元测试50
Browse files Browse the repository at this point in the history
  • Loading branch information
harbourlga committed Oct 14, 2024
1 parent 89fff9b commit be56a1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
1 change: 1 addition & 0 deletions contrib/registry/consul/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func (r *Registry) resolve(ctx context.Context, ss *serviceSet) error {
tmpService, tmpIdx, err := r.cli.Service(timeoutCtx, ss.serviceName, idx, true)
cancel()
if err != nil {
fmt.Println("timeoutctx err:", err, ", tag:", tag)
time.Sleep(time.Second)
continue
}
Expand Down
48 changes: 22 additions & 26 deletions contrib/registry/consul/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,6 @@ func TestRegistry_IdleAndWatch2(t *testing.T) {
if !reflect.DeepEqual(service, tt.want) {
t.Errorf("GetService() got = %v, want %v", service, tt.want)
}
err = watch.Stop()
if err != nil {
t.Errorf("watch stop err:%v", err)
}
})
}
}
Expand Down Expand Up @@ -735,30 +731,30 @@ func TestRegistry_ExitOldResolverAndReWatch(t *testing.T) {
t.Error(err)
}
// time.Sleep(time.Second * 2)
// newWatchCtx, newWatchCancel := context.WithCancel(context.Background())
// c := make(chan struct{}, 1)
// go func() {
fmt.Println("begin TestRegistry_ExitOldResolverAndReWatch 1, t:", time.Now().Unix())
service, err = newWatch.Next()
if (err != nil) != tt.wantErr {
t.Errorf("GetService() error = %v, wantErr %v", err, tt.wantErr)
t.Errorf("GetService() got = %v", service)
newWatchCtx, newWatchCancel := context.WithCancel(context.Background())
c := make(chan struct{}, 1)
go func() {
fmt.Println("begin TestRegistry_ExitOldResolverAndReWatch 1, t:", time.Now().Unix())
service, err = newWatch.Next()
if (err != nil) != tt.wantErr {
t.Errorf("GetService() error = %v, wantErr %v", err, tt.wantErr)
t.Errorf("GetService() got = %v", service)
return
}
fmt.Println("begin TestRegistry_ExitOldResolverAndReWatch 2, t:", time.Now().Unix())
if !reflect.DeepEqual(service, tt.want) {
t.Errorf("GetService() got = %v, want %v", service, tt.want)
}
c <- struct{}{}
}()
time.AfterFunc(time.Second*10, newWatchCancel)
// fmt.Println("begin TestRegistry_ExitOldResolverAndReWatch 3, t:", time.Now().Unix())
select {
case <-newWatchCtx.Done():
t.Errorf("Timeout getservice. May be no new resolve goroutine to obtain the latest service information")
case <-c:
return
}
fmt.Println("begin TestRegistry_ExitOldResolverAndReWatch 2, t:", time.Now().Unix())
if !reflect.DeepEqual(service, tt.want) {
t.Errorf("GetService() got = %v, want %v", service, tt.want)
}
// c <- struct{}{}
// }()
// time.AfterFunc(time.Second*10, newWatchCancel)
// // fmt.Println("begin TestRegistry_ExitOldResolverAndReWatch 3, t:", time.Now().Unix())
// select {
// case <-newWatchCtx.Done():
// t.Errorf("Timeout getservice. May be no new resolve goroutine to obtain the latest service information")
// case <-c:
// return
// }
})
}
}
Expand Down

0 comments on commit be56a1b

Please sign in to comment.