Search in sources :

Example 71 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class GridInternalTaskUnusedWalSegmentsTest method testCorrectnessOfDeletionTaskSegments.

/**
 * Tests correctness of {@link VisorWalTaskOperation}.
 *
 * @throws Exception if failed.
 */
@Test
@WithSystemProperty(key = IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, value = "2")
public void testCorrectnessOfDeletionTaskSegments() throws Exception {
    try {
        IgniteEx ig0 = (IgniteEx) startGrids(4);
        ig0.cluster().active(true);
        try (IgniteDataStreamer streamer = ig0.dataStreamer(DEFAULT_CACHE_NAME)) {
            for (int k = 0; k < 10_000; k++) streamer.addData(k, new byte[1024]);
        }
        forceCheckpoint();
        try (IgniteDataStreamer streamer = ig0.dataStreamer(DEFAULT_CACHE_NAME)) {
            for (int k = 0; k < 1_000; k++) streamer.addData(k, new byte[1024]);
        }
        forceCheckpoint();
        VisorWalTaskResult printRes = ig0.compute().execute(VisorWalTask.class, new VisorTaskArgument<>(ig0.cluster().node().id(), new VisorWalTaskArg(VisorWalTaskOperation.PRINT_UNUSED_WAL_SEGMENTS), false));
        assertEquals("Check that print task finished without exceptions", printRes.results().size(), 4);
        List<File> walArchives = new ArrayList<>();
        for (Collection<String> pathsPerNode : printRes.results().values()) {
            for (String path : pathsPerNode) walArchives.add(Paths.get(path).toFile());
        }
        VisorWalTaskResult delRes = ig0.compute().execute(VisorWalTask.class, new VisorTaskArgument<>(ig0.cluster().node().id(), new VisorWalTaskArg(VisorWalTaskOperation.DELETE_UNUSED_WAL_SEGMENTS), false));
        assertEquals("Check that delete task finished with no exceptions", delRes.results().size(), 4);
        List<File> walDeletedArchives = new ArrayList<>();
        for (Collection<String> pathsPerNode : delRes.results().values()) {
            for (String path : pathsPerNode) walDeletedArchives.add(Paths.get(path).toFile());
        }
        for (File f : walDeletedArchives) assertTrue("Checking existing of deleted WAL archived segments: " + f.getAbsolutePath(), !f.exists());
        for (File f : walArchives) assertTrue("Checking existing of WAL archived segments from print task after delete: " + f.getAbsolutePath(), !f.exists());
    } finally {
        stopAllGrids();
    }
}
Also used : VisorWalTaskArg(org.apache.ignite.internal.visor.misc.VisorWalTaskArg) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) IgniteEx(org.apache.ignite.internal.IgniteEx) VisorWalTaskResult(org.apache.ignite.internal.visor.misc.VisorWalTaskResult) ArrayList(java.util.ArrayList) File(java.io.File) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Aggregations

WithSystemProperty (org.apache.ignite.testframework.junits.WithSystemProperty)71 Test (org.junit.Test)71 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)59 IgniteEx (org.apache.ignite.internal.IgniteEx)46 Ignite (org.apache.ignite.Ignite)20 LogListener (org.apache.ignite.testframework.LogListener)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)12 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)11 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)10 File (java.io.File)9 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)8 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)8 List (java.util.List)7 IgniteCache (org.apache.ignite.IgniteCache)7 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)7 ClusterNode (org.apache.ignite.cluster.ClusterNode)7 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)7