@@ -717,7 +717,7 @@ public void testCdsError() throws IOException {
717717 }
718718
719719 @ Test
720- public void updatesAfterShutdown () {
720+ public void ldsUpdateAfterShutdown () {
721721 XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS" ,
722722 ENDPOINT_HOSTNAME , ENDPOINT_PORT );
723723
@@ -727,39 +727,125 @@ public void updatesAfterShutdown() {
727727 verify (xdsConfigWatcher , timeout (1000 )).onUpdate (any ());
728728
729729 @ SuppressWarnings ("unchecked" )
730- XdsClient .ResourceWatcher <XdsListenerResource .LdsUpdate > serverNameWatcher =
730+ XdsClient .ResourceWatcher <XdsListenerResource .LdsUpdate > resourceWatcher =
731731 mock (XdsClient .ResourceWatcher .class );
732732 xdsClient .watchXdsResource (
733733 XdsListenerResource .getInstance (),
734- serverName + "2" ,
735- serverNameWatcher ,
734+ serverName ,
735+ resourceWatcher ,
736736 MoreExecutors .directExecutor ());
737+ verify (resourceWatcher , timeout (5000 )).onChanged (any ());
738+
739+ syncContext .execute (() -> {
740+ // Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
741+ // Runnable returns
742+ xdsDependencyManager .shutdown ();
743+
744+ XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS2" , "CDS" , "EDS" ,
745+ ENDPOINT_HOSTNAME , ENDPOINT_PORT );
746+ verify (resourceWatcher , timeout (5000 ).times (2 )).onChanged (any ());
747+ xdsClient .cancelXdsResourceWatch (
748+ XdsListenerResource .getInstance (), serverName , resourceWatcher );
749+ });
750+ }
751+
752+ @ Test
753+ public void rdsUpdateAfterShutdown () {
754+ XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS" ,
755+ ENDPOINT_HOSTNAME , ENDPOINT_PORT );
756+
757+ xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
758+ serverName , serverName , nameResolverArgs , scheduler );
759+
760+ verify (xdsConfigWatcher , timeout (1000 )).onUpdate (any ());
761+
762+ @ SuppressWarnings ("unchecked" )
763+ XdsClient .ResourceWatcher <XdsRouteConfigureResource .RdsUpdate > resourceWatcher =
764+ mock (XdsClient .ResourceWatcher .class );
765+ xdsClient .watchXdsResource (
766+ XdsRouteConfigureResource .getInstance (),
767+ "RDS" ,
768+ resourceWatcher ,
769+ MoreExecutors .directExecutor ());
770+ verify (resourceWatcher , timeout (5000 )).onChanged (any ());
771+
772+ syncContext .execute (() -> {
773+ // Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
774+ // Runnable returns
775+ xdsDependencyManager .shutdown ();
776+
777+ XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS2" , "EDS" ,
778+ ENDPOINT_HOSTNAME , ENDPOINT_PORT );
779+ verify (resourceWatcher , timeout (5000 ).times (2 )).onChanged (any ());
780+ xdsClient .cancelXdsResourceWatch (
781+ XdsRouteConfigureResource .getInstance (), serverName , resourceWatcher );
782+ });
783+ }
784+
785+ @ Test
786+ public void cdsUpdateAfterShutdown () {
787+ XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS" ,
788+ ENDPOINT_HOSTNAME , ENDPOINT_PORT );
789+
790+ xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
791+ serverName , serverName , nameResolverArgs , scheduler );
792+
793+ verify (xdsConfigWatcher , timeout (1000 )).onUpdate (any ());
794+
795+ @ SuppressWarnings ("unchecked" )
796+ XdsClient .ResourceWatcher <XdsClusterResource .CdsUpdate > resourceWatcher =
797+ mock (XdsClient .ResourceWatcher .class );
798+ xdsClient .watchXdsResource (
799+ XdsClusterResource .getInstance (),
800+ "CDS" ,
801+ resourceWatcher ,
802+ MoreExecutors .directExecutor ());
803+ verify (resourceWatcher , timeout (5000 )).onChanged (any ());
737804
738805 syncContext .execute (() -> {
739806 // Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
740807 // Runnable returns
741808 xdsDependencyManager .shutdown ();
742809
743- // Cause an onChanged() for each type, and maybe onResourceDoesNotExist(), going from EDS up
744- // the tree since updates won't be processed immediately by the dependency manager (we're
745- // blocking the sync context)
746- XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS" ,
747- ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT );
748810 XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS2" ,
749- ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT );
750- XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS2" , "EDS2" ,
751- ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT );
752- XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS2" , "CDS2" , "EDS2" ,
753- ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT );
754- XdsTestUtils .setAdsConfig (controlPlaneService , serverName + "2" , "RDS2" , "CDS2" , "EDS2" ,
755- ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT );
811+ ENDPOINT_HOSTNAME , ENDPOINT_PORT );
812+ verify (resourceWatcher , timeout (5000 ).times (2 )).onChanged (any ());
813+ xdsClient .cancelXdsResourceWatch (
814+ XdsClusterResource .getInstance (), serverName , resourceWatcher );
756815 });
816+ }
817+
818+ @ Test
819+ public void edsUpdateAfterShutdown () {
820+ XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS" ,
821+ ENDPOINT_HOSTNAME , ENDPOINT_PORT );
757822
758- // Wait for the prior updates to be processed by XdsClient. This can't be done in the
759- // syncContext as flow control prevents further updates until previous callbacks have completed.
760- verify (serverNameWatcher , timeout (5000 )).onChanged (any ());
761- xdsClient .cancelXdsResourceWatch (
762- XdsListenerResource .getInstance (), serverName + "2" , serverNameWatcher );
823+ xdsDependencyManager = new XdsDependencyManager (xdsClient , xdsConfigWatcher , syncContext ,
824+ serverName , serverName , nameResolverArgs , scheduler );
825+
826+ verify (xdsConfigWatcher , timeout (1000 )).onUpdate (any ());
827+
828+ @ SuppressWarnings ("unchecked" )
829+ XdsClient .ResourceWatcher <XdsEndpointResource .EdsUpdate > resourceWatcher =
830+ mock (XdsClient .ResourceWatcher .class );
831+ xdsClient .watchXdsResource (
832+ XdsEndpointResource .getInstance (),
833+ "EDS" ,
834+ resourceWatcher ,
835+ MoreExecutors .directExecutor ());
836+ verify (resourceWatcher , timeout (5000 )).onChanged (any ());
837+
838+ syncContext .execute (() -> {
839+ // Shutdown before any updates. This will unsubscribe from XdsClient, but only after this
840+ // Runnable returns
841+ xdsDependencyManager .shutdown ();
842+
843+ XdsTestUtils .setAdsConfig (controlPlaneService , serverName , "RDS" , "CDS" , "EDS" ,
844+ ENDPOINT_HOSTNAME + "2" , ENDPOINT_PORT );
845+ verify (resourceWatcher , timeout (5000 ).times (2 )).onChanged (any ());
846+ xdsClient .cancelXdsResourceWatch (
847+ XdsEndpointResource .getInstance (), serverName , resourceWatcher );
848+ });
763849 }
764850
765851 private Listener buildInlineClientListener (String rdsName , String clusterName ) {
0 commit comments