diff options
author | Googler <noreply@google.com> | 2018-07-26 10:57:36 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-07-26 10:59:00 -0700 |
commit | e2f31cb8f872d0127f8cb0a25271717806682266 (patch) | |
tree | 1ce56dcc12985b68dddb32d7e2bddb7f1bcb0a99 /src/test/java/com/google | |
parent | 5582965ba54063f26972e1591b9ff5238ed4cf4d (diff) |
Make timestamps of InternalOrderedBuildEvent immutable.
Similar to the sequence number, the timestamp should be immutable and computed when the event is enqueued (not at serialization time).
PiperOrigin-RevId: 206186036
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java b/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java index e26bb419e9..c97ac5abea 100644 --- a/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java +++ b/src/test/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceProtoUtilTest.java @@ -35,6 +35,7 @@ import com.google.devtools.build.v1.PublishLifecycleEventRequest.ServiceLevel; import com.google.devtools.build.v1.StreamId; import com.google.devtools.build.v1.StreamId.BuildComponent; import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; import com.google.protobuf.util.Timestamps; import org.junit.Test; import org.junit.runner.RunWith; @@ -63,8 +64,8 @@ public class BuildEventServiceProtoUtilTest { @Test public void testBuildEnqueued() { - long expected = clock.advanceMillis(100); - assertThat(besProtocol.buildEnqueued()) + Timestamp expected = Timestamps.fromMillis(clock.advanceMillis(100)); + assertThat(besProtocol.buildEnqueued(expected)) .isEqualTo( PublishLifecycleEventRequest.newBuilder() .setServiceLevel(ServiceLevel.INTERACTIVE) @@ -78,15 +79,15 @@ public class BuildEventServiceProtoUtilTest { .setSequenceNumber(1) .setEvent( BuildEvent.newBuilder() - .setEventTime(Timestamps.fromMillis(expected)) + .setEventTime(expected) .setBuildEnqueued(BuildEnqueued.newBuilder()))) .build()); } @Test public void testInvocationAttemptStarted() { - long expected = clock.advanceMillis(100); - assertThat(besProtocol.invocationStarted()) + Timestamp expected = Timestamps.fromMillis(clock.advanceMillis(100)); + assertThat(besProtocol.invocationStarted(expected)) .isEqualTo( PublishLifecycleEventRequest.newBuilder() .setServiceLevel(ServiceLevel.INTERACTIVE) @@ -101,7 +102,7 @@ public class BuildEventServiceProtoUtilTest { .setSequenceNumber(1) .setEvent( BuildEvent.newBuilder() - .setEventTime(Timestamps.fromMillis(expected)) + .setEventTime(expected) .setInvocationAttemptStarted( InvocationAttemptStarted.newBuilder().setAttemptNumber(1)))) .build()); @@ -109,8 +110,8 @@ public class BuildEventServiceProtoUtilTest { @Test public void testInvocationAttemptFinished() { - long expected = clock.advanceMillis(100); - assertThat(besProtocol.invocationFinished(Result.COMMAND_SUCCEEDED)) + Timestamp expected = Timestamps.fromMillis(clock.advanceMillis(100)); + assertThat(besProtocol.invocationFinished(expected, Result.COMMAND_SUCCEEDED)) .isEqualTo( PublishLifecycleEventRequest.newBuilder() .setServiceLevel(ServiceLevel.INTERACTIVE) @@ -125,7 +126,7 @@ public class BuildEventServiceProtoUtilTest { .setSequenceNumber(2) .setEvent( BuildEvent.newBuilder() - .setEventTime(Timestamps.fromMillis(expected)) + .setEventTime(expected) .setInvocationAttemptFinished( InvocationAttemptFinished.newBuilder() .setInvocationStatus( @@ -136,8 +137,8 @@ public class BuildEventServiceProtoUtilTest { @Test public void testBuildFinished() { - long expected = clock.advanceMillis(100); - assertThat(besProtocol.buildFinished(Result.COMMAND_SUCCEEDED)) + Timestamp expected = Timestamps.fromMillis(clock.advanceMillis(100)); + assertThat(besProtocol.buildFinished(expected, Result.COMMAND_SUCCEEDED)) .isEqualTo( PublishLifecycleEventRequest.newBuilder() .setServiceLevel(ServiceLevel.INTERACTIVE) @@ -151,7 +152,7 @@ public class BuildEventServiceProtoUtilTest { .setSequenceNumber(2) .setEvent( BuildEvent.newBuilder() - .setEventTime(Timestamps.fromMillis(expected)) + .setEventTime(expected) .setBuildFinished( BuildFinished.newBuilder() .setStatus( @@ -162,9 +163,9 @@ public class BuildEventServiceProtoUtilTest { @Test public void testStreamEvents() { - long firstEventTimestamp = clock.advanceMillis(100); + Timestamp firstEventTimestamp = Timestamps.fromMillis(clock.advanceMillis(100)); Any anything = Any.getDefaultInstance(); - assertThat(besProtocol.bazelEvent(1, anything)) + assertThat(besProtocol.bazelEvent(1, firstEventTimestamp, anything)) .isEqualTo( PublishBuildToolEventStreamRequest.newBuilder() .addAllNotificationKeywords(EXPECTED_KEYWORDS) @@ -178,13 +179,13 @@ public class BuildEventServiceProtoUtilTest { .setSequenceNumber(1) .setEvent( BuildEvent.newBuilder() - .setEventTime(Timestamps.fromMillis(firstEventTimestamp)) + .setEventTime(firstEventTimestamp) .setBazelEvent(anything)) .build()) .build()); - long secondEventTimestamp = clock.advanceMillis(100); - assertThat(besProtocol.bazelEvent(2, anything)) + Timestamp secondEventTimestamp = Timestamps.fromMillis(clock.advanceMillis(100)); + assertThat(besProtocol.bazelEvent(2, secondEventTimestamp, anything)) .isEqualTo( PublishBuildToolEventStreamRequest.newBuilder() .setOrderedBuildEvent( @@ -197,13 +198,13 @@ public class BuildEventServiceProtoUtilTest { .setSequenceNumber(2) .setEvent( BuildEvent.newBuilder() - .setEventTime(Timestamps.fromMillis(secondEventTimestamp)) + .setEventTime(secondEventTimestamp) .setBazelEvent(anything)) .build()) .build()); - long thirdEventTimestamp = clock.advanceMillis(100); - assertThat(besProtocol.streamFinished(3)) + Timestamp thirdEventTimestamp = Timestamps.fromMillis(clock.advanceMillis(100)); + assertThat(besProtocol.streamFinished(3, thirdEventTimestamp)) .isEqualTo( PublishBuildToolEventStreamRequest.newBuilder() .setOrderedBuildEvent( @@ -216,7 +217,7 @@ public class BuildEventServiceProtoUtilTest { .setSequenceNumber(3) .setEvent( BuildEvent.newBuilder() - .setEventTime(Timestamps.fromMillis(thirdEventTimestamp)) + .setEventTime(thirdEventTimestamp) .setComponentStreamFinished( BuildComponentStreamFinished.newBuilder() .setType(FinishType.FINISHED))) |