xdsChannelForTest creates an xdsChannel to the specified serverURI for testing purposes.
(t *testing.T, serverURI, nodeID string, watchExpiryTimeout time.Duration)
| 51 | // xdsChannelForTest creates an xdsChannel to the specified serverURI for |
| 52 | // testing purposes. |
| 53 | func xdsChannelForTest(t *testing.T, serverURI, nodeID string, watchExpiryTimeout time.Duration) *xdsChannel { |
| 54 | t.Helper() |
| 55 | |
| 56 | // Create a grpc transport to the above management server. |
| 57 | si := clients.ServerIdentifier{ |
| 58 | ServerURI: serverURI, |
| 59 | Extensions: grpctransport.ServerIdentifierExtension{ConfigName: "insecure"}, |
| 60 | } |
| 61 | configs := map[string]grpctransport.Config{"insecure": {Credentials: insecure.NewBundle()}} |
| 62 | tr, err := (grpctransport.NewBuilder(configs)).Build(si) |
| 63 | if err != nil { |
| 64 | t.Fatalf("Failed to create a transport for server config %v: %v", si, err) |
| 65 | } |
| 66 | |
| 67 | serverCfg := ServerConfig{ |
| 68 | ServerIdentifier: si, |
| 69 | } |
| 70 | clientConfig := Config{ |
| 71 | Servers: []ServerConfig{serverCfg}, |
| 72 | Node: clients.Node{ID: nodeID}, |
| 73 | ResourceTypes: map[string]ResourceType{xdsresource.V3ListenerURL: listenerType}, |
| 74 | } |
| 75 | // Create an xdsChannel that uses everything set up above. |
| 76 | xc, err := newXDSChannel(xdsChannelOpts{ |
| 77 | transport: tr, |
| 78 | serverConfig: &serverCfg, |
| 79 | clientConfig: &clientConfig, |
| 80 | eventHandler: newTestEventHandler(), |
| 81 | watchExpiryTimeout: watchExpiryTimeout, |
| 82 | }) |
| 83 | if err != nil { |
| 84 | t.Fatalf("Failed to create xdsChannel: %v", err) |
| 85 | } |
| 86 | t.Cleanup(func() { xc.close() }) |
| 87 | return xc |
| 88 | } |
| 89 | |
| 90 | // verifyUpdateAndMetadata verifies that the event handler received the expected |
| 91 | // updates and metadata. It checks that the received resource type matches the |
no test coverage detected