|
1 | 1 | from itertools import zip_longest
|
| 2 | +from diraccfg import CFG |
2 | 3 |
|
3 | 4 | import pytest
|
4 | 5 | from unittest.mock import MagicMock
|
5 | 6 |
|
| 7 | +from DIRAC import gConfig |
| 8 | +from DIRAC.ConfigurationSystem.Client import ConfigurationData |
6 | 9 | from DIRAC.ConfigurationSystem.Client.Helpers.Resources import (
|
7 | 10 | getDIRACPlatform,
|
8 | 11 | getCompatiblePlatforms,
|
9 | 12 | _platformSortKey,
|
| 13 | + getQueue, |
10 | 14 | )
|
11 | 15 |
|
12 | 16 |
|
@@ -122,3 +126,79 @@ def test_getCompatiblePlatforms(mocker, mockGCReplyInput, requested, expectedRes
|
122 | 126 | assert res["OK"] is expectedRes, res
|
123 | 127 | if expectedRes:
|
124 | 128 | assert set(res["Value"]) == set(expectedValue), res["Value"]
|
| 129 | + |
| 130 | + |
| 131 | +config = """ |
| 132 | +Resources |
| 133 | +{ |
| 134 | + Sites |
| 135 | + { |
| 136 | + LHCb |
| 137 | + { |
| 138 | + LHCb.CERN.cern |
| 139 | + { |
| 140 | + CEs |
| 141 | + { |
| 142 | + ce1.cern.ch |
| 143 | + { |
| 144 | + CEType = AREX |
| 145 | + architecture = x86_64 |
| 146 | + OS = linux_CentOS_7.9.2009 |
| 147 | + Tag = Token |
| 148 | + Queues |
| 149 | + { |
| 150 | + nordugrid-SLURM-grid |
| 151 | + { |
| 152 | + SI00 = 2775 |
| 153 | + MaxRAM = 128534 |
| 154 | + CPUTime = 3836159 |
| 155 | + maxCPUTime = 5760 |
| 156 | + Tag = MultiProcessor |
| 157 | + MaxWaitingJobs = 10 |
| 158 | + MaxTotalJobs = 200 |
| 159 | + LocalCEType = Pool/Singularity |
| 160 | + OS = linux_AlmaLinux_9.4.2104 |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + } |
| 165 | + } |
| 166 | + } |
| 167 | + } |
| 168 | +} |
| 169 | +""" |
| 170 | + |
| 171 | + |
| 172 | +def test_getQueue(): |
| 173 | + """Test getQueue function.""" |
| 174 | + |
| 175 | + # Set up the configuration file |
| 176 | + ConfigurationData.localCFG = CFG() |
| 177 | + cfg = CFG() |
| 178 | + cfg.loadFromBuffer(config) |
| 179 | + gConfig.loadCFG(cfg) |
| 180 | + |
| 181 | + # Test getQueue |
| 182 | + site = "LHCb.CERN.cern" |
| 183 | + ce = "ce1.cern.ch" |
| 184 | + queue = "nordugrid-SLURM-grid" |
| 185 | + |
| 186 | + result = getQueue(site, ce, queue) |
| 187 | + assert result["OK"] |
| 188 | + |
| 189 | + expectedDict = { |
| 190 | + "CEType": "AREX", |
| 191 | + "Queue": "nordugrid-SLURM-grid", |
| 192 | + "architecture": "x86_64", |
| 193 | + "SI00": "2775", |
| 194 | + "MaxRAM": "128534", |
| 195 | + "CPUTime": "3836159", |
| 196 | + "maxCPUTime": "5760", |
| 197 | + "Tag": ["MultiProcessor", "Token"], |
| 198 | + "MaxWaitingJobs": "10", |
| 199 | + "MaxTotalJobs": "200", |
| 200 | + "LocalCEType": "Pool/Singularity", |
| 201 | + "OS": "linux_AlmaLinux_9.4.2104", |
| 202 | + } |
| 203 | + |
| 204 | + assert result["Value"] == expectedDict |
0 commit comments