Skip to content

Commit

Permalink
postgresql-testing: Extract PostgresAround from the Sandbox t… (dig…
Browse files Browse the repository at this point in the history
…ital-asset#4197)

* postgresql-testing: Extract `PostgresAround` from the Sandbox tests.

CHANGELOG_BEGIN
CHANGELOG_END

* postgresql-testing: Split into several files.

* postgresql-testing: Pull out the host and database names into variables.

* postgresql-testing: Don't publish to Maven.

I have no idea why the build wasn't failing before.

* postgresql-testing: Assimilate the `@postgresql_dev_env` dependency.
  • Loading branch information
SamirTalwar authored Jan 24, 2020
1 parent 706464d commit f3f7def
Show file tree
Hide file tree
Showing 39 changed files with 241 additions and 189 deletions.
3 changes: 2 additions & 1 deletion extractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ da_scala_library(
"//ledger/sandbox",
"//ledger/sandbox:sandbox-scala-tests-lib",
"//libs-scala/auth-utils",
"//libs-scala/postgresql-testing",
"@maven//:com_chuusai_shapeless_2_12",
"@maven//:com_lihaoyi_sourcecode_2_12",
"@maven//:com_typesafe_akka_akka_actor_2_12",
Expand Down Expand Up @@ -191,7 +192,6 @@ da_scala_test_suite(
"//extractor:TransactionExample.dar",
"//extractor:VeryLargeArchive.dar",
"//ledger/test-common:Test-stable.dar",
"@postgresql_dev_env//:all",
],
resources = glob(["src/test/resources/**/*"]),
deps = [
Expand All @@ -217,6 +217,7 @@ da_scala_test_suite(
"//ledger/test-common",
"//libs-scala/auth-utils",
"//libs-scala/grpc-utils",
"//libs-scala/postgresql-testing",
"//libs-scala/timer-utils",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_chuusai_shapeless_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

package com.digitalasset.extractor.services

import cats.effect.{ContextShift, IO}
import com.digitalasset.daml.lf.data.Ref.Party
import com.digitalasset.extractor.Extractor
import com.digitalasset.extractor.config.{ExtractorConfig, SnapshotEndSetting}
import com.digitalasset.extractor.targets.PostgreSQLTarget
import com.digitalasset.daml.lf.data.Ref.Party
import com.digitalasset.ledger.api.v1.ledger_offset.LedgerOffset
import com.digitalasset.ledger.api.tls.TlsConfiguration
import com.digitalasset.platform.sandbox.persistence.PostgresAround
import com.digitalasset.ledger.api.v1.ledger_offset.LedgerOffset
import com.digitalasset.platform.sandbox.services.SandboxFixture
import scalaz.OneAnd
import cats.effect.{ContextShift, IO}
import com.digitalasset.testing.postgresql.PostgresAround
import doobie._
import doobie.implicits._
import org.scalatest._
import scalaz.OneAnd

import scala.concurrent.{Await, ExecutionContext}
import scala.concurrent.duration._
import scala.concurrent.{Await, ExecutionContext}

trait ExtractorFixture extends SandboxFixture with PostgresAround with Types {
self: Suite =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@

package com.digitalasset.extractor

import java.io.File

import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll

import org.scalatest._
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.parser._
import java.io.File

import scalaz._
import Scalaz._
import org.scalatest._
import scalaz.Scalaz._

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class BasicPrimitiveTypesSpec
extends FlatSpec
with Suite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.io.File
import com.digitalasset.daml.bazeltools.BazelRunfiles.rlocation
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.parser._
import org.scalatest.{FlatSpec, Inside, Matchers, Suite}
import scalaz.Scalaz._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import java.io.File
import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.parser._
import org.scalatest._
import scalaz.Scalaz._
//import scalaz._

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class GenMapSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@

package com.digitalasset.extractor

import java.io.File

import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll

import org.scalatest._
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.parser._
import java.io.File

import scalaz._
import Scalaz._
import org.scalatest._
import scalaz.Scalaz._

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class ListsSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@

package com.digitalasset.extractor

import java.io.File

import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.daml.lf.data.Ref.Party
import com.digitalasset.daml.lf.value.ValueGenerators.{party => partyGen}
import config.ExtractorConfig
import config.CustomScoptReaders._
import services.ExtractorFixtureAroundAll
import com.digitalasset.extractor.config.CustomScoptReaders._
import com.digitalasset.extractor.config.ExtractorConfig
import com.digitalasset.extractor.services.ExtractorFixtureAroundAll
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll

import com.digitalasset.testing.postgresql.PostgresAroundAll
import org.scalacheck.Arbitrary
import org.scalatest._
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import java.io.File
import scopt.Read

import scalaz._
import scalaz.scalacheck.ScalazArbitrary._
import scalaz.std.list._
import scalaz.std.option._
import scalaz.std.string._
import scalaz.syntax.foldable._
import scalaz.syntax.functor._
import scalaz.scalacheck.ScalazArbitrary._
import scopt.Read

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class MultiPartySpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.digitalasset.daml.lf.data.Ref.Party
import com.digitalasset.extractor.config.{ExtractorConfig, TemplateConfig}
import com.digitalasset.extractor.services.ExtractorFixtureAroundAll
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll
import com.digitalasset.testing.postgresql.PostgresAroundAll
import org.scalatest.{FlatSpec, Inside, Matchers, Suite}
import scalaz.OneAnd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@

package com.digitalasset.extractor

import java.io.File

import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll

import org.scalatest._
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.parser._
import java.io.File

import scalaz._
import Scalaz._
import org.scalatest._
import scalaz.Scalaz._

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class OptionalSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@

package com.digitalasset.extractor

import java.io.File

import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll

import org.scalatest._
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.parser._
import java.io.File

import scalaz._
import Scalaz._
import org.scalatest._
import scalaz.Scalaz._

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class RecordsAndVariantsSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.digitalasset.daml.lf.data.Ref.Party
import com.digitalasset.extractor.config.{ExtractorConfig, TemplateConfig}
import com.digitalasset.extractor.services.ExtractorFixtureAroundAll
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll
import com.digitalasset.testing.postgresql.PostgresAroundAll
import org.scalatest.{FlatSpec, Inside, Matchers, Suite}
import scalaz.OneAnd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@

package com.digitalasset.extractor

import java.io.File

import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll

import org.scalatest._
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.parser._
import java.io.File

import scalaz._
import Scalaz._
import org.scalatest._
import scalaz.Scalaz._

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class TextMapsSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import cats.implicits._
import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll
import io.circe.syntax._
import com.digitalasset.testing.postgresql.PostgresAroundAll
import doobie.implicits._

import io.circe.syntax._
import org.scalatest._

import scala.concurrent.duration._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import cats.implicits._
import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.{CustomMatchers, ExtractorFixtureAroundAll}
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll
import com.digitalasset.testing.postgresql.PostgresAroundAll
import io.circe.syntax._
import org.scalatest._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

package com.digitalasset.extractor

import java.io.File

import com.digitalasset.daml.bazeltools.BazelRunfiles._
import com.digitalasset.extractor.services.ExtractorFixture
import com.digitalasset.ledger.api.testing.utils.SuiteResourceManagementAroundAll
import com.digitalasset.platform.sandbox.persistence.PostgresAroundEach
import com.digitalasset.testing.postgresql.PostgresAroundEach
import io.grpc.StatusRuntimeException
import org.scalatest._

import scala.concurrent.Await
import scala.concurrent.duration._
import io.grpc.StatusRuntimeException
import org.scalatest._
import java.io.File

@SuppressWarnings(Array("org.wartremover.warts.Any"))
class VeryLargeArchiveSpec
Expand Down
3 changes: 1 addition & 2 deletions ledger-service/http-json/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ da_scala_test(
data = [
":Account.dar",
"//docs:quickstart-model.dar",
"@postgresql_dev_env//:all",
],
resources = glob(["src/test/resources/**/*"]),
scalacopts = hj_scalacopts,
Expand All @@ -136,8 +135,8 @@ da_scala_test(
"//ledger/ledger-api-common",
"//ledger/participant-state",
"//ledger/sandbox",
"//ledger/sandbox:sandbox-scala-tests-lib",
"//libs-scala/auth-utils",
"//libs-scala/postgresql-testing",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_chuusai_shapeless_2_12",
"@maven//:com_lihaoyi_sourcecode_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

package com.digitalasset.http

import com.digitalasset.platform.sandbox.persistence.PostgresAroundAll
import spray.json.{JsString, JsValue}
import com.digitalasset.http.Statement.discard
import com.digitalasset.testing.postgresql.PostgresAroundAll
import spray.json.{JsString, JsValue}

import scala.concurrent.Future

Expand Down Expand Up @@ -57,9 +57,10 @@ class HttpServiceWithPostgresIntTest

private def selectAllDbContracts
: Future[List[(String, String, JsValue, JsValue, Vector[String], Vector[String], String)]] = {
import doobie.implicits._, doobie.postgres.implicits._
import com.digitalasset.http.dbbackend.Queries.Implicits._
import dao.logHandler
import doobie.implicits._
import doobie.postgres.implicits._

val q =
sql"""SELECT contract_id, tpid, key, payload, signatories, observers, agreement_text FROM contract"""
Expand Down
5 changes: 1 addition & 4 deletions ledger/api-server-damlonx/reference-v2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,12 @@ da_scala_test(
da_scala_binary(
name = "ephemeral-postgres-reference-server",
srcs = glob(["src/test/lib/scala/**/*.scala"]),
data = [
"@postgresql_dev_env//:all",
],
main_class = "com.daml.ledger.api.server.damlonx.reference.v2.EphemeralPostgresReferenceServerMain",
resources = ["src/main/resources/logback.xml"],
visibility = ["//visibility:public"],
deps = [
":reference-v2",
"//ledger/sandbox:sandbox-scala-tests-lib",
"//libs-scala/postgresql-testing",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.daml.ledger.api.server.damlonx.reference.v2

import com.digitalasset.platform.sandbox.persistence.PostgresAround
import com.digitalasset.testing.postgresql.PostgresAround

object EphemeralPostgresReferenceServerMain extends App with PostgresAround {
startEphemeralPostgres()
Expand Down
1 change: 1 addition & 0 deletions ledger/sandbox-perf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ da_scala_library(
"//ledger/sandbox:sandbox-scala-tests-lib",
"//ledger/test-common",
"//libs-scala/direct-execution-context",
"//libs-scala/postgresql-testing",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_typesafe_akka_akka_actor_2_12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import com.digitalasset.ledger.api.domain.LedgerId
import com.digitalasset.ledger.api.testing.utils.Resource
import com.digitalasset.platform.common.LedgerIdMode
import com.digitalasset.platform.sandbox.config.SandboxConfig
import com.digitalasset.platform.sandbox.persistence.{PostgresFixture, PostgresResource}
import com.digitalasset.platform.services.time.TimeProviderType
import com.digitalasset.testing.postgresql.{PostgresFixture, PostgresResource}

object LedgerFactories {

Expand Down
Loading

0 comments on commit f3f7def

Please sign in to comment.