Add call-home device connection verification 01/109301/4
authorlubos-cicut <lubos.cicut@pantheon.tech>
Wed, 13 Dec 2023 11:30:46 +0000 (12:30 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 8 Jan 2024 15:16:04 +0000 (16:16 +0100)
Add verification to check that when netconf device calls home then
ODL connects it (enable in topology).

JIRA: NETCONF-1212
Change-Id: I843bc151b54b2bc20fedc2ead1b04d523b41f60b
Signed-off-by: lubos-cicut <lubos.cicut@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
apps/callhome-provider/src/test/java/org/opendaylight/netconf/callhome/mount/CallHomeMountServiceTest.java

index 93a7cf91cde487f006427c0748d7dc71b41f2b87..a62adbdbef8d45580035bed077d7b8e361a05dfb 100644 (file)
@@ -61,6 +61,7 @@ public class CallHomeMountServiceTest {
 
     private CallHomeMountService service;
     private ListenableFuture<NetconfClientSession> netconfSessionFuture;
+    private Node node1;
 
     @BeforeEach
     void beforeEach() {
@@ -70,11 +71,11 @@ public class CallHomeMountServiceTest {
          * for ID1 only.
          */
         doAnswer(invocation -> {
-            final var node = (Node) invocation.getArguments()[0];
-            if (ID1.equals(node.requireNodeId().getValue())) {
+            node1 = (Node) invocation.getArguments()[0];
+            if (ID1.equals(node1.requireNodeId().getValue())) {
                 final var configBuilderFactory = CallHomeMountService.createClientConfigurationBuilderFactory();
                 final var config = configBuilderFactory
-                    .createClientConfigurationBuilder(node.requireNodeId(), node.augmentation(NetconfNode.class))
+                    .createClientConfigurationBuilder(node1.requireNodeId(), node1.augmentation(NetconfNode.class))
                     .withSessionListener(sessionListener).build();
                 try {
                     netconfSessionFuture = service.createClientFactory().createClient(config);
@@ -106,6 +107,9 @@ public class CallHomeMountServiceTest {
         // id 2 -- netconf layer omitted
         assertNull(sshSessionContextManager.createContext(ID2, sshSession));
 
+        // verify that node is enabled with SSH
+        verify(topology, times(1)).enableNode(node1);
+
         // remove context
         sshSessionContextManager.remove(ID1);
         verify(topology, times(1)).disableNode(eq(NODE_ID1));
@@ -127,6 +131,9 @@ public class CallHomeMountServiceTest {
         // id 2 -- netconf layer omitted
         assertNull(tlsSessionContextManager.createContext(ID2, nettyChannel));
 
+        // verify that node is enabled with TLS
+        verify(topology, times(1)).enableNode(node1);
+
         // remove context
         tlsSessionContextManager.remove(ID1);
         verify(topology, times(1)).disableNode(eq(NODE_ID1));