blob: 032fed434217b24ad5a8fcbc092d44c4d23ec273 [file] [log] [blame]
Devin Lime6fe3c42017-10-18 16:28:40 -07001"""
2The functions for intentInstallWithdrawLat
3
4"""
5import numpy
6import time
7import json
8
9
10def _init_( self ):
11 self.default = ''
12
13
14def sanityCheck( main, linkNumExpected, flowNumExpected, intentNumExpected ):
15 """
16 Sanity check on numbers of links, flows and intents in ONOS
17 """
18 attemps = 0
19 main.verify = main.FALSE
20 linkNum = 0
21 flowNum = 0
22 intentNum = 0
23 while attemps <= main.verifyAttempts:
24 time.sleep( main.verifySleep )
25 summary = json.loads( main.Cluster.active( 0 ).CLI.summary( timeout=main.timeout ) )
26 linkNum = summary.get( "links" )
27 flowNum = main.Cluster.active( 0 ).CLI.getTotalFlowsNum( timeout=600, noExit=True )
28 intentNum = summary.get( "intents" )
29 if linkNum == linkNumExpected and flowNum == flowNumExpected and intentNum == intentNumExpected:
30 main.log.info( "links: {}, flows: {}, intents: {}".format( linkNum, flowNum, intentNum ) )
31 main.verify = main.TRUE
32 break
33 attemps += 1
34 if not main.verify:
35 main.log.warn( "Links or flows or intents number not as expected" )
36 main.log.warn( "[Expected] links: {}, flows: {}, intents: {}".format( linkNumExpected, flowNumExpected, intentNumExpected ) )
37 main.log.warn( "[Actual] links: {}, flows: {}, intents: {}".format( linkNum, flowNum, intentNum ) )
38 # bring back topology
39 bringBackTopology( main )
40 if main.validrun >= main.warmUp:
41 main.invalidrun += 1
42 else:
43 main.validrun += 1
44
45def bringBackTopology( main ):
46 main.log.info( "Bring back topology " )
47
48 main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress,
49 main.egress,
50 main.batchSize,
51 offset=1,
52 options="-w",
53 timeout=main.timeout )
54 main.Cluster.active( 0 ).CLI.purgeWithdrawnIntents()
55 # configure apps
56 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
57 "deviceCount", value=0 )
58 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
59 "enabled", value="false" )
60 main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg,
61 "skipReleaseResourcesOnWithdrawal",
62 value="false" )
63 if main.flowObj:
64 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
65 "useFlowObjectives", value="false" )
66 time.sleep( main.startUpSleep )
67 main.Cluster.active( 0 ).CLI.wipeout()
68 time.sleep( main.startUpSleep )
69 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
70 "deviceCount", value=main.deviceCount )
71 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
72 "enabled", value="true" )
73 main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg,
74 "skipReleaseResourcesOnWithdrawal",
75 value="true" )
76 if main.flowObj:
77 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
78 "useFlowObjectives", value="true" )
79 time.sleep( main.startUpSleep )
80
81 # balanceMasters
82 main.Cluster.active( 0 ).CLI.balanceMasters()
83 time.sleep( main.startUpSleep )