Avoid adding overlapping intents in CHOTestMonkey

Change-Id: I5bedabb47ed44ad1083c3e40631ed818f787dbaf
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
index 848e4cc..0805112 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
@@ -20,7 +20,7 @@
     # 100. Do something else
     # Sample sequence: 0,1,2,3,[10,30,21,31,10,32,21,33,50,10,30,21,31,10,32,21,33,51,40,60,10,30,21,31,10,32,21,33,50,10,30,21,31,10,32,21,33,51,41,60]*500,100
     <testcases>
-        0,1,2,3,70,[30,21,31,32,21,33]*500,100
+        0,1,2,3,70
     </testcases>
 
     <TEST>
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
index 11459b3..42c0ff7 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
@@ -806,30 +806,26 @@
                 n = random.randint( 5, 50 )
                 for i in range( n ):
                     cliIndex = random.sample( upControllers, 1 )[ 0 ]
-                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_HOST_ADD, EventScheduleMethod().RUN_NON_BLOCK, 'random', 'random', cliIndex )
+                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_HOST_ADD, EventScheduleMethod().RUN_BLOCK, 'random', 'random', cliIndex )
                     hostIntentNum += 1
-                main.eventGenerator.triggerEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
             elif event == 'del-host-intent':
                 n = random.randint( 5, hostIntentNum )
                 for i in range( n ):
                     cliIndex = random.sample( upControllers, 1 )[ 0 ]
-                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_HOST_DEL, EventScheduleMethod().RUN_NON_BLOCK, 'random', 'random', cliIndex )
+                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_HOST_DEL, EventScheduleMethod().RUN_BLOCK, 'random', 'random', cliIndex )
                     hostIntentNum -= 1
-                main.eventGenerator.triggerEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
             elif event == 'add-point-intent':
                 n = random.randint( 5, 50 )
                 for i in range( n ):
                     cliIndex = random.sample( upControllers, 1 )[ 0 ]
-                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_POINT_ADD, EventScheduleMethod().RUN_NON_BLOCK, 'random', 'random', cliIndex, 'bidirectional' )
+                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_POINT_ADD, EventScheduleMethod().RUN_BLOCK, 'random', 'random', cliIndex, 'bidirectional' )
                     pointIntentNum += 1
-                main.eventGenerator.triggerEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
             elif event == 'del-point-intent':
                 n = random.randint( 5, pointIntentNum )
                 for i in range( n ):
                     cliIndex = random.sample( upControllers, 1 )[ 0 ]
-                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_POINT_DEL, EventScheduleMethod().RUN_NON_BLOCK, 'random', 'random', cliIndex, 'bidirectional' )
+                    main.eventGenerator.triggerEvent( EventType().APP_INTENT_POINT_DEL, EventScheduleMethod().RUN_BLOCK, 'random', 'random', cliIndex, 'bidirectional' )
                     pointIntentNum -= 1
-                main.eventGenerator.triggerEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
             elif event == 'link-down':
                 main.eventGenerator.triggerEvent( EventType().NETWORK_LINK_DOWN, EventScheduleMethod().RUN_BLOCK, 'random', 'random' )
                 downLinkNum += 1
@@ -849,7 +845,6 @@
             main.eventGenerator.triggerEvent( EventType().CHECK_TRAFFIC, EventScheduleMethod().RUN_NON_BLOCK )
             main.eventGenerator.triggerEvent( EventType().CHECK_FLOW, EventScheduleMethod().RUN_NON_BLOCK )
             main.eventGenerator.triggerEvent( EventType().CHECK_INTENT, EventScheduleMethod().RUN_NON_BLOCK )
-            main.eventGenerator.triggerEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
             with main.eventScheduler.idleCondition:
                 while not main.eventScheduler.isIdle():
                     main.eventScheduler.idleCondition.wait()
diff --git a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
index 17e9e73..e9dff29 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
@@ -58,7 +58,6 @@
 
     def setWithdrawn( self ):
         self.expectedState = 'WITHDRAWN'
-        # TODO: should we check whether hostA and hostB are made correspondents by other intents/flows?
         if self.hostB in self.hostA.correspondents:
             self.hostA.correspondents.remove( self.hostB )
         if self.hostA in self.hostB.correspondents:
@@ -66,17 +65,12 @@
 
     def setFailed( self ):
         self.expectedState = 'FAILED'
-        # TODO: should we check whether hostA and hostB are made correspondents by other intents/flows?
-        if self.hostB in self.hostA.correspondents:
-            self.hostA.correspondents.remove( self.hostB )
-        if self.hostA in self.hostB.correspondents:
-            self.hostB.correspondents.remove( self.hostA )
 
     def setInstalled( self ):
+        if self.expectedState == 'UNKNOWN':
+            self.hostA.correspondents.append( self.hostB )
+            self.hostB.correspondents.append( self.hostA )
         self.expectedState = 'INSTALLED'
-        # TODO: should we check whether hostA and hostB are already correspondents?
-        self.hostA.correspondents.append( self.hostB )
-        self.hostB.correspondents.append( self.hostA )
 
     def __str__( self ):
         return "ID: " + self.id
@@ -97,16 +91,13 @@
 
     def setFailed( self ):
         self.expectedState = 'FAILED'
-        for hostA in self.deviceA.hosts:
-            for hostB in self.deviceB.hosts:
-                if hostB in hostA.correspondents:
-                    hostA.correspondents.remove( hostB )
 
     def setInstalled( self ):
+        if self.expectedState == 'UNKNOWN':
+            for hostA in self.deviceA.hosts:
+                for hostB in self.deviceB.hosts:
+                    hostA.correspondents.append( hostB )
         self.expectedState = 'INSTALLED'
-        for hostA in self.deviceA.hosts:
-            for hostB in self.deviceB.hosts:
-                hostA.correspondents.append( hostB )
 
     def __str__( self ):
         return "ID: " + self.id