Skip to content

Commit

Permalink
fix: commit check failure
Browse files Browse the repository at this point in the history
  • Loading branch information
D-D-H committed Oct 9, 2023
1 parent 411a820 commit ecb1b42
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ k8s/*.tgz
cloud/
*.tgz

bin
bin

.test-temp
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,4 @@ afterEvaluate {
jarNames.add('heap-dump-analysis-impl-' + version + '.jar')
def listFileName = 'list'
Files.writeString(depsDirPath.resolve(listFileName), jarNames.stream().collect(Collectors.joining(",")))
println depsDirPath.resolve(listFileName).toAbsolutePath().toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

import com.sun.management.HotSpotDiagnosticMXBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.eclipse.jifa.analysis.listener.ProgressListener;
import org.eclipse.jifa.hda.api.HeapDumpAnalyzer;
import org.eclipse.jifa.hda.api.Model;
import org.eclipse.jifa.hda.api.SearchType;
import org.eclipse.jifa.hdp.provider.HeapDumpAnalysisApiExecutor;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

Expand All @@ -32,19 +34,18 @@
@Slf4j
public class TestHeapDumpAnalyzerImpl {

private static Path DIRECTORY;

private static HeapDumpAnalyzer ANALYZER;

@BeforeAll
public static void init() throws Exception {
// init environment
Path heapFile = Files.createTempFile("test-heap", ".hprof").toAbsolutePath();
DIRECTORY = Files.createTempDirectory("test-heap-dir");
Path heapFile = Files.createTempFile(DIRECTORY, "test-heap", ".hprof").toAbsolutePath();
Files.delete(heapFile);
HotSpotDiagnosticMXBean platformMXBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
platformMXBean.dumpHeap(heapFile.toString(), false);
if (Files.exists(heapFile)) {
log.info("Heap dump file: {}", heapFile);
heapFile.toFile().deleteOnExit();
}
Method buildAnalyzer = HeapDumpAnalysisApiExecutor.class.getDeclaredMethod("buildAnalyzer", Path.class, Map.class, ProgressListener.class);
buildAnalyzer.setAccessible(true);
ANALYZER = (HeapDumpAnalyzer) buildAnalyzer.invoke(new HeapDumpAnalysisApiExecutor(),
Expand All @@ -53,6 +54,13 @@ public static void init() throws Exception {
ProgressListener.NoOpProgressListener);
}

@AfterAll
public static void clean() {
if (DIRECTORY != null) {
FileUtils.deleteQuietly(DIRECTORY.toFile());
}
}

@Test
public void testGetDetails() {
ANALYZER.getDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,19 @@ public class HeapDumpAnalysisApiExecutor extends AbstractApiExecutor<HeapDumpAna

String osgiWorkspace = path + "/osgi_workspace";
String osgiConfiguration = path + "/osgi_configuration";

if (Files.exists(Path.of(osgiWorkspace))) {
FileUtils.deleteQuietly(new File(osgiWorkspace));
}
if (Files.exists(Path.of(osgiConfiguration))) {
FileUtils.deleteQuietly(new File(osgiConfiguration));
}

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
FileUtils.deleteQuietly(new File(osgiWorkspace));
FileUtils.deleteQuietly(new File(osgiConfiguration));
}));

config.put(EquinoxLocations.PROP_INSTANCE_AREA_DEFAULT, osgiWorkspace);
config.put(Location.CONFIGURATION_AREA_TYPE, osgiConfiguration);

Expand Down
10 changes: 10 additions & 0 deletions gradle/java.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ java {
compile.options.compilerArgs << '-parameters'
}

def testTempPath = rootProject.projectDir.toPath().toAbsolutePath().resolve('.test-temp')
if (!testTempPath.toFile().exists()) {
testTempPath.toFile().mkdir()
}

test {
testLogging.showStandardStreams = true
useJUnitPlatform()

systemProperty 'java.io.tmpdir', testTempPath.toString()
systemProperty 'jdk.util.zip.disableZip64ExtraFieldValidation', true

finalizedBy jacocoTestReport
}

Expand Down

0 comments on commit ecb1b42

Please sign in to comment.