Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2016 Open Networking Foundation ( ONF ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 21 | class Utils: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 22 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 23 | def __init__( self ): |
| 24 | self.default = '' |
| 25 | |
| 26 | def mininetCleanIntro( self ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 27 | """ |
| 28 | Description: |
| 29 | Introduction information of the mininet clean up |
| 30 | Required: |
| 31 | Returns: |
| 32 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 33 | main.log.report( "Stop Mininet" ) |
| 34 | |
| 35 | main.case( "Stop Mininet" ) |
| 36 | main.caseExplanation = "Stopping the current mininet to start up fresh" |
| 37 | |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 38 | def mininetCleanup( self, Mininet, timeout=5, exitTimeout=1000 ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 39 | """ |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 49 | main.step( "Stopping Mininet" ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 50 | topoResult = Mininet.stopNet( timeout=timeout, exitTimeout=exitTimeout ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 51 | 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 Lim | 97b6b86 | 2018-01-23 22:51:25 -0800 | [diff] [blame] | 57 | def copyKarafLog( self, copyFileName="", before=False ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 58 | """ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 59 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 65 | """ |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 66 | # TODO: Also grab the rotated karaf logs |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 67 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 75 | for ctrl in main.Cluster.runningNodes: |
| 76 | scpResult = scpResult and main.ONOSbench.scp( ctrl, |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 77 | "/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 Lim | 97b6b86 | 2018-01-23 22:51:25 -0800 | [diff] [blame] | 81 | copyFileName= ( copyFileName + "_karaf.log." + |
| 82 | ctrl.name + "_" ) |
| 83 | if before else |
| 84 | ( "karaf.log." + ctrl.name + |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 85 | "." + copyFileName ) ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 86 | 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 Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 93 | onfail="Failed to copy remote ONOS logs" ) |