mirror of
https://github.com/corda/corda.git
synced 2025-06-06 09:21:47 +00:00
TM-89 Moving pod log outside the temp folder (#5696)
* TM-89 creating log outside of temp folder * TM-89 reverting build.gradle changes now that the practical test worked. logs for each container can be viewed in the artifacts section
This commit is contained in:
parent
7fb404bd85
commit
cc0e92e988
@ -238,17 +238,17 @@ public class KubesTest extends DefaultTask {
|
|||||||
ByteArrayOutputStream errChannelStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream errChannelStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
CompletableFuture<Integer> waiter = new CompletableFuture<>();
|
CompletableFuture<Integer> waiter = new CompletableFuture<>();
|
||||||
File podOutput = executeBuild(namespace, numberOfPods, podIdx, podName, printOutput, stdOutOs, stdOutIs, errChannelStream, waiter);
|
File podLogsDirectory = new File(getProject().getBuildDir(), "pod-logs");
|
||||||
|
if (!podLogsDirectory.exists()) {
|
||||||
|
podLogsDirectory.mkdirs();
|
||||||
|
}
|
||||||
|
File podOutput = executeBuild(namespace, numberOfPods, podIdx, podName, podLogsDirectory, printOutput, stdOutOs, stdOutIs, errChannelStream, waiter);
|
||||||
|
|
||||||
int resCode = waiter.join();
|
int resCode = waiter.join();
|
||||||
getProject().getLogger().lifecycle("build has ended on on pod " + podName + " (" + podIdx + "/" + numberOfPods + ") with result " + resCode + " , gathering results");
|
getProject().getLogger().lifecycle("build has ended on on pod " + podName + " (" + podIdx + "/" + numberOfPods + ") with result " + resCode + " , gathering results");
|
||||||
Collection<File> binaryResults = downloadTestXmlFromPod(namespace, createdPod);
|
Collection<File> binaryResults = downloadTestXmlFromPod(namespace, createdPod);
|
||||||
getLogger().lifecycle("removing pod " + podName + " (" + podIdx + "/" + numberOfPods + ") after completed build");
|
getLogger().lifecycle("removing pod " + podName + " (" + podIdx + "/" + numberOfPods + ") after completed build");
|
||||||
File podLogsDirectory = new File(getProject().getBuildDir(), "pod-logs");
|
|
||||||
if (!podLogsDirectory.exists()) {
|
|
||||||
podLogsDirectory.mkdirs();
|
|
||||||
}
|
|
||||||
File logFileToArchive = new File(podLogsDirectory, podName + ".log");
|
File logFileToArchive = new File(podLogsDirectory, podName + ".log");
|
||||||
try (FileInputStream logIn = new FileInputStream(podOutput); FileOutputStream logOut = new FileOutputStream(logFileToArchive)) {
|
try (FileInputStream logIn = new FileInputStream(podOutput); FileOutputStream logOut = new FileOutputStream(logFileToArchive)) {
|
||||||
IOUtils.copy(logIn, logOut);
|
IOUtils.copy(logIn, logOut);
|
||||||
@ -269,6 +269,7 @@ public class KubesTest extends DefaultTask {
|
|||||||
int numberOfPods,
|
int numberOfPods,
|
||||||
int podIdx,
|
int podIdx,
|
||||||
String podName,
|
String podName,
|
||||||
|
File podLogsDirectory,
|
||||||
boolean printOutput,
|
boolean printOutput,
|
||||||
PipedOutputStream stdOutOs,
|
PipedOutputStream stdOutOs,
|
||||||
PipedInputStream stdOutIs,
|
PipedInputStream stdOutIs,
|
||||||
@ -286,7 +287,7 @@ public class KubesTest extends DefaultTask {
|
|||||||
.usingListener(execListener)
|
.usingListener(execListener)
|
||||||
.exec(getBuildCommand(numberOfPods, podIdx));
|
.exec(getBuildCommand(numberOfPods, podIdx));
|
||||||
|
|
||||||
return startLogPumping(stdOutIs, podIdx, printOutput);
|
return startLogPumping(stdOutIs, podIdx, podLogsDirectory, printOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pod buildPodRequest(String podName, PersistentVolumeClaim pvc) {
|
private Pod buildPodRequest(String podName, PersistentVolumeClaim pvc) {
|
||||||
@ -334,10 +335,11 @@ public class KubesTest extends DefaultTask {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private File startLogPumping(InputStream stdOutIs, int podIdx, boolean printOutput) throws IOException {
|
private File startLogPumping(InputStream stdOutIs, int podIdx, File podLogsDirectory, boolean printOutput) throws IOException {
|
||||||
File outputFile = Files.createTempFile("container", ".log").toFile();
|
File outputFile = new File(podLogsDirectory, "container-" + podIdx + ".log");
|
||||||
|
outputFile.createNewFile();
|
||||||
Thread loggingThread = new Thread(() -> {
|
Thread loggingThread = new Thread(() -> {
|
||||||
try (BufferedWriter out = new BufferedWriter(new FileWriter(outputFile));
|
try (BufferedWriter out = new BufferedWriter(new FileWriter(outputFile, true));
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(stdOutIs))) {
|
BufferedReader br = new BufferedReader(new InputStreamReader(stdOutIs))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user