blob: 240d4b26acb051777633943f5e824e0f826e8764 [file] [log] [blame]
Devin Lim142b5342017-07-20 15:22:39 -07001"""
2Copyright 2016 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"""
Devin Lim58046fa2017-07-05 16:55:00 -070021class Utils:
22 def __init__( self ):
23 self.default = ''
24
25 def mininetCleanIntro( self ):
Devin Lim142b5342017-07-20 15:22:39 -070026 """
27 Description:
28 Introduction information of the mininet clean up
29 Required:
30 Returns:
31 """
Devin Lim58046fa2017-07-05 16:55:00 -070032 main.log.report( "Stop Mininet" )
33
34 main.case( "Stop Mininet" )
35 main.caseExplanation = "Stopping the current mininet to start up fresh"
36
37 def mininetCleanup( self, Mininet, timeout=5 ):
Devin Lim142b5342017-07-20 15:22:39 -070038 """
39 Description:
40 Clean up the mininet using stopNet and verify it.
41 Required:
42 * Mininet - mininet driver to use
43 * timeout - time out of mininet.stopNet.
44 Returns:
45 Returns main.TRUE if successfully stopping minient.
46 else returns main.FALSE
47 """
Devin Lim58046fa2017-07-05 16:55:00 -070048 main.step( "Stopping Mininet" )
49 topoResult = Mininet.stopNet( timeout=timeout )
50 utilities.assert_equals( expect=main.TRUE,
51 actual=topoResult,
52 onpass="Successfully stopped mininet",
53 onfail="Failed to stopped mininet" )
54 return topoResult
55
Devin Lim142b5342017-07-20 15:22:39 -070056 def copyKarafLog( self, copyFileName="" ):
Devin Lim58046fa2017-07-05 16:55:00 -070057 """
Devin Lim142b5342017-07-20 15:22:39 -070058 Description:
59 copy the karaf log and verify it.
60 Required:
61 * copyFileName - name of the end portion of the
62 copyFileName.
63 Returns:
Devin Lim58046fa2017-07-05 16:55:00 -070064 """
Jon Hallca319892017-06-15 15:25:22 -070065 # TODO: Also grab the rotated karaf logs
Devin Lim58046fa2017-07-05 16:55:00 -070066 main.log.report( "Copy karaf logs" )
67 main.case( "Copy karaf logs" )
68 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
69 "reinstalling ONOS"
70 main.step( "Copying karaf logs" )
71 stepResult = main.TRUE
72 scpResult = main.TRUE
73 copyResult = main.TRUE
Devin Lim142b5342017-07-20 15:22:39 -070074 for ctrl in main.Cluster.runningNodes:
75 scpResult = scpResult and main.ONOSbench.scp( ctrl,
Devin Lim58046fa2017-07-05 16:55:00 -070076 "/opt/onos/log/karaf.log",
77 "/tmp/karaf.log",
78 direction="from" )
79 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Devin Lim142b5342017-07-20 15:22:39 -070080 copyFileName=( "karaf.log." + ctrl.name +
81 "." + copyFileName ) )
Devin Lim58046fa2017-07-05 16:55:00 -070082 if scpResult and copyResult:
83 stepResult = main.TRUE and stepResult
84 else:
85 stepResult = main.FALSE and stepResult
86 utilities.assert_equals( expect=main.TRUE,
87 actual=stepResult,
88 onpass="Successfully copied remote ONOS logs",
Jon Hallca319892017-06-15 15:25:22 -070089 onfail="Failed to copy remote ONOS logs" )