blob: 044c8a3981f676e4653aaba35a3b9fcc540dd469 [file] [log] [blame]
Devin Lim3ebd5e72017-11-14 10:38:00 -08001"""
2Copyright 2017 Open Networking Foundation ( ONF )
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 ( at your option ) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21import json
22
23def checkingNumNodes( main, expected ):
24 """
25 check the number of nodes
26 :param expected:
27 Expected number of nodes
28 :return:
29 main.TRUE if all the number of the nodes are matched
30 main.FALSE if not.
31 """
32 result = main.TRUE
33 for cluster in main.Cluster.active():
34 actual = json.loads( cluster.CLI.summary() ).get( 'nodes' )
35 thisResult = main.TRUE if expected == actual else main.FALSE
36 if not thisResult:
37 main.log.error( "Number of the nodes not matched." +
38 "\nExpected nodes: " + str( expected ) +
39 "\nActual nodes: " + str( actual ) )
40 return result
41
42def checkingApp( main, appToBeChecked, cluster, expectedToBeThere ):
43 """
44 check the existence of app
45 :param appToBeChecked:
46 Name of the apps to be checked
47 :param cluster:
48 nth cluster to be checked
49 :param expectedToBeThere:
50 True if it is expected to be installed. False if it is expected not to be installed.
51 :return:
52 main.TRUE if they are all matched. Otherwise main.FALSE
53 """
54 result = False
55 appStatus = cluster.CLI.appStatus( appToBeChecked )
56 if appStatus == "ACTIVE" if expectedToBeThere else "UNINSTALL":
57 result = True
58 if result:
59 main.log.info( "App is " + ( "not " if not expectedToBeThere else "" ) + "there as expected" )
60 return main.TRUE
61 else:
62 main.log.error("App is " + ( "" if not expectedToBeThere else "not " ) + "there which should" +
63 ( "n't" if not expectedToBeThere else "" ) + " be there.")
64 return main.FALSE