Coverage for tests / test_slurmPlugin.py: 23%
54 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:27 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:27 +0000
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 "--nodeset",
54 "DRP",
55 "-O",
56 "outlog",
57 "-E",
58 "errlog",
59 "-v",
60 ]
62 al = AllocatorParser(sys.argv[0])
63 args = al.getArgs()
65 # create the plugin class
66 schedulerName = "slurm"
68 schedulerClass = NamedClassFactory.createClass("lsst.ctrl.execute." + schedulerName + "Plugin")
70 p0 = os.path.join("tests/testfiles", "config_condorInfo.py")
71 condor_info_file = p0
73 self.config = CondorConfig()
74 path = os.path.join("tests", "testfiles", "config_condor.py")
75 self.config.load(path)
76 self.assertEqual(self.config.platform.defaultRoot, "/usr")
78 self.assertTrue(schedulerClass)
79 self.assertTrue(args)
80 self.assertTrue(self.config)
81 self.assertTrue(condor_info_file)
83 platform = "test1"
84 configuration = CondorConfig()
85 p1 = os.path.join("tests/testfiles", "config_execconfig.py")
86 execConfigName = p1
87 configuration.load(execConfigName)
88 scheduler: Allocator = schedulerClass(platform, args, configuration, condor_info_file)
89 self.assertTrue(scheduler)
91 peakcpus = scheduler.getPeakcpus()
92 peakmemory = scheduler.getPeakmemory()
93 autocpus = scheduler.getAutoCPUs()
94 minautocpus = scheduler.getMinAutoCPUs()
95 cpus = scheduler.getCPUs()
96 nodes = scheduler.getNodes()
97 nodeset = scheduler.getNodeset()
98 wallclock = scheduler.getWallClock()
99 self.assertEqual(peakcpus, 120)
100 self.assertEqual(peakmemory, 737280)
101 self.assertEqual(autocpus, 16)
102 self.assertEqual(minautocpus, 15)
103 self.assertEqual(cpus, 12)
104 self.assertEqual(nodes, 64)
105 self.assertEqual(nodeset, "DRP")
106 self.assertEqual(wallclock, "00:30:00")
109if __name__ == "__main__": 109 ↛ 110line 109 didn't jump to line 110 because the condition on line 109 was never true
110 lsst.utils.tests.init()
111 unittest.main()