Fix CSIT failure in unsubscribeDtcl RPC
[controller.git] / opendaylight / md-sal / samples / clustering-test-app / provider / src / main / java / org / opendaylight / controller / clustering / it / provider / MdsalLowLevelTestProvider.java
index 0c0a3b241089b8da2eb4110471fa5c13736f7bb2..3b9f386b09f7fb59c89269ca02bbaf31741c18a7 100644 (file)
@@ -537,9 +537,8 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
         dtclReg = null;
 
         if (!idIntsListener.hasTriggered()) {
-            final RpcError error = RpcResultBuilder.newError(
-                    ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received"
-                            + "any notifications.");
+            final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "operation-failed",
+                    "id-ints listener has not received any notifications.");
             return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed()
                     .withRpcError(error).build());
         }
@@ -551,18 +550,23 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
 
             if (!readResult.isPresent()) {
                 final RpcError error = RpcResultBuilder.newError(
-                        ErrorType.APPLICATION, "Final read empty.", "No data read from id-ints list.");
+                        ErrorType.APPLICATION, "data-missing", "No data read from id-ints list.");
                 return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed()
                         .withRpcError(error).build());
             }
 
+            final boolean nodesEqual = idIntsListener.checkEqual(readResult.get());
+            if (!nodesEqual) {
+                LOG.error("Final read of id-int does not match IdIntsListener's copy. {}",
+                        idIntsListener.diffWithLocalCopy(readResult.get()));
+            }
+
             return Futures.immediateFuture(
-                    RpcResultBuilder.success(new UnsubscribeDtclOutputBuilder()
-                            .setCopyMatches(idIntsListener.checkEqual(readResult.get()))).build());
+                    RpcResultBuilder.success(new UnsubscribeDtclOutputBuilder().setCopyMatches(nodesEqual)).build());
 
         } catch (final InterruptedException | ExecutionException e) {
             final RpcError error = RpcResultBuilder.newError(
-                    ErrorType.APPLICATION, "Read failed.", "Final read from id-ints failed.");
+                    ErrorType.APPLICATION, "operation-failed", "Final read from id-ints failed.", null, null, e);
             return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed()
                     .withRpcError(error).build());
 
@@ -681,7 +685,7 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
 
         context.findLocalShardAsync(shardName).onComplete(new OnComplete<ActorRef>() {
             @Override
-            public void onComplete(final Throwable throwable, final ActorRef actorRef) throws Throwable {
+            public void onComplete(final Throwable throwable, final ActorRef actorRef) {
                 if (throwable != null) {
                     shutdownShardAsk.failure(throwable);
                 } else {
@@ -692,7 +696,7 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
 
         shutdownShardAsk.future().onComplete(new OnComplete<Boolean>() {
             @Override
-            public void onComplete(final Throwable throwable, final Boolean gracefulStopResult) throws Throwable {
+            public void onComplete(final Throwable throwable, final Boolean gracefulStopResult) {
                 if (throwable != null) {
                     final RpcResult<T> failedResult = RpcResultBuilder.<T>failed()
                             .withError(ErrorType.APPLICATION, "Failed to gracefully shutdown shard", throwable).build();