sven-lange-last commented on a change in pull request #2878: Streamingly read
user-logs.
URL:
https://github.com/apache/incubator-openwhisk/pull/2878#discussion_r152256277
##########
File path:
tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
##########
@@ -630,45 +610,44 @@ class DockerContainerTests
val thirdLogFirstEntry =
LogLine(Instant.EPOCH.plusMillis(4L).toString, "stdout", "This is the
first line in third log.\n")
- val firstRawLog = toRawLog(Seq(firstLogFirstEntry, firstLogSecondEntry),
appendSentinel = true)
+ val firstRawLog = toRawLog(Seq(firstLogFirstEntry, firstLogSecondEntry),
appendSentinel = false)
val secondRawLog = toRawLog(Seq(secondLogFirstEntry,
secondLogSecondEntry), appendSentinel = false)
val thirdRawLog = toRawLog(Seq(thirdLogFirstEntry), appendSentinel = true)
val returnValues = mutable.Queue(firstRawLog, secondRawLog, thirdRawLog)
implicit val docker = new TestDockerClient {
- override def rawContainerLogs(containerId: ContainerId, fromPos: Long):
Future[ByteBuffer] = {
+ override def rawContainerLogs(containerId: ContainerId,
+ fromPos: Long,
+ pollInterval: Option[FiniteDuration]):
Source[ByteString, Any] = {
rawContainerLogsInvocations += ((containerId, fromPos))
- Future.successful(returnValues.dequeue())
+ Source.single(returnValues.dequeue())
}
}
implicit val runc = stub[RuncApi]
val container = dockerContainer()()
- val processedFirstLog = await(container.logs(limit =
firstLogFirstEntry.log.sizeInBytes, waitForSentinel = true))
+ val processedFirstLog = awaitLogs(container.logs(limit =
(firstRawLog.length - 1).bytes, waitForSentinel = true))
val processedSecondLog =
- await(container.logs(limit =
secondLogFirstEntry.log.take(secondLogLimit).sizeInBytes, waitForSentinel =
false))
- val processedThirdLog = await(container.logs(limit = 1.MB, waitForSentinel
= true))
+ awaitLogs(container.logs(limit = (secondRawLog.length - 1).bytes,
waitForSentinel = false))
+ val processedThirdLog = awaitLogs(container.logs(limit = 1.MB,
waitForSentinel = true))
docker.rawContainerLogsInvocations should have size 3
val (_, fromPos1) = docker.rawContainerLogsInvocations(0)
fromPos1 shouldBe 0
val (_, fromPos2) = docker.rawContainerLogsInvocations(1)
- fromPos2 shouldBe firstRawLog.capacity() // second read should start
behind full content of first read
+ fromPos2 shouldBe firstRawLog.length // second read should start behind
full content of first read
Review comment:
If the requested limit is `firstRawLog.length - 1`, will `container.logs()`
still fully read the truncated line? It should do so to make sure that the next
`container.logs()` invocation won't start with the remainder from the truncated
line.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services