import os
import osgtest.library.core as core
import unittest

class TestStartGridFTP(unittest.TestCase):

    def test_01_start_gridftp(self):
        core.config['gridftp.pid-file'] = '/var/run/globus-gridftp-server.pid'
        core.state['gridftp.started-server'] = False

        if not core.rpm_is_installed('globus-gridftp-server-progs'):
            core.skip('not installed')
            return
        if os.path.exists(core.config['gridftp.pid-file']):
            core.skip('apparently running')
            return

        command = ('service', 'globus-gridftp-server', 'start')
        stdout, _, fail = core.check_system(command, 'Start GridFTP server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(os.path.exists(core.config['gridftp.pid-file']),
                     'GridFTP server PID file missing')
        core.state['gridftp.started-server'] = True

import os
from osgtest.library import core, osgunittest
import unittest

class TestStartGridFTP(osgunittest.OSGTestCase):

    def test_01_start_gridftp(self):
        core.config['gridftp.pid-file'] = '/var/run/globus-gridftp-server.pid'
        core.state['gridftp.started-server'] = False

        core.skip_ok_unless_installed('globus-gridftp-server-progs')
        self.skip_ok_if(os.path.exists(core.config['gridftp.pid-file']), 'already running')

        command = ('service', 'globus-gridftp-server', 'start')
        stdout, _, fail = core.check_system(command, 'Start GridFTP server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(os.path.exists(core.config['gridftp.pid-file']),
                     'GridFTP server PID file missing')
        core.state['gridftp.started-server'] = True

Update 13_gridftp to use OkSkip functionality
Update 13_gridftp to use OkSkip functionality

git-svn-id: 884a03e47e2adb735d896e55bb5ad6bc3421ba19@16527 4e558342-562e-0410-864c-e07659590f8c

  import os
- import osgtest.library.core as core
+ from osgtest.library import core, osgunittest
  import unittest
  
- class TestStartGridFTP(unittest.TestCase):
+ class TestStartGridFTP(osgunittest.OSGTestCase):
  
      def test_01_start_gridftp(self):
          core.config['gridftp.pid-file'] = '/var/run/globus-gridftp-server.pid'
          core.state['gridftp.started-server'] = False
  
-         if not core.rpm_is_installed('globus-gridftp-server-progs'):
+         core.skip_ok_unless_installed('globus-gridftp-server-progs')
-             core.skip('not installed')
-             return
-         if os.path.exists(core.config['gridftp.pid-file']):
+         self.skip_ok_if(os.path.exists(core.config['gridftp.pid-file']), 'already running')
-             core.skip('apparently running')
-             return
  
          command = ('service', 'globus-gridftp-server', 'start')
          stdout, _, fail = core.check_system(command, 'Start GridFTP server')
          self.assert_(stdout.find('FAILED') == -1, fail)
          self.assert_(os.path.exists(core.config['gridftp.pid-file']),
                       'GridFTP server PID file missing')
          core.state['gridftp.started-server'] = True
  
Update 13_gridftp to use OkSkip functionality
## Code Before:
import os
import osgtest.library.core as core
import unittest

class TestStartGridFTP(unittest.TestCase):

    def test_01_start_gridftp(self):
        core.config['gridftp.pid-file'] = '/var/run/globus-gridftp-server.pid'
        core.state['gridftp.started-server'] = False

        if not core.rpm_is_installed('globus-gridftp-server-progs'):
            core.skip('not installed')
            return
        if os.path.exists(core.config['gridftp.pid-file']):
            core.skip('apparently running')
            return

        command = ('service', 'globus-gridftp-server', 'start')
        stdout, _, fail = core.check_system(command, 'Start GridFTP server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(os.path.exists(core.config['gridftp.pid-file']),
                     'GridFTP server PID file missing')
        core.state['gridftp.started-server'] = True

## Instruction:
Update 13_gridftp to use OkSkip functionality
## Code After:
import os
from osgtest.library import core, osgunittest
import unittest

class TestStartGridFTP(osgunittest.OSGTestCase):

    def test_01_start_gridftp(self):
        core.config['gridftp.pid-file'] = '/var/run/globus-gridftp-server.pid'
        core.state['gridftp.started-server'] = False

        core.skip_ok_unless_installed('globus-gridftp-server-progs')
        self.skip_ok_if(os.path.exists(core.config['gridftp.pid-file']), 'already running')

        command = ('service', 'globus-gridftp-server', 'start')
        stdout, _, fail = core.check_system(command, 'Start GridFTP server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(os.path.exists(core.config['gridftp.pid-file']),
                     'GridFTP server PID file missing')
        core.state['gridftp.started-server'] = True
