コード例 #1
0
ファイル: test_BSS_Slurm.py プロジェクト: DriesVerachtert/tsi
    def test_submit_fail(self):
        os.chdir(basedir)
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config['tsi.submit_cmd'] = "/bin/false"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % uuid.uuid4()
        os.mkdir(uspace)
        
        msg = """#!/bin/bash
#TSI_SUBMIT
#TSI_OUTCOME_DIR %s
#TSI_USPACE_DIR %s
ENDOFMESSAGE
""" % (uspace, uspace)
                
        control_out = io.StringIO()
        connector = MockConnector.MockConnector(None, control_out, None,
                                                None, self.LOG)
        
        self.bss.submit(msg,connector, config, self.LOG)
        result = control_out.getvalue()
        print(result)
        assert "TSI_FAILED" in result
        os.chdir(cwd)
コード例 #2
0
ファイル: test_UFTP.py プロジェクト: UNICORE-EU/tsi
    def test_submit(self):
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config['tsi.submit_cmd'] = "echo 1234.server"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % int(100 * time.time())
        os.mkdir(uspace)
        msg = """#!/bin/bash
#TSI_UFTP
#TSI_USPACE_DIR %s
#TSI_OUTCOME_DIR %s
#TSI_UFTP_HOST localhost
#TSI_UFTP_PORT 54434
#TSI_UFTP_SECRET test123
#TSI_UFTP_MODE GET
#TSI_UFTP_REMOTE_FILE foo
#TSI_UFTP_LOCAL_FILE bar

""" % (uspace, uspace)
        control_source = io.BufferedReader(io.BytesIO(msg.encode("UTF-8")))
        control_in = io.TextIOWrapper(control_source)
        control_out = io.StringIO()
        connector = MockConnector.MockConnector(control_in, control_out, None,
                                                None, self.LOG)
        UFTP.uftp(msg, connector, config, self.LOG)
        result = control_out.getvalue()
        if "TSI_FAILED" in result:
            print(result)
        else:
            print("OK!")
        control_source.close()
        os.chdir(cwd)
コード例 #3
0
ファイル: test_BSS_Slurm.py プロジェクト: DriesVerachtert/tsi
    def test_submit_raw(self):
        os.chdir(basedir)
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config['tsi.submit_cmd'] = "echo 'Submitted batch job 1234'"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % uuid.uuid4()
        os.mkdir(uspace)
        with open(uspace+"/foo.sh", "w") as f:
            f.write("""#!/bin/bash
#SLURM --myopts
            """)
        
        msg = """#!/bin/bash
#TSI_SUBMIT
#TSI_JOB_MODE raw
#TSI_JOB_FILE foo.sh
#TSI_OUTCOME_DIR %s
#TSI_USPACE_DIR %s
ENDOFMESSAGE
""" % (uspace, uspace)
                
        control_out = io.StringIO()
        connector = MockConnector.MockConnector(None, control_out, None,
                                                None, self.LOG)
        
        self.bss.submit(msg,connector, config, self.LOG)
        result = control_out.getvalue()
        assert "1234" in result
        os.chdir(cwd)
コード例 #4
0
ファイル: test_BSS_Slurm.py プロジェクト: DriesVerachtert/tsi
    def test_submit_normal(self):
        os.chdir(basedir)
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config['tsi.submit_cmd'] = "echo 'Submitted batch job 1234'"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % uuid.uuid4()
        os.mkdir(uspace)
        
        msg = """#!/bin/bash
#TSI_SUBMIT
#TSI_JOB_MODE normal
#TSI_OUTCOME_DIR %s
#TSI_USPACE_DIR %s
#TSI_SCRIPT
echo "Hello World!"

ENDOFMESSAGE
""" % (uspace, uspace)
                
        control_out = io.StringIO()
        connector = MockConnector.MockConnector(None, control_out, None,
                                                None, self.LOG)
        
        self.bss.submit(msg,connector, config, self.LOG)
        result = control_out.getvalue()
        assert "1234" in result
        os.chdir(cwd)
