aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-07-10 13:08:19 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-10 14:37:11 +0200
commitfb3c57222799e50ae262b8a35f701cb8ef22e6f9 (patch)
treeffd16d0a991d6e5e59eb8d75df5d6c21153600b0 /src/test/java/com/google/devtools/build/lib
parent3d4f6d6e3640af45f62a77d379ec79b24549c61f (diff)
BEP: Positively identify the last message
Set an additional flag in the last BEP message to indicate the end of the proto sequence. While the last event is implicit from the child-relation (the sequence of protos is finished, if at least one event is seen and all announced events have occurred in the stream), an explicit marking of the last event simplifies processing. Change-Id: I6554476f975dc9e52fdb27fb3221bd27f6097ed9 PiperOrigin-RevId: 161377092
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r--src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
index a3b5b7e4e1..cda02a7eff 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/BuildEventStreamerTest.java
@@ -269,7 +269,9 @@ public class BuildEventStreamerTest extends FoundationTestCase {
@Test(timeout = 5000)
public void testSimpleStream() {
// Verify that a well-formed event is passed through and that completion of the
- // build clears the pending progress-update event.
+ // build clears the pending progress-update event. However, there is no guarantee
+ // on the order of the flushed events.
+ // Additionally, assert that the actual last event has the last_message flag set.
EventBusHandler handler = new EventBusHandler();
eventBus.register(handler);
@@ -295,8 +297,14 @@ public class BuildEventStreamerTest extends FoundationTestCase {
List<BuildEvent> finalStream = transport.getEvents();
assertThat(finalStream).hasSize(3);
- assertThat(finalStream.get(1).getEventId()).isEqualTo(BuildEventId.buildFinished());
- assertThat(finalStream.get(2).getEventId()).isEqualTo(ProgressEvent.INITIAL_PROGRESS_UPDATE);
+ assertThat(ImmutableSet.of(finalStream.get(1).getEventId(), finalStream.get(2).getEventId()))
+ .isEqualTo(
+ ImmutableSet.of(BuildEventId.buildFinished(), ProgressEvent.INITIAL_PROGRESS_UPDATE));
+
+ // verify the "last_message" flag.
+ assertThat(transport.getEventProtos().get(0).getLastMessage()).isFalse();
+ assertThat(transport.getEventProtos().get(1).getLastMessage()).isFalse();
+ assertThat(transport.getEventProtos().get(2).getLastMessage()).isTrue();
while (!handler.transportSet.isEmpty()) {
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(100));