Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.microsoft.gctoolkit.integration;

import com.microsoft.gctoolkit.GCToolKit;
import com.microsoft.gctoolkit.integration.aggregation.CollectionCycleCountsSummary;
import com.microsoft.gctoolkit.integration.io.TestLogFile;
import com.microsoft.gctoolkit.io.GCLogFile;
import com.microsoft.gctoolkit.io.SingleGCLogFile;
import com.microsoft.gctoolkit.parser.GenerationalHeapParser;
import com.microsoft.gctoolkit.vertx.VertxDataSourceChannel;
import com.microsoft.gctoolkit.vertx.VertxJVMEventChannel;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.assertThrows;

@Tag("classPath")
public class DirtyDataIntegrationTest {

/**
* Test a GC log file that contains only the header but no actual events
*/
@Test
public void testNoEventLog() {
Path path = new TestLogFile("streaming/gc_no_event.log").getFile().toPath();
assertThrows(IllegalStateException.class, () -> analyze(path.toString()));
}

/**
* Test an empty file that contains nothing
*/
@Test
public void testEmptyFile() {
Path path = new TestLogFile("streaming/gc_empty.log").getFile().toPath();
assertThrows(IllegalStateException.class, () -> analyze(path.toString()));
}

public void analyze(String gcLogFile) throws IOException {
GCLogFile logFile = new SingleGCLogFile(Path.of(gcLogFile));
GCToolKit gcToolKit = new GCToolKit();

gcToolKit.loadDataSourceChannel(new VertxDataSourceChannel());
gcToolKit.loadJVMEventChannel(new VertxJVMEventChannel());
gcToolKit.loadDataSourceParser(new GenerationalHeapParser());

gcToolKit.loadAggregation(new CollectionCycleCountsSummary());

gcToolKit.analyze(logFile);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public GCLogParser() {}
public void diary(Diary diary) {
this.diary = diary;
this.clock = diary.getTimeOfFirstEvent();
if (this.clock == null) {
LOGGER.log(Level.SEVERE, "Time of first event is null, are there any events presented in the log file?");
throw new IllegalStateException("Missing log events");
}
}

/**
Expand Down
Loading