コード例 #5
0
    def test_submit_raw(self):
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config['tsi.submit_cmd'] = "echo 1234.server"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % int(105 * time.time())
        os.mkdir(uspace)
        msg = """#!/bin/bash
#TSI_SUBMIT
#TSI_JOB_MODE raw
#TSI_JOB_FILE %s/tests/input/raw-job-file.sh

#TSI_OUTCOME_DIR %s
#TSI_USPACE_DIR %s
""" % (cwd, uspace, uspace)
        control_source = io.BufferedReader(io.BytesIO(msg.encode("UTF-8")))
        control_in = io.TextIOWrapper(control_source)
        control_out = io.StringIO()
        connector = MockConnector.MockConnector(control_in, control_out, None,
                                                None, self.LOG)
        self.bss.submit(msg, connector, config, self.LOG)
        result = control_out.getvalue()
        if "TSI_FAILED" in result:
            print(result)
        else:
            print("Submitted with ID %s" % result)
            print (uspace)
        control_source.close()
コード例 #6
0
 def setUp(self):
     # setup logger
     self.LOG = Log.Logger("tsi.testing")
     self.config = {'tsi.testing': True, 'tsi.switch_uid': False}
     TSI.setup_defaults(self.config)
     self.bss = BSS.BSS()
     self.bss.init(self.config, self.LOG)
コード例 #7
0
    def test_run_alloc_cmd(self):
        os.chdir(basedir)
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config[
            'tsi.alloc_cmd'] = "echo 'salloc: Granted job allocation 115463'"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % uuid.uuid4()
        os.mkdir(uspace)

        msg = """#!/bin/bash
#TSI_SUBMIT
#TSI_JOB_MODE allocate
#TSI_USPACE_DIR %s
#TSI_QUEUE fast
#TSI_PROJECT myproject
#TSI_NODES 4
""" % (uspace)

        control_out = io.StringIO()
        connector = MockConnector.MockConnector(None, control_out, None, None,
                                                self.LOG)

        self.bss.submit(msg, connector, config, self.LOG)
        result = control_out.getvalue()
        sleep(10)
        with open("%s/ALLOCATION_ID" % uspace) as f:
            line = f.readlines()[0]
            print("Allocation ID : %s" % line)
            self.assertTrue("115463" in line)
        os.chdir(cwd)
コード例 #8
0
ファイル: test_BSS_Slurm.py プロジェクト: DriesVerachtert/tsi
 def test_parse_details(self):
     os.chdir(basedir)
     config = {'tsi.testing': True}
     TSI.setup_defaults(config)
     with open("tests/input/details_slurm.txt", "r") as f:
         raw = f.read()
     parsed = self.bss.parse_job_details(raw)
     print(parsed)
コード例 #9
0
ファイル: test_BSS_LSF.py プロジェクト: UNICORE-EU/tsi
 def setUp(self):
     self.LOG = Log.Logger("tsi.testing")
     self.bss = lsf.BSS.BSS()
     self.config = {'tsi.testing': True,
         # mock submit cmd
         'tsi.submit_cmd': "echo 1234.server" }
     TSI.setup_defaults(self.config)
     self.bss.init(self.config, self.LOG)
コード例 #10
0
 def setUp(self):
     self.LOG = Log.Logger("tsi.testing")
     self.bss = slurm.BSS.BSS()
     self.config = {
         'tsi.testing': True,
         # mock submit/alloc cmds
         'tsi.submit_cmd': "echo 'Submitted batch job 1234'",
         'tsi.alloc_cmd': "echo 'salloc: Granted job allocation 115463'"
     }
     TSI.setup_defaults(self.config)
     self.bss.init(self.config, self.LOG)
コード例 #11
0
ファイル: test_BSS_Slurm.py プロジェクト: DriesVerachtert/tsi
 def test_report_details(self):
     os.chdir(basedir)
     config = {'tsi.testing': True}
     config['tsi.details_cmd'] = "cat "    
     TSI.setup_defaults(config)
     control_out = io.StringIO()
     connector = MockConnector.MockConnector(None, control_out, None,
                                             None, self.LOG)
     msg = "#TSI_BSSID tests/input/details_slurm.txt\n"
     self.bss.get_job_details(msg, connector, config, self.LOG)
     result = control_out.getvalue()
     print(result)
