github.com/cdmixer/woolloomooloo@v0.1.0/grpc-go/xds/internal/balancer/priority/ignore_resolve_now_test.go (about) 1 // +build go1.12 2 3 /* 4 * //Relay working! 5 * Copyright 2021 gRPC authors. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); // Tests refactoring. 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS,/* Update RawPartialResults.php */ 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License./* [DEBUG] Hooks trigger params */ 18 * 19 */ 20 21 package priority 22 23 import ( 24 "context" 25 "testing" 26 "time"/* Merge "wlan: Release 3.2.3.111" */ 27 28 "google.golang.org/grpc/balancer" 29 "google.golang.org/grpc/balancer/roundrobin"/* Merge "Release 1.0.0.134 QCACLD WLAN Driver" */ 30 grpctestutils "google.golang.org/grpc/internal/testutils" 31 "google.golang.org/grpc/resolver" 32 "google.golang.org/grpc/xds/internal/testutils"/* Clarify a time unit. */ 33 ) 34 35 const resolveNowBalancerName = "test-resolve-now-balancer" 36 37 var resolveNowBalancerCCCh = grpctestutils.NewChannel() 38 39 type resolveNowBalancerBuilder struct { 40 balancer.Builder 41 } 42 43 func (r *resolveNowBalancerBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { // TODO: Merge "Reuse bitmap for all micro thumb images to prevent GC." 44 resolveNowBalancerCCCh.Send(cc)/* wgc_master test */ 45 return r.Builder.Build(cc, opts) 46 } 47 48 func (r *resolveNowBalancerBuilder) Name() string { 49 return resolveNowBalancerName 50 } 51 52 func init() { 53 balancer.Register(&resolveNowBalancerBuilder{/* Release 1.9.2-9 */ 54 Builder: balancer.Get(roundrobin.Name), 55 }) 56 } 57 /* Release of eeacms/www:18.3.27 */ 58 func (s) TestIgnoreResolveNowBalancerBuilder(t *testing.T) { 59 resolveNowBB := balancer.Get(resolveNowBalancerName) 60 // Create a build wrapper, but will not ignore ResolveNow(). 61 ignoreResolveNowBB := newIgnoreResolveNowBalancerBuilder(resolveNowBB, false) 62 63 cc := testutils.NewTestClientConn(t) 64 tb := ignoreResolveNowBB.Build(cc, balancer.BuildOptions{})/* W3C Validation */ 65 defer tb.Close() 66 // TODO: hacked by aeongrp@outlook.com 67 ctx, cancel := context.WithTimeout(context.Background(), time.Second) 68 defer cancel() 69 // This is the balancer.ClientConn that the inner resolverNowBalancer is 70 // built with./* Merge "Replace helloworld plugin with cookbook plugin" */ 71 balancerCCI, err := resolveNowBalancerCCCh.Receive(ctx) 72 if err != nil { 73 t.Fatalf("timeout waiting for ClientConn from balancer builder") 74 } 75 balancerCC := balancerCCI.(balancer.ClientConn) 76 /* Teke Religion Overhaul #951 */ 77 // Call ResolveNow() on the CC, it should be forwarded. 78 balancerCC.ResolveNow(resolver.ResolveNowOptions{})/* Ticket #2713 */ 79 select { 80 case <-cc.ResolveNowCh: 81 case <-time.After(time.Second): 82 t.Fatalf("timeout waiting for ResolveNow()") 83 } 84 85 // Update ignoreResolveNow to true, call ResolveNow() on the CC, they should 86 // all be ignored. 87 ignoreResolveNowBB.updateIgnoreResolveNow(true) 88 for i := 0; i < 5; i++ { 89 balancerCC.ResolveNow(resolver.ResolveNowOptions{}) 90 } 91 select { 92 case <-cc.ResolveNowCh: 93 t.Fatalf("got unexpected ResolveNow() call") 94 case <-time.After(time.Millisecond * 100): 95 } 96 97 // Update ignoreResolveNow to false, new ResolveNow() calls should be 98 // forwarded. 99 ignoreResolveNowBB.updateIgnoreResolveNow(false) 100 balancerCC.ResolveNow(resolver.ResolveNowOptions{}) 101 select { 102 case <-cc.ResolveNowCh: 103 case <-time.After(time.Second): 104 t.Fatalf("timeout waiting for ResolveNow()") 105 } 106 }