aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-11-21 02:31:25 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-21 02:32:41 -0800
commit0fd76922d60bd1a39dd57d56b42c94edc2674243 (patch)
tree7b872d3aedf1968afb6b268708edb27b27fb0dcb /src/test
parent6d8b8440d5b013e38827c7ed5c065c52ebe5c7ec (diff)
UI: distinguish executing actions
When showing the current actions, the most interesting are those that are currently being executed, not those that are waiting for resources or otherwise in the process of being scheduled. Therefore, show the executing actions at the top of the list. Also add more visual hints to distinguish executing from non executing actions. Screenshot (14:51:21) [160 / 230] 32 actions, 11 running Compiling lotsofwork/true986.c; 0s linux-sandbox Compiling lotsofwork/true982.c; 0s linux-sandbox Compiling lotsofwork/true983.c; 0s linux-sandbox Executing genrule //lotsofwork:true975_c; 0s linux-sandbox Compiling lotsofwork/true981.c; 0s linux-sandbox Linking lotsofwork/true_999; 0s linux-sandbox Linking lotsofwork/true_996; 0s linux-sandbox Linking lotsofwork/true_998; 0s linux-sandbox Compiling lotsofwork/true980.c; 0s linux-sandbox Compiling lotsofwork/true98.c; 0s linux-sandbox Executing genrule //lotsofwork:true974_c; 0s linux-sandbox [Sched] Creating runfiles tree bazel-out/k8-fastbuild/bin/lotsofwork/true_974.runfiles [Sched] Linking lotsofwork/true_997 [Sched] Linking lotsofwork/true_995 [Sched] Linking lotsofwork/true_99 [Sched] Linking lotsofwork/true_991 ... Improves on #4089. Change-Id: I1bc6636d5e53a16151023bba595e38259eb1ac88 PiperOrigin-RevId: 176483192
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
index d827f64b4c..6307ff8169 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
@@ -557,6 +557,113 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase {
}
@Test
+ public void testStatusShown() throws Exception {
+ // Verify that for non-executing actions, at least the first 3 characters of the
+ // status are shown.
+ // Also verify that the number of running actions is reported correctly, if there is
+ // more than one active action and not all are running.
+ ManualClock clock = new ManualClock();
+ clock.advanceMillis(120000);
+ ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
+ Action actionFoo = mockAction("Building foo", "foo/foo");
+ ActionOwner ownerFoo = Mockito.mock(ActionOwner.class);
+ when(actionFoo.getOwner()).thenReturn(ownerFoo);
+ Action actionBar = mockAction("Building bar", "bar/bar");
+ ActionOwner ownerBar = Mockito.mock(ActionOwner.class);
+ when(actionBar.getOwner()).thenReturn(ownerBar);
+ LoggingTerminalWriter terminalWriter;
+ String output;
+
+ // Action foo being analyzed.
+ stateTracker.actionStarted(new ActionStartedEvent(actionFoo, 123456700));
+ stateTracker.actionStatusMessage(ActionStatusMessage.analysisStrategy(actionFoo));
+
+ terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/ true);
+ stateTracker.writeProgressBar(terminalWriter);
+ output = terminalWriter.getTranscript();
+ assertWithMessage("Action foo being analyzed should be visible in output:\n" + output)
+ .that(output.contains("ana") || output.contains("Ana"))
+ .isTrue();
+
+ // Then action bar gets scheduled.
+ stateTracker.actionStarted(new ActionStartedEvent(actionBar, 123456701));
+ stateTracker.actionStatusMessage(ActionStatusMessage.schedulingStrategy(actionBar));
+
+ terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/ true);
+ stateTracker.writeProgressBar(terminalWriter);
+ output = terminalWriter.getTranscript();
+ assertWithMessage("Action bar being scheduled should be visible in output:\n" + output)
+ .that(output.contains("sch") || output.contains("Sch"))
+ .isTrue();
+ assertWithMessage("Action foo being analyzed should still be visible in output:\n" + output)
+ .that(output.contains("ana") || output.contains("Ana"))
+ .isTrue();
+ assertWithMessage("Indication at no actions are running is missing in output:\n" + output)
+ .that(output.contains("0 running"))
+ .isTrue();
+ assertWithMessage("Total number of actions expected in output:\n" + output)
+ .that(output.contains("2 actions"))
+ .isTrue();
+
+ // Then foo starts.
+ stateTracker.actionStatusMessage(ActionStatusMessage.runningStrategy(actionFoo, "xyz-sandbox"));
+ stateTracker.writeProgressBar(terminalWriter);
+
+ terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/ true);
+ stateTracker.writeProgressBar(terminalWriter);
+ output = terminalWriter.getTranscript();
+ assertWithMessage("Action foo's xyz-sandbox strategy should be shown in output:\n" + output)
+ .that(output.contains("xyz-sandbox"))
+ .isTrue();
+ assertWithMessage("Action foo should no longer be analyzed in output:\n" + output)
+ .that(output.contains("ana") || output.contains("Ana"))
+ .isFalse();
+ assertWithMessage("Action bar being scheduled should still be visible in output:\n" + output)
+ .that(output.contains("sch") || output.contains("Sch"))
+ .isTrue();
+ assertWithMessage("Indication at one action is running is missing in output:\n" + output)
+ .that(output.contains("1 running"))
+ .isTrue();
+ assertWithMessage("Total number of actions expected in output:\n" + output)
+ .that(output.contains("2 actions"))
+ .isTrue();
+ }
+
+ @Test
+ public void testExecutingActionsFirst() throws Exception {
+ // Verify that executing actions, even if started late, are visible.
+ ManualClock clock = new ManualClock();
+ ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
+ clock.advanceMillis(120000);
+
+ for (int i = 0; i < 30; i++) {
+ Action action = mockAction("Takes long to schedule number " + i, "long/startup" + i);
+ ActionOwner owner = Mockito.mock(ActionOwner.class);
+ when(action.getOwner()).thenReturn(owner);
+ stateTracker.actionStarted(new ActionStartedEvent(action, 123456789 + i));
+ stateTracker.actionStatusMessage(ActionStatusMessage.schedulingStrategy(action));
+ }
+
+ for (int i = 0; i < 3; i++) {
+ Action action = mockAction("quickstart" + i, "pkg/quickstart" + i);
+ ActionOwner owner = Mockito.mock(ActionOwner.class);
+ when(action.getOwner()).thenReturn(owner);
+ stateTracker.actionStarted(new ActionStartedEvent(action, 123457000 + i));
+ stateTracker.actionStatusMessage(ActionStatusMessage.runningStrategy(action, "xyz-sandbox"));
+
+ LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/ true);
+ stateTracker.writeProgressBar(terminalWriter);
+ String output = terminalWriter.getTranscript();
+ assertWithMessage("Action quickstart" + i + " should be visible in output:\n" + output)
+ .that(output.contains("quickstart" + i))
+ .isTrue();
+ assertWithMessage("Number of running actions should be indicated in output:\n" + output)
+ .that(output.contains("" + (i + 1) + " running"))
+ .isTrue();
+ }
+ }
+
+ @Test
public void testAggregation() throws Exception {
// Assert that actions for the same test are aggregated so that an action afterwards
// is still shown.