Skip to content

Commit

Permalink
Update scalatest (#173)
Browse files Browse the repository at this point in the history
* update scalatest to support scala 2.13

* fix cli module
  • Loading branch information
Saverio Veltri authored Oct 29, 2020
1 parent 4b6d7f6 commit d8f127a
Show file tree
Hide file tree
Showing 64 changed files with 189 additions and 138 deletions.
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ lazy val `nsdb-core` = project
.enablePlugins(AutomateHeaderPlugin)
.settings(LicenseHeader.settings: _*)
.settings(libraryDependencies ++= Dependencies.Core.libraries)
.dependsOn(`nsdb-common`)
.dependsOn(`nsdb-common` % "compile->compile;test->test")
lazy val `nsdb-http` = project
.settings(Commons.settings: _*)
.settings(PublishSettings.dontPublish: _*)
Expand Down Expand Up @@ -212,7 +212,7 @@ lazy val `nsdb-sql` = project
.settings(libraryDependencies ++= Dependencies.SQL.libraries)
.enablePlugins(AutomateHeaderPlugin)
.settings(LicenseHeader.settings: _*)
.dependsOn(`nsdb-common`)
.dependsOn(`nsdb-common` % "compile->compile;test->test")
lazy val `nsdb-java-api` = project
.settings(Commons.settings: _*)
.settings(crossPaths := false)
Expand All @@ -237,6 +237,7 @@ lazy val `nsdb-cli` = project
.enablePlugins(AutomateHeaderPlugin)
.settings(LicenseHeader.settings: _*)
.dependsOn(`nsdb-rpc`)
.dependsOn(`nsdb-common` % "compile->compile;test->test")
lazy val `nsdb-perf` = (project in file("nsdb-perf"))
.settings(Commons.settings: _*)
.settings(PublishSettings.dontPublish: _*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package io.radicalbit.nsdb.cli

import io.radicalbit.nsdb.cli.table.ASCIITableBuilder
import io.radicalbit.nsdb.common.protocol.{Bit, SQLStatementExecuted}
import org.scalatest.{Matchers, WordSpec}
import io.radicalbit.nsdb.test.NSDbSpec

import scala.util.Success

class ASCIITableBuilderSpec extends WordSpec with Matchers {
class ASCIITableBuilderSpec extends NSDbSpec {

def statementFor(res: Seq[Bit]) = SQLStatementExecuted(db = "db", namespace = "registry", metric = "people", res)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package io.radicalbit.nsdb

import akka.cluster.Cluster
import akka.remote.testconductor.RoleName
import org.scalatest.{BeforeAndAfterAll, WordSpecLike}
import org.scalatest.Matchers
import akka.remote.testkit.{MultiNodeSpec, MultiNodeSpecCallbacks}
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest.BeforeAndAfterAll

/**
* Hooks up MultiNodeSpec with ScalaTest
*/
trait STMultiNodeSpec extends MultiNodeSpecCallbacks with WordSpecLike with Matchers with BeforeAndAfterAll { this: MultiNodeSpec =>
trait STMultiNodeSpec extends MultiNodeSpecCallbacks with NSDbSpecLike with BeforeAndAfterAll { this: MultiNodeSpec =>

protected lazy val cluster: Cluster = Cluster(system)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ import io.radicalbit.nsdb.common.protocol.Bit
import io.radicalbit.nsdb.model.Location
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.protocol.MessageProtocol.Events._
import org.scalatest.{BeforeAndAfter, FlatSpecLike, Matchers}
import io.radicalbit.nsdb.test.NSDbFlatSpecLike
import org.scalatest.BeforeAndAfter

import scala.concurrent.Await
import scala.concurrent.duration._

class MetricsDataActorSpec()
extends TestKit(ActorSystem("metricsDataActorSpec"))
with ImplicitSender
with FlatSpecLike
with Matchers
with NSDbFlatSpecLike
with BeforeAndAfter {

val probe = TestProbe()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import io.radicalbit.nsdb.cluster.coordinator.mockedData.MockedData._
import io.radicalbit.nsdb.cluster.logic.LocalityReadNodesSelection
import io.radicalbit.nsdb.model.Location
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest._

import scala.concurrent.Await
Expand All @@ -43,8 +44,7 @@ abstract class AbstractReadCoordinatorSpec
.withValue("akka.log-dead-letters-during-shutdown", ConfigValueFactory.fromAnyRef("off"))
))
with ImplicitSender
with WordSpecLike
with Matchers
with NSDbSpecLike
with BeforeAndAfterAll
with WriteInterval {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import io.radicalbit.nsdb.commit_log.CommitLogWriterActor._
import io.radicalbit.nsdb.common.protocol.Bit
import io.radicalbit.nsdb.common.statement.{AbsoluteComparisonValue, Condition, DeleteSQLStatement, RangeExpression}
import io.radicalbit.nsdb.model.Location
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest.BeforeAndAfterAll

import scala.concurrent.duration._

class CommitLogCoordinatorSpec
extends TestKit(ActorSystem("CommitLogCoordinatorSpec"))
with ImplicitSender
with WordSpecLike
with Matchers
with NSDbSpecLike
with BeforeAndAfterAll {

private val commitLogCoordinatorActor = system actorOf Props[CommitLogCoordinator]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import io.radicalbit.nsdb.common.protocol.Bit
import io.radicalbit.nsdb.model.Location
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.protocol.MessageProtocol.Events.MetricInfoGot
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest._

import scala.concurrent.Await
Expand All @@ -49,8 +50,7 @@ class MetadataCoordinatorSpec
.withValue("nsdb.sharding.interval", ConfigValueFactory.fromAnyRef("60s"))
))
with ImplicitSender
with WordSpecLike
with Matchers
with NSDbSpecLike
with BeforeAndAfterEach
with BeforeAndAfterAll {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import io.radicalbit.nsdb.common.protocol._
import io.radicalbit.nsdb.common.statement.{AscOrderOperator, ListFields, SelectSQLStatement}
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.protocol.MessageProtocol.Events.{InputMapped, SelectStatementExecuted}
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest._

import scala.concurrent.Await
Expand All @@ -55,8 +56,7 @@ class RetentionSpec
.withValue("nsdb.retention.check.interval", ConfigValueFactory.fromAnyRef("50ms"))
))
with ImplicitSender
with WordSpecLike
with Matchers
with NSDbSpecLike
with BeforeAndAfterAll
with WriteInterval {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import io.radicalbit.nsdb.common.protocol._
import io.radicalbit.nsdb.model.Schema
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.protocol.MessageProtocol.Events._
import io.radicalbit.nsdb.test.NSDbFlatSpecLike
import org.scalatest._

import scala.concurrent.Await
Expand All @@ -32,8 +33,7 @@ import scala.concurrent.duration._
class SchemaCoordinatorSpec
extends TestKit(ActorSystem("SchemaCoordinatorSpec"))
with ImplicitSender
with FlatSpecLike
with Matchers
with NSDbFlatSpecLike
with OneInstancePerTest
with BeforeAndAfter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import io.radicalbit.nsdb.common.statement._
import io.radicalbit.nsdb.model.Schema
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.protocol.MessageProtocol.Events._
import org.scalatest.{Matchers, _}
import io.radicalbit.nsdb.test.NSDbSpecLike

import scala.concurrent.duration._

Expand All @@ -55,7 +55,7 @@ class FakeReadCoordinatorActor extends Actor {
}
}

trait WriteCoordinatorBehaviour { this: TestKit with WordSpecLike with Matchers =>
trait WriteCoordinatorBehaviour { this: TestKit with NSDbSpecLike =>

val probe = TestProbe()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import io.radicalbit.nsdb.common.protocol.Bit
import io.radicalbit.nsdb.model.Location
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.protocol.MessageProtocol.Events.RecordRejected
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll, Matchers, WordSpecLike}
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll}

import scala.collection.mutable
import scala.concurrent.Await
Expand Down Expand Up @@ -65,8 +66,7 @@ class WriteCoordinatorErrorsSpec
.withValue("nsdb.sharding.interval", ConfigValueFactory.fromAnyRef("5s"))
))
with ImplicitSender
with WordSpecLike
with Matchers
with NSDbSpecLike
with BeforeAndAfter
with BeforeAndAfterAll {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import akka.testkit.{ImplicitSender, TestKit}
import akka.util.Timeout
import com.typesafe.config.{ConfigFactory, ConfigValueFactory}
import io.radicalbit.nsdb.protocol.MessageProtocol.Commands._
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest._

import scala.concurrent.Await
Expand All @@ -36,8 +37,7 @@ class WriteCoordinatorSpec
.withValue("nsdb.sharding.interval", ConfigValueFactory.fromAnyRef("5s"))
))
with ImplicitSender
with WordSpecLike
with Matchers
with NSDbSpecLike
with BeforeAndAfter
with BeforeAndAfterAll
with WriteCoordinatorBehaviour {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ import java.util.UUID
import io.radicalbit.nsdb.index.StorageStrategy.Memory
import io.radicalbit.nsdb.index.{DirectorySupport, StorageStrategy}
import io.radicalbit.nsdb.model.Location
import io.radicalbit.nsdb.test.NSDbFlatSpec
import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.index.{IndexWriter, IndexWriterConfig}
import org.scalatest.{FlatSpec, Matchers, OneInstancePerTest}
import org.scalatest.OneInstancePerTest

class LocationIndexTest extends FlatSpec with Matchers with OneInstancePerTest with DirectorySupport {
class LocationIndexTest extends NSDbFlatSpec with OneInstancePerTest with DirectorySupport {

override def indexStorageStrategy: StorageStrategy = Memory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import java.util.UUID
import io.radicalbit.nsdb.common.model.MetricInfo
import io.radicalbit.nsdb.index.StorageStrategy.Memory
import io.radicalbit.nsdb.index.{DirectorySupport, StorageStrategy}
import org.scalatest.{FlatSpec, Matchers, OneInstancePerTest}
import io.radicalbit.nsdb.test.NSDbFlatSpec
import org.scalatest.OneInstancePerTest

class MetricInfoIndexTest extends FlatSpec with Matchers with OneInstancePerTest with DirectorySupport {
class MetricInfoIndexTest extends NSDbFlatSpec with OneInstancePerTest with DirectorySupport {

override def indexStorageStrategy: StorageStrategy = Memory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package io.radicalbit.nsdb.cluster.logic
import akka.cluster.metrics._
import akka.actor.Address
import io.radicalbit.nsdb.cluster.metrics.{DiskMetricsSelector, NSDbMixMetricSelector}
import org.scalatest.{Matchers, WordSpec}
import io.radicalbit.nsdb.test.NSDbSpec

/**
* only the disk metric selector is tested because the other selectors have been already accurately tested inside the akka project.
*/
class CapacityWriteNodesSelectionLogicSpec extends WordSpec with Matchers {
class CapacityWriteNodesSelectionLogicSpec extends NSDbSpec {

def akkaClusterMetric: Set[Metric] =
Set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package io.radicalbit.nsdb.cluster.logic

import io.radicalbit.nsdb.model.Location
import org.scalatest.{Matchers, WordSpec}
import io.radicalbit.nsdb.test.NSDbSpec

class LocalityReadNodesSelectionSpec extends WordSpec with Matchers {
class LocalityReadNodesSelectionSpec extends NSDbSpec {

val localityReadNodesSelection = new LocalityReadNodesSelection("this")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import akka.actor.Address
import akka.cluster.metrics.StandardMetrics._
import akka.cluster.metrics.{Metric, NodeMetrics}
import io.radicalbit.nsdb.cluster.metrics.NSDbMetrics._
import org.scalatest.{Matchers, WordSpec}
import io.radicalbit.nsdb.test.NSDbSpec
import org.scalatest.OptionValues._

class DiskMetricsSelectorSpec extends WordSpec with Matchers {
class DiskMetricsSelectorSpec extends NSDbSpec {

val emptyNode = Address("nsdb", "NSDb", "emptyNode", 2552)
val almostFullNode = Address("nsdb", "NSDb", "node1", 2552)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package io.radicalbit.nsdb.common.configuration
import com.typesafe.config.{Config, ConfigFactory}
import io.radicalbit.nsdb.common.configuration.NSDbConfig.HighLevel._
import io.radicalbit.nsdb.common.configuration.NSDbConfig.LowLevel._
import org.scalatest.{Matchers, OneInstancePerTest, WordSpec}
import io.radicalbit.nsdb.test._
import org.scalatest.OneInstancePerTest

class NSDbConfigProviderSpec extends WordSpec with Matchers with OneInstancePerTest with NSDbConfigProvider {
class NSDbConfigProviderSpec extends NSDbSpec with OneInstancePerTest with NSDbConfigProvider {

override def userDefinedConfig: Config = ConfigFactory.parseResources("nsdb-test.conf").resolve()
override def lowLevelTemplateConfig: Config = ConfigFactory.parseResources("application-test.conf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package io.radicalbit.nsdb.common.configuration
import java.math.{MathContext, RoundingMode}

import io.radicalbit.nsdb.common.NSDbNumericType
import org.scalatest.{Matchers, WordSpec}
import io.radicalbit.nsdb.test.NSDbSpec

class NSDbNumericTypeSpec extends WordSpec with Matchers {
class NSDbNumericTypeSpec extends NSDbSpec {

implicit val mathContext: MathContext = new MathContext(10, RoundingMode.HALF_UP)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2018-2020 Radicalbit S.r.l.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.radicalbit.nsdb.test

import org.scalatest.flatspec.{AnyFlatSpec, AnyFlatSpecLike}
import org.scalatest.matchers.should
import org.scalatest.wordspec.{AnyWordSpec, AnyWordSpecLike}

/**
* Mix-in scalatest [[AnyWordSpecLike]] with should matchers
*/
trait NSDbSpecLike extends AnyWordSpecLike with should.Matchers

/**
* Mix-in scalatest [[AnyFlatSpec]] with should matchers
*/
trait NSDbFlatSpec extends AnyFlatSpec with should.Matchers

/**
* Mix-in scalatest [[AnyFlatSpecLike]] with should matchers
*/
trait NSDbFlatSpecLike extends AnyFlatSpecLike with should.Matchers

/**
* Mix-in scalatest [[AnyWordSpec]] with should matchers
*/
trait NSDbSpec extends AnyWordSpec with should.Matchers
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ object StatementParserErrors {
lazy val MULTIPLE_COUNT_AGGREGATIONS = "Only one Count and one Count Distinct is allowed"
lazy val SORT_DIMENSION_NOT_IN_GROUP =
"cannot sort group by query result by a field not in group by clause"
lazy val GRACE_PERIOD_NOT_ALLOWED = "grace period clause is allowed only in temporal group by queries"
def notExistingField(field: String) = s"field $field does not exist"
lazy val GRACE_PERIOD_NOT_ALLOWED = "grace period clause is allowed only in temporal group by queries"
def notExistingField(field: String) = s"field $field does not exist"
def notExistingFields(fields: Seq[String]) = s"field [${fields.mkString(",")}] does not exist"
def nonCompatibleOperator(operator: String, dimTypeAllowed: String) =
s"cannot use $operator operator on dimension different from $dimTypeAllowed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ package io.radicalbit.nsdb.actors

import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import io.radicalbit.nsdb.test.NSDbSpecLike
import org.scalatest.BeforeAndAfterAll

class JournalServiceSpec
extends TestKit(ActorSystem("nsdb-test"))
with ImplicitSender
with WordSpecLike
with Matchers
with NSDbSpecLike
with BeforeAndAfterAll {

"A partition" when {
Expand Down
Loading

0 comments on commit d8f127a

Please sign in to comment.