Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onlab.stc; |
| 17 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 18 | import com.google.common.collect.ImmutableList; |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 19 | import com.google.common.io.Files; |
Thomas Vachuska | 750ab04 | 2015-06-17 10:42:15 -0700 | [diff] [blame] | 20 | import org.eclipse.jetty.server.Server; |
| 21 | import org.eclipse.jetty.servlet.ServletHandler; |
| 22 | import org.eclipse.jetty.util.log.Logger; |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 23 | import org.onlab.stc.Coordinator.Status; |
| 24 | |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 25 | import java.io.File; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 26 | import java.io.FileInputStream; |
| 27 | import java.io.FileNotFoundException; |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 28 | import java.io.IOException; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 29 | import java.text.SimpleDateFormat; |
| 30 | import java.util.Date; |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 31 | import java.util.List; |
| 32 | import java.util.Objects; |
Thomas Vachuska | 29e8217 | 2015-08-27 11:13:59 -0700 | [diff] [blame] | 33 | import java.util.Set; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 34 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 35 | import static java.lang.System.currentTimeMillis; |
| 36 | import static org.onlab.stc.Coordinator.Status.*; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 37 | import static org.onlab.stc.Coordinator.print; |
| 38 | |
| 39 | /** |
| 40 | * Main program for executing system test coordinator. |
| 41 | */ |
| 42 | public final class Main { |
| 43 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 44 | private static final String NONE = "\u001B[0m"; |
| 45 | private static final String GRAY = "\u001B[30;1m"; |
| 46 | private static final String RED = "\u001B[31;1m"; |
| 47 | private static final String GREEN = "\u001B[32;1m"; |
| 48 | private static final String BLUE = "\u001B[36m"; |
| 49 | |
Thomas Vachuska | d542cc4 | 2015-09-11 16:15:36 -0700 | [diff] [blame] | 50 | private static final String SUCCESS_SUMMARY = |
| 51 | "%s %sPassed! %d steps succeeded%s"; |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 52 | private static final String MIXED_SUMMARY = |
| 53 | "%s%d steps succeeded; %s%d steps failed; %s%d steps skipped%s"; |
Thomas Vachuska | d542cc4 | 2015-09-11 16:15:36 -0700 | [diff] [blame] | 54 | private static final String FAILURE_SUMMARY = "%s %sFailed! " + MIXED_SUMMARY; |
| 55 | private static final String ABORTED_SUMMARY = "%s %sAborted! " + MIXED_SUMMARY; |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 56 | |
| 57 | private boolean isReported = false; |
Thomas Vachuska | 29e8217 | 2015-08-27 11:13:59 -0700 | [diff] [blame] | 58 | |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 59 | private enum Command { |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 60 | LIST, RUN, RUN_RANGE, HELP |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 63 | private final String scenarioFile; |
| 64 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 65 | private Command command = Command.HELP; |
| 66 | private String runFromPatterns = ""; |
| 67 | private String runToPatterns = ""; |
| 68 | |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 69 | private Coordinator coordinator; |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 70 | private Compiler compiler; |
Thomas Vachuska | b51b8bc | 2015-07-27 08:37:12 -0700 | [diff] [blame] | 71 | private Monitor monitor; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 72 | private Listener delegate = new Listener(); |
| 73 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 74 | private static boolean useColor = Objects.equals("true", System.getenv("stcColor")); |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 75 | private static boolean dumpLogs = Objects.equals("true", System.getenv("stcDumpLogs")); |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 76 | |
| 77 | // usage: stc [<scenario-file>] [run] |
| 78 | // usage: stc [<scenario-file>] run [from <from-patterns>] [to <to-patterns>]] |
| 79 | // usage: stc [<scenario-file>] list |
| 80 | |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 81 | // Public construction forbidden |
| 82 | private Main(String[] args) { |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 83 | this.scenarioFile = args[0]; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 84 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 85 | if (args.length <= 1 || args.length == 2 && args[1].equals("run")) { |
| 86 | command = Command.RUN; |
| 87 | } else if (args.length == 2 && args[1].equals("list")) { |
| 88 | command = Command.LIST; |
| 89 | } else if (args.length >= 4 && args[1].equals("run")) { |
| 90 | int i = 2; |
| 91 | if (args[i].equals("from")) { |
| 92 | command = Command.RUN_RANGE; |
| 93 | runFromPatterns = args[i + 1]; |
| 94 | i += 2; |
| 95 | } |
| 96 | |
| 97 | if (args.length >= i + 2 && args[i].equals("to")) { |
| 98 | command = Command.RUN_RANGE; |
| 99 | runToPatterns = args[i + 1]; |
| 100 | } |
| 101 | } |
| 102 | } |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * Main entry point for coordinating test scenario execution. |
| 106 | * |
| 107 | * @param args command-line arguments |
| 108 | */ |
| 109 | public static void main(String[] args) { |
| 110 | Main main = new Main(args); |
| 111 | main.run(); |
| 112 | } |
| 113 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 114 | // Runs the scenario processing |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 115 | private void run() { |
| 116 | try { |
| 117 | // Load scenario |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 118 | Scenario scenario = Scenario.loadScenario(new FileInputStream(scenarioFile)); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 119 | |
| 120 | // Elaborate scenario |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 121 | compiler = new Compiler(scenario); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 122 | compiler.compile(); |
| 123 | |
Thomas Vachuska | b51b8bc | 2015-07-27 08:37:12 -0700 | [diff] [blame] | 124 | // Setup the process flow coordinator |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 125 | coordinator = new Coordinator(scenario, compiler.processFlow(), |
| 126 | compiler.logDir()); |
| 127 | coordinator.addListener(delegate); |
Thomas Vachuska | 750ab04 | 2015-06-17 10:42:15 -0700 | [diff] [blame] | 128 | |
Thomas Vachuska | b51b8bc | 2015-07-27 08:37:12 -0700 | [diff] [blame] | 129 | // Prepare the GUI monitor |
| 130 | monitor = new Monitor(coordinator, compiler); |
| 131 | startMonitorServer(monitor); |
Thomas Vachuska | 750ab04 | 2015-06-17 10:42:15 -0700 | [diff] [blame] | 132 | |
Thomas Vachuska | b51b8bc | 2015-07-27 08:37:12 -0700 | [diff] [blame] | 133 | // Execute process flow |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 134 | processCommand(); |
| 135 | |
| 136 | } catch (FileNotFoundException e) { |
| 137 | print("Unable to find scenario file %s", scenarioFile); |
| 138 | } |
| 139 | } |
| 140 | |
Thomas Vachuska | 750ab04 | 2015-06-17 10:42:15 -0700 | [diff] [blame] | 141 | // Initiates a web-server for the monitor GUI. |
Thomas Vachuska | b51b8bc | 2015-07-27 08:37:12 -0700 | [diff] [blame] | 142 | private static void startMonitorServer(Monitor monitor) { |
Thomas Vachuska | 750ab04 | 2015-06-17 10:42:15 -0700 | [diff] [blame] | 143 | org.eclipse.jetty.util.log.Log.setLog(new NullLogger()); |
| 144 | Server server = new Server(9999); |
| 145 | ServletHandler handler = new ServletHandler(); |
| 146 | server.setHandler(handler); |
Thomas Vachuska | b51b8bc | 2015-07-27 08:37:12 -0700 | [diff] [blame] | 147 | MonitorWebSocketServlet.setMonitor(monitor); |
Thomas Vachuska | 750ab04 | 2015-06-17 10:42:15 -0700 | [diff] [blame] | 148 | handler.addServletWithMapping(MonitorWebSocketServlet.class, "/*"); |
| 149 | try { |
| 150 | server.start(); |
| 151 | } catch (Exception e) { |
| 152 | e.printStackTrace(); |
| 153 | } |
| 154 | } |
| 155 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 156 | // Processes the appropriate command |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 157 | private void processCommand() { |
| 158 | switch (command) { |
| 159 | case RUN: |
| 160 | processRun(); |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 161 | break; |
| 162 | case LIST: |
| 163 | processList(); |
| 164 | break; |
| 165 | case RUN_RANGE: |
| 166 | processRunRange(); |
| 167 | break; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 168 | default: |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 169 | print("Unsupported command %s", command); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 173 | // Processes the scenario 'run' command. |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 174 | private void processRun() { |
Thomas Vachuska | 1b403a5 | 2015-08-26 11:30:48 -0700 | [diff] [blame] | 175 | coordinator.reset(); |
| 176 | runCoordinator(); |
| 177 | } |
| 178 | |
| 179 | // Processes the scenario 'run' command for range of steps. |
| 180 | private void processRunRange() { |
| 181 | coordinator.reset(list(runFromPatterns), list(runToPatterns)); |
| 182 | runCoordinator(); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 185 | // Processes the scenario 'list' command. |
| 186 | private void processList() { |
| 187 | coordinator.getRecords() |
Thomas Vachuska | 0ec6ff4 | 2015-07-17 11:00:02 -0700 | [diff] [blame] | 188 | .forEach(event -> logStatus(event.time(), event.name(), event.status(), event.command())); |
Thomas Vachuska | d542cc4 | 2015-09-11 16:15:36 -0700 | [diff] [blame] | 189 | printSummary(0, false); |
Thomas Vachuska | 1b403a5 | 2015-08-26 11:30:48 -0700 | [diff] [blame] | 190 | System.exit(0); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Thomas Vachuska | 1b403a5 | 2015-08-26 11:30:48 -0700 | [diff] [blame] | 193 | // Runs the coordinator and waits for it to finish. |
| 194 | private void runCoordinator() { |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 195 | try { |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 196 | Runtime.getRuntime().addShutdownHook(new ShutdownHook()); |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 197 | coordinator.start(); |
| 198 | int exitCode = coordinator.waitFor(); |
| 199 | pause(100); // allow stdout to flush |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 200 | printSummary(exitCode, false); |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 201 | System.exit(exitCode); |
| 202 | } catch (InterruptedException e) { |
| 203 | print("Unable to execute scenario %s", scenarioFile); |
| 204 | } |
| 205 | } |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 206 | |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 207 | private synchronized void printSummary(int exitCode, boolean isAborted) { |
| 208 | if (!isReported) { |
| 209 | isReported = true; |
| 210 | Set<Step> steps = coordinator.getSteps(); |
Thomas Vachuska | d542cc4 | 2015-09-11 16:15:36 -0700 | [diff] [blame] | 211 | String duration = formatDuration((int) (coordinator.duration() / 1_000)); |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 212 | int count = steps.size(); |
| 213 | if (exitCode == 0) { |
Thomas Vachuska | d542cc4 | 2015-09-11 16:15:36 -0700 | [diff] [blame] | 214 | print(SUCCESS_SUMMARY, duration, color(SUCCEEDED), count, color(null)); |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 215 | } else { |
| 216 | long success = steps.stream().filter(s -> coordinator.getStatus(s) == SUCCEEDED).count(); |
| 217 | long failed = steps.stream().filter(s -> coordinator.getStatus(s) == FAILED).count(); |
| 218 | long skipped = steps.stream().filter(s -> coordinator.getStatus(s) == SKIPPED).count(); |
Thomas Vachuska | d542cc4 | 2015-09-11 16:15:36 -0700 | [diff] [blame] | 219 | print(isAborted ? ABORTED_SUMMARY : FAILURE_SUMMARY, duration, |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 220 | color(FAILED), color(SUCCEEDED), success, |
| 221 | color(FAILED), failed, color(SKIPPED), skipped, color(null)); |
| 222 | } |
Thomas Vachuska | 29e8217 | 2015-08-27 11:13:59 -0700 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 226 | /** |
| 227 | * Internal delegate to monitor the process execution. |
| 228 | */ |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 229 | private class Listener implements StepProcessListener { |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 230 | @Override |
Thomas Vachuska | b51b8bc | 2015-07-27 08:37:12 -0700 | [diff] [blame] | 231 | public void onStart(Step step, String command) { |
| 232 | logStatus(currentTimeMillis(), step.name(), IN_PROGRESS, command); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | @Override |
Thomas Vachuska | 8643937 | 2015-06-05 09:21:32 -0700 | [diff] [blame] | 236 | public void onCompletion(Step step, Status status) { |
Thomas Vachuska | 0ec6ff4 | 2015-07-17 11:00:02 -0700 | [diff] [blame] | 237 | logStatus(currentTimeMillis(), step.name(), status, null); |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 238 | if (dumpLogs && !(step instanceof Group) && status == FAILED) { |
| 239 | dumpLogs(step); |
| 240 | } |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | @Override |
| 244 | public void onOutput(Step step, String line) { |
| 245 | } |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 248 | // Logs the step status. |
Thomas Vachuska | 0ec6ff4 | 2015-07-17 11:00:02 -0700 | [diff] [blame] | 249 | private static void logStatus(long time, String name, Status status, String cmd) { |
| 250 | if (cmd != null) { |
| 251 | print("%s %s%s %s%s -- %s", time(time), color(status), name, action(status), color(null), cmd); |
| 252 | } else { |
| 253 | print("%s %s%s %s%s", time(time), color(status), name, action(status), color(null)); |
| 254 | } |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Thomas Vachuska | 7c5b653 | 2015-11-02 14:50:33 -0800 | [diff] [blame] | 257 | // Dumps the step logs to standard output. |
| 258 | private void dumpLogs(Step step) { |
| 259 | File logFile = new File(compiler.logDir(), step.name() + ".log"); |
| 260 | try { |
| 261 | print(">>>>>"); |
| 262 | Files.copy(logFile, System.out); |
| 263 | print("<<<<<"); |
| 264 | } catch (IOException e) { |
| 265 | print("Unable to dump log file %s", logFile.getName()); |
| 266 | } |
| 267 | } |
| 268 | |
Thomas Vachuska | 50ec1af | 2015-06-02 00:42:52 -0700 | [diff] [blame] | 269 | // Produces a description of event using the specified step status. |
| 270 | private static String action(Status status) { |
| 271 | return status == IN_PROGRESS ? "started" : |
| 272 | (status == SUCCEEDED ? "completed" : |
| 273 | (status == FAILED ? "failed" : |
| 274 | (status == SKIPPED ? "skipped" : "waiting"))); |
| 275 | } |
| 276 | |
| 277 | // Produces an ANSI escape code for color using the specified step status. |
| 278 | private static String color(Status status) { |
| 279 | if (!useColor) { |
| 280 | return ""; |
| 281 | } |
| 282 | return status == null ? NONE : |
| 283 | (status == IN_PROGRESS ? BLUE : |
| 284 | (status == SUCCEEDED ? GREEN : |
| 285 | (status == FAILED ? RED : GRAY))); |
| 286 | } |
| 287 | |
| 288 | // Produces a list from the specified comma-separated string. |
| 289 | private static List<String> list(String patterns) { |
| 290 | return ImmutableList.copyOf(patterns.split(",")); |
| 291 | } |
| 292 | |
| 293 | // Produces a formatted time stamp. |
| 294 | private static String time(long time) { |
| 295 | return new SimpleDateFormat("YYYY-MM-dd HH:mm:ss").format(new Date(time)); |
| 296 | } |
| 297 | |
| 298 | // Pauses for the specified number of millis. |
| 299 | private static void pause(int ms) { |
| 300 | try { |
| 301 | Thread.sleep(ms); |
| 302 | } catch (InterruptedException e) { |
| 303 | print("Interrupted!"); |
| 304 | } |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Thomas Vachuska | d542cc4 | 2015-09-11 16:15:36 -0700 | [diff] [blame] | 307 | // Formats time duration |
| 308 | private static String formatDuration(int totalSeconds) { |
| 309 | int seconds = totalSeconds % 60; |
| 310 | int totalMinutes = totalSeconds / 60; |
| 311 | int minutes = totalMinutes % 60; |
| 312 | int hours = totalMinutes / 60; |
| 313 | return hours > 0 ? |
| 314 | String.format("%d:%02d:%02d", hours, minutes, seconds) : |
| 315 | String.format("%d:%02d", minutes, seconds); |
| 316 | } |
| 317 | |
Thomas Vachuska | d6c965d | 2015-09-08 20:48:58 -0700 | [diff] [blame] | 318 | // Shutdown hook to report status even when aborted. |
| 319 | private class ShutdownHook extends Thread { |
| 320 | @Override |
| 321 | public void run() { |
| 322 | printSummary(1, true); |
| 323 | } |
| 324 | } |
| 325 | |
Thomas Vachuska | 750ab04 | 2015-06-17 10:42:15 -0700 | [diff] [blame] | 326 | // Logger to quiet Jetty down |
| 327 | private static class NullLogger implements Logger { |
| 328 | @Override |
| 329 | public String getName() { |
| 330 | return "quiet"; |
| 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public void warn(String msg, Object... args) { |
| 335 | } |
| 336 | |
| 337 | @Override |
| 338 | public void warn(Throwable thrown) { |
| 339 | } |
| 340 | |
| 341 | @Override |
| 342 | public void warn(String msg, Throwable thrown) { |
| 343 | } |
| 344 | |
| 345 | @Override |
| 346 | public void info(String msg, Object... args) { |
| 347 | } |
| 348 | |
| 349 | @Override |
| 350 | public void info(Throwable thrown) { |
| 351 | } |
| 352 | |
| 353 | @Override |
| 354 | public void info(String msg, Throwable thrown) { |
| 355 | } |
| 356 | |
| 357 | @Override |
| 358 | public boolean isDebugEnabled() { |
| 359 | return false; |
| 360 | } |
| 361 | |
| 362 | @Override |
| 363 | public void setDebugEnabled(boolean enabled) { |
| 364 | } |
| 365 | |
| 366 | @Override |
| 367 | public void debug(String msg, Object... args) { |
| 368 | } |
| 369 | |
| 370 | @Override |
| 371 | public void debug(Throwable thrown) { |
| 372 | } |
| 373 | |
| 374 | @Override |
| 375 | public void debug(String msg, Throwable thrown) { |
| 376 | } |
| 377 | |
| 378 | @Override |
| 379 | public Logger getLogger(String name) { |
| 380 | return this; |
| 381 | } |
| 382 | |
| 383 | @Override |
| 384 | public void ignore(Throwable ignored) { |
| 385 | } |
| 386 | } |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 387 | } |