Skip to content

Commit

Permalink
Update common-jvm for Postgres testing. (#1169)
Browse files Browse the repository at this point in the history
The unused AWS Kingdom schema and its associated test are deleted.
  • Loading branch information
SanjayVas authored Aug 16, 2023
1 parent e3eda0f commit 1867a50
Show file tree
Hide file tree
Showing 38 changed files with 421 additions and 563 deletions.
4 changes: 2 additions & 2 deletions build/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def wfa_measurement_system_repositories():
wfa_repo_archive(
name = "wfa_common_jvm",
repo = "common-jvm",
sha256 = "71e2051b40c384d5d7f506cc985c5f7aa74292a9a7fddb1f34f5d352f2953032",
version = "0.62.0",
sha256 = "328f4707c79ff1b309784463309f4c5918c6a2fab8c0187efda014f8b3bc79eb",
version = "0.63.0",
)

wfa_repo_archive(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package(
default_testonly = True,
default_visibility = [
"//src/test/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/integration/common/duchy:__pkg__",
"//src/test/kotlin/org/wfanet/measurement/integration:__subpackages__",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ private const val MAX_BATCH_INSERT = 1000
*
* @param createConnection is a function that creates a postgres JDBC connection that will be owned
* by the backing store and should not be used outside this backing store.
*
* TODO(@uakyol): Use R2DBC-based
* [org.wfanet.measurement.common.db.r2dbc.postgres.PostgresDatabaseClient] instead of JDBC.
*/
class PostgresBackingStore(createConnection: () -> Connection) : PrivacyBudgetLedgerBackingStore {
// TODO(@duliomatos1) : redesign this to reduce connection lifetime, e.g. using a Connection for
// a single transaction/operation and then closing it.
private val connection = createConnection()
init {
connection.autoCommit = false
Expand All @@ -58,7 +59,6 @@ class PostgresBackingStore(createConnection: () -> Connection) : PrivacyBudgetLe
)
}
connection.createStatement().use { statement: Statement ->
// TODO(@duliomatos) Make the blocking IO run within a dispatcher using coroutines
statement.executeUpdate("begin transaction")
return PostgresBackingStoreTransactionContext(connection)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ import org.wfanet.measurement.loadtest.measurementconsumer.MeasurementConsumerDa
import org.wfanet.measurement.loadtest.resourcesetup.DuchyCert
import org.wfanet.measurement.loadtest.resourcesetup.EntityContent
import org.wfanet.measurement.loadtest.resourcesetup.ResourceSetup
import org.wfanet.measurement.storage.StorageClient
import org.wfanet.measurement.system.v1alpha.ComputationLogEntriesGrpcKt.ComputationLogEntriesCoroutineStub

class InProcessCmmsComponents(
private val kingdomDataServicesRule: ProviderRule<DataServices>,
private val duchyDependenciesRule:
ProviderRule<(String, ComputationLogEntriesCoroutineStub) -> InProcessDuchy.DuchyDependencies>,
private val storageClient: StorageClient,
) : TestRule {
private val kingdomDataServices: DataServices
get() = kingdomDataServicesRule.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.wfanet.measurement.kingdom.deploy.common.service.DataServices
import org.wfanet.measurement.loadtest.measurementconsumer.MeasurementConsumerData
import org.wfanet.measurement.loadtest.measurementconsumer.MeasurementConsumerSimulator
import org.wfanet.measurement.loadtest.measurementconsumer.MetadataSyntheticGeneratorEventQuery
import org.wfanet.measurement.storage.StorageClient
import org.wfanet.measurement.system.v1alpha.ComputationLogEntriesGrpcKt.ComputationLogEntriesCoroutineStub

/**
Expand All @@ -42,19 +41,15 @@ import org.wfanet.measurement.system.v1alpha.ComputationLogEntriesGrpcKt.Computa
* This is abstract so that different implementations of dependencies can all run the same tests
* easily.
*/
abstract class InProcessLifeOfAMeasurementIntegrationTest {
abstract val kingdomDataServicesRule: ProviderRule<DataServices>

/** Provides a function from Duchy to the dependencies needed to start the Duchy to the test. */
abstract val duchyDependenciesRule:
abstract class InProcessLifeOfAMeasurementIntegrationTest(
kingdomDataServicesRule: ProviderRule<DataServices>,
duchyDependenciesRule:
ProviderRule<(String, ComputationLogEntriesCoroutineStub) -> InProcessDuchy.DuchyDependencies>

abstract val storageClient: StorageClient
) {

@get:Rule
val inProcessCmmsComponents: InProcessCmmsComponents by lazy {
InProcessCmmsComponents(kingdomDataServicesRule, duchyDependenciesRule, storageClient)
}
val inProcessCmmsComponents =
InProcessCmmsComponents(kingdomDataServicesRule, duchyDependenciesRule)

private lateinit var mcSimulator: MeasurementConsumerSimulator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import org.wfanet.measurement.reporting.v2alpha.periodicTimeInterval
import org.wfanet.measurement.reporting.v2alpha.report
import org.wfanet.measurement.reporting.v2alpha.reportingSet
import org.wfanet.measurement.reporting.v2alpha.timeIntervals
import org.wfanet.measurement.storage.StorageClient
import org.wfanet.measurement.system.v1alpha.ComputationLogEntriesGrpcKt

/**
Expand All @@ -110,30 +109,23 @@ import org.wfanet.measurement.system.v1alpha.ComputationLogEntriesGrpcKt
* This is abstract so that different implementations of dependencies can all run the same tests
* easily.
*/
abstract class InProcessLifeOfAReportIntegrationTest {
abstract val kingdomDataServicesRule: ProviderRule<DataServices>

/** Provides a function from Duchy to the dependencies needed to start the Duchy to the test. */
abstract val duchyDependenciesRule:
abstract class InProcessLifeOfAReportIntegrationTest(
kingdomDataServicesRule: ProviderRule<DataServices>,
duchyDependenciesRule:
ProviderRule<
(
String, ComputationLogEntriesGrpcKt.ComputationLogEntriesCoroutineStub
) -> InProcessDuchy.DuchyDependencies
>

abstract val storageClient: StorageClient

private val inProcessCmmsComponents: InProcessCmmsComponents by lazy {
InProcessCmmsComponents(kingdomDataServicesRule, duchyDependenciesRule, storageClient)
}

private val inProcessCmmsComponentsStartup: TestRule by lazy {
TestRule { statement, _ ->
object : Statement() {
override fun evaluate() {
inProcessCmmsComponents.startDaemons()
statement.evaluate()
}
) {
private val inProcessCmmsComponents: InProcessCmmsComponents =
InProcessCmmsComponents(kingdomDataServicesRule, duchyDependenciesRule)

private val inProcessCmmsComponentsStartup = TestRule { base, _ ->
object : Statement() {
override fun evaluate() {
inProcessCmmsComponents.startDaemons()
base.evaluate()
}
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1867a50

Please sign in to comment.