diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-03 14:08:10 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-03 14:08:10 -0800 |
commit | 643ee33289bd2cb9e6afbfb09b4ed72d467ba1c2 (patch) | |
tree | c2c376a44a359544fe3d4c45eb0cc0e2ec4a7080 /framework/src/onos/utils/stc | |
parent | 46eeb79b54345bdafb6055b8ee4bad4ce8b01274 (diff) |
This updates ONOS src tree to commit id
03fa5e571cabbd001ddb1598847e1150b11c7333
Change-Id: I13b554026d6f902933e35887d29bd5fdb669c0bd
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/utils/stc')
-rw-r--r-- | framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java index bc10ec7a..ca04a7c2 100644 --- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java +++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Main.java @@ -16,13 +16,16 @@ package org.onlab.stc; import com.google.common.collect.ImmutableList; +import com.google.common.io.Files; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.util.log.Logger; import org.onlab.stc.Coordinator.Status; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -64,10 +67,12 @@ public final class Main { private String runToPatterns = ""; private Coordinator coordinator; + private Compiler compiler; private Monitor monitor; private Listener delegate = new Listener(); private static boolean useColor = Objects.equals("true", System.getenv("stcColor")); + private static boolean dumpLogs = Objects.equals("true", System.getenv("stcDumpLogs")); // usage: stc [<scenario-file>] [run] // usage: stc [<scenario-file>] run [from <from-patterns>] [to <to-patterns>]] @@ -113,7 +118,7 @@ public final class Main { Scenario scenario = Scenario.loadScenario(new FileInputStream(scenarioFile)); // Elaborate scenario - Compiler compiler = new Compiler(scenario); + compiler = new Compiler(scenario); compiler.compile(); // Setup the process flow coordinator @@ -221,7 +226,7 @@ public final class Main { /** * Internal delegate to monitor the process execution. */ - private static class Listener implements StepProcessListener { + private class Listener implements StepProcessListener { @Override public void onStart(Step step, String command) { logStatus(currentTimeMillis(), step.name(), IN_PROGRESS, command); @@ -230,6 +235,9 @@ public final class Main { @Override public void onCompletion(Step step, Status status) { logStatus(currentTimeMillis(), step.name(), status, null); + if (dumpLogs && !(step instanceof Group) && status == FAILED) { + dumpLogs(step); + } } @Override @@ -246,6 +254,18 @@ public final class Main { } } + // Dumps the step logs to standard output. + private void dumpLogs(Step step) { + File logFile = new File(compiler.logDir(), step.name() + ".log"); + try { + print(">>>>>"); + Files.copy(logFile, System.out); + print("<<<<<"); + } catch (IOException e) { + print("Unable to dump log file %s", logFile.getName()); + } + } + // Produces a description of event using the specified step status. private static String action(Status status) { return status == IN_PROGRESS ? "started" : |