@@ -3220,6 +3220,55 @@ public void cdsResourceDeleted_failOnDataErrors_false() {
32203220 BootstrapperImpl .xdsDataErrorHandlingEnabled = false ;
32213221 }
32223222
3223+ /**
3224+ * Tests that a NACKed LDS resource update drops the cached resource when fail_on_data_errors
3225+ * is enabled.
3226+ */
3227+ @ Test
3228+ public void ldsResourceNacked_withFailOnDataErrors_dropsResource () {
3229+ BootstrapperImpl .xdsDataErrorHandlingEnabled = true ;
3230+ xdsServerInfo = ServerInfo .create (SERVER_URI , CHANNEL_CREDENTIALS , false ,
3231+ true , false , true );
3232+ BootstrapInfo bootstrapInfo =
3233+ Bootstrapper .BootstrapInfo .builder ()
3234+ .servers (Collections .singletonList (xdsServerInfo ))
3235+ .node (NODE )
3236+ .build ();
3237+ xdsClient = new XdsClientImpl (
3238+ xdsTransportFactory ,
3239+ bootstrapInfo ,
3240+ fakeClock .getScheduledExecutorService (),
3241+ backoffPolicyProvider ,
3242+ fakeClock .getStopwatchSupplier (),
3243+ timeProvider ,
3244+ MessagePrinter .INSTANCE ,
3245+ new TlsContextManagerImpl (bootstrapInfo ),
3246+ xdsClientMetricReporter );
3247+
3248+ InOrder inOrder = inOrder (ldsResourceWatcher );
3249+ DiscoveryRpcCall call = startResourceWatcher (XdsListenerResource .getInstance (), LDS_RESOURCE ,
3250+ ldsResourceWatcher );
3251+ call .sendResponse (LDS , testListenerVhosts , VERSION_1 , "0000" );
3252+ call .verifyRequest (LDS , LDS_RESOURCE , VERSION_1 , "0000" , NODE );
3253+ inOrder .verify (ldsResourceWatcher ).onResourceChanged (ldsUpdateCaptor .capture ());
3254+ StatusOr <LdsUpdate > initialUpdate = ldsUpdateCaptor .getValue ();
3255+ assertThat (initialUpdate .hasValue ()).isTrue ();
3256+ verifyGoldenListenerVhosts (initialUpdate .getValue ());
3257+ Message invalidListener = mf .buildListenerWithApiListenerInvalid (LDS_RESOURCE );
3258+ call .sendResponse (LDS , Collections .singletonList (Any .pack (invalidListener )), VERSION_2 , "0001" );
3259+ String expectedError = "LDS response Listener '" + LDS_RESOURCE + "' validation error" ;
3260+ call .verifyRequestNack (LDS , LDS_RESOURCE , VERSION_1 , "0001" , NODE ,
3261+ Collections .singletonList (expectedError ));
3262+
3263+ inOrder .verify (ldsResourceWatcher ).onResourceChanged (ldsUpdateCaptor .capture ());
3264+ StatusOr <LdsUpdate > finalUpdate = ldsUpdateCaptor .getValue ();
3265+ assertThat (finalUpdate .hasValue ()).isFalse ();
3266+ assertThat (finalUpdate .getStatus ().getCode ()).isEqualTo (Status .Code .UNAVAILABLE );
3267+ assertThat (finalUpdate .getStatus ().getDescription ()).contains (expectedError );
3268+
3269+ BootstrapperImpl .xdsDataErrorHandlingEnabled = false ;
3270+ }
3271+
32233272 @ Test
32243273 @ SuppressWarnings ("unchecked" )
32253274 public void multipleCdsWatchers () {
0 commit comments