Skip to content

Commit c3a993a

Browse files
committed
Added more tests for pe detection in sge
Refs #627
1 parent 555756d commit c3a993a

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

src/main/java/nl/esciencecenter/xenon/adaptors/schedulers/gridengine/GridEngineSetup.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ Optional<ParallelEnvironmentInfo> getSingleNodeParallelEnvironment(int coresPerN
178178
Set<String> pesOfQueue = new HashSet<>(Arrays.asList(queue.getParallelEnvironments()));
179179
stream = stream.filter(pe -> pesOfQueue.contains(pe.getName()));
180180
}
181-
return stream.findFirst();
181+
Optional<ParallelEnvironmentInfo> r = stream.findFirst();
182+
LOGGER.debug("Gridengine choose to use following pe: " + r.toString());
183+
return r;
182184
}
183185

184186
/**

src/main/java/nl/esciencecenter/xenon/adaptors/schedulers/gridengine/ParallelEnvironmentInfo.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ public String toString() {
124124
* @return True if pe can
125125
*/
126126
boolean canAllocateSingleNode(int coresPerNode) {
127-
return (
127+
boolean validAllocationRule = (
128128
allocationRule == AllocationRule.PE_SLOTS
129129
// TODO check if hosts (of queue) have that many slots
130130
) || (
131131
allocationRule == AllocationRule.INTEGER && ppn >= coresPerNode
132-
) && coresPerNode <= slots;
132+
);
133+
boolean validSlots = slots >= coresPerNode;
134+
return validAllocationRule && validSlots;
133135
}
134136

135137
/**
@@ -140,8 +142,8 @@ boolean canAllocateSingleNode(int coresPerNode) {
140142
* @return True if pe can
141143
*/
142144
boolean canAllocateMultiNode(int coresPerNode, int nodes) {
143-
return (
144-
allocationRule == AllocationRule.INTEGER && ppn == coresPerNode && coresPerNode * nodes <= slots
145-
);
145+
boolean validAllocationRule = allocationRule == AllocationRule.INTEGER && ppn == coresPerNode;
146+
boolean validSlots = slots >= coresPerNode * nodes;
147+
return validAllocationRule && validSlots;
146148
}
147149
}

src/test/java/nl/esciencecenter/xenon/adaptors/schedulers/gridengine/GridEngineSetupTest.java

+27
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
package nl.esciencecenter.xenon.adaptors.schedulers.gridengine;
1717

1818
import static org.junit.Assert.assertArrayEquals;
19+
import static org.junit.Assert.assertEquals;
1920
import static org.junit.Assert.assertFalse;
2021
import static org.junit.Assert.assertTrue;
2122

2223
import java.util.Arrays;
2324
import java.util.HashMap;
2425
import java.util.Map;
26+
import java.util.Optional;
2527
import java.util.stream.Collectors;
2628

2729
import org.junit.FixMethodOrder;
@@ -163,6 +165,31 @@ public void test_getSingleNodeParallelEnvironment_queueuabsent_peinqueues() {
163165
assertTrue(setup.getSingleNodeParallelEnvironment(4, null).isPresent());
164166
}
165167

168+
@Test
169+
public void test_getSingleNodeParallelEnvironment_peWithTooFewSlots() {
170+
GridEngineSetup setup = getGridEngineSetup(
171+
new ParallelEnvironmentInfo("smp", 1, AllocationRule.PE_SLOTS, 0)
172+
);
173+
174+
assertFalse(setup.getSingleNodeParallelEnvironment(24, null).isPresent());
175+
}
176+
177+
@Test
178+
public void test_getSingleNodeParallelEnvironment_multiplePEs() {
179+
ParallelEnvironmentInfo pe = new ParallelEnvironmentInfo("some.pe", 6000, AllocationRule.PE_SLOTS, 0);
180+
GridEngineSetup setup = getGridEngineSetup(
181+
new ParallelEnvironmentInfo("make", 1, AllocationRule.ROUND_ROBIN, 0),
182+
new ParallelEnvironmentInfo("mpi", 250, AllocationRule.ROUND_ROBIN, 0),
183+
new ParallelEnvironmentInfo("smp", 1, AllocationRule.PE_SLOTS, 0),
184+
pe
185+
);
186+
187+
Optional<ParallelEnvironmentInfo> chosenPe = setup.getSingleNodeParallelEnvironment(24, null);
188+
189+
assertTrue(chosenPe.isPresent());
190+
assertEquals(pe, chosenPe.get());
191+
}
192+
166193
@Test
167194
public void test03_qconfPeDetailsArguments() {
168195
String[] input = new String[] { "some.pe", "other.pe", "this.pe", "that.pe" };

0 commit comments

Comments
 (0)