L2GW Junit failure 98/89598/7
authorChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Tue, 5 May 2020 08:02:03 +0000 (13:32 +0530)
committerHema Gopalakrishnan <hema.gopalkrishnan@ericsson.com>
Sun, 26 Jul 2020 10:37:43 +0000 (10:37 +0000)
Description:
Th Junit case as adding DeviceTeps for External tunnels only into
default-transport-zone and was querying in TZA resulting in read
failure.

Since the current RPC only have ip and node-id as inputs, Changes are
done in addL2GwMlagDevice() API to add the given Teps in all available
transportzone.

Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Change-Id: I75db7338b696471db653417bd3124bc742e5e85d
Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
itm/itm-impl/src/main/java/org/opendaylight/genius/itm/rpc/ItmManagerRpcService.java
itm/itm-impl/src/test/java/org/opendaylight/genius/itm/tests/ItmManagerRpcServiceTest.java

index c2ecab9aeaf50d430ddf3a32b69cf35f4662d995..db71fa6a4949c4541edb6ccdb72e4aafeb226964 100644 (file)
@@ -878,54 +878,64 @@ public class ItmManagerRpcService implements ItmRpcService {
                     containerPath, dataBroker);
             if (transportZonesOptional.isPresent()) {
                 TransportZones transportZones = transportZonesOptional.get();
-                if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
+                if (transportZones.getTransportZone() == null || transportZones.getTransportZone()
+                    .isEmpty()) {
                     LOG.error("No teps configured");
                     result.set(RpcResultBuilder.<AddL2GwMlagDeviceOutput>failed()
-                            .withError(RpcError.ErrorType.APPLICATION, "No teps Configured").build());
+                        .withError(RpcError.ErrorType.APPLICATION, "No teps Configured").build());
                     return result;
                 }
-                String transportZone = transportZones.getTransportZone().get(0).getZoneName();
-                DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId.get(0));
-                InstanceIdentifier<DeviceVteps> path =
+                for (TransportZone tzone : transportZones.getTransportZone()) {
+                    if (!TunnelTypeVxlan.class.equals(tzone.getTunnelType())) {
+                        continue;
+                    }
+                    String transportZone = tzone.getZoneName();
+                    DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId.get(0));
+                    InstanceIdentifier<DeviceVteps> path =
                         InstanceIdentifier.builder(TransportZones.class)
-                                .child(TransportZone.class, new TransportZoneKey(transportZone))
-                                .child(DeviceVteps.class, deviceVtepKey).build();
-                DeviceVteps deviceVtep = new DeviceVtepsBuilder().withKey(deviceVtepKey).setIpAddress(hwIp)
+                            .child(TransportZone.class, new TransportZoneKey(transportZone))
+                            .child(DeviceVteps.class, deviceVtepKey).build();
+                    DeviceVteps deviceVtep = new DeviceVtepsBuilder().withKey(deviceVtepKey)
+                        .setIpAddress(hwIp)
                         .setNodeId(nodeId.get(0)).setTopologyId(input.getTopologyId()).build();
-                LOG.trace("writing hWvtep{}", deviceVtep);
-                FluentFuture<Void> future =
-                    retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
-                        tx -> {
-                            tx.mergeParentStructurePut(path, deviceVtep);
-                            if (nodeId.size() == 2) {
-                                LOG.trace("second node-id {}", nodeId.get(1));
-                                DeviceVtepsKey deviceVtepKey2 = new DeviceVtepsKey(hwIp, nodeId.get(1));
-                                InstanceIdentifier<DeviceVteps> path2 = InstanceIdentifier
+                    LOG.trace("writing hWvtep{}", deviceVtep);
+                    FluentFuture<Void> future =
+                        retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+                            tx -> {
+                                tx.mergeParentStructurePut(path, deviceVtep);
+                                if (nodeId.size() == 2) {
+                                    LOG.trace("second node-id {}", nodeId.get(1));
+                                    DeviceVtepsKey deviceVtepKey2 = new DeviceVtepsKey(hwIp,
+                                        nodeId.get(1));
+                                    InstanceIdentifier<DeviceVteps> path2 = InstanceIdentifier
                                         .builder(TransportZones.class)
                                         .child(TransportZone.class, new TransportZoneKey(transportZone))
                                         .child(DeviceVteps.class, deviceVtepKey2).build();
-                                DeviceVteps deviceVtep2 = new DeviceVtepsBuilder().withKey(deviceVtepKey2)
+                                    DeviceVteps deviceVtep2 = new DeviceVtepsBuilder()
+                                        .withKey(deviceVtepKey2)
                                         .setIpAddress(hwIp).setNodeId(nodeId.get(1))
                                         .setTopologyId(input.getTopologyId()).build();
-                                LOG.trace("writing {}", deviceVtep2);
-                                tx.mergeParentStructurePut(path2, deviceVtep2);
-                            }
-                        });
-                future.addCallback(new FutureCallback<Void>() {
-                    @Override
-                    public void onSuccess(Void voidInstance) {
-                        result.set(RpcResultBuilder.<AddL2GwMlagDeviceOutput>success().build());
-                    }
+                                    LOG.trace("writing {}", deviceVtep2);
+                                    tx.mergeParentStructurePut(path2, deviceVtep2);
+                                }
+                            });
+                    future.addCallback(new FutureCallback<Void>() {
+                        @Override
+                        public void onSuccess(Void voidInstance) {
+                            result.set(RpcResultBuilder.<AddL2GwMlagDeviceOutput>success().build());
+                        }
 
-                    @Override
-                    public void onFailure(Throwable error) {
-                        String msg = String.format("Unable to write HwVtep %s to datastore", nodeId);
-                        LOG.error("Unable to write HwVtep {}, {} to datastore", nodeId , hwIp);
-                        result.set(RpcResultBuilder.<AddL2GwMlagDeviceOutput>failed()
+                        @Override
+                        public void onFailure(Throwable error) {
+                            String msg = String
+                                .format("Unable to write HwVtep %s to datastore", nodeId);
+                            LOG.error("Unable to write HwVtep {}, {} to datastore", nodeId, hwIp);
+                            result.set(RpcResultBuilder.<AddL2GwMlagDeviceOutput>failed()
                                 .withError(RpcError.ErrorType.APPLICATION, msg, error)
                                 .build());
-                    }
-                }, MoreExecutors.directExecutor());
+                        }
+                    }, MoreExecutors.directExecutor());
+                }
             }
             return result;
         } catch (RuntimeException e) {
index 275e8e91d12fb3d1b137445d2546a31ad20a7409..6b348c2a75a3b426ebbed1b4aa4f3845c6de159d 100644 (file)
@@ -19,7 +19,6 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import javax.inject.Inject;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.MethodRule;
@@ -360,14 +359,13 @@ public class ItmManagerRpcServiceTest {
                 .read(LogicalDatastoreType.CONFIGURATION, deviceVtepsIdentifier).get().get());
     }
 
-    @Ignore
     @Test
     public void testAddL2GwMlagDevice() throws Exception {
         ListenableFuture<RpcResult<AddL2GwMlagDeviceOutput>> rpcRes =
                 itmManagerRpcService.addL2GwMlagDevice(addL2GwMlagDeviceInput);
 
         coordinatorEventsWaiter.awaitEventsConsumption();
-        Thread.sleep(8000);
+        Thread.sleep(5000);
 
 
         // check RPC response is SUCCESS