Coverage for tests / test_slurmPlugin.py: 26%
48 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-07 01:40 -0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-07 01:40 -0800
1#
2# This file is part of daf_execute.
3#
4# Developed for the LSST Data Management System.
5# LSST Data Management System
6# Copyright 2008-2012 LSST Corporation.
7# This product includes software developed by the
8# LSST Project (http://www.lsst.org/).
9# # This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the LSST License Statement and
20# the GNU General Public License along with this program. If not,
21# see <http://www.lsstcorp.org/LegalNotices/>.
22#
24import os.path
25import sys
26import unittest
28import lsst.utils.tests
29from lsst.ctrl.execute.allocator import Allocator
30from lsst.ctrl.execute.allocatorParser import AllocatorParser
31from lsst.ctrl.execute.condorConfig import CondorConfig
32from lsst.ctrl.execute.namedClassFactory import NamedClassFactory
35def setup_module(module):
36 lsst.utils.tests.init()
39class SlurmPluginTest(lsst.utils.tests.TestCase):
40 def test1(self):
41 os.environ["SCRATCH"] = "/scratch/test1"
42 sys.argv = [
43 "test1",
44 "test_platform",
45 "-n",
46 "64",
47 "-c",
48 "12",
49 "-m",
50 "00:30:00",
51 "-q",
52 "normal",
53 "-O",
54 "outlog",
55 "-E",
56 "errlog",
57 "-v",
58 ]
60 al = AllocatorParser(sys.argv[0])
61 args = al.getArgs()
63 # create the plugin class
64 schedulerName = "slurm"
66 schedulerClass = NamedClassFactory.createClass("lsst.ctrl.execute." + schedulerName + "Plugin")
68 p0 = os.path.join("tests/testfiles", "config_condorInfo.py")
69 condor_info_file = p0
71 self.config = CondorConfig()
72 path = os.path.join("tests", "testfiles", "config_condor.py")
73 self.config.load(path)
74 self.assertEqual(self.config.platform.defaultRoot, "/usr")
76 self.assertTrue(schedulerClass)
77 self.assertTrue(args)
78 self.assertTrue(self.config)
79 self.assertTrue(condor_info_file)
81 platform = "test1"
82 configuration = CondorConfig()
83 p1 = os.path.join("tests/testfiles", "config_execconfig.py")
84 execConfigName = p1
85 configuration.load(execConfigName)
86 scheduler: Allocator = schedulerClass(platform, args, configuration, condor_info_file)
87 self.assertTrue(scheduler)
89 autocpus = scheduler.getAutoCPUs()
90 minautocpus = scheduler.getMinAutoCPUs()
91 cpus = scheduler.getCPUs()
92 nodes = scheduler.getNodes()
93 wallclock = scheduler.getWallClock()
94 self.assertEqual(autocpus, 16)
95 self.assertEqual(minautocpus, 15)
96 self.assertEqual(cpus, 12)
97 self.assertEqual(nodes, 64)
98 self.assertEqual(wallclock, "00:30:00")
101if __name__ == "__main__": 101 ↛ 102line 101 didn't jump to line 102 because the condition on line 101 was never true
102 lsst.utils.tests.init()
103 unittest.main()