コード例 #12
0
 def setUp(self):
     # setup logger
     self.LOG = logging.getLogger("tsi.testing")
     self.LOG.setLevel(logging.INFO)
     ch = logging.StreamHandler()
     ch.setLevel(logging.DEBUG)
     formatter = logging.Formatter(
         '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
     ch.setFormatter(formatter)
     self.LOG.handlers = [ch]
     self.config = {'tsi.testing': True}
     TSI.setup_defaults(self.config)
     BecomeUser.initialize(self.config, self.LOG)
コード例 #13
0
ファイル: test_BSS_Slurm.py プロジェクト: DriesVerachtert/tsi
    def test_create_submit_script(self):
        os.chdir(basedir)
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config['tsi.submit_cmd'] = "echo 'Submitted batch job 1234'"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % uuid.uuid4()
        os.mkdir(uspace)
        msg = """#!/bin/bash
#TSI_SUBMIT
#TSI_OUTCOME_DIR %s
#TSI_USPACE_DIR %s
#TSI_STDOUT stdout
#TSI_STDERR stderr
#TSI_SCRIPT
#TSI_QUEUE fast
#TSI_PROJECT myproject
#TSI_TIME 60
#TSI_MEMORY 32
#TSI_NODES 1
#TSI_PROCESSORS_PER_NODE 64
#TSI_ARRAY 10
#TSI_ARRAY_LIMIT 2
#TSI_BSS_NODES_FILTER NONE
#TSI_JOBNAME test_job
#TSI_SCRIPT
echo "Hello World!"
sleep 3
ENDOFMESSAGE
""" % (uspace, uspace)
        submit_cmds = self.bss.create_submit_script(msg, config, self.LOG)
        self.assertTrue(self.has_directive(submit_cmds, "#SBATCH --partition", "fast"))
        self.assertTrue(self.has_directive(submit_cmds, "#SBATCH --nodes", "1"))
        self.assertTrue(self.has_directive(submit_cmds, "#SBATCH --ntasks-per-node", "64"))
        self.assertTrue(self.has_directive(submit_cmds, "#SBATCH --mem", "32"))
        self.assertTrue(self.has_directive(submit_cmds, "#SBATCH --time", "1"))
        self.assertTrue(self.has_directive(submit_cmds, "#SBATCH --array", "10%2"))
        self.assertTrue(self.has_directive(submit_cmds, "#SBATCH --account", "myproject"))
        self.assertFalse(self.has_directive(submit_cmds, "#SBATCH --constraint"))
コード例 #14
0
    def test_submit(self):
        config = {'tsi.testing': True}
        TSI.setup_defaults(config)
        # mock submit cmd
        config['tsi.submit_cmd'] = "echo 1234.server"
        cwd = os.getcwd()
        uspace = cwd + "/build/uspace-%s" % int(100 * time.time())
        os.mkdir(uspace)
        msg = """#!/bin/bash
#TSI_SUBMIT
#TSI_OUTCOME_DIR %s
#TSI_USPACE_DIR %s
#TSI_STDOUT stdout
#TSI_STDERR stderr
#TSI_SCRIPT
#TSI_QUEUE fast
#TSI_PROJECT myproject
#TSI_TIME 60
#TSI_MEMORY 32
#TSI_NODES 1
#TSI_PROCESSORS_PER_NODE 64
#TSI_ARRAY 10
#TSI_ARRAY_LIMIT 2
#TSI_JOBNAME test_job
#TSI_SCRIPT
echo "Hello World!"
sleep 3
""" % (uspace, uspace)
        submit_cmds = self.bss.create_submit_script(msg, config, self.LOG)
        print(submit_cmds)
        self.assertTrue(self.has_directive(submit_cmds, "#PBS -q", "fast"))
        self.assertTrue(
            self.has_directive(submit_cmds, "#PBS -l", "nodes=1:ppn=64"))
        self.assertTrue(
            self.has_directive(submit_cmds, "#PBS -l", "walltime=60"))
        self.assertTrue(self.has_directive(submit_cmds, "#PBS -A",
                                           "myproject"))
        self.assertTrue(self.has_directive(submit_cmds, "#PBS -t", "10%2"))
コード例 #15
0
ファイル: test_BecomeUser.py プロジェクト: UNICORE-EU/tsi
 def setUp(self):
     self.LOG = Log.Logger("tsi.testing", use_syslog=False)
     self.config = {'tsi.testing': True, "tsi.switch_uid": False}
     TSI.setup_defaults(self.config)
     BecomeUser.initialize(self.config, self.LOG)