blob: 6537afc56d8b5dcedddd526749b714ea5490b205 [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
Devin Lim0c972b72018-02-08 14:53:59 -080026 def mininetCleanIntro( self, includeCaseDesc=True ):
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" )
Devin Lim0c972b72018-02-08 14:53:59 -080034 if includeCaseDesc:
35 main.case( "Stop Mininet" )
36 main.caseExplanation = "Stopping the current mininet to start up fresh"
Devin Lim58046fa2017-07-05 16:55:00 -070037
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 Lim0c972b72018-02-08 14:53:59 -080057 def copyKarafLog( self, copyFileName="", before=False, includeCaseDesc=True ):
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" )
Devin Lim0c972b72018-02-08 14:53:59 -080068 if includeCaseDesc:
69 main.case( "Copy karaf logs" )
70 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
71 "reinstalling ONOS"
Devin Lim58046fa2017-07-05 16:55:00 -070072 main.step( "Copying karaf logs" )
73 stepResult = main.TRUE
74 scpResult = main.TRUE
75 copyResult = main.TRUE
Devin Lim142b5342017-07-20 15:22:39 -070076 for ctrl in main.Cluster.runningNodes:
77 scpResult = scpResult and main.ONOSbench.scp( ctrl,
Devin Lim58046fa2017-07-05 16:55:00 -070078 "/opt/onos/log/karaf.log",
79 "/tmp/karaf.log",
80 direction="from" )
81 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Devin Lim0c972b72018-02-08 14:53:59 -080082 copyFileName=( copyFileName + "_karaf.log." +
83 ctrl.name + "_" ) if before else
84 ( "karaf.log." + ctrl.name +
85 "." + copyFileName ) )
Devin Lim58046fa2017-07-05 16:55:00 -070086 if scpResult and copyResult:
87 stepResult = main.TRUE and stepResult
88 else:
89 stepResult = main.FALSE and stepResult
90 utilities.assert_equals( expect=main.TRUE,
91 actual=stepResult,
92 onpass="Successfully copied remote ONOS logs",
Jon Hallca319892017-06-15 15:25:22 -070093 onfail="Failed to copy remote ONOS logs" )