Example #1
0
 def test_ConfigureSite(self):
     """ Test ConfigureSite command
 """
     pp = PilotParams()
     pp.configureScript = 'echo'
     cs = ConfigureSite(pp)
     self.assertEqual(cs.execute(), None)
Example #2
0
 def test_ConfigureSite ( self ):
   """ Test ConfigureSite command
   """
   pp = PilotParams()
   pp.configureScript = 'echo'
   cs = ConfigureSite( pp )
   res = cs.execute()
   self.assertEqual(res, None)
Example #3
0
  def test_ReplaceDIRACCode ( self ):
    """ Test UnpackDev command
    """
    # Set up the dev.tgz file
    os.system( 'echo 123 > 123.txt ; tar zcvf testing.tgz 123.txt ; rm -f 123.txt ' )

    # Fails if tar zxvf command fails
    pp = PilotParams()
    pp.replaceDIRACCode = 'testing.tgz'
    pp.installEnv['PYTHONPATH'] = '/some/where'
    pp.installEnv['PATH'] = '/some/where/else'
    up = ReplaceDIRACCode( pp )
    res = up.execute()
    self.assertEqual(res, None)
Example #4
0
 def test_CheckWorkerNode(self):
     """ Test CheckWorkerNode command
 """
     pp = PilotParams()
     cwn = CheckWorkerNode(pp)
     res = cwn.execute()
     self.assertEqual(res, None)
Example #5
0
    def test_ReplaceDIRACCode(self):
        """ Test UnpackDev command
    """
        # Set up the dev.tgz file
        os.system(
            'echo 123 > 123.txt ; tar zcvf testing.tgz 123.txt ; rm -f 123.txt '
        )

        # Fails if tar zxvf command fails
        pp = PilotParams()
        pp.replaceDIRACCode = 'testing.tgz'
        pp.installEnv['PYTHONPATH'] = '/some/where'
        pp.installEnv['PATH'] = '/some/where/else'
        up = ReplaceDIRACCode(pp)
        res = up.execute()
        self.assertEqual(res, None)
Example #6
0
    def test_InitJSON(self):
        """Test the pilot.json and command line parsing"""
        sys.argv[1:] = [
            "--Name", "grid1.example.com", "--commandOptions", "a=1,b=2", "-Z",
            "c=3"
        ]
        pp = PilotParams()

        self.assertEqual(pp.commands, ["x", "y", "z"])
        self.assertEqual(pp.commandExtensions,
                         ["TestExtension1", "TestExtension2"])

        self.assertEqual(pp.commandOptions["a"], "1")
        self.assertEqual(pp.commandOptions["b"], "2")
        self.assertEqual(pp.commandOptions["c"], "3")

        sys.argv[1:] = [
            "--Name",
            "grid1.example.com",
            "--commandOptions",
            "a = 1,  b=2",
            "-Z",
            " c=3",
        ]  # just some spaces
        pp = PilotParams()

        self.assertEqual(pp.commandOptions["a"], "1")
        self.assertEqual(pp.commandOptions["b"], "2")
        self.assertEqual(pp.commandOptions["c"], "3")

        sys.argv[1:] = [
            "--Name", "grid1.example.com", "--commandOptions=a = 1,  b=2",
            "-Z", " c=3"
        ]  # spaces and '=''
        pp = PilotParams()

        self.assertEqual(pp.commandOptions["a"], "1")
        self.assertEqual(pp.commandOptions["b"], "2")
        self.assertEqual(pp.commandOptions["c"], "3")
Example #7
0
    def test_InitJSON(self):
        """ Test the pilot.json and command line parsing
    """
        sys.argv[1:] = [
            '--Name', 'grid1.example.com', '--commandOptions', 'a=1,b=2', '-Z',
            'c=3'
        ]
        pp = PilotParams()

        self.assertEqual(pp.commands, ['x', 'y', 'z'])
        self.assertEqual(pp.commandExtensions,
                         ['TestExtension1', 'TestExtension2'])

        self.assertEqual(pp.commandOptions['a'], '1')
        self.assertEqual(pp.commandOptions['b'], '2')
        self.assertEqual(pp.commandOptions['c'], '3')

        sys.argv[1:] = [
            '--Name', 'grid1.example.com', '--commandOptions', 'a = 1,  b=2',
            '-Z', ' c=3'
        ]  #just some spaces
        pp = PilotParams()

        self.assertEqual(pp.commandOptions['a'], '1')
        self.assertEqual(pp.commandOptions['b'], '2')
        self.assertEqual(pp.commandOptions['c'], '3')

        sys.argv[1:] = [
            '--Name', 'grid1.example.com', '--commandOptions=a = 1,  b=2',
            '-Z', ' c=3'
        ]  #spaces and '=''
        pp = PilotParams()

        self.assertEqual(pp.commandOptions['a'], '1')
        self.assertEqual(pp.commandOptions['b'], '2')
        self.assertEqual(pp.commandOptions['c'], '3')
Example #8
0
    def test_NagiosProbes(self):
        """Test NagiosProbes command"""
        pp = PilotParams()
        nagios = NagiosProbes(pp)

        with open("Nagios1", "w") as fp:
            fp.write("#!/bin/sh\necho 123\n")

        os.chmod("Nagios1", stat.S_IRWXU)

        with open("Nagios2", "w") as fp:
            fp.write("#!/bin/sh\necho 567\n")

        os.chmod("Nagios2", stat.S_IRWXU)

        nagios.execute()

        self.assertEqual(nagios.nagiosProbes, ["Nagios1", "Nagios2"])
        self.assertEqual(nagios.nagiosPutURL, "https://127.0.0.2/")
Example #9
0
    def test_NagiosProbes(self):
        """ Test NagiosProbes command
    """
        pp = PilotParams()
        nagios = NagiosProbes(pp)

        with open('Nagios1', 'w') as fp:
            fp.write('#!/bin/sh\necho 123\n')

        os.chmod('Nagios1', stat.S_IRWXU)

        with open('Nagios2', 'w') as fp:
            fp.write('#!/bin/sh\necho 567\n')

        os.chmod('Nagios2', stat.S_IRWXU)

        nagios.execute()

        self.assertEqual(nagios.nagiosProbes, ['Nagios1', 'Nagios2'])
        self.assertEqual(nagios.nagiosPutURL, 'https://127.0.0.2/')
Example #10
0
############################
# python 2 -> 3 "hacks"
try:
    from Pilot.pilotTools import Logger, pythonPathCheck, PilotParams, getCommand
except ImportError:
    from pilotTools import Logger, pythonPathCheck, PilotParams, getCommand
############################

if __name__ == "__main__":

    pilotStartTime = int(time.time())

    log = Logger('Pilot', debugFlag=True)

    pilotParams = PilotParams()
    if pilotParams.debugFlag:
        log.setDebug()
    if pilotParams.keepPythonPath:
        pythonPathCheck()
    else:
        log.info("Clearing PYTHONPATH for child processes.")
        if "PYTHONPATH" in os.environ:
            os.environ["PYTHONPATH_SAVE"] = os.environ["PYTHONPATH"]
            os.environ["PYTHONPATH"] = ""

    pilotParams.pilotStartTime = pilotStartTime
    pilotParams.pilotRootPath = os.getcwd()
    pilotParams.pilotScript = os.path.realpath(sys.argv[0])
    pilotParams.pilotScriptName = os.path.basename(pilotParams.pilotScript)
    log.debug('PARAMETER [%s]' % ', '.join(map(str, pilotParams.optList)))
Example #11
0
 def setUp( self ):
   self.pp = PilotParams()