From 096175e2dc3cc70765ad47ff00a012dd36c61754 Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Tue, 26 Sep 2023 13:57:15 -0700 Subject: [PATCH] Format all Kotlin files with ktfmt 0.46. (#1241) --- .../measurement/api/v2alpha/tools/Benchmark.kt | 1 + .../api/v2alpha/tools/CreateMeasurementFlags.kt | 2 ++ .../api/v2alpha/tools/MeasurementSystem.kt | 2 ++ .../common/identity/testing/DuchyIdSetter.kt | 1 + .../measurement/common/k8s/JsonPatchOperation.kt | 1 + .../measurement/duchy/daemon/mill/MillBase.kt | 4 ++++ .../mill/liquidlegionsv2/LiquidLegionsV2Mill.kt | 1 + .../ComputationProtocolStageDetailsHelper.kt | 6 +++++- .../db/computation/ProtocolStageEnumHelper.kt | 2 ++ .../testing/FakeComputationsDatabase.kt | 3 +-- .../postgres/PostgresComputationsService.kt | 3 +-- .../deploy/common/postgres/writers/ClaimWork.kt | 3 +-- .../postgres/writers/ComputationMutations.kt | 3 +-- .../GcpSpannerComputationsDatabaseTransactor.kt | 15 ++++++++------- .../gcloud/spanner/computation/GlobalIdsQuery.kt | 1 + .../spanner/computation/UnclaimedTasksQuery.kt | 2 ++ .../spanner/computation/UnfinishedAttemptQuery.kt | 2 ++ .../continuationtoken/ContinuationTokenReader.kt | 1 + .../AsyncComputationControlService.kt | 3 +-- .../internal/computations/ComputationsService.kt | 3 +-- .../validation/EventFilterValidator.kt | 3 +-- .../eventdataprovider/noiser/GaussianNoiser.kt | 1 + .../InMemoryBackingStore.kt | 3 +-- .../common/postgres/PostgresBackingStore.kt | 2 ++ .../AbstractPrivacyBudgetLedgerStoreTest.kt | 1 + .../testing/TestInMemoryBackingStore.kt | 1 + .../kingdom/batch/ExchangesDeletion.kt | 1 + .../batch/PendingMeasurementsCancellation.kt | 1 + .../kingdom/deploy/common/Llv2ProtocolConfig.kt | 2 ++ .../kingdom/deploy/common/RoLlv2ProtocolConfig.kt | 2 ++ .../gcloud/spanner/SpannerAccountsService.kt | 6 ++---- .../gcloud/spanner/SpannerApiKeysService.kt | 3 +-- .../gcloud/spanner/SpannerDataProvidersService.kt | 4 ++-- .../gcloud/spanner/SpannerExchangeStepsService.kt | 3 +-- .../gcloud/spanner/SpannerExchangesService.kt | 3 +-- .../spanner/SpannerMeasurementConsumersService.kt | 3 +-- .../gcloud/spanner/SpannerMeasurementsService.kt | 6 ++---- .../spanner/SpannerModelProvidersService.kt | 4 ++-- .../gcloud/spanner/SpannerModelReleasesService.kt | 3 +-- .../gcloud/spanner/SpannerModelSuitesService.kt | 3 +-- .../spanner/SpannerRecurringExchangesService.kt | 3 +-- .../gcloud/spanner/SpannerRequisitionsService.kt | 3 +-- .../gcloud/spanner/queries/StreamMeasurements.kt | 2 ++ .../gcloud/spanner/readers/CertificateReader.kt | 3 +-- .../gcloud/spanner/readers/DataProviderReader.kt | 3 +-- .../spanner/readers/MeasurementConsumerReader.kt | 3 +-- .../gcloud/spanner/writers/ActivateAccount.kt | 3 +-- .../spanner/writers/ClaimReadyExchangeStep.kt | 3 +-- .../gcloud/spanner/writers/CreateAccount.kt | 3 +-- .../deploy/gcloud/spanner/writers/CreateApiKey.kt | 3 +-- .../gcloud/spanner/writers/CreateCertificate.kt | 3 +-- .../gcloud/spanner/writers/CreateEventGroup.kt | 3 +-- .../spanner/writers/CreateMeasurementConsumer.kt | 3 +-- .../gcloud/spanner/writers/CreateModelRollout.kt | 1 + .../spanner/writers/CreateRecurringExchange.kt | 6 ++---- .../deploy/gcloud/spanner/writers/DeleteApiKey.kt | 3 +-- .../gcloud/spanner/writers/DeleteModelShard.kt | 3 +-- .../spanner/writers/FinishExchangeStepAttempt.kt | 3 +-- .../writers/ReplaceDataProviderRequiredDuchies.kt | 1 + .../spanner/writers/SetMeasurementResult.kt | 1 + .../gcloud/spanner/writers/UpdatePublicKey.kt | 3 +-- .../kingdom/deploy/tools/CreateResource.kt | 1 + .../service/api/v2alpha/DataProvidersService.kt | 1 + .../service/api/v2alpha/EventGroupsService.kt | 2 +- .../service/api/v2alpha/RequisitionsService.kt | 2 +- .../internal/testing/DataProvidersServiceTest.kt | 1 + .../testing/MeasurementLogEntriesServiceTest.kt | 1 + .../internal/testing/MeasurementsServiceTest.kt | 1 + .../service/internal/testing/Population.kt | 1 + .../service/system/v1alpha/ComputationsService.kt | 1 + .../measurement/loadtest/resourcesetup/Output.kt | 1 + .../postgres/writers/SetMeasurementFailure.kt | 3 +-- .../postgres/writers/SetMeasurementResult.kt | 3 +-- .../deploy/v2/postgres/PostgresReportsService.kt | 3 +-- .../deploy/v2/postgres/writers/CreateReport.kt | 1 + .../service/api/v1alpha/ReportsService.kt | 3 +-- .../service/api/v1alpha/tools/Reporting.kt | 2 ++ .../service/api/v2alpha/tools/Reporting.kt | 2 ++ .../testing/JniQueryEvaluatorContext.kt | 1 + .../certificates/aws/CreateCertificateClient.kt | 1 + .../api/v2alpha/tools/MeasurementSystemTest.kt | 1 + .../v1alpha/ComputationControlServiceTest.kt | 2 ++ .../InMemoryBackingStoreTest.kt | 1 + .../PrivacyBudgetManagerTest.kt | 1 + .../integration/k8s/AbstractCorrectnessTest.kt | 1 + .../api/v2alpha/CertificatesServiceTest.kt | 1 + .../deploy/common/EncryptionKeyPairMapTest.kt | 1 + .../client/eventpreprocessing/BatchingDoFnTest.kt | 3 +++ .../wfanet/panelmatch/client/logger/LoggerTest.kt | 3 +++ 89 files changed, 124 insertions(+), 94 deletions(-) diff --git a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/Benchmark.kt b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/Benchmark.kt index 72d0d277bcd..3b8e7797d7b 100644 --- a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/Benchmark.kt +++ b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/Benchmark.kt @@ -616,6 +616,7 @@ class BenchmarkReport private constructor(val clock: Clock = Clock.systemUTC()) buildMutualTlsChannel(apiFlags.apiTarget, clientCerts, apiFlags.apiCertHost) .withShutdownTimeout(JavaDuration.ofSeconds(1)) } + override fun run() { val benchmark = Benchmark(baseFlags, createMeasurementFlags, channel, apiAuthenticationKey, clock) diff --git a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/CreateMeasurementFlags.kt b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/CreateMeasurementFlags.kt index 5dd4dd75967..0321e05ae14 100644 --- a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/CreateMeasurementFlags.kt +++ b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/CreateMeasurementFlags.kt @@ -289,6 +289,7 @@ class CreateMeasurementFlags { @ArgGroup(exclusive = true, multiplicity = "1", heading = "Event Measurement and params\n") var eventMeasurementTypeParams = EventMeasurementTypeParams() } + class PopulationMeasurementParams { class PopulationInput { @Option( @@ -330,6 +331,7 @@ class CreateMeasurementFlags { @ArgGroup(exclusive = false, heading = "Population Params\n") lateinit var populationInputs: PopulationInput private set + @ArgGroup(exclusive = false, heading = "Set Population Data Provider\n") lateinit var populationDataProviderInput: PopulationDataProviderInput diff --git a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystem.kt b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystem.kt index 211fa0dc5de..37c729e69a7 100644 --- a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystem.kt +++ b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystem.kt @@ -634,6 +634,7 @@ class CreateMeasurement : Runnable { } } } + private fun getEventDataProviderEntry( eventDataProviderInput: CreateMeasurementFlags.MeasurementParams.EventMeasurementParams.EventDataProviderInput, @@ -931,6 +932,7 @@ private class DataProviders { required = true, ) private lateinit var dataProviderName: String + @Command(name = "replace-required-duchies", description = ["Replaces DataProvider's duchy list"]) fun replaceRequiredDuchyList( @Option( diff --git a/src/main/kotlin/org/wfanet/measurement/common/identity/testing/DuchyIdSetter.kt b/src/main/kotlin/org/wfanet/measurement/common/identity/testing/DuchyIdSetter.kt index cf3e164cf28..e685c3e23da 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/identity/testing/DuchyIdSetter.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/identity/testing/DuchyIdSetter.kt @@ -22,6 +22,7 @@ import org.wfanet.measurement.common.identity.DuchyInfo /** JUnit rule that sets the global list of all valid Duchy ids to [duchyIds]. */ class DuchyIdSetter(val duchyIds: Set) : TestRule { constructor(duchyIds: Iterable) : this(duchyIds.toSet()) + constructor(vararg duchyIds: String) : this(duchyIds.toSet()) override fun apply(base: Statement, description: Description): Statement { diff --git a/src/main/kotlin/org/wfanet/measurement/common/k8s/JsonPatchOperation.kt b/src/main/kotlin/org/wfanet/measurement/common/k8s/JsonPatchOperation.kt index 8d697436d38..66a76665f6f 100644 --- a/src/main/kotlin/org/wfanet/measurement/common/k8s/JsonPatchOperation.kt +++ b/src/main/kotlin/org/wfanet/measurement/common/k8s/JsonPatchOperation.kt @@ -24,6 +24,7 @@ private constructor( val op: String ) { data class Replace(val path: String, val value: Any) : JsonPatchOperation("replace") + data class Add(val path: String, val value: Any) : JsonPatchOperation("add") companion object { diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/MillBase.kt b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/MillBase.kt index 8f00ffc06b5..ccd82606e97 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/MillBase.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/MillBase.kt @@ -554,6 +554,7 @@ abstract class MillBase( private inner class CpuDurationLogger(private val getTimeMillis: () -> Long) { private val start = getTimeMillis() + suspend fun logStageDurationMetric( token: ComputationToken, metricName: String, @@ -563,11 +564,13 @@ abstract class MillBase( logStageDurationMetric(token, metricName, time, histogram) } } + private fun cpuDurationLogger(): CpuDurationLogger = CpuDurationLogger(this::getCpuTimeMillis) @OptIn(ExperimentalTime::class) private inner class WallDurationLogger() { private val timeMark = TimeSource.Monotonic.markNow() + suspend fun logStageDurationMetric( token: ComputationToken, metricName: String, @@ -577,6 +580,7 @@ abstract class MillBase( logStageDurationMetric(token, metricName, time, histogram) } } + private fun wallDurationLogger(): WallDurationLogger = WallDurationLogger() companion object { diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/liquidlegionsv2/LiquidLegionsV2Mill.kt b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/liquidlegionsv2/LiquidLegionsV2Mill.kt index 9df925448f7..640ebbd0fce 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/liquidlegionsv2/LiquidLegionsV2Mill.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/daemon/mill/liquidlegionsv2/LiquidLegionsV2Mill.kt @@ -1012,6 +1012,7 @@ class LiquidLegionsV2Mill( directoryPath = Paths.get("any_sketch_java/src/main/java/org/wfanet/anysketch/crypto") ) } + private val logger: Logger = Logger.getLogger(this::class.java.name) } } diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ComputationProtocolStageDetailsHelper.kt b/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ComputationProtocolStageDetailsHelper.kt index b8b75085c36..397e0ec3346 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ComputationProtocolStageDetailsHelper.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ComputationProtocolStageDetailsHelper.kt @@ -16,7 +16,11 @@ package org.wfanet.measurement.duchy.db.computation /** Deals with stage specific details for MPC protocols. */ interface ComputationProtocolStageDetailsHelper< - ProtocolT, StageT, StageDetailsT, ComputationDetailsT> { + ProtocolT, + StageT, + StageDetailsT, + ComputationDetailsT +> { /** Creates the stage specific details for a given computation stage. */ fun detailsFor(stage: StageT, computationDetails: ComputationDetailsT): StageDetailsT diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ProtocolStageEnumHelper.kt b/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ProtocolStageEnumHelper.kt index 5a7d42688f5..6c79cfe58a3 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ProtocolStageEnumHelper.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/ProtocolStageEnumHelper.kt @@ -21,7 +21,9 @@ interface ProtocolStageEnumHelper { fun validInitialStage(stage: StageT): Boolean { return stage in validInitialStages } + val validTerminalStages: Set + fun validTerminalStage(stage: StageT): Boolean = stage in validTerminalStages val validSuccessors: Map> diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/testing/FakeComputationsDatabase.kt b/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/testing/FakeComputationsDatabase.kt index 5ca85e8d735..a2c90b81021 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/testing/FakeComputationsDatabase.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/db/computation/testing/FakeComputationsDatabase.kt @@ -367,8 +367,7 @@ private constructor( globalId = it.globalComputationId, ) } - .firstOrNull() - ?: return null + .firstOrNull() ?: return null updateToken(claimed) { existing -> claimedComputationIds.add(existing.globalComputationId) diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/PostgresComputationsService.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/PostgresComputationsService.kt index 80511abc5c9..936a86ab4b3 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/PostgresComputationsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/PostgresComputationsService.kt @@ -209,8 +209,7 @@ class PostgresComputationsService( KeyCase.REQUISITION_KEY -> computationReader.readComputationToken(client, request.requisitionKey) KeyCase.KEY_NOT_SET -> failGrpc(Status.INVALID_ARGUMENT) { "key not set" } - } - ?: failGrpc(Status.NOT_FOUND) { "Computation not found" } + } ?: failGrpc(Status.NOT_FOUND) { "Computation not found" } return token.toGetComputationTokenResponse() } diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ClaimWork.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ClaimWork.kt index e0b781b5718..98b1f8fc0c6 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ClaimWork.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ClaimWork.kt @@ -117,8 +117,7 @@ class ClaimWork( unclaimedTask.computationId, stageLongValue, currentAttempt - ) - ?: throw IllegalStateException("Computation stage details is missing.") + ) ?: throw IllegalStateException("Computation stage details is missing.") // If the computation was locked, but that lock was expired we need to finish off the // current attempt of the stage. updateComputationStageAttempt( diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ComputationMutations.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ComputationMutations.kt index 45c83f2eaf9..b39978cd456 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ComputationMutations.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/common/postgres/writers/ComputationMutations.kt @@ -228,8 +228,7 @@ suspend fun PostgresWriter.TransactionScope.checkComputationUnmodified( transactionContext .executeQuery(sql) .consume { row -> row.get("UpdateTime") } - .firstOrNull() - ?: throw ComputationNotFoundException(localId) + .firstOrNull() ?: throw ComputationNotFoundException(localId) val updateTimeMillis = updateTime.toEpochMilli() if (editVersion != updateTimeMillis) { val editVersionTime = Instant.ofEpochMilli(editVersion) diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GcpSpannerComputationsDatabaseTransactor.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GcpSpannerComputationsDatabaseTransactor.kt index 4cfe41ea8a6..f280e150597 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GcpSpannerComputationsDatabaseTransactor.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GcpSpannerComputationsDatabaseTransactor.kt @@ -53,7 +53,11 @@ import org.wfanet.measurement.internal.duchy.copy /** Implementation of [ComputationsDatabaseTransactor] using GCP Spanner Database. */ class GcpSpannerComputationsDatabaseTransactor< - ProtocolT, StageT, StageDT : Message, ComputationDT : Message>( + ProtocolT, + StageT, + StageDT : Message, + ComputationDT : Message +>( private val databaseClient: AsyncDatabaseClient, private val computationMutations: ComputationMutations, private val clock: Clock = Clock.systemUTC() @@ -319,8 +323,7 @@ class GcpSpannerComputationsDatabaseTransactor< val detailsBytes = txn .readRow("Computations", Key.of(token.localId), listOf("ComputationDetails")) - ?.getBytesAsByteArray("ComputationDetails") - ?: error("Computation missing $token") + ?.getBytesAsByteArray("ComputationDetails") ?: error("Computation missing $token") val details = computationMutations.parseComputationDetails(detailsBytes) txn.buffer( computationMutations.updateComputation( @@ -399,8 +402,7 @@ class GcpSpannerComputationsDatabaseTransactor< "RequisitionsByExternalId", Key.of(it.key.externalRequisitionId, it.key.requisitionFingerprint.toGcloudByteArray()), listOf("ComputationId", "RequisitionId") - ) - ?: error("No Computation found row for this requisition: ${it.key}") + ) ?: error("No Computation found row for this requisition: ${it.key}") txn.buffer( computationMutations.updateRequisition( localComputationId = row.getLong("ComputationId"), @@ -645,8 +647,7 @@ class GcpSpannerComputationsDatabaseTransactor< externalRequisitionKey.requisitionFingerprint.toGcloudByteArray() ), listOf("ComputationId", "RequisitionId") - ) - ?: error("No Computation found row for this requisition: $externalRequisitionKey") + ) ?: error("No Computation found row for this requisition: $externalRequisitionKey") val localComputationId = row.getLong("ComputationId") val requisitionId = row.getLong("RequisitionId") require(localComputationId == token.localId) { diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GlobalIdsQuery.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GlobalIdsQuery.kt index c61e3999d37..30f1137f7cb 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GlobalIdsQuery.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/GlobalIdsQuery.kt @@ -39,6 +39,7 @@ class GlobalIdsQuery( AND Protocol = @protocol """ } + override val sql: Statement = statement(parameterizedQuery) { bind("stages") diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnclaimedTasksQuery.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnclaimedTasksQuery.kt index cf64710b463..e41f1687edc 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnclaimedTasksQuery.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnclaimedTasksQuery.kt @@ -48,6 +48,7 @@ class UnclaimedTasksQuery( LIMIT 50 """ } + override val sql: Statement = Statement.newBuilder(parameterizedQueryString) .bind("current_time") @@ -55,6 +56,7 @@ class UnclaimedTasksQuery( .bind("protocol") .to(protocol) .build() + override fun asResult(struct: Struct): UnclaimedTaskQueryResult = UnclaimedTaskQueryResult( computationId = struct.getLong("ComputationId"), diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnfinishedAttemptQuery.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnfinishedAttemptQuery.kt index fde6f78c6f1..e7967f95142 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnfinishedAttemptQuery.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/computation/UnfinishedAttemptQuery.kt @@ -36,8 +36,10 @@ class UnfinishedAttemptQuery( AND EndTime IS NULL """ } + override val sql: Statement = Statement.newBuilder(parameterizedQueryString).bind("local_id").to(localId).build() + override fun asResult(struct: Struct): UnfinishedAttemptQueryResult = UnfinishedAttemptQueryResult( computationId = localId, diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/continuationtoken/ContinuationTokenReader.kt b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/continuationtoken/ContinuationTokenReader.kt index 06ba882ab2c..9ea1a6f61f4 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/continuationtoken/ContinuationTokenReader.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/deploy/gcloud/spanner/continuationtoken/ContinuationTokenReader.kt @@ -27,6 +27,7 @@ class ContinuationTokenReader() : SqlBasedQuery { Limit 1 """ } + override val sql: Statement = Statement.newBuilder(parameterizedQueryString).build() override fun asResult(struct: Struct): ContinuationTokenReaderResult = diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computationcontrol/AsyncComputationControlService.kt b/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computationcontrol/AsyncComputationControlService.kt index 6affae38e0f..12b747bcff2 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computationcontrol/AsyncComputationControlService.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computationcontrol/AsyncComputationControlService.kt @@ -106,8 +106,7 @@ class AsyncComputationControlService( val outputBlob = token.blobsList.firstOrNull { it.blobId == request.blobId && it.dependencyType == ComputationBlobDependency.OUTPUT - } - ?: failGrpc(Status.FAILED_PRECONDITION) { "No output blob with ID ${request.blobId}" } + } ?: failGrpc(Status.FAILED_PRECONDITION) { "No output blob with ID ${request.blobId}" } if (outputBlob.path.isNotEmpty()) { if (outputBlob.path != request.blobPath) { throw Status.FAILED_PRECONDITION.withDescription( diff --git a/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computations/ComputationsService.kt b/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computations/ComputationsService.kt index 352aa95c6d3..828d96cdaaf 100644 --- a/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computations/ComputationsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/duchy/service/internal/computations/ComputationsService.kt @@ -224,8 +224,7 @@ class ComputationsService( KeyCase.REQUISITION_KEY -> computationsDatabase.readComputationToken(request.requisitionKey) KeyCase.KEY_NOT_SET -> throw Status.INVALID_ARGUMENT.withDescription("key not set").asRuntimeException() - } - ?: throw Status.NOT_FOUND.asRuntimeException() + } ?: throw Status.NOT_FOUND.asRuntimeException() return computationToken.toGetComputationTokenResponse() } diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration/validation/EventFilterValidator.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration/validation/EventFilterValidator.kt index 6d8ab276ff2..792fb7efb79 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration/validation/EventFilterValidator.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration/validation/EventFilterValidator.kt @@ -295,8 +295,7 @@ private fun Expr.nonOperativeComparisonNode(operativeFields: Set): Boole val selectExpr = listOf(callExpr.argsList[0], callExpr.argsList[1]) .singleOrNull { it.hasSelectExpr() } - ?.selectExpr - ?: return false + ?.selectExpr ?: return false val fieldName: String = getFieldName(selectExpr) if (!operativeFields.contains(fieldName)) { diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/noiser/GaussianNoiser.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/noiser/GaussianNoiser.kt index ace84208eca..46b304c9c15 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/noiser/GaussianNoiser.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/noiser/GaussianNoiser.kt @@ -29,6 +29,7 @@ class GaussianNoiser(privacyParams: DpParams, random: Random) : AbstractNoiser() return NormalDistribution(RandomGeneratorFactory.createRandomGenerator(random), 0.0, sigma) } + override val variance: Double get() = distribution.numericalVariance diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStore.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStore.kt index 1cbc61e01d0..71a7f732783 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStore.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStore.kt @@ -73,8 +73,7 @@ class InMemoryBackingStoreTransactionContext( val lastEntry = transactionReferenceLedger[reference.measurementConsumerId] ?.filter { it.referenceId == reference.referenceId } - ?.maxByOrNull { it.createTime } - ?: return false + ?.maxByOrNull { it.createTime } ?: return false return lastEntry.isRefund == reference.isRefund } diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/deploy/common/postgres/PostgresBackingStore.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/deploy/common/postgres/PostgresBackingStore.kt index fbb87deab7d..3fe2b3dd91a 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/deploy/common/postgres/PostgresBackingStore.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/deploy/common/postgres/PostgresBackingStore.kt @@ -41,9 +41,11 @@ private const val MAX_BATCH_INSERT = 1000 */ class PostgresBackingStore(createConnection: () -> Connection) : PrivacyBudgetLedgerBackingStore { private val connection = createConnection() + init { connection.autoCommit = false } + private var previousTransactionContext: PostgresBackingStoreTransactionContext? = null override fun startTransaction(): PostgresBackingStoreTransactionContext { diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/AbstractPrivacyBudgetLedgerStoreTest.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/AbstractPrivacyBudgetLedgerStoreTest.kt index ef22aa51305..22ff423af31 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/AbstractPrivacyBudgetLedgerStoreTest.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/AbstractPrivacyBudgetLedgerStoreTest.kt @@ -32,6 +32,7 @@ import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.Referenc abstract class AbstractPrivacyBudgetLedgerStoreTest { protected abstract fun createBackingStore(): PrivacyBudgetLedgerBackingStore + protected abstract fun recreateSchema() @Before diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/TestInMemoryBackingStore.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/TestInMemoryBackingStore.kt index 08c3383056f..ec07be20d1a 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/TestInMemoryBackingStore.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/testing/TestInMemoryBackingStore.kt @@ -17,5 +17,6 @@ import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.InMemory class TestInMemoryBackingStore : InMemoryBackingStore() { fun getDpBalancesMap() = dpBalances.toMap() + fun getAcdpBalancesMap() = acdpBalances.toMap() } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/batch/ExchangesDeletion.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/batch/ExchangesDeletion.kt index 3c086d15eb5..6cd9f5f06d2 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/batch/ExchangesDeletion.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/batch/ExchangesDeletion.kt @@ -83,6 +83,7 @@ class ExchangesDeletion( } } } + companion object { private val logger: Logger = Logger.getLogger(this::class.java.name) } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/batch/PendingMeasurementsCancellation.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/batch/PendingMeasurementsCancellation.kt index 9766165d397..6eb951ba614 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/batch/PendingMeasurementsCancellation.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/batch/PendingMeasurementsCancellation.kt @@ -57,6 +57,7 @@ class PendingMeasurementsCancellation( .counterBuilder("pending_measurements_cancellation_total") .setDescription("Total number of pending measurements cancelled under retention policy") .build() + fun run() { if (timeToLive.toMillis() == 0L) { logger.warning("Time to live cannot be 0. TTL=$timeToLive") diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/Llv2ProtocolConfig.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/Llv2ProtocolConfig.kt index f017dfb0c97..b7f2cf03ee9 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/Llv2ProtocolConfig.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/Llv2ProtocolConfig.kt @@ -26,8 +26,10 @@ object Llv2ProtocolConfig { const val name = "llv2" lateinit var protocolConfig: ProtocolConfig.LiquidLegionsV2 private set + lateinit var duchyProtocolConfig: DuchyProtocolConfig.LiquidLegionsV2 private set + lateinit var requiredExternalDuchyIds: Set private set diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/RoLlv2ProtocolConfig.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/RoLlv2ProtocolConfig.kt index c4ef4ce9d88..9510214fe98 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/RoLlv2ProtocolConfig.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common/RoLlv2ProtocolConfig.kt @@ -26,8 +26,10 @@ object RoLlv2ProtocolConfig { const val name = "rollv2" lateinit var protocolConfig: ProtocolConfig.LiquidLegionsV2 private set + lateinit var duchyProtocolConfig: DuchyProtocolConfig.LiquidLegionsV2 private set + lateinit var requiredExternalDuchyIds: Set private set diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerAccountsService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerAccountsService.kt index 5f033a164fd..a76ef5a4b97 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerAccountsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerAccountsService.kt @@ -159,13 +159,11 @@ class SpannerAccountsService( client.singleUse(), request.identity.issuer, request.identity.subject - ) - ?: failGrpc(Status.NOT_FOUND) { "Identity not found" } + ) ?: failGrpc(Status.NOT_FOUND) { "Identity not found" } return AccountReader() .readByInternalAccountId(client.singleUse(), identityResult.accountId) - ?.account - ?: failGrpc(Status.NOT_FOUND) { "Account not found" } + ?.account ?: failGrpc(Status.NOT_FOUND) { "Account not found" } } override suspend fun generateOpenIdRequestParams( diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerApiKeysService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerApiKeysService.kt index e4d6d35be91..6854dc952b6 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerApiKeysService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerApiKeysService.kt @@ -71,8 +71,7 @@ class SpannerApiKeysService( val apiKey = MeasurementConsumerApiKeyReader() .readByAuthenticationKeyHash(txn, request.authenticationKeyHash) - ?.apiKey - ?: failGrpc(Status.NOT_FOUND) { "ApiKey not found for hash" } + ?.apiKey ?: failGrpc(Status.NOT_FOUND) { "ApiKey not found for hash" } return MeasurementConsumerReader() .readByExternalMeasurementConsumerId(txn, ExternalId(apiKey.externalMeasurementConsumerId)) diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerDataProvidersService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerDataProvidersService.kt index 032ca8d4e76..045fc7126f0 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerDataProvidersService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerDataProvidersService.kt @@ -44,11 +44,11 @@ class SpannerDataProvidersService( } return CreateDataProvider(request).execute(client, idGenerator) } + override suspend fun getDataProvider(request: GetDataProviderRequest): DataProvider { return DataProviderReader() .readByExternalDataProviderId(client.singleUse(), ExternalId(request.externalDataProviderId)) - ?.dataProvider - ?: failGrpc(Status.NOT_FOUND) { "DataProvider not found" } + ?.dataProvider ?: failGrpc(Status.NOT_FOUND) { "DataProvider not found" } } override suspend fun replaceDataProviderRequiredDuchies( diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangeStepsService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangeStepsService.kt index 5efb95af966..367e3a275be 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangeStepsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangeStepsService.kt @@ -75,8 +75,7 @@ class SpannerExchangeStepsService( appendClause("LIMIT 1") } .execute(client.singleUse()) - .singleOrNull() - ?: failGrpc(Status.NOT_FOUND) { "ExchangeStep not found" } + .singleOrNull() ?: failGrpc(Status.NOT_FOUND) { "ExchangeStep not found" } return exchangeStepResult.exchangeStep } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangesService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangesService.kt index 79ed79af8cd..20bff1c3afe 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangesService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerExchangesService.kt @@ -65,8 +65,7 @@ class SpannerExchangesService( } .execute(client.singleUse()) .singleOrNull() - ?.exchange - ?: failGrpc(Status.NOT_FOUND) { "Exchange not found" } + ?.exchange ?: failGrpc(Status.NOT_FOUND) { "Exchange not found" } } override fun streamExchanges(request: StreamExchangesRequest): Flow { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementConsumersService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementConsumersService.kt index 0a4402d4ef0..c23826da3bf 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementConsumersService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementConsumersService.kt @@ -83,8 +83,7 @@ class SpannerMeasurementConsumersService( client.singleUse(), ExternalId(request.externalMeasurementConsumerId) ) - ?.measurementConsumer - ?: failGrpc(Status.NOT_FOUND) { "MeasurementConsumer not found" } + ?.measurementConsumer ?: failGrpc(Status.NOT_FOUND) { "MeasurementConsumer not found" } } override suspend fun addMeasurementConsumerOwner( diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementsService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementsService.kt index 4482d4a3ca1..8045c7aaa78 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerMeasurementsService.kt @@ -116,8 +116,7 @@ class SpannerMeasurementsService( ExternalId(request.externalMeasurementConsumerId), ExternalId(request.externalMeasurementId) ) - ?.measurement - ?: failGrpc(Status.NOT_FOUND) { "Measurement not found" } + ?.measurement ?: failGrpc(Status.NOT_FOUND) { "Measurement not found" } } override suspend fun getMeasurementByComputationId( @@ -125,8 +124,7 @@ class SpannerMeasurementsService( ): Measurement { return MeasurementReader(Measurement.View.COMPUTATION) .readByExternalComputationId(client.singleUse(), ExternalId(request.externalComputationId)) - ?.measurement - ?: failGrpc(Status.NOT_FOUND) { "Measurement not found" } + ?.measurement ?: failGrpc(Status.NOT_FOUND) { "Measurement not found" } } override fun streamMeasurements(request: StreamMeasurementsRequest): Flow { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelProvidersService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelProvidersService.kt index 0fdd31a88af..dd1c8a072b6 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelProvidersService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelProvidersService.kt @@ -32,13 +32,13 @@ class SpannerModelProvidersService( override suspend fun createModelProvider(request: ModelProvider): ModelProvider { return CreateModelProvider().execute(client, idGenerator) } + override suspend fun getModelProvider(request: GetModelProviderRequest): ModelProvider { return ModelProviderReader() .readByExternalModelProviderId( client.singleUse(), ExternalId(request.externalModelProviderId) ) - ?.modelProvider - ?: failGrpc(Status.NOT_FOUND) { "ModelProvider not found" } + ?.modelProvider ?: failGrpc(Status.NOT_FOUND) { "ModelProvider not found" } } } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelReleasesService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelReleasesService.kt index ae623acf1e8..d68b1c59ab6 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelReleasesService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelReleasesService.kt @@ -54,8 +54,7 @@ class SpannerModelReleasesService( ExternalId(request.externalModelSuiteId), ExternalId(request.externalModelProviderId) ) - ?.modelRelease - ?: failGrpc(Status.NOT_FOUND) { "ModelRelease not found." } + ?.modelRelease ?: failGrpc(Status.NOT_FOUND) { "ModelRelease not found." } } override fun streamModelReleases(request: StreamModelReleasesRequest): Flow { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelSuitesService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelSuitesService.kt index 39b44d7baf0..0f63f509d1e 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelSuitesService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerModelSuitesService.kt @@ -54,8 +54,7 @@ class SpannerModelSuitesService( ExternalId(request.externalModelProviderId), ExternalId(request.externalModelSuiteId) ) - ?.modelSuite - ?: failGrpc(Status.NOT_FOUND) { "ModelSuite not found" } + ?.modelSuite ?: failGrpc(Status.NOT_FOUND) { "ModelSuite not found" } } override fun streamModelSuites(request: StreamModelSuitesRequest): Flow { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRecurringExchangesService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRecurringExchangesService.kt index fa20b6e9a98..0ad704f7d9f 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRecurringExchangesService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRecurringExchangesService.kt @@ -44,7 +44,6 @@ class SpannerRecurringExchangesService( client.singleUse(), ExternalId(request.externalRecurringExchangeId) ) - ?.recurringExchange - ?: failGrpc(Status.NOT_FOUND) { "RecurringExchange not found" } + ?.recurringExchange ?: failGrpc(Status.NOT_FOUND) { "RecurringExchange not found" } } } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRequisitionsService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRequisitionsService.kt index 2658edbc9ad..c3c9e6f6f30 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRequisitionsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/SpannerRequisitionsService.kt @@ -50,8 +50,7 @@ class SpannerRequisitionsService( externalDataProviderId = request.externalDataProviderId, externalRequisitionId = request.externalRequisitionId ) - ?.requisition - ?: failGrpc(Status.NOT_FOUND) { "Requisition not found" } + ?.requisition ?: failGrpc(Status.NOT_FOUND) { "Requisition not found" } } override fun streamRequisitions(request: StreamRequisitionsRequest): Flow { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/queries/StreamMeasurements.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/queries/StreamMeasurements.kt index 374131f1f33..26ad894160c 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/queries/StreamMeasurements.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/queries/StreamMeasurements.kt @@ -169,12 +169,14 @@ class StreamMeasurements( "externalMeasurementConsumerCertificateId" const val UPDATED_AFTER = "updatedAfter" const val STATES_PARAM = "states" + object AfterParams { const val UPDATE_TIME = "after_updateTime" const val EXTERNAL_MEASUREMENT_CONSUMER_ID = "after_externalMeasurementConsumerId" const val EXTERNAL_MEASUREMENT_ID = "after_externalMeasurementId" const val EXTERNAL_COMPUTATION_ID = "after_externalComputationId" } + const val UPDATED_BEFORE = "updatedBefore" const val CREATED_BEFORE = "createdBefore" } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/CertificateReader.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/CertificateReader.kt index 9476c5115d3..ab9067e429d 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/CertificateReader.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/CertificateReader.kt @@ -294,8 +294,7 @@ class CertificateReader(private val parentType: ParentType) : "DuchyCertificatesByExternalId", Key.of(duchyId.value, externalDuchyCertificateId.value), "CertificateId" - ) - ?: return null + ) ?: return null return InternalId(struct.getLong("CertificateId")) } } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/DataProviderReader.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/DataProviderReader.kt index 3fafeaae00d..7d837c23d39 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/DataProviderReader.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/DataProviderReader.kt @@ -104,8 +104,7 @@ class DataProviderReader : SpannerReader() { "DataProvidersByExternalId", Key.of(externalDataProviderId.value), column - ) - ?: return null + ) ?: return null return row.getInternalId(column) } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/MeasurementConsumerReader.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/MeasurementConsumerReader.kt index 69b8f395f53..f166d010546 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/MeasurementConsumerReader.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/readers/MeasurementConsumerReader.kt @@ -88,8 +88,7 @@ class MeasurementConsumerReader : SpannerReader DuchyIds.getInternalId(certificate.externalDuchyId)?.let { InternalId(it) } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateEventGroup.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateEventGroup.kt index bd08dbda7ac..0aae77657f6 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateEventGroup.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateEventGroup.kt @@ -47,8 +47,7 @@ class CreateEventGroup(private val request: CreateEventGroupRequest) : MeasurementConsumerReader.readMeasurementConsumerId( transactionContext, externalMeasurementConsumerId - ) - ?: throw MeasurementConsumerNotFoundException(externalMeasurementConsumerId) + ) ?: throw MeasurementConsumerNotFoundException(externalMeasurementConsumerId) val externalDataProviderId = ExternalId(request.eventGroup.externalDataProviderId) val dataProviderId: InternalId = diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateMeasurementConsumer.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateMeasurementConsumer.kt index be2b19539db..31ac3e9c2d8 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateMeasurementConsumer.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateMeasurementConsumer.kt @@ -112,8 +112,7 @@ class CreateMeasurementConsumer( .readByMeasurementConsumerCreationTokenHash( transactionContext, measurementConsumerCreationTokenHash - ) - ?: throw PermissionDeniedException() + ) ?: throw PermissionDeniedException() private suspend fun TransactionScope.readAccount( externalAccountId: ExternalId diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateModelRollout.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateModelRollout.kt index feddeabc964..5a20f8b9398 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateModelRollout.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateModelRollout.kt @@ -49,6 +49,7 @@ class CreateModelRollout(private val modelRollout: ModelRollout, private val clo val externalModelRolloutId: Long, val rolloutPeriodStartTime: Timestamp? ) + override suspend fun TransactionScope.runTransaction(): ModelRollout { val now = clock.instant().toProtoTime() if (Timestamps.compare(now, modelRollout.rolloutPeriodStartTime) >= 0) { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateRecurringExchange.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateRecurringExchange.kt index 21f3ac3a983..eeb3895f078 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateRecurringExchange.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/CreateRecurringExchange.kt @@ -42,15 +42,13 @@ class CreateRecurringExchange(private val recurringExchange: RecurringExchange) val dataProviderId = DataProviderReader() .readByExternalDataProviderId(transactionContext, externalDataProviderId) - ?.dataProviderId - ?: throw DataProviderNotFoundException(externalDataProviderId) + ?.dataProviderId ?: throw DataProviderNotFoundException(externalDataProviderId) val externalModelProviderId = ExternalId(recurringExchange.externalModelProviderId) val modelProviderId = ModelProviderReader() .readByExternalModelProviderId(transactionContext, externalModelProviderId) - ?.modelProviderId - ?: throw ModelProviderNotFoundException(externalModelProviderId) + ?.modelProviderId ?: throw ModelProviderNotFoundException(externalModelProviderId) val externalId = idGenerator.generateExternalId() transactionContext.bufferInsertMutation("RecurringExchanges") { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteApiKey.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteApiKey.kt index 547bf82f113..f2894d2c3b2 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteApiKey.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteApiKey.kt @@ -60,8 +60,7 @@ class DeleteApiKey( MeasurementConsumerReader.readMeasurementConsumerId( transactionContext, externalMeasurementConsumerId - ) - ?: throw MeasurementConsumerNotFoundException(externalMeasurementConsumerId) + ) ?: throw MeasurementConsumerNotFoundException(externalMeasurementConsumerId) private suspend fun TransactionScope.readApiKey( externalApiKeyId: ExternalId diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteModelShard.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteModelShard.kt index b3be1c097a1..f6fa36aead0 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteModelShard.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/DeleteModelShard.kt @@ -68,8 +68,7 @@ class DeleteModelShard( private suspend fun TransactionScope.readInternalDataProviderId(): Long = DataProviderReader() .readByExternalDataProviderId(transactionContext, externalDataProviderId) - ?.dataProviderId - ?: throw DataProviderNotFoundException(externalDataProviderId) + ?.dataProviderId ?: throw DataProviderNotFoundException(externalDataProviderId) private suspend fun TransactionScope.readModelShard(): ModelShardReader.Result = ModelShardReader() diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/FinishExchangeStepAttempt.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/FinishExchangeStepAttempt.kt index b141c4b2547..13eaa018085 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/FinishExchangeStepAttempt.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/FinishExchangeStepAttempt.kt @@ -127,8 +127,7 @@ class FinishExchangeStepAttempt( .singleOrNull() ?.recurringExchange ?.details - ?.exchangeWorkflow - ?: throw RecurringExchangeNotFoundException(externalRecurringExchangeId) + ?.exchangeWorkflow ?: throw RecurringExchangeNotFoundException(externalRecurringExchangeId) val steps = findNewlyUnblockedExchangeSteps(workflow) updateExchangeStepsToReady( diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/ReplaceDataProviderRequiredDuchies.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/ReplaceDataProviderRequiredDuchies.kt index 276da8ed34b..e8149c5e872 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/ReplaceDataProviderRequiredDuchies.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/ReplaceDataProviderRequiredDuchies.kt @@ -64,6 +64,7 @@ class ReplaceDataProviderRequiredDuchies( .addAllRequiredExternalDuchyIds(desiredRequiredDuchyList) .build() } + override fun ResultScope.buildResult(): DataProvider { return checkNotNull(transactionResult) } diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/SetMeasurementResult.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/SetMeasurementResult.kt index da6c24934af..78dcbf363d6 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/SetMeasurementResult.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/SetMeasurementResult.kt @@ -100,6 +100,7 @@ class SetMeasurementResult(private val request: SetMeasurementResultRequest) : } } } + override fun ResultScope.buildResult(): Measurement { return checkNotNull(transactionResult).copy { updateTime = commitTimestamp.toProto() diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/UpdatePublicKey.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/UpdatePublicKey.kt index 9f99dc82b4a..db3d4922229 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/UpdatePublicKey.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/gcloud/spanner/writers/UpdatePublicKey.kt @@ -87,8 +87,7 @@ class UpdatePublicKey(private val request: UpdatePublicKeyRequest) : SimpleSpann .readByExternalDataProviderId( transactionContext, ExternalId(request.externalDataProviderId) - ) - ?: throw DataProviderNotFoundException(ExternalId(request.externalDataProviderId)) + ) ?: throw DataProviderNotFoundException(ExternalId(request.externalDataProviderId)) val certificateId: InternalId = CertificateReader(CertificateReader.ParentType.DATA_PROVIDER) diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/tools/CreateResource.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/tools/CreateResource.kt index b4a67464c76..52a127730ac 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/tools/CreateResource.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/deploy/tools/CreateResource.kt @@ -150,6 +150,7 @@ private class CreateDataProviderCommand : CreatePrincipalCommand() { required = false, ) private var requiredDuchies: List = emptyList() + override fun run() { val dataProvider = dataProvider { certificate = this@CreateDataProviderCommand.certificate diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/DataProvidersService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/DataProvidersService.kt index a2a25eac341..3e5a90771c4 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/DataProvidersService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/DataProvidersService.kt @@ -80,6 +80,7 @@ class DataProvidersService(private val internalClient: DataProvidersCoroutineStu return internalDataProvider.toDataProvider() } + override suspend fun replaceDataProviderRequiredDuchies( request: ReplaceDataProviderRequiredDuchiesRequest ): DataProvider { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/EventGroupsService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/EventGroupsService.kt index fa8f2423395..d980392a364 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/EventGroupsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/EventGroupsService.kt @@ -307,7 +307,7 @@ class EventGroupsService(private val internalEventGroupsStub: InternalEventGroup val parentKey: ResourceKey = DataProviderKey.fromName(request.parent) ?: MeasurementConsumerKey.fromName(request.parent) - ?: throw Status.INVALID_ARGUMENT.withDescription("parent unspecified or invalid") + ?: throw Status.INVALID_ARGUMENT.withDescription("parent unspecified or invalid") .asRuntimeException() if (parentKey != principalFromCurrentContext.resourceKey) { throw permissionDeniedStatus().asRuntimeException() diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsService.kt index eecc89b5c94..9810097b275 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/RequisitionsService.kt @@ -95,7 +95,7 @@ class RequisitionsService( val parentKey = DataProviderKey.fromName(request.parent) ?: MeasurementKey.fromName(request.parent) - ?: throw Status.INVALID_ARGUMENT.withDescription("parent is invalid").asRuntimeException() + ?: throw Status.INVALID_ARGUMENT.withDescription("parent is invalid").asRuntimeException() val principal: MeasurementPrincipal = principalFromCurrentContext when (parentKey) { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/DataProvidersServiceTest.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/DataProvidersServiceTest.kt index a90cfa6b517..2ed141fbfd3 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/DataProvidersServiceTest.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/DataProvidersServiceTest.kt @@ -211,6 +211,7 @@ abstract class DataProvidersServiceTest { assertThat(dataProviderRead).isEqualTo(createdDataProvider) } + @Test fun `replaceDataProviderRequiredDuchies succeeds`() = runBlocking { val dataProvider = dataProvider { diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/MeasurementLogEntriesServiceTest.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/MeasurementLogEntriesServiceTest.kt index c4e9721a8fc..1ec5d134acf 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/MeasurementLogEntriesServiceTest.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/MeasurementLogEntriesServiceTest.kt @@ -66,6 +66,7 @@ abstract class MeasurementLogEntriesServiceTest { assertThat(exception.status.code).isEqualTo(Status.Code.INVALID_ARGUMENT) assertThat(exception).hasMessageThat().contains("exceeds limit") } + @Test fun `batchDeleteMeasurements deletes Measurements when all etags match`() = runBlocking { val measurementConsumer = diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/Population.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/Population.kt index b005d6e72ec..b5d8ed04e1a 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/Population.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/internal/testing/Population.kt @@ -89,6 +89,7 @@ class Population(val clock: Clock, val idGenerator: IdGenerator) { val WORKER2_DUCHY = DuchyIds.Entry(3, "worker2", VALID_ACTIVE_START_TIME..VALID_ACTIVE_END_TIME) val DUCHIES = listOf(AGGREGATOR_DUCHY, WORKER1_DUCHY, WORKER2_DUCHY) } + private fun buildRequestCertificate( derUtf8: String, skidUtf8: String, diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ComputationsService.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ComputationsService.kt index 08979920555..9205ff2a83f 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ComputationsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/system/v1alpha/ComputationsService.kt @@ -221,6 +221,7 @@ private val STATES_SUBSCRIBED = private object ContinuationTokenConverter { fun encode(token: StreamActiveComputationsContinuationToken): String = token.toByteArray().base64UrlEncode() + fun decode(token: String): StreamActiveComputationsContinuationToken = StreamActiveComputationsContinuationToken.parseFrom(token.base64UrlDecode()) } diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/resourcesetup/Output.kt b/src/main/kotlin/org/wfanet/measurement/loadtest/resourcesetup/Output.kt index eb84ef06841..e6d0b9239a5 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/resourcesetup/Output.kt +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/resourcesetup/Output.kt @@ -26,6 +26,7 @@ import java.io.File */ internal sealed interface Output { fun resolve(relative: String): Output + fun writer(): Writable } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementFailure.kt b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementFailure.kt index a32ea835e61..dd495932826 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementFailure.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementFailure.kt @@ -40,8 +40,7 @@ class SetMeasurementFailure(private val request: SetMeasurementFailureRequest) : transactionContext, measurementConsumerReferenceId = request.measurementConsumerReferenceId, measurementReferenceId = request.measurementReferenceId - ) - ?: throw MeasurementNotFoundException() + ) ?: throw MeasurementNotFoundException() if (measurementResult.measurement.state != Measurement.State.PENDING) { throw MeasurementStateInvalidException() diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementResult.kt b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementResult.kt index 76ba467120b..869949b24b4 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementResult.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/postgres/writers/SetMeasurementResult.kt @@ -60,8 +60,7 @@ class SetMeasurementResult(private val request: SetMeasurementResultRequest) : transactionContext, measurementConsumerReferenceId = request.measurementConsumerReferenceId, measurementReferenceId = request.measurementReferenceId - ) - ?: throw MeasurementNotFoundException() + ) ?: throw MeasurementNotFoundException() if (measurementResult.measurement.state != Measurement.State.PENDING) { throw MeasurementStateInvalidException() diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/PostgresReportsService.kt b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/PostgresReportsService.kt index b806a2e13ee..6335df7d3a2 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/PostgresReportsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/PostgresReportsService.kt @@ -79,8 +79,7 @@ class PostgresReportsService( return try { ReportReader(readContext) .readReportByExternalId(request.cmmsMeasurementConsumerId, request.externalReportId) - ?.report - ?: throw Status.NOT_FOUND.withDescription("Report not found.").asRuntimeException() + ?.report ?: throw Status.NOT_FOUND.withDescription("Report not found.").asRuntimeException() } finally { readContext.close() } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/writers/CreateReport.kt b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/writers/CreateReport.kt index 833c914d750..8854887c716 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/writers/CreateReport.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/writers/CreateReport.kt @@ -52,6 +52,7 @@ class CreateReport(private val request: CreateReportRequest) : PostgresWriter Unit>, val updatedReportingMetricEntries: Map, ) + override suspend fun TransactionScope.runTransaction(): Report { val measurementConsumerId = (MeasurementConsumerReader(transactionContext) diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsService.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsService.kt index 3097cc53b10..571c7db8386 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsService.kt @@ -726,8 +726,7 @@ class ReportsService( encryptionKeyPairStore.getPrivateKeyHandle( principalName, EncryptionPublicKey.parseFrom(measurementSpec.measurementPublicKey).data - ) - ?: failGrpc(Status.PERMISSION_DENIED) { "Encryption private key not found" } + ) ?: failGrpc(Status.PERMISSION_DENIED) { "Encryption private key not found" } val setInternalMeasurementResultRequest = buildSetInternalMeasurementResultRequest( diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/tools/Reporting.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/tools/Reporting.kt index 983cf33c4fe..b4d47350c65 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/tools/Reporting.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/tools/Reporting.kt @@ -180,6 +180,7 @@ class ReportingSetsCommand : Runnable { val reportingSetStub: ReportingSetsCoroutineStub by lazy { ReportingSetsCoroutineStub(parent.channel) } + override fun run() {} } @@ -485,6 +486,7 @@ class Reporting : Runnable { buildMutualTlsChannel(apiFlags.apiTarget, clientCerts, apiFlags.apiCertHost) .withShutdownTimeout(Duration.ofSeconds(1)) } + override fun run() {} companion object { diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/tools/Reporting.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/tools/Reporting.kt index 3facd5b355a..07e0aee70ed 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/tools/Reporting.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/tools/Reporting.kt @@ -220,6 +220,7 @@ class ReportingSetsCommand : Runnable { val reportingSetStub: ReportingSetsCoroutineStub by lazy { ReportingSetsCoroutineStub(parent.channel) } + override fun run() {} } @@ -614,6 +615,7 @@ class Reporting : Runnable { buildMutualTlsChannel(apiFlags.apiTarget, clientCerts, apiFlags.apiCertHost) .withShutdownTimeout(Duration.ofSeconds(1)) } + override fun run() {} companion object { diff --git a/src/main/kotlin/org/wfanet/panelmatch/client/privatemembership/testing/JniQueryEvaluatorContext.kt b/src/main/kotlin/org/wfanet/panelmatch/client/privatemembership/testing/JniQueryEvaluatorContext.kt index 11b9f8378f9..cddb40531ba 100644 --- a/src/main/kotlin/org/wfanet/panelmatch/client/privatemembership/testing/JniQueryEvaluatorContext.kt +++ b/src/main/kotlin/org/wfanet/panelmatch/client/privatemembership/testing/JniQueryEvaluatorContext.kt @@ -35,6 +35,7 @@ class JniQueryEvaluatorContext(shardCount: Int, bucketsPerShardCount: Int) : Ser val privateMembershipPublicKey: PublicKey val privateMembershipPrivateKey: PrivateKey + init { val response = JniPrivateMembership.generateKeys( diff --git a/src/main/kotlin/org/wfanet/panelmatch/common/certificates/aws/CreateCertificateClient.kt b/src/main/kotlin/org/wfanet/panelmatch/common/certificates/aws/CreateCertificateClient.kt index 3e2a54a5f74..49458cd96e8 100644 --- a/src/main/kotlin/org/wfanet/panelmatch/common/certificates/aws/CreateCertificateClient.kt +++ b/src/main/kotlin/org/wfanet/panelmatch/common/certificates/aws/CreateCertificateClient.kt @@ -21,5 +21,6 @@ import software.amazon.awssdk.services.acmpca.model.IssueCertificateResponse interface CreateCertificateClient { suspend fun issueCertificate(request: IssueCertificateRequest): IssueCertificateResponse + suspend fun getCertificate(request: GetCertificateRequest): GetCertificateResponse } diff --git a/src/test/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystemTest.kt b/src/test/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystemTest.kt index 045376629ad..0d05321427a 100644 --- a/src/test/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystemTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/api/v2alpha/tools/MeasurementSystemTest.kt @@ -1570,6 +1570,7 @@ class MeasurementSystemTest { } ) } + @Test fun `list model outages succeeds omitting optional params`() { val args = diff --git a/src/test/kotlin/org/wfanet/measurement/duchy/service/system/v1alpha/ComputationControlServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/duchy/service/system/v1alpha/ComputationControlServiceTest.kt index 2856c900066..5c8882d13d3 100644 --- a/src/test/kotlin/org/wfanet/measurement/duchy/service/system/v1alpha/ComputationControlServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/duchy/service/system/v1alpha/ComputationControlServiceTest.kt @@ -67,6 +67,7 @@ private const val BLOB_ID = 1234L class ComputationControlServiceTest { private val mockAsyncControlService: AsyncComputationControlCoroutineImplBase = mockService() private val advanceAsyncComputationRequests = mutableListOf() + private fun stubAsyncService() { mockAsyncControlService.stub { onBlocking { advanceComputation(any()) } @@ -103,6 +104,7 @@ class ComputationControlServiceTest { @get:Rule val ruleChain = chainRulesSequentially(tempDirectory, duchyIdSetter, grpcTestServerRule) private lateinit var senderContext: SenderContext + private suspend fun withSender( sender: DuchyIdentity, rpcCall: suspend ComputationControlService.() -> R diff --git a/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStoreTest.kt b/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStoreTest.kt index 0a268567934..f2bd965c459 100644 --- a/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStoreTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/InMemoryBackingStoreTest.kt @@ -19,6 +19,7 @@ class InMemoryBackingStoreTest : AbstractPrivacyBudgetLedgerStoreTest() { companion object { @JvmStatic private var backingStore: InMemoryBackingStore? = null } + override fun createBackingStore(): PrivacyBudgetLedgerBackingStore { if (backingStore == null) { backingStore = InMemoryBackingStore() diff --git a/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/PrivacyBudgetManagerTest.kt b/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/PrivacyBudgetManagerTest.kt index 3bbec5ff31a..c616f62a282 100644 --- a/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/PrivacyBudgetManagerTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/PrivacyBudgetManagerTest.kt @@ -104,6 +104,7 @@ class PrivacyBudgetManagerTest { ) .isTrue() } + @Test fun `referenceWillBeProcessed returns false for the same reference that will not be processed`() = runBlocking { diff --git a/src/test/kotlin/org/wfanet/measurement/integration/k8s/AbstractCorrectnessTest.kt b/src/test/kotlin/org/wfanet/measurement/integration/k8s/AbstractCorrectnessTest.kt index 0836d9183e4..051559891ed 100644 --- a/src/test/kotlin/org/wfanet/measurement/integration/k8s/AbstractCorrectnessTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/integration/k8s/AbstractCorrectnessTest.kt @@ -32,6 +32,7 @@ import org.wfanet.measurement.loadtest.measurementconsumer.MeasurementConsumerSi abstract class AbstractCorrectnessTest(private val measurementSystem: MeasurementSystem) { private val runId: String get() = measurementSystem.runId + private val testHarness: MeasurementConsumerSimulator get() = measurementSystem.testHarness diff --git a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/CertificatesServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/CertificatesServiceTest.kt index 3dd073014ee..6f369b0cf54 100644 --- a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/CertificatesServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/CertificatesServiceTest.kt @@ -369,6 +369,7 @@ class CertificatesServiceTest { assertFailsWith { runBlocking { service.getCertificate(request) } } assertThat(exception.status.code).isEqualTo(Status.Code.UNAUTHENTICATED) } + @Test fun `getCertificate throws PERMISSION_DENIED when MC caller doesn't match parent MC`() { val request = getCertificateRequest { name = MEASUREMENT_CONSUMER_CERTIFICATE_NAME_2 } diff --git a/src/test/kotlin/org/wfanet/measurement/reporting/deploy/common/EncryptionKeyPairMapTest.kt b/src/test/kotlin/org/wfanet/measurement/reporting/deploy/common/EncryptionKeyPairMapTest.kt index ae83d461bea..39ddc565f8b 100644 --- a/src/test/kotlin/org/wfanet/measurement/reporting/deploy/common/EncryptionKeyPairMapTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/reporting/deploy/common/EncryptionKeyPairMapTest.kt @@ -79,6 +79,7 @@ class EncryptionKeyPairMapTest { keyPairMap: Map>>, ) = keyPairMap[principal]?.find { (key, _): Pair -> key == publicKey } + @Test fun `keyPairMap returns corresponding private keys`() { val args = diff --git a/src/test/kotlin/org/wfanet/panelmatch/client/eventpreprocessing/BatchingDoFnTest.kt b/src/test/kotlin/org/wfanet/panelmatch/client/eventpreprocessing/BatchingDoFnTest.kt index c15ed550f0c..33c72c1a80e 100644 --- a/src/test/kotlin/org/wfanet/panelmatch/client/eventpreprocessing/BatchingDoFnTest.kt +++ b/src/test/kotlin/org/wfanet/panelmatch/client/eventpreprocessing/BatchingDoFnTest.kt @@ -84,12 +84,15 @@ class BatchingDoFnTest : BeamTestBase() { mutableListOf("3") ) } + private fun makeParDo(maxByteSize: Long): ParDo.SingleOutput>? { return ParDo.of(BatchingDoFn(maxByteSize, StringLengthSize)) } + private fun makeTestStream(): TestStream.Builder { return TestStream.create(StringUtf8Coder.of()) } + private fun batchSingleBundle( batchSize: Long, item: String, diff --git a/src/test/kotlin/org/wfanet/panelmatch/client/logger/LoggerTest.kt b/src/test/kotlin/org/wfanet/panelmatch/client/logger/LoggerTest.kt index ddfa7ac34b2..f477cc01870 100644 --- a/src/test/kotlin/org/wfanet/panelmatch/client/logger/LoggerTest.kt +++ b/src/test/kotlin/org/wfanet/panelmatch/client/logger/LoggerTest.kt @@ -38,6 +38,7 @@ private class JobTestClass1 { delay(100) logger.addToTaskLog("logWithDelay: Log Message B") } + companion object { private val logger by loggerFor() } @@ -51,6 +52,7 @@ private class JobTestClass2 { logger.addToTaskLog("logWithDelay: Log Message D") } } + companion object { private val logger by loggerFor() } @@ -64,6 +66,7 @@ private class JobTestClass3 { logger.addToTaskLog("logWithDelay: Log Message D") } } + companion object { private val logger by loggerFor() }