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_r152233786
 
 

 ##########
 File path: 
tests/src/test/scala/whisk/core/containerpool/docker/test/DockerContainerTests.scala
 ##########
 @@ -429,34 +446,35 @@ class DockerContainerTests
     bb
   }
 
-  def toRawLog(log: Seq[LogLine], appendSentinel: Boolean = true): ByteBuffer 
= {
+  def toRawLog(log: Seq[LogLine], appendSentinel: Boolean = true): ByteString 
= {
     val appendedLog = if (appendSentinel) {
       val lastTime = log.lastOption.map { case LogLine(time, _, _) => time 
}.getOrElse(Instant.EPOCH.toString)
       log :+
-        LogLine(lastTime, "stderr", 
s"${DockerActionLogDriver.LOG_ACTIVATION_SENTINEL}\n") :+
-        LogLine(lastTime, "stdout", 
s"${DockerActionLogDriver.LOG_ACTIVATION_SENTINEL}\n")
+        LogLine(lastTime, "stderr", 
s"${DockerContainer.ActivationSentinel.utf8String}\n") :+
+        LogLine(lastTime, "stdout", 
s"${DockerContainer.ActivationSentinel.utf8String}\n")
     } else {
       log
     }
-    toByteBuffer(appendedLog.map(_.toJson.compactPrint).mkString("", "\n", 
"\n"))
+    ByteString(appendedLog.map(_.toJson.compactPrint).mkString("", "\n", "\n"))
   }
 
   it should "read a simple log with sentinel" in {
     val expectedLogEntry = LogLine(Instant.EPOCH.toString, "stdout", "This is 
a log entry.\n")
     val rawLog = toRawLog(Seq(expectedLogEntry), appendSentinel = true)
-    val readResults = mutable.Queue(rawLog)
 
     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(readResults.dequeue())
+        Source.single(rawLog)
       }
     }
     implicit val runc = stub[RuncApi]
 
     val container = dockerContainer(id = containerId)()
     // Read with tight limit to verify that no truncation occurs
-    val processedLogs = await(container.logs(limit = 
expectedLogEntry.log.sizeInBytes, waitForSentinel = true))
+    val processedLogs = awaitLogs(container.logs(limit = (rawLog.length + 
1).bytes, waitForSentinel = true))
 
 Review comment:
   Why `rawLog.length + 1` instead of `rawLog.length`?

----------------------------------------------------------------
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

Reply via email to