-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pool: fix open queue flag when template defined by
queue define class
Motivation: the a hsm class queue defined as template with queue define class -expire=N -pending=M -total=B -open <hsmType> * command, then we expect that any storage class that is not explicitly defined will inherit that attributes. This not the case for `-open` option. Modification: propagate 'open' flag when a storage class queue is created from a template. Added unit test. Result: fixes storage class template propagation Ticket: #10213 Acked-by: Lea Morschel Acked-by: Paul Millar Target: master, 7.2, 7.1, 7.0, 6.2 Require-book: no Require-notes: yes (cherry picked from commit aeadc6c) Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
- Loading branch information
1 parent
7b401f1
commit 4630b7d
Showing
2 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
modules/dcache/src/test/java/org/dcache/pool/classic/StorageClassContainerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.dcache.pool.classic; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import diskCacheV111.util.CacheException; | ||
import java.util.concurrent.TimeUnit; | ||
import org.dcache.pool.nearline.NearlineStorageHandler; | ||
import org.dcache.pool.repository.CacheEntry; | ||
import org.dcache.vehicles.FileAttributes; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
public class StorageClassContainerTest { | ||
|
||
|
||
private StorageClassContainer scc; | ||
|
||
|
||
@Before | ||
public void setUp() throws Exception { | ||
|
||
scc = new StorageClassContainer(); | ||
scc.setNearlineStorageHandler(mock(NearlineStorageHandler.class)); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
} | ||
|
||
@Test | ||
public void testTemplatePropagation() throws CacheException, InterruptedException { | ||
|
||
var template1 = scc.defineStorageClass("osm1", "*"); | ||
template1.setOpen(false); | ||
template1.setExpiration(TimeUnit.SECONDS.toMillis(1)); | ||
template1.setMaxSize(2); | ||
template1.setPending(3); | ||
|
||
var template2 = scc.defineStorageClass("osm2", "*"); | ||
template2.setOpen(true); | ||
template2.setExpiration(TimeUnit.SECONDS.toMillis(4)); | ||
template2.setMaxSize(5); | ||
template2.setPending(6); | ||
|
||
var ce1 = givenCacheEntry("osm1", "test:tape"); | ||
scc.addCacheEntry(ce1); | ||
|
||
var ce2 = givenCacheEntry("osm2", "test:tape"); | ||
scc.addCacheEntry(ce2); | ||
|
||
StorageClassInfo sci1 = scc.getStorageClassInfo("osm1", "test:tape"); | ||
assertMatchTemplate(template1, sci1); | ||
|
||
StorageClassInfo sci2 = scc.getStorageClassInfo("osm2", "test:tape"); | ||
assertMatchTemplate(template2, sci2); | ||
|
||
} | ||
|
||
private void assertMatchTemplate(StorageClassInfo template, StorageClassInfo actual) { | ||
assertEquals(template.getExpiration(), actual.getExpiration()); | ||
assertEquals(template.getMaxSize(), actual.getMaxSize()); | ||
assertEquals(template.getPending(), actual.getPending()); | ||
assertEquals(template.isOpen(), actual.isOpen()); | ||
} | ||
|
||
|
||
private CacheEntry givenCacheEntry(String hsm, String storageClass) { | ||
|
||
|
||
var attr = FileAttributes.of() | ||
.storageClass(storageClass) | ||
.hsm(hsm) | ||
.build(); | ||
|
||
var ce = mock(CacheEntry.class); | ||
when(ce.getFileAttributes()).thenReturn(attr); | ||
|
||
return ce; | ||
} | ||
} |