Skip to content

Commit

Permalink
Disable backup handler in tests
Browse files Browse the repository at this point in the history
We've been witnessing random test suites freezes (since ages).
We've observed that when these freezes happen, there are usually a lot of
"too many open files" errors raised by the OS.

The backup handler is a likely culprit as the IntegrationSpec is running
multiple nodes and exchanging HTLCs at a fast rate.

At least it won't hurt disabling it in tests, and will speed up the test suite.
  • Loading branch information
t-bast committed Apr 29, 2020
1 parent 0447bac commit 47ce588
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ import scala.concurrent.duration._
* @param datadir directory where eclair-core will write/read its data.
* @param overrideDefaults use this parameter to programmatically override the node configuration .
* @param seed_opt optional seed, if set eclair will use it instead of generating one and won't create a seed.dat file.
* @param db optional databases to use, if not set eclair will create the necessary databases
* @param disableBackup disable automatic database backup (to speed up tests)
*/
class Setup(datadir: File,
overrideDefaults: Config = ConfigFactory.empty(),
seed_opt: Option[ByteVector] = None,
db: Option[Databases] = None)(implicit system: ActorSystem) extends Logging {
db: Option[Databases] = None,
disableBackup: Boolean = false)(implicit system: ActorSystem) extends Logging {

implicit val timeout = Timeout(30 seconds)
implicit val formats = org.json4s.DefaultFormats
Expand Down Expand Up @@ -117,8 +120,10 @@ class Setup(datadir: File,
val feeratesPerKw = new AtomicReference[FeeratesPerKw](null)

val feeEstimator = new FeeEstimator {
// @formatter:off
override def getFeeratePerKb(target: Int): Long = feeratesPerKB.get().feePerBlock(target)
override def getFeeratePerKw(target: Int): Long = feeratesPerKw.get().feePerBlock(target)
// @formatter:on
}

val nodeParams = NodeParams.makeNodeParams(config, keyManager, initTor(), database, blockCount, feeEstimator)
Expand Down Expand Up @@ -153,7 +158,7 @@ class Setup(datadir: File,
blocks = (json \ "blocks").extract[Long]
headers = (json \ "headers").extract[Long]
chainHash <- bitcoinClient.invoke("getblockhash", 0).map(_.extract[String]).map(s => ByteVector32.fromValidHex(s)).map(_.reverse)
bitcoinVersion <- bitcoinClient.invoke("getnetworkinfo").map(json => (json \ "version")).map(_.extract[Int])
bitcoinVersion <- bitcoinClient.invoke("getnetworkinfo").map(json => json \ "version").map(_.extract[Int])
unspentAddresses <- bitcoinClient.invoke("listunspent").collect { case JArray(values) =>
values
.filter(value => (value \ "spendable").extract[Boolean])
Expand Down Expand Up @@ -270,17 +275,19 @@ class Setup(datadir: File,
implicit val timeout = Timeout(30 seconds)
new ElectrumEclairWallet(electrumWallet, nodeParams.chainHash)
}
_ = wallet.getFinalAddress.map {
case address => logger.info(s"initial wallet address=$address")
}
_ = wallet.getFinalAddress.map(address => logger.info(s"initial wallet address=$address"))
// do not change the name of this actor. it is used in the configuration to specify a custom bounded mailbox

backupHandler = system.actorOf(SimpleSupervisor.props(
BackupHandler.props(
nodeParams.db,
new File(chaindir, "eclair.sqlite.bak"),
if (config.hasPath("backup-notify-script")) Some(config.getString("backup-notify-script")) else None
), "backuphandler", SupervisorStrategy.Resume))
backupHandler = if (!disableBackup) {
system.actorOf(SimpleSupervisor.props(
BackupHandler.props(
nodeParams.db,
new File(chaindir, "eclair.sqlite.bak"),
if (config.hasPath("backup-notify-script")) Some(config.getString("backup-notify-script")) else None
), "backuphandler", SupervisorStrategy.Resume))
} else {
system.deadLetters
}
audit = system.actorOf(SimpleSupervisor.props(Auditor.props(nodeParams), "auditor", SupervisorStrategy.Resume))
register = system.actorOf(SimpleSupervisor.props(Props(new Register), "register", SupervisorStrategy.Resume))
commandBuffer = system.actorOf(SimpleSupervisor.props(Props(new CommandBuffer(nodeParams, register)), "command-buffer", SupervisorStrategy.Resume))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class IntegrationSpec extends TestKit(ActorSystem("test")) with BitcoindService
close()
}
implicit val system = ActorSystem(s"system-$name")
val setup = new Setup(datadir)
val setup = new Setup(datadir, disableBackup = true)
val kit = Await.result(setup.bootstrap, 10 seconds)
nodes = nodes + (name -> kit)
}
Expand Down

0 comments on commit 47ce588

Please sign in to comment.