-
Notifications
You must be signed in to change notification settings - Fork 144
pool: exclude p2p requests from numberOfRequestsFor count #8048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
greenc-FNAL
wants to merge
1
commit into
11.2
Choose a base branch
from
fix/11.2/RB-14628
base: 11.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
52 changes: 52 additions & 0 deletions
52
modules/dcache/src/test/java/org/dcache/pool/classic/IoQueueManagerTest.java
This file contains hidden or 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,52 @@ | ||
| package org.dcache.pool.classic; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import diskCacheV111.util.PnfsId; | ||
| import org.dcache.pool.movers.Mover; | ||
| import org.dcache.util.IoPriority; | ||
| import org.dcache.vehicles.FileAttributes; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
||
| public class IoQueueManagerTest { | ||
|
|
||
| private IoQueueManager ioQueueManager; | ||
| private PnfsId pnfsId = new PnfsId("000000000000000000000000000000000001"); | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| ioQueueManager = new IoQueueManager(); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldSumRequestsAcrossQueuesExcludingP2P() throws Exception { | ||
| // Add a regular mover to the default queue | ||
| addMover(IoQueueManager.DEFAULT_QUEUE, false); | ||
|
|
||
| // Add a P2P mover to the p2p queue | ||
| addMover(IoQueueManager.P2P_QUEUE_NAME, true); | ||
|
|
||
| // Add another regular mover to a custom queue | ||
| ioQueueManager.setQueues(new String[]{"custom"}); | ||
| addMover("custom", false); | ||
|
|
||
| // Total should be 2 (1 from default, 1 from custom, 0 from p2p) | ||
| assertEquals(2, ioQueueManager.numberOfRequestsFor(pnfsId)); | ||
| } | ||
|
|
||
| private void addMover(String queueName, boolean isP2P) throws Exception { | ||
| Mover mover = mock(Mover.class); | ||
| FileAttributes attributes = new FileAttributes(); | ||
| attributes.setPnfsId(pnfsId); | ||
| when(mover.getFileAttributes()).thenReturn(attributes); | ||
| when(mover.isPoolToPoolTransfer()).thenReturn(isP2P); | ||
|
|
||
| MoverSupplier supplier = mock(MoverSupplier.class); | ||
| when(supplier.createMover()).thenReturn(mover); | ||
|
|
||
| ioQueueManager.getOrCreateMover(queueName, "door-" + queueName + "-" + System.nanoTime(), supplier, IoPriority.REGULAR); | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
modules/dcache/src/test/java/org/dcache/pool/classic/MoverRequestSchedulerTest.java
This file contains hidden or 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,66 @@ | ||
| package org.dcache.pool.classic; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import diskCacheV111.util.PnfsId; | ||
| import org.dcache.pool.movers.Mover; | ||
| import org.dcache.util.IoPriority; | ||
| import org.dcache.vehicles.FileAttributes; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| public class MoverRequestSchedulerTest { | ||
|
|
||
| private MoverRequestScheduler scheduler; | ||
| private PnfsId pnfsId = new PnfsId("000000000000000000000000000000000001"); | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| scheduler = new MoverRequestScheduler("test-queue", 0, MoverRequestScheduler.Order.FIFO); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldCountNonP2PRequests() throws Exception { | ||
| addMover(pnfsId, false); | ||
| addMover(pnfsId, false); | ||
|
|
||
| assertEquals(2, scheduler.numberOfRequestsFor(pnfsId)); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldNotCountP2PRequests() throws Exception { | ||
| addMover(pnfsId, true); | ||
| addMover(pnfsId, false); | ||
|
|
||
| assertEquals(1, scheduler.numberOfRequestsFor(pnfsId)); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldReturnZeroWhenNoRequests() { | ||
| assertEquals(0, scheduler.numberOfRequestsFor(pnfsId)); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldNotCountRequestsForDifferentPnfsId() throws Exception { | ||
| PnfsId otherPnfsId = new PnfsId("000000000000000000000000000000000002"); | ||
| addMover(otherPnfsId, false); | ||
|
|
||
| assertEquals(0, scheduler.numberOfRequestsFor(pnfsId)); | ||
| } | ||
|
|
||
| private void addMover(PnfsId pnfsId, boolean isP2P) throws Exception { | ||
| Mover mover = mock(Mover.class); | ||
| FileAttributes attributes = new FileAttributes(); | ||
| attributes.setPnfsId(pnfsId); | ||
| when(mover.getFileAttributes()).thenReturn(attributes); | ||
| when(mover.isPoolToPoolTransfer()).thenReturn(isP2P); | ||
|
|
||
| MoverSupplier supplier = mock(MoverSupplier.class); | ||
| when(supplier.createMover()).thenReturn(mover); | ||
|
|
||
| scheduler.getOrCreateMover(supplier, "door-" + System.nanoTime(), IoPriority.REGULAR); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an unused import (
java.util.concurrent.atomic.AtomicInteger) in this new test file. Java treats unused imports as compilation errors, so it must be removed.