Comments (3)
For you interest, I made a workaround for this problem creating a LogLineReciever that can also be used as readyChecker.
import com.whisk.docker.{DockerCommandExecutor, DockerContainerState, DockerReadyChecker, LogLineReceiver}
import grizzled.slf4j.Logging
import scala.concurrent.{ExecutionContext, Promise}
class BufferingLogLineReceiver(linesToKeep: Int = 100) extends LogLineReceiver(true, _ => {}) with Logging {
import BufferingLogLineReceiver._
private var buffer = Vector.empty[String]
private var checkers: List[String => Unit] = List.empty
override val f = (logLine: String) => {
addToBuffer(logLine)
callCheckers(logLine)
}
private def addToBuffer(content: String): Unit = {
buffer = (buffer ++ content.split("\n")) takeRight linesToKeep
}
private def callCheckers(content: String): Unit = {
checkers.foreach(_.apply(content))
}
def printAsError(): Unit = {
if (buffer.length == linesToKeep) {
error(s"${buffer.mkString("\n")}\n...}")
} else {
error(buffer.mkString("\n"))
}
}
def logLineContains(partOfLine: String): DockerReadyChecker = {
val checker = new SimpleContainsLineReadyCheck(partOfLine)
checkers = checkers :+ checker.checkLine _
//process already collected buffer
buffer.foreach(checker.checkLine)
checker
}
}
object BufferingLogLineReceiver {
private class SimpleContainsLineReadyCheck(partOfLine: String) extends DockerReadyChecker {
val complete: Promise[Boolean] = Promise()
override def apply(container: DockerContainerState)(implicit docker: DockerCommandExecutor, ec: ExecutionContext) = {
complete.future
}
def checkLine(line: String): Unit = {
if(line.toLowerCase.contains(partOfLine.toLowerCase)) {
complete.trySuccess(true)
}
}
}
}
Hope it helps you for now.
from docker-it-scala.
I think that LogLineReceiver is limited and the same time not properly working abstraction. I've just created #93 to address it in new version.
from docker-it-scala.
Defienietly easier to just log it during checking:
case class LogLineAndCheckContains(str: String) extends DockerReadyChecker {
override def apply(container: DockerContainerState)(implicit docker: DockerCommandExecutor,
ec: ExecutionContext): Future[Boolean] = {
for {
id <- container.id
_ <- docker.withLogStreamLinesRequirement(id, withErr = true) {
s =>
print(s)
s.contains(str)
}
} yield {
true
}
}
}
from docker-it-scala.
Related Issues (20)
- Missing support for running container in privileged mode HOT 1
- Concurrency issues on logs
- No support for UDP?
- Timeout or Race condition resulting in Cannot run all required containers HOT 1
- Shutdown connection before running tests HOT 1
- Pulling image timeout gives an error message about not being able to pull windows image
- Publish v0.9.7 for 2.11 ? HOT 1
- Plans to publish a jar with shaded spotify docker-client? HOT 8
- Setup steps unclear HOT 2
- PostgresServiceSpec fails with driver libraries from 42 HOT 1
- Allow pausing/unpausing of containers in DockerExecutor
- Release for Scala 2.13 HOT 5
- run unpublished docker image with whisk labs docker-it-scala HOT 1
- Incompatible with ScalaTest's AsyncTestSuite
- Issues with SBT 1.3.x
- An image without a tag pulls all tags
- Persisting container across multiple test classes
- withUnlinkedDependencies not starting dependent container
- DockerContainer should have an option to configure withIpv6Address and withExtraHosts
- Missing release for docker-testkit-impl-docker-java 0.11.0 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-it-scala.