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

class TestStopXrootd(osgunittest.OSGTestCase):

    def test_01_stop_xrootd(self):
        if (core.config['xrootd.gsi'] == "ON") and (core.state['xrootd.backups-exist'] == True):
            files.restore('/etc/xrootd/xrootd-clustered.cfg',"xrootd")
            files.restore('/etc/xrootd/auth_file',"xrootd")
            files.restore('/etc/grid-security/xrd/xrdmapfile',"xrootd")
        core.skip_ok_unless_installed('xrootd')
        self.skip_ok_if(['xrootd.started-server'] == False, 'did not start server')

        command = ('service', 'xrootd', 'stop')
        stdout, _, fail = core.check_system(command, 'Stop Xrootd server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(not os.path.exists(core.config['xrootd.pid-file']),
                     'Xrootd server PID file still present')

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

class TestStopXrootd(osgunittest.OSGTestCase):

    def test_01_stop_xrootd(self):
        if (core.config['xrootd.gsi'] == "ON") and (core.state['xrootd.backups-exist'] == True):
            files.restore('/etc/xrootd/xrootd-clustered.cfg',"xrootd")
            files.restore('/etc/xrootd/auth_file',"xrootd")
            files.restore('/etc/grid-security/xrd/xrdmapfile',"xrootd")
        core.skip_ok_unless_installed('xrootd')
        self.skip_ok_if(core.state['xrootd.started-server'] == False, 'did not start server')

        command = ('service', 'xrootd', 'stop')
        stdout, _, fail = core.check_system(command, 'Stop Xrootd server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(not os.path.exists(core.config['xrootd.pid-file']),
                     'Xrootd server PID file still present')

Fix test if server started in xrootd cleanup code
Fix test if server started in xrootd cleanup code

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

  import os
  import osgtest.library.core as core
  import osgtest.library.files as files
  import osgtest.library.osgunittest as osgunittest
  import unittest
  
  class TestStopXrootd(osgunittest.OSGTestCase):
  
      def test_01_stop_xrootd(self):
          if (core.config['xrootd.gsi'] == "ON") and (core.state['xrootd.backups-exist'] == True):
              files.restore('/etc/xrootd/xrootd-clustered.cfg',"xrootd")
              files.restore('/etc/xrootd/auth_file',"xrootd")
              files.restore('/etc/grid-security/xrd/xrdmapfile',"xrootd")
          core.skip_ok_unless_installed('xrootd')
-         self.skip_ok_if(['xrootd.started-server'] == False, 'did not start server')
+         self.skip_ok_if(core.state['xrootd.started-server'] == False, 'did not start server')
  
          command = ('service', 'xrootd', 'stop')
          stdout, _, fail = core.check_system(command, 'Stop Xrootd server')
          self.assert_(stdout.find('FAILED') == -1, fail)
          self.assert_(not os.path.exists(core.config['xrootd.pid-file']),
                       'Xrootd server PID file still present')
  
Fix test if server started in xrootd cleanup code
## Code Before:
import os
import osgtest.library.core as core
import osgtest.library.files as files
import osgtest.library.osgunittest as osgunittest
import unittest

class TestStopXrootd(osgunittest.OSGTestCase):

    def test_01_stop_xrootd(self):
        if (core.config['xrootd.gsi'] == "ON") and (core.state['xrootd.backups-exist'] == True):
            files.restore('/etc/xrootd/xrootd-clustered.cfg',"xrootd")
            files.restore('/etc/xrootd/auth_file',"xrootd")
            files.restore('/etc/grid-security/xrd/xrdmapfile',"xrootd")
        core.skip_ok_unless_installed('xrootd')
        self.skip_ok_if(['xrootd.started-server'] == False, 'did not start server')

        command = ('service', 'xrootd', 'stop')
        stdout, _, fail = core.check_system(command, 'Stop Xrootd server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(not os.path.exists(core.config['xrootd.pid-file']),
                     'Xrootd server PID file still present')

## Instruction:
Fix test if server started in xrootd cleanup code
## Code After:
import os
import osgtest.library.core as core
import osgtest.library.files as files
import osgtest.library.osgunittest as osgunittest
import unittest

class TestStopXrootd(osgunittest.OSGTestCase):

    def test_01_stop_xrootd(self):
        if (core.config['xrootd.gsi'] == "ON") and (core.state['xrootd.backups-exist'] == True):
            files.restore('/etc/xrootd/xrootd-clustered.cfg',"xrootd")
            files.restore('/etc/xrootd/auth_file',"xrootd")
            files.restore('/etc/grid-security/xrd/xrdmapfile',"xrootd")
        core.skip_ok_unless_installed('xrootd')
        self.skip_ok_if(core.state['xrootd.started-server'] == False, 'did not start server')

        command = ('service', 'xrootd', 'stop')
        stdout, _, fail = core.check_system(command, 'Stop Xrootd server')
        self.assert_(stdout.find('FAILED') == -1, fail)
        self.assert_(not os.path.exists(core.config['xrootd.pid-file']),
                     'Xrootd server PID file still present')
