@@ -580,6 +580,76 @@ public void run() {
580580 verify (listener , timeout (10000 )).onNotServing (any ());
581581 }
582582
583+ @ Test
584+ public void onChanged_listenerIsNull ()
585+ throws ExecutionException , InterruptedException , TimeoutException {
586+
587+ xdsServerWrapper = new XdsServerWrapper ("10.1.2.3:1" , mockBuilder , listener ,
588+ selectorManager , new FakeXdsClientPoolFactory (xdsClient ),
589+ filterRegistry , executor .getScheduledExecutorService ());
590+
591+ final SettableFuture <Server > start = SettableFuture .create ();
592+ Executors .newSingleThreadExecutor ().execute (new Runnable () {
593+ @ Override
594+ public void run () {
595+ try {
596+ start .set (xdsServerWrapper .start ());
597+ } catch (Exception ex ) {
598+ start .setException (ex );
599+ }
600+ }
601+ });
602+ String ldsResource = xdsClient .ldsResource .get (5 , TimeUnit .SECONDS );
603+ assertThat (ldsResource ).isEqualTo ("grpc/server?udpa.resource.listening_address=10.1.2.3:1" );
604+
605+ VirtualHost virtualHost =
606+ VirtualHost .create (
607+ "virtual-host" , Collections .singletonList ("auth" ), new ArrayList <Route >(),
608+ ImmutableMap .<String , FilterConfig >of ());
609+
610+ xdsClient .deliverLdsUpdateWithApiListener (0L , Arrays .asList (virtualHost ));
611+ verify (listener , timeout (10000 )).onNotServing (any ());
612+ }
613+
614+ @ Test
615+ public void onChanged_listenerAddressPortMismatch ()
616+ throws ExecutionException , InterruptedException , TimeoutException {
617+
618+ xdsServerWrapper = new XdsServerWrapper ("10.1.2.3:1" , mockBuilder , listener ,
619+ selectorManager , new FakeXdsClientPoolFactory (xdsClient ),
620+ filterRegistry , executor .getScheduledExecutorService ());
621+
622+ final SettableFuture <Server > start = SettableFuture .create ();
623+ Executors .newSingleThreadExecutor ().execute (new Runnable () {
624+ @ Override
625+ public void run () {
626+ try {
627+ start .set (xdsServerWrapper .start ());
628+ } catch (Exception ex ) {
629+ start .setException (ex );
630+ }
631+ }
632+ });
633+ String ldsResource = xdsClient .ldsResource .get (5 , TimeUnit .SECONDS );
634+ assertThat (ldsResource ).isEqualTo ("grpc/server?udpa.resource.listening_address=10.1.2.3:1" );
635+
636+ VirtualHost virtualHost =
637+ VirtualHost .create (
638+ "virtual-host" , Collections .singletonList ("auth" ), new ArrayList <Route >(),
639+ ImmutableMap .<String , FilterConfig >of ());
640+ HttpConnectionManager httpConnectionManager = HttpConnectionManager .forVirtualHosts (
641+ 0L , Collections .singletonList (virtualHost ), new ArrayList <NamedFilterConfig >());
642+ EnvoyServerProtoData .FilterChain filterChain = EnvoyServerProtoData .FilterChain .create (
643+ "filter-chain-foo" , createMatch (), httpConnectionManager , createTls (),
644+ mock (TlsContextManager .class ));
645+
646+ LdsUpdate listenerUpdate = LdsUpdate .forTcpListener (
647+ Listener .create ("listener" , "10.1.2.3:2" ,
648+ ImmutableList .copyOf (Collections .singletonList (filterChain )), null , Protocol .TCP ));
649+ xdsClient .deliverLdsUpdate (listenerUpdate );
650+ verify (listener , timeout (10000 )).onNotServing (any ());
651+ }
652+
583653 @ Test
584654 public void discoverState_rds () throws Exception {
585655 final SettableFuture <Server > start = SettableFuture .create ();
@@ -1853,7 +1923,7 @@ private static HttpConnectionManager createRds(String name) {
18531923 /**
18541924 * Returns the least-specific match-all Filter Chain Match.
18551925 */
1856- private static FilterChainMatch createMatch () {
1926+ static FilterChainMatch createMatch () {
18571927 return FilterChainMatch .create (
18581928 0 ,
18591929 ImmutableList .of (),
@@ -1909,7 +1979,7 @@ private static MethodDescriptor<Void, Void> createMethod(String path) {
19091979 .build ();
19101980 }
19111981
1912- private static EnvoyServerProtoData .DownstreamTlsContext createTls () {
1982+ static EnvoyServerProtoData .DownstreamTlsContext createTls () {
19131983 return CommonTlsContextTestsUtil .buildTestInternalDownstreamTlsContext ("CERT1" , "VA1" );
19141984 }
19151985}
0 commit comments