mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 08:53:43 -05:00
Wait one second between checks in swap test
This commit is contained in:
parent
b010622442
commit
465a39c564
1 changed files with 11 additions and 7 deletions
|
@ -83,13 +83,17 @@ public class SwapJobImplTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void waitASecond() {
|
||||
try { Thread.sleep(1 * 1000); } catch (Exception _e) {}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startingTimerAlwaysCausesASwap() {
|
||||
swapJob.lowWatermarkBytes = 16384;
|
||||
swapJob.interval = Duration.ofHours(1);
|
||||
assertEquals(0, swapJob.swaps.get());
|
||||
swapJob.start();
|
||||
while (swapJob.swaps.get() <= 0);
|
||||
do { waitASecond(); } while (swapJob.swaps.get() <= 0);
|
||||
assertTrue(swapJob.swaps.get() > 0);
|
||||
}
|
||||
|
||||
|
@ -98,7 +102,7 @@ public class SwapJobImplTest {
|
|||
swapJob.lowWatermarkBytes = 16384;
|
||||
assertEquals(0, swapJob.swaps.get());
|
||||
swapJob.start();
|
||||
while (swapJob.swaps.get() <= 1);
|
||||
do { waitASecond(); } while (swapJob.swaps.get() <= 1);
|
||||
assertTrue(swapJob.swaps.get() > 1);
|
||||
}
|
||||
|
||||
|
@ -107,7 +111,7 @@ public class SwapJobImplTest {
|
|||
swapJob.highWatermarkBytes = 65536;
|
||||
assertEquals(2, dbStore.getNumUnswappedProjects());
|
||||
swapJob.start();
|
||||
while (swapJob.swaps.get() < 1);
|
||||
do { waitASecond(); } while (swapJob.swaps.get() < 1);
|
||||
assertEquals(2, dbStore.getNumUnswappedProjects());
|
||||
}
|
||||
|
||||
|
@ -118,14 +122,14 @@ public class SwapJobImplTest {
|
|||
assertEquals(2, dbStore.getNumUnswappedProjects());
|
||||
assertEquals("proj2", dbStore.getOldestUnswappedProject());
|
||||
swapJob.start();
|
||||
while (swapJob.swaps.get() < 1);
|
||||
do { waitASecond(); } while (swapJob.swaps.get() < 1);
|
||||
assertEquals(1, dbStore.getNumUnswappedProjects());
|
||||
assertEquals("proj1", dbStore.getOldestUnswappedProject());
|
||||
assertEquals("bzip2", dbStore.getSwapCompression("proj2"));
|
||||
swapJob.restore("proj2");
|
||||
assertEquals(null, dbStore.getSwapCompression("proj2"));
|
||||
int numSwaps = swapJob.swaps.get();
|
||||
while (swapJob.swaps.get() <= numSwaps);
|
||||
do { waitASecond(); } while (swapJob.swaps.get() <= numSwaps);
|
||||
assertEquals(1, dbStore.getNumUnswappedProjects());
|
||||
assertEquals("proj2", dbStore.getOldestUnswappedProject());
|
||||
}
|
||||
|
@ -147,14 +151,14 @@ public class SwapJobImplTest {
|
|||
assertEquals(2, dbStore.getNumUnswappedProjects());
|
||||
assertEquals("proj2", dbStore.getOldestUnswappedProject());
|
||||
swapJob.start();
|
||||
while (swapJob.swaps.get() < 1);
|
||||
do { waitASecond(); } while (swapJob.swaps.get() < 1);
|
||||
assertEquals(1, dbStore.getNumUnswappedProjects());
|
||||
assertEquals("proj1", dbStore.getOldestUnswappedProject());
|
||||
assertEquals("gzip", dbStore.getSwapCompression("proj2"));
|
||||
swapJob.restore("proj2");
|
||||
assertEquals(null, dbStore.getSwapCompression("proj2"));
|
||||
int numSwaps = swapJob.swaps.get();
|
||||
while (swapJob.swaps.get() <= numSwaps);
|
||||
do { waitASecond(); } while (swapJob.swaps.get() <= numSwaps);
|
||||
assertEquals(1, dbStore.getNumUnswappedProjects());
|
||||
assertEquals("proj2", dbStore.getOldestUnswappedProject());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue