Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2016 Open Networking Foundation (ONF) |
| 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 |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 21 | class Utils: |
| 22 | def __init__( self ): |
| 23 | self.default = '' |
| 24 | |
| 25 | def mininetCleanIntro( self ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 26 | """ |
| 27 | Description: |
| 28 | Introduction information of the mininet clean up |
| 29 | Required: |
| 30 | Returns: |
| 31 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 32 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 38 | """ |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 48 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 56 | def copyKarafLog( self, copyFileName="" ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 57 | """ |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 58 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 64 | """ |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 65 | # TODO: Also grab the rotated karaf logs |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 66 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 74 | for ctrl in main.Cluster.runningNodes: |
| 75 | scpResult = scpResult and main.ONOSbench.scp( ctrl, |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 76 | "/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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 80 | copyFileName=( "karaf.log." + ctrl.name + |
| 81 | "." + copyFileName ) ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 82 | 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 Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 89 | onfail="Failed to copy remote ONOS logs" ) |