blob: e1c2027375d1a9ef4d9a1685159b6d2b5581a717 [file] [log] [blame]
Devin Lim142b5342017-07-20 15:22:39 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Devin Lim142b5342017-07-20 15:22:39 -07003
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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Devin Lim142b5342017-07-20 15:22:39 -070012
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"""
Devin Lim58046fa2017-07-05 16:55:00 -070021class Utils:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070022
Devin Lim58046fa2017-07-05 16:55:00 -070023 def __init__( self ):
24 self.default = ''
25
26 def mininetCleanIntro( self ):
Devin Lim142b5342017-07-20 15:22:39 -070027 """
28 Description:
29 Introduction information of the mininet clean up
30 Required:
31 Returns:
32 """
Devin Lim58046fa2017-07-05 16:55:00 -070033 main.log.report( "Stop Mininet" )
34
35 main.case( "Stop Mininet" )
36 main.caseExplanation = "Stopping the current mininet to start up fresh"
37
Devin Lima7cfdbd2017-09-29 15:02:22 -070038 def mininetCleanup( self, Mininet, timeout=5, exitTimeout=1000 ):
Devin Lim142b5342017-07-20 15:22:39 -070039 """
40 Description:
41 Clean up the mininet using stopNet and verify it.
42 Required:
43 * Mininet - mininet driver to use
44 * timeout - time out of mininet.stopNet.
45 Returns:
46 Returns main.TRUE if successfully stopping minient.
47 else returns main.FALSE
48 """
Devin Lim58046fa2017-07-05 16:55:00 -070049 main.step( "Stopping Mininet" )
Devin Lima7cfdbd2017-09-29 15:02:22 -070050 topoResult = Mininet.stopNet( timeout=timeout, exitTimeout=exitTimeout )
Devin Lim58046fa2017-07-05 16:55:00 -070051 utilities.assert_equals( expect=main.TRUE,
52 actual=topoResult,
53 onpass="Successfully stopped mininet",
54 onfail="Failed to stopped mininet" )
55 return topoResult
56
Devin Lim142b5342017-07-20 15:22:39 -070057 def copyKarafLog( self, copyFileName="" ):
Devin Lim58046fa2017-07-05 16:55:00 -070058 """
Devin Lim142b5342017-07-20 15:22:39 -070059 Description:
60 copy the karaf log and verify it.
61 Required:
62 * copyFileName - name of the end portion of the
63 copyFileName.
64 Returns:
Devin Lim58046fa2017-07-05 16:55:00 -070065 """
Jon Hallca319892017-06-15 15:25:22 -070066 # TODO: Also grab the rotated karaf logs
Devin Lim58046fa2017-07-05 16:55:00 -070067 main.log.report( "Copy karaf logs" )
68 main.case( "Copy karaf logs" )
69 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
70 "reinstalling ONOS"
71 main.step( "Copying karaf logs" )
72 stepResult = main.TRUE
73 scpResult = main.TRUE
74 copyResult = main.TRUE
Devin Lim142b5342017-07-20 15:22:39 -070075 for ctrl in main.Cluster.runningNodes:
76 scpResult = scpResult and main.ONOSbench.scp( ctrl,
Devin Lim58046fa2017-07-05 16:55:00 -070077 "/opt/onos/log/karaf.log",
78 "/tmp/karaf.log",
79 direction="from" )
80 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Devin Lim142b5342017-07-20 15:22:39 -070081 copyFileName=( "karaf.log." + ctrl.name +
82 "." + copyFileName ) )
Devin Lim58046fa2017-07-05 16:55:00 -070083 if scpResult and copyResult:
84 stepResult = main.TRUE and stepResult
85 else:
86 stepResult = main.FALSE and stepResult
87 utilities.assert_equals( expect=main.TRUE,
88 actual=stepResult,
89 onpass="Successfully copied remote ONOS logs",
Jon Hallca319892017-06-15 15:25:22 -070090 onfail="Failed to copy remote ONOS logs" )