Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 2.12 upgrade preview with mysql tests fixed #346

Merged
merged 8 commits into from
May 10, 2017
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ language: scala
sudo: false
matrix:
include:
- scala: 2.10.6
script: umask 0022 && ./sbt ++$TRAVIS_SCALA_VERSION clean test mimaReportBinaryIssues

- scala: 2.11.8
- scala: 2.11.11
jdk: oraclejdk8
script: umask 0022 && ./sbt ++$TRAVIS_SCALA_VERSION clean coverage test coverageReport mimaReportBinaryIssues
after_success:
- bash <(curl -s https://codecov.io/bash)
- scala: 2.12.2
jdk: oraclejdk8
script: umask 0022 && ./sbt ++$TRAVIS_SCALA_VERSION clean coverage test coverageReport
after_success:
- bash <(curl -s https://codecov.io/bash)
before_script:
- sleep 15 # https://docs.travis-ci.com/user/database-setup/#MongoDB
- mongo mydb_test --eval 'db.addUser("travis", "test");'
- mysql -u root -e "create database storehaus_test;"
- mysql -u root -e "create user 'storehaususer'@'localhost' identified by 'test1234';"
- mysql -u root -e "grant all on storehaus_test.* to 'storehaususer'@'localhost';"
services:
- mysql
- redis-server
- memcache
- mongodb
Expand Down
63 changes: 44 additions & 19 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,40 @@ val ignoredABIProblems = {
exclude[MissingMethodProblem]("com.twitter.storehaus.ReadThroughStore.mutex"),
exclude[MissingClassProblem]("com.twitter.storehaus.kafka.JavaFutureToTwitterFutureConverter$Closed$"),
exclude[DirectMissingMethodProblem]("com.twitter.storehaus.kafka.KafkaStore.<init>$default$3"),
exclude[MissingMethodProblem]("com.twitter.storehaus.cache.Cache.occupancy")
exclude[MissingMethodProblem]("com.twitter.storehaus.cache.Cache.occupancy"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.mysql.MySqlStore.apply"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.mysql.MySqlLongStore.apply"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.mysql.ValueMapper.toChannelBuffer"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.mysql.ValueMapper.toLong"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.mysql.ValueMapper.toString"),
exclude[IncompatibleResultTypeProblem]("com.twitter.storehaus.mysql.MySqlValue.v"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.mysql.MySqlValue.this"),
exclude[IncompatibleResultTypeProblem]("com.twitter.storehaus.mysql.MySqlStore.client"),
exclude[IncompatibleResultTypeProblem]("com.twitter.storehaus.mysql.MySqlStore.deleteStmt"),
exclude[IncompatibleResultTypeProblem]("com.twitter.storehaus.mysql.MySqlStore.updateStmt"),
exclude[IncompatibleResultTypeProblem]("com.twitter.storehaus.mysql.MySqlStore.selectStmt"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.mysql.MySqlStore.this"),
exclude[IncompatibleResultTypeProblem]("com.twitter.storehaus.mysql.MySqlStore.insertStmt"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisStore.set"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisStore.get"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisSortedSetMembershipView.get"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisSortedSetMembershipView.this"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisHashStore.set"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisHashStore.get"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisSetStore.set"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisSetStore.get"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisSetStore.delete"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisSortedSetStore.get"),
exclude[IncompatibleMethTypeProblem]("com.twitter.storehaus.redis.RedisSortedSetStore.members")
)
}

val sharedSettings = extraSettings ++ ciSettings ++ Seq(
organization := "com.twitter",
scalaVersion := "2.11.7",
crossScalaVersions := Seq("2.10.6", "2.11.7"),
javacOptions ++= Seq("-source", "1.6", "-target", "1.6"),
javacOptions in doc := Seq("-source", "1.6"),
scalaVersion := "2.11.11",
crossScalaVersions := Seq("2.11.11", "2.12.2"),
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
javacOptions in doc := Seq("-source", "1.8"),
libraryDependencies += "org.scalatest" %% "scalatest" % scalatestVersion % "test",
resolvers ++= Seq(
Opts.resolver.sonatypeSnapshots,
Expand All @@ -86,7 +110,7 @@ val sharedSettings = extraSettings ++ ciSettings ++ Seq(
),

// add linter for common scala issues: https://github.com/HairyFotr/linter
addCompilerPlugin("org.psywerx.hairyfotr" %% "linter" % "0.1.14"),
addCompilerPlugin("org.psywerx.hairyfotr" %% "linter" % "0.1.17"),

// Publishing options:

Expand Down Expand Up @@ -162,12 +186,14 @@ lazy val noPublishSettings = Seq(
publishArtifact := false
)

val algebirdVersion = "0.12.0"
val bijectionVersion = "0.9.1"
val utilVersion = "6.34.0"
val scaldingVersion = "0.16.0-RC1"
val finagleVersion = "6.35.0"
val scalatestVersion = "2.2.4"
val algebirdVersion = "0.13.0"
val bijectionVersion = "0.9.5"
val utilVersion = "6.41.0"

val scaldingVersion = "0.17.0"
val finagleVersion = "6.41.0"
val scalatestVersion = "3.0.1"
val scalaCheckVersion = "1.13.4"

lazy val storehaus = Project(
id = "storehaus",
Expand Down Expand Up @@ -228,9 +254,8 @@ lazy val storehausMemcache = module("memcache").settings(
"com.twitter" %% "bijection-core" % bijectionVersion,
"com.twitter" %% "bijection-netty" % bijectionVersion,
"com.twitter" %% "finagle-memcached" % finagleVersion excludeAll(
// we don't use this and its not on maven central.
ExclusionRule("com.twitter.common.zookeeper"),
ExclusionRule("com.twitter.common")
// we don't use this
ExclusionRule("com.twitter.common.zookeeper")
)
)
).dependsOn(storehausAlgebra % "test->test;compile->compile")
Expand Down Expand Up @@ -290,7 +315,7 @@ lazy val storehausKafka = module("kafka").settings(
"com.twitter" %% "bijection-avro" % bijectionVersion,
"org.apache.kafka" % "kafka-clients" % "0.9.0.1",
"org.apache.zookeeper" % "zookeeper" % "3.4.8" % "test",
"org.apache.kafka" %% "kafka" % "0.9.0.1" % "test"
"org.apache.kafka" %% "kafka" % "0.10.1.1" % "test"
),
// we don't want various tests clobbering each others keys
parallelExecution in Test := false
Expand All @@ -299,15 +324,15 @@ lazy val storehausKafka = module("kafka").settings(
lazy val storehausMongoDB = module("mongodb").settings(
libraryDependencies ++= Seq(
"com.twitter" %% "bijection-core" % bijectionVersion,
"org.mongodb" %% "casbah" % "2.8.2"
"org.mongodb" %% "casbah" % "3.1.1"
),
parallelExecution in Test := false
).dependsOn(storehausAlgebra % "test->test;compile->compile")

lazy val storehausElastic = module("elasticsearch").settings(
libraryDependencies ++= Seq (
"org.elasticsearch" % "elasticsearch" % "0.90.9",
"org.json4s" %% "json4s-native" % "3.2.10",
"org.json4s" %% "json4s-native" % "3.5.0",
"com.google.code.findbugs" % "jsr305" % "1.3.9",
"com.twitter" %% "bijection-json4s" % bijectionVersion,
"org.slf4j" % "slf4j-api" % "1.7.21" % "test",
Expand All @@ -323,7 +348,7 @@ lazy val storehausTesting = Project(
settings = sharedSettings ++ Seq(
name := "storehaus-testing",
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.12.2" withSources(),
"org.scalacheck" %% "scalacheck" % scalaCheckVersion withSources(),
withCross("com.twitter" %% "util-core" % utilVersion)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
package com.twitter.storehaus.memcache

import com.twitter.algebird.Semigroup
import com.twitter.bijection.{ Codec, Injection }
import com.twitter.bijection.{Codec, Injection}
import com.twitter.bijection.netty.Implicits._
import com.twitter.conversions.time._
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.finagle.memcached.KetamaClientBuilder
import com.twitter.finagle.memcached.protocol.text.Memcached
import com.twitter.finagle.netty3.{BufChannelBuffer, ChannelBufferBuf}
import com.twitter.util.{ Duration, Future, Time }
import com.twitter.util.{Duration, Future, Time}
import com.twitter.finagle.memcached.Client
import com.twitter.storehaus.{ FutureOps, Store, WithPutTtl }
import com.twitter.storehaus.{FutureOps, Store, WithPutTtl}
import com.twitter.storehaus.algebra.MergeableStore
import org.jboss.netty.buffer.ChannelBuffer

import Store.enrich
import com.twitter.finagle.transport.Transport

/**
* @author Oscar Boykin
Expand Down Expand Up @@ -70,12 +70,14 @@ object MemcacheStore {
.tcpConnectTimeout(timeout)
.requestTimeout(timeout)
.connectTimeout(timeout)
.readerIdleTimeout(timeout)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a maybe logical change. Are we sure there is nothing to replace it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied the alternative way of doing this.

.hostConnectionLimit(hostConnectionLimit)
.codec(Memcached())

val liveness = builder.params[Transport.Liveness].copy(readTimeout = timeout)
val liveBuilder = builder.configured(liveness)

KetamaClientBuilder()
.clientBuilder(builder)
.clientBuilder(liveBuilder)
.nodes(nodeString)
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ import com.mongodb.casbah.Imports._

object MongoStoreProperties extends Properties("MongoStore") {

private[this] class PropertyCached(ps: PropertySpecifier) {
def update(propName: String, p: Prop) = {
ps(propName) = p
}
}

/**
* Property specification is used by name since scalacheck 1.13.4, which breaks
* tests here. This simulates the old behavior.
*/
private[this] val propertyCached = new PropertyCached(property)

def putAndGetStoreTest[K, V](store: Store[K, V], pairs: Gen[List[(K, Option[V])]]): Prop =
forAll(pairs) {
(examples: List[(K, Option[V])]) => {
Expand All @@ -43,49 +55,49 @@ object MongoStoreProperties extends Properties("MongoStore") {
}
}

property("MongoStore[String, String]") =
propertyCached("MongoStore[String, String]") =
putAndGetStoreTest[String, String](MongoStore[String, String](
MongoClient("127.0.0.1", 27017),
"storehaus",
"data.stringMap"
), NonEmpty.Pairing.alphaStrs())

property("MongoStore[Long, Long]") =
propertyCached("MongoStore[Long, Long]") =
putAndGetStoreTest[Long, Long](MongoStore[Long, Long](
MongoClient("127.0.0.1", 27017),
"storehaus",
"data.longMap"
), NonEmpty.Pairing.numerics[Long]())

property("MongoStore[Int, Int]") =
propertyCached("MongoStore[Int, Int]") =
putAndGetStoreTest[Int, Int](MongoStore[Int, Int](
MongoClient("127.0.0.1", 27017),
"storehaus",
"data.intMap"
), NonEmpty.Pairing.numerics[Int]())

property("MongoStore[Double, Double]") =
propertyCached("MongoStore[Double, Double]") =
putAndGetStoreTest[Double, Double](MongoStore[Double, Double](
MongoClient("127.0.0.1", 27017),
"storehaus",
"data.doubleMap"
), NonEmpty.Pairing.numerics[Double]())

property("MongoStore[String, Int]") =
propertyCached("MongoStore[String, Int]") =
putAndGetStoreTest[String, Int](MongoStore[String, Int](
MongoClient("127.0.0.1", 27017),
"storehaus",
"data.stringIntMap"
), NonEmpty.Pairing.alphaStrNumerics[Int]())

property("MongoStore[String, Long]") =
propertyCached("MongoStore[String, Long]") =
putAndGetStoreTest[String, Long](MongoStore[String, Long](
MongoClient("127.0.0.1", 27017),
"storehaus",
"data.stringLongMap"
), NonEmpty.Pairing.alphaStrNumerics[Long]())

property("MongoStore[String, Double]") =
propertyCached("MongoStore[String, Double]") =
putAndGetStoreTest[String, Double](MongoStore[String, Double](
MongoClient("127.0.0.1", 27017),
"storehaus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.twitter.storehaus.mysql

import com.twitter.algebird.Semigroup
import com.twitter.bijection.Injection
import com.twitter.finagle.exp.mysql.Client
import com.twitter.finagle.mysql.Client

/**
* @author Ruban Monu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.twitter.storehaus.mysql

import com.twitter.finagle.exp.mysql.{ Client, Result, Parameter }
import com.twitter.finagle.mysql.{ Client, Result, Parameter }
import com.twitter.storehaus.FutureOps
import com.twitter.storehaus.Store
import com.twitter.util.{Future, Time}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.twitter.storehaus.mysql

import com.twitter.bijection.Injection
import com.twitter.finagle.exp.mysql.{
import com.twitter.finagle.mysql.{
EmptyValue,
IntValue,
LongValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,31 @@

package com.twitter.storehaus.mysql

import com.twitter.finagle.exp.Mysql
import com.twitter.finagle.exp.mysql.Client
import com.twitter.finagle.Mysql
import com.twitter.finagle.mysql.Client
import com.twitter.storehaus.testing.SelfAggregatingCloseableCleanup
import com.twitter.storehaus.testing.generator.NonEmpty
import com.twitter.util.{Future, Await}

import org.scalacheck.{Prop, Gen, Properties}
import com.twitter.util.{Await, Future}
import org.scalacheck.{Gen, Prop, Properties}
import org.scalacheck.Prop.forAll



object MySqlLongStoreProperties extends Properties("MySqlLongStore")
with SelfAggregatingCloseableCleanup[MySqlLongStore] {

private[this] class PropertyCached(ps: PropertySpecifier) {
def update(propName: String, p: Prop) = {
ps(propName) = p
}
}

/**
* Property specification is used by name since scalacheck 1.13.4, which breaks
* tests here. This simulates the old behavior.
*/
private[this] val propertyCached = new PropertyCached(property)

def put(s: MySqlLongStore, pairs: List[(MySqlValue, Option[Long])]): Unit = {
pairs.foreach { case (k, v) =>
Await.result(s.put((k, v)))
Expand Down Expand Up @@ -89,10 +102,11 @@ object MySqlLongStoreProperties extends Properties("MySqlLongStore")
isMatch
}

property("MySqlLongStore put and get") =

propertyCached("MySqlLongStore put and get") =
withStore(putAndGetStoreTest(_), "text", "bigint")

property("MySqlLongStore multiMerge") =
propertyCached("MySqlLongStore multiMerge") =
withStore(multiMergeStoreTest(_), "text", "bigint", merge = true)

private def withStore[T](f: MySqlLongStore => T, kColType: String, vColType: String,
Expand Down
Loading