<commit_before>package com.avsystem.commons
package redis

import java.io.File

import org.apache.commons.io.FileUtils
import org.scalatest.{BeforeAndAfterAll, Suite}

import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.sys.process._

/**
  * Author: ghik
  * Created: 27/06/16.
  */
trait UsesClusterServers extends BeforeAndAfterAll with RedisProcessUtils { this: Suite =>

  val clusterDir = new File("cluster/" + System.currentTimeMillis())

  def ports: Seq[Int]

  lazy val addresses = ports.map(port => NodeAddress(port = port))
  var redisProcesses: Seq[Process] = _

  protected def prepareDirectory(): Unit

  override protected def beforeAll() = {
    super.beforeAll()
    prepareDirectory()
    redisProcesses = Await.result(Future.traverse(ports)(port => launchRedis(
      "--port", port.toString,
      "--daemonize", "no",
      "--pidfile", "redis.pid",
      "--dbfilename", "dump.rdb",
      "--dir", s"$clusterDir/$port",
      "--appendonly", "yes",
      "--appendfilename", "appendonly.aof",
      "--cluster-enabled", "yes",
      "--cluster-config-file", "nodes.conf"
    )), 10.seconds)
  }

  override protected def afterAll() = {
    Await.result(Future.traverse(ports zip redisProcesses) {
      case (port, process) => shutdownRedis(port, process)
    }, 10.seconds)
    FileUtils.deleteDirectory(clusterDir)
    super.afterAll()<commit_msg>redis process communication timeouts increased<commit_after>package com.avsystem.commons
package redis

import java.io.File

import org.apache.commons.io.FileUtils
import org.scalatest.{BeforeAndAfterAll, Suite}

import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.sys.process._

/**
  * Author: ghik
  * Created: 27/06/16.
  */
trait UsesClusterServers extends BeforeAndAfterAll with RedisProcessUtils { this: Suite =>

  val clusterDir = new File("cluster/" + System.currentTimeMillis())

  def ports: Seq[Int]

  lazy val addresses = ports.map(port => NodeAddress(port = port))
  var redisProcesses: Seq[Process] = _

  protected def prepareDirectory(): Unit

  override protected def beforeAll() = {
    super.beforeAll()
    prepareDirectory()
    redisProcesses = Await.result(Future.traverse(ports)(port => launchRedis(
      "--port", port.toString,
      "--daemonize", "no",
      "--pidfile", "redis.pid",
      "--dbfilename", "dump.rdb",
      "--dir", s"$clusterDir/$port",
      "--appendonly", "yes",
      "--appendfilename", "appendonly.aof",
      "--cluster-enabled", "yes",
      "--cluster-config-file", "nodes.conf"
    )), 60.seconds)
  }

  override protected def afterAll() = {
    Await.result(Future.traverse(ports zip redisProcesses) {
      case (port, process) => shutdownRedis(port, process)
    }, 60.seconds)
    FileUtils.deleteDirectory(clusterDir)
    super.afterAll()
{'fraction_non_alphanumeric': 0.14391014391014392, 'fraction_numerical': 0.00702000702000702, 'mean_word_length': 3.6644844517184945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2280211', 'n_tokens_mistral': 915, 'n_tokens_neox': 886, 'n_words': 191}