@@ -223,6 +223,39 @@ public void testWritePoolFallBackAllPoolsInZoneFull() throws Exception {
223223
224224 assertEquals ("pool2" , selector .selectWritePool (0 ).name ());
225225 }
226+ @ Test
227+ public void testStagePoolZonePreference () throws Exception {
228+ _partitionManager .setProperties (null , Map .of ("fallback-onspace" , "yes" ));
229+ prepareCostModule (false , true , false , false );
230+
231+ FileAttributes attributes = FileAttributes .of ()
232+ .pnfsId (_pnfsId )
233+ .locations (Collections .emptyList ())
234+ .build ();
235+ StorageInfos .injectInto (_storageInfo , attributes );
236+
237+ PoolSelector selector = _poolMonitor .getPoolSelector (attributes , _protocolInfo ,
238+ null , Optional .of ("1" ), Collections .EMPTY_SET );
239+
240+ assertEquals ("pool1" , selector .selectStagePool (Optional .empty ()).name ());
241+ }
242+
243+ @ Test
244+ public void testStagePoolZoneFallback () throws Exception {
245+ _partitionManager .setProperties (null , Map .of ("fallback-onspace" , "yes" ));
246+ prepareCostModule (false , true , false , true );
247+
248+ FileAttributes attributes = FileAttributes .of ()
249+ .pnfsId (_pnfsId )
250+ .locations (Collections .emptyList ())
251+ .build ();
252+ StorageInfos .injectInto (_storageInfo , attributes );
253+
254+ PoolSelector selector = _poolMonitor .getPoolSelector (attributes , _protocolInfo ,
255+ null , Optional .of ("1" ), Collections .EMPTY_SET );
256+
257+ assertEquals ("pool2" , selector .selectStagePool (Optional .empty ()).name ());
258+ }
226259
227260 private void prepareCostModule (boolean linkPerPool ) throws Exception {
228261 prepareCostModule (linkPerPool , false );
@@ -255,7 +288,7 @@ private void prepareCostModule(boolean linkPerPool, boolean withZones, boolean p
255288 }
256289
257290 PoolManagerPoolUpMessage pool1UpMessage = new PoolManagerPoolUpMessage ("pool1" ,
258- serialId , poolMode , poolCost1 );
291+ serialId , poolMode , poolCost1 );
259292 pool1UpMessage .setHostName (_localhost );
260293
261294 if (withZones ) {
@@ -266,21 +299,25 @@ private void prepareCostModule(boolean linkPerPool, boolean withZones, boolean p
266299 envelope1 .addSourceAddress (new CellAddressCore ("pool1" ));
267300 _costModule .messageArrived (envelope1 , pool1UpMessage );
268301
302+ _selectionUnit .getPool ("pool1" ).setHsmInstances (Set .of ("osm" ));
303+
269304 if (!pool2Offline ) {
270305 PoolCostInfo poolCost2 = new PoolCostInfo ("pool2" , IoQueueManager .DEFAULT_QUEUE );
271306 poolCost2 .setSpaceUsage (100 , 20 , 30 , 50 );
272307 PoolManagerPoolUpMessage pool2UpMessage = new PoolManagerPoolUpMessage ("pool2" ,
273- serialId , poolMode , poolCost2 );
308+ serialId , poolMode , poolCost2 );
274309 pool2UpMessage .setHostName (_localhost );
275310 if (withZones ) {
276311 pool2UpMessage .setTagMap (Map .of ("zone" , "2" ));
277312 }
278313 CellMessage envelope2 = new CellMessage (new CellAddressCore ("PoolManager" ), null );
279314 envelope2 .addSourceAddress (new CellAddressCore ("pool2" ));
280315 _costModule .messageArrived (envelope2 , pool2UpMessage );
316+ _selectionUnit .getPool ("pool2" ).setHsmInstances (Set .of ("osm" ));
281317 }
282318 }
283319
320+
284321 private PoolSelector prepareHostExclusion () throws Exception {
285322 /*
286323 * Emulate the poolup message arrival on the PoolManager
0 commit comments