diff --git a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/BUILD.bazel index 26a29e94153..0589f4ae5e0 100644 --- a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/BUILD.bazel @@ -90,12 +90,3 @@ kt_jvm_library( "@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common", ], ) - -kt_jvm_library( - name = "time_intervals", - srcs = ["TimeIntervals.kt"], - deps = [ - "//src/main/proto/wfa/measurement/api/v2alpha:requisition_spec_kt_jvm_proto", - "@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common", - ], -) diff --git a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/TimeIntervals.kt b/src/main/kotlin/org/wfanet/measurement/api/v2alpha/TimeIntervals.kt deleted file mode 100644 index 8d846834d86..00000000000 --- a/src/main/kotlin/org/wfanet/measurement/api/v2alpha/TimeIntervals.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2022 The Cross-Media Measurement Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.wfanet.measurement.api.v2alpha - -import org.wfanet.measurement.common.OpenEndTimeRange -import org.wfanet.measurement.common.toInstant - -fun TimeInterval.toRange(): OpenEndTimeRange = - OpenEndTimeRange(startTime.toInstant(), endTime.toInstant()) 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 9f3c624f3c4..db1c793542b 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 @@ -50,6 +50,7 @@ package org.wfanet.measurement.api.v2alpha.tools import com.google.protobuf.ByteString +import com.google.type.interval import io.grpc.ManagedChannel import java.io.File import java.security.SecureRandom @@ -87,7 +88,6 @@ import org.wfanet.measurement.api.v2alpha.getMeasurementRequest import org.wfanet.measurement.api.v2alpha.measurement import org.wfanet.measurement.api.v2alpha.measurementSpec import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.api.withAuthenticationKey import org.wfanet.measurement.common.commandLineMain import org.wfanet.measurement.common.crypto.Hashing @@ -413,7 +413,7 @@ private fun getDataProviderEntry( eventGroupEntry { key = it.name value = eventGroupEntryValue { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = it.eventStartTime.toProtoTime() endTime = it.eventEndTime.toProtoTime() } 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 5a1650ce006..225c25a377b 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 @@ -20,6 +20,7 @@ import com.google.crypto.tink.BinaryKeysetReader import com.google.crypto.tink.CleartextKeysetHandle import com.google.protobuf.ByteString import com.google.protobuf.kotlin.toByteString +import com.google.type.interval import io.grpc.ManagedChannel import java.io.File import java.security.SecureRandom @@ -125,7 +126,6 @@ import org.wfanet.measurement.api.v2alpha.scheduleModelRolloutFreezeRequest import org.wfanet.measurement.api.v2alpha.setModelLineActiveEndTimeRequest import org.wfanet.measurement.api.v2alpha.setModelLineHoldbackModelLineRequest import org.wfanet.measurement.api.v2alpha.signedData -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.api.v2alpha.updatePublicKeyRequest import org.wfanet.measurement.api.withAuthenticationKey import org.wfanet.measurement.api.withIdToken @@ -860,7 +860,7 @@ class CreateMeasurement : Runnable { key = it.name value = EventGroupEntries.value { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = it.eventStartTime.toProtoTime() endTime = it.eventEndTime.toProtoTime() } @@ -1505,7 +1505,7 @@ private class ModelOutages { val request = createModelOutageRequest { parent = modelLineName modelOutage = modelOutage { - outageInterval = timeInterval { + outageInterval = interval { startTime = outageStartTime.toProtoTime() endTime = outageEndTime.toProtoTime() } @@ -1574,7 +1574,7 @@ private class ModelOutages { if (outageStartTime != null && outageEndTime != null) { filter = ListModelOutagesRequestKt.filter { - outageIntervalOverlapping = timeInterval { + outageIntervalOverlapping = interval { startTime = outageStartTime.toProtoTime() endTime = outageEndTime.toProtoTime() } @@ -1780,7 +1780,7 @@ private class ModelRollouts { if (instantRolloutTime != null) { this.instantRolloutTime = instantRolloutTime.toProtoTime() } else { - gradualRolloutPeriod = timeInterval { + gradualRolloutPeriod = interval { startTime = rolloutStartTime!!.toProtoTime() endTime = rolloutEndTime!!.toProtoTime() } @@ -1842,7 +1842,7 @@ private class ModelRollouts { if (rolloutPeriodStartTime != null && rolloutPeriodEndTime != null) { filter = ListModelRolloutsRequestKt.filter { - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = rolloutPeriodStartTime.toProtoTime() endTime = rolloutPeriodEndTime.toProtoTime() } diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/BUILD.bazel index 28ea382a83f..b85ae365c3e 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/BUILD.bazel @@ -9,7 +9,6 @@ kt_jvm_library( name = "privacy_query_mapper", srcs = glob(["*.kt"]), deps = [ - "//src/main/kotlin/org/wfanet/measurement/api/v2alpha:time_intervals", "//src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration:event_filters", "//src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement:privacy_budget_manager", "//src/main/proto/wfa/measurement/api/v2alpha:measurement_spec_kt_jvm_proto", diff --git a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapper.kt b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapper.kt index 6b3379a7df5..f96a7b32154 100644 --- a/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapper.kt +++ b/src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapper.kt @@ -16,7 +16,7 @@ package org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.api.v2a import org.wfanet.measurement.api.v2alpha.MeasurementSpec import org.wfanet.measurement.api.v2alpha.MeasurementSpec.MeasurementTypeCase import org.wfanet.measurement.api.v2alpha.RequisitionSpec -import org.wfanet.measurement.api.v2alpha.toRange +import org.wfanet.measurement.common.toRange import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.DpCharge import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.EventGroupSpec import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.LandscapeMask diff --git a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt index 18419b451e3..0d5bb397b55 100644 --- a/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt +++ b/src/main/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ProtoConversions.kt @@ -15,6 +15,7 @@ package org.wfanet.measurement.kingdom.service.api.v2alpha import com.google.protobuf.util.Timestamps +import com.google.type.interval import org.wfanet.measurement.api.Version import org.wfanet.measurement.api.v2alpha.DataProviderCertificateKey import org.wfanet.measurement.api.v2alpha.DataProviderKey @@ -77,7 +78,6 @@ import org.wfanet.measurement.api.v2alpha.modelShard import org.wfanet.measurement.api.v2alpha.modelSuite import org.wfanet.measurement.api.v2alpha.protocolConfig import org.wfanet.measurement.api.v2alpha.signedData -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.common.identity.apiIdToExternalId import org.wfanet.measurement.common.identity.externalIdToApiId import org.wfanet.measurement.common.toLocalDate @@ -404,7 +404,7 @@ fun InternalModelOutage.toModelOutage(): ModelOutage { externalIdToApiId(source.externalModelOutageId) ) .toName() - outageInterval = timeInterval { + outageInterval = interval { startTime = source.modelOutageStartTime endTime = source.modelOutageEndTime } @@ -444,7 +444,7 @@ fun InternalModelRollout.toModelRollout(): ModelRollout { if (Timestamps.compare(source.rolloutPeriodStartTime, source.rolloutPeriodEndTime) == 0) { instantRolloutTime = source.rolloutPeriodStartTime } else { - gradualRolloutPeriod = timeInterval { + gradualRolloutPeriod = interval { startTime = source.rolloutPeriodStartTime endTime = source.rolloutPeriodEndTime } diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BUILD.bazel index 7841831f865..c66d19ba6e3 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BUILD.bazel @@ -29,7 +29,6 @@ kt_jvm_library( "//imports/java/com/google:cel-generated-pb", "//imports/java/org/projectnessie/cel", "//src/main/kotlin/org/wfanet/measurement/api/v2alpha:resource_key", - "//src/main/kotlin/org/wfanet/measurement/api/v2alpha:time_intervals", "//src/main/kotlin/org/wfanet/measurement/eventdataprovider/eventfiltration:event_filters", "//src/main/kotlin/org/wfanet/measurement/eventdataprovider/noiser", "//src/main/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement:privacy_budget_manager", diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BigQueryEventQuery.kt b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BigQueryEventQuery.kt index 21c7bf0950e..ea2ae1121bc 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BigQueryEventQuery.kt +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/BigQueryEventQuery.kt @@ -23,12 +23,12 @@ import com.google.cloud.bigquery.JobId import com.google.cloud.bigquery.JobInfo import com.google.cloud.bigquery.QueryJobConfiguration import com.google.cloud.bigquery.QueryParameterValue +import com.google.type.Interval import java.time.Instant import java.time.temporal.ChronoUnit import java.util.UUID import java.util.logging.Logger import org.wfanet.measurement.api.v2alpha.RequisitionSpec.EventFilter -import org.wfanet.measurement.api.v2alpha.TimeInterval import org.wfanet.measurement.api.v2alpha.event_templates.testing.Person import org.wfanet.measurement.api.v2alpha.event_templates.testing.PersonKt import org.wfanet.measurement.api.v2alpha.event_templates.testing.TestEvent @@ -47,10 +47,7 @@ class BigQueryEventQuery( private val publisherId: Int, ) : EventQuery { - override fun getUserVirtualIds( - timeInterval: TimeInterval, - eventFilter: EventFilter - ): Sequence { + override fun getUserVirtualIds(timeInterval: Interval, eventFilter: EventFilter): Sequence { val queryConfig = buildQueryConfig( publisherId = publisherId, diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EventQuery.kt b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EventQuery.kt index beeb11c7fcb..6a6be48e527 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EventQuery.kt +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EventQuery.kt @@ -15,10 +15,10 @@ package org.wfanet.measurement.loadtest.dataprovider import com.google.protobuf.Descriptors +import com.google.type.Interval import org.projectnessie.cel.Program import org.projectnessie.cel.common.types.BoolT import org.wfanet.measurement.api.v2alpha.RequisitionSpec.EventFilter -import org.wfanet.measurement.api.v2alpha.TimeInterval import org.wfanet.measurement.eventdataprovider.eventfiltration.EventFilters /** A query to get the list of user virtual IDs for a particular requisition. */ @@ -29,7 +29,7 @@ interface EventQuery { * Each element in the returned value represents a single event. As a result, the same VID may be * returned multiple times. */ - fun getUserVirtualIds(timeInterval: TimeInterval, eventFilter: EventFilter): Sequence + fun getUserVirtualIds(timeInterval: Interval, eventFilter: EventFilter): Sequence companion object { private val TRUE_EVAL_RESULT = Program.newEvalResult(BoolT.True, null) diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/InMemoryEventQuery.kt b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/InMemoryEventQuery.kt index 8b2a06c60d2..a7ccb2c6208 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/InMemoryEventQuery.kt +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/InMemoryEventQuery.kt @@ -13,12 +13,12 @@ */ package org.wfanet.measurement.loadtest.dataprovider +import com.google.type.Interval import org.wfanet.measurement.api.v2alpha.RequisitionSpec -import org.wfanet.measurement.api.v2alpha.TimeInterval import org.wfanet.measurement.api.v2alpha.event_templates.testing.TestEvent import org.wfanet.measurement.api.v2alpha.event_templates.testing.timeOrNull -import org.wfanet.measurement.api.v2alpha.toRange import org.wfanet.measurement.common.toInstant +import org.wfanet.measurement.common.toRange import org.wfanet.measurement.eventdataprovider.eventfiltration.EventFilters /** Fulfills the query with matching events using filters. */ @@ -30,7 +30,7 @@ open class InMemoryEventQuery(private val events: Iterable) : Eve data class LabelledEvent(val vid: Long, val event: TestEvent) override fun getUserVirtualIds( - timeInterval: TimeInterval, + timeInterval: Interval, eventFilter: RequisitionSpec.EventFilter ): Sequence { val timeRange = timeInterval.toRange() diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/RandomEventQuery.kt b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/RandomEventQuery.kt index 6cd02bb8777..29c5fbc0fd6 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/RandomEventQuery.kt +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/RandomEventQuery.kt @@ -14,10 +14,10 @@ package org.wfanet.measurement.loadtest.dataprovider +import com.google.type.Interval import java.util.logging.Logger import kotlin.random.Random import org.wfanet.measurement.api.v2alpha.RequisitionSpec.EventFilter -import org.wfanet.measurement.api.v2alpha.TimeInterval data class SketchGenerationParams( val reach: Int, @@ -28,10 +28,7 @@ data class SketchGenerationParams( class RandomEventQuery(private val sketchGenerationParams: SketchGenerationParams) : EventQuery { /** Returns VIDs generated from random values, ignoring [timeInterval] and [eventFilter]. */ - override fun getUserVirtualIds( - timeInterval: TimeInterval, - eventFilter: EventFilter - ): Sequence { + override fun getUserVirtualIds(timeInterval: Interval, eventFilter: EventFilter): Sequence { // TODO(@alberthsuu): Generate eventId, deduplicate the list of (eventId, vid), and // return the vids in case eventGroups overlap in some way diff --git a/src/main/kotlin/org/wfanet/measurement/loadtest/frontend/FrontendSimulator.kt b/src/main/kotlin/org/wfanet/measurement/loadtest/frontend/FrontendSimulator.kt index 256deaed47c..cadc2ad6bd4 100644 --- a/src/main/kotlin/org/wfanet/measurement/loadtest/frontend/FrontendSimulator.kt +++ b/src/main/kotlin/org/wfanet/measurement/loadtest/frontend/FrontendSimulator.kt @@ -16,6 +16,7 @@ package org.wfanet.measurement.loadtest.frontend import com.google.common.truth.Truth.assertThat import com.google.protobuf.ByteString +import com.google.type.interval import io.grpc.StatusException import java.nio.file.Paths import java.security.SignatureException @@ -81,7 +82,6 @@ import org.wfanet.measurement.api.v2alpha.measurement import org.wfanet.measurement.api.v2alpha.measurementSpec import org.wfanet.measurement.api.v2alpha.requisitionSpec import org.wfanet.measurement.api.v2alpha.testing.MeasurementResultSubject.Companion.assertThat -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.api.withAuthenticationKey import org.wfanet.measurement.common.OpenEndTimeRange import org.wfanet.measurement.common.crypto.Hashing @@ -674,7 +674,7 @@ class FrontendSimulator( key = eventGroup.name value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = EVENT_RANGE.start.toProtoTime() endTime = EVENT_RANGE.endExclusive.toProtoTime() } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MeasurementReader.kt b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MeasurementReader.kt index 390a6a33224..c92f3cda00e 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MeasurementReader.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MeasurementReader.kt @@ -16,6 +16,8 @@ package org.wfanet.measurement.reporting.deploy.v2.postgres.readers +import com.google.type.Interval +import com.google.type.interval import java.time.Instant import java.util.UUID import kotlinx.coroutines.flow.Flow @@ -29,9 +31,7 @@ import org.wfanet.measurement.common.identity.InternalId import org.wfanet.measurement.common.toProtoTime import org.wfanet.measurement.internal.reporting.v2.Measurement import org.wfanet.measurement.internal.reporting.v2.ReportingSetKt -import org.wfanet.measurement.internal.reporting.v2.TimeInterval import org.wfanet.measurement.internal.reporting.v2.measurement -import org.wfanet.measurement.internal.reporting.v2.timeInterval class MeasurementReader(private val readContext: ReadContext) { data class Result( @@ -45,7 +45,7 @@ class MeasurementReader(private val readContext: ReadContext) { val cmmsMeasurementConsumerId: String, val cmmsMeasurementId: String?, val cmmsCreateMeasurementRequestId: String, - val timeInterval: TimeInterval, + val timeInterval: Interval, // Key is primitiveReportingSetBasisId. val primitiveReportingSetBasisInfoMap: MutableMap, val state: Measurement.State, @@ -220,7 +220,7 @@ class MeasurementReader(private val readContext: ReadContext) { val measurementInfo = measurementInfoMap.computeIfAbsent(measurementId) { - val timeInterval = timeInterval { + val timeInterval = interval { startTime = measurementTimeIntervalStart.toProtoTime() endTime = measurementTimeIntervalEnd.toProtoTime() } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MetricReader.kt b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MetricReader.kt index 8461ceaffb8..0bc8a86c40c 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MetricReader.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/MetricReader.kt @@ -17,6 +17,8 @@ package org.wfanet.measurement.reporting.deploy.v2.postgres.readers import com.google.protobuf.Timestamp +import com.google.type.Interval +import com.google.type.interval import java.time.Instant import java.util.UUID import kotlinx.coroutines.flow.Flow @@ -36,11 +38,9 @@ import org.wfanet.measurement.internal.reporting.v2.MetricSpec import org.wfanet.measurement.internal.reporting.v2.MetricSpecKt import org.wfanet.measurement.internal.reporting.v2.ReportingSetKt import org.wfanet.measurement.internal.reporting.v2.StreamMetricsRequest -import org.wfanet.measurement.internal.reporting.v2.TimeInterval import org.wfanet.measurement.internal.reporting.v2.measurement import org.wfanet.measurement.internal.reporting.v2.metric import org.wfanet.measurement.internal.reporting.v2.metricSpec -import org.wfanet.measurement.internal.reporting.v2.timeInterval class MetricReader(private val readContext: ReadContext) { data class Result( @@ -58,7 +58,7 @@ class MetricReader(private val readContext: ReadContext) { val metricId: InternalId, val externalMetricId: String, val createTime: Timestamp, - val timeInterval: TimeInterval, + val timeInterval: Interval, val metricSpec: MetricSpec, val weightedMeasurementInfoMap: MutableMap, val details: Metric.Details, @@ -78,7 +78,7 @@ class MetricReader(private val readContext: ReadContext) { private data class MeasurementInfo( val cmmsMeasurementId: String?, val cmmsCreateMeasurementRequestId: String, - val timeInterval: TimeInterval, + val timeInterval: Interval, // Key is primitiveReportingSetBasisId. val primitiveReportingSetBasisInfoMap: MutableMap, val state: Measurement.State, @@ -389,7 +389,7 @@ class MetricReader(private val readContext: ReadContext) { val metricInfo = metricInfoMap.computeIfAbsent(externalMetricId) { - val metricTimeInterval = timeInterval { + val metricTimeInterval = interval { startTime = metricTimeIntervalStart.toProtoTime() endTime = metricTimeIntervalEnd.toProtoTime() } @@ -493,7 +493,7 @@ class MetricReader(private val readContext: ReadContext) { metricId = metricId, ) ) { - val timeInterval = timeInterval { + val timeInterval = interval { startTime = measurementTimeIntervalStart.toProtoTime() endTime = measurementTimeIntervalEnd.toProtoTime() } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/ReportReader.kt b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/ReportReader.kt index 7b8d180133d..8ba13feb7e4 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/ReportReader.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/readers/ReportReader.kt @@ -18,6 +18,8 @@ package org.wfanet.measurement.reporting.deploy.v2.postgres.readers import com.google.protobuf.Timestamp import com.google.protobuf.util.Timestamps +import com.google.type.Interval +import com.google.type.interval import java.time.Instant import java.time.ZoneOffset import java.util.Optional @@ -34,10 +36,8 @@ import org.wfanet.measurement.common.toProtoTime import org.wfanet.measurement.internal.reporting.v2.Report import org.wfanet.measurement.internal.reporting.v2.ReportKt import org.wfanet.measurement.internal.reporting.v2.StreamReportsRequest -import org.wfanet.measurement.internal.reporting.v2.TimeInterval import org.wfanet.measurement.internal.reporting.v2.periodicTimeInterval import org.wfanet.measurement.internal.reporting.v2.report -import org.wfanet.measurement.internal.reporting.v2.timeInterval import org.wfanet.measurement.internal.reporting.v2.timeIntervals const val STREAM_DEFAULT_LIMIT = 50 @@ -57,7 +57,7 @@ class ReportReader(private val readContext: ReadContext) { val reportId: InternalId, val externalReportId: String, val createTime: Timestamp, - val timeIntervals: MutableSet, + val timeIntervals: MutableSet, /** Map of external reporting set ID to [ReportingMetricCalculationSpecInfo]. */ val reportingSetReportingMetricCalculationSpecInfoMap: MutableMap, @@ -298,19 +298,15 @@ class ReportReader(private val readContext: ReadContext) { row.getProtoMessage("ReportingMetricDetails", Report.ReportingMetric.Details.parser()) val externalMetricId: String? = row["ExternalMetricId"] - val source = this - - source.timeIntervals.add( - timeInterval { + timeIntervals.add( + interval { startTime = timeIntervalStart.toProtoTime() endTime = timeIntervalEnd.toProtoTime() } ) val reportingMetricCalculationSpecInfo = - source.reportingSetReportingMetricCalculationSpecInfoMap.computeIfAbsent( - externalReportingSetId - ) { + reportingSetReportingMetricCalculationSpecInfoMap.computeIfAbsent(externalReportingSetId) { ReportingMetricCalculationSpecInfo( metricCalculationSpecInfoMap = mutableMapOf(), ) @@ -381,7 +377,7 @@ class ReportReader(private val readContext: ReadContext) { } else { timeIntervals = timeIntervals { sortedTimeIntervals.forEach { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = it.startTime endTime = it.endTime } 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 224468d8c45..88610f54f5e 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 @@ -21,6 +21,8 @@ import com.google.protobuf.Duration import com.google.protobuf.duration import com.google.protobuf.util.Durations import com.google.protobuf.util.Timestamps +import com.google.type.Interval +import com.google.type.interval import io.grpc.Status import io.grpc.StatusException import java.io.File @@ -58,7 +60,6 @@ import org.wfanet.measurement.api.v2alpha.MeasurementSpecKt import org.wfanet.measurement.api.v2alpha.MeasurementsGrpcKt.MeasurementsCoroutineStub import org.wfanet.measurement.api.v2alpha.RequisitionSpec.EventGroupEntry import org.wfanet.measurement.api.v2alpha.RequisitionSpecKt -import org.wfanet.measurement.api.v2alpha.TimeInterval as MeasurementTimeInterval import org.wfanet.measurement.api.v2alpha.createMeasurementRequest import org.wfanet.measurement.api.v2alpha.differentialPrivacyParams import org.wfanet.measurement.api.v2alpha.getCertificateRequest @@ -68,7 +69,6 @@ import org.wfanet.measurement.api.v2alpha.getMeasurementRequest import org.wfanet.measurement.api.v2alpha.measurement import org.wfanet.measurement.api.v2alpha.measurementSpec import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.timeInterval as measurementTimeInterval import org.wfanet.measurement.api.withAuthenticationKey import org.wfanet.measurement.common.base64UrlDecode import org.wfanet.measurement.common.base64UrlEncode @@ -1095,7 +1095,7 @@ class ReportsService( */ private fun groupEventGroupEntriesByDataProvider( reportingSetNames: List, - timeInterval: MeasurementTimeInterval, + timeInterval: Interval, eventGroupFilters: Map, internalReportingSetMap: Map ): Map> { @@ -1555,10 +1555,10 @@ private fun buildInternalMeasurementKeys( } } -/** Converts an [TimeInterval] to a [MeasurementTimeInterval] for measurement request. */ -private fun TimeInterval.toMeasurementTimeInterval(): MeasurementTimeInterval { +/** Converts an [TimeInterval] to a [Interval] for measurement request. */ +private fun TimeInterval.toMeasurementTimeInterval(): Interval { val source = this - return measurementTimeInterval { + return interval { startTime = source.startTime endTime = source.endTime } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsService.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsService.kt index 7ca9b0a59d2..eda74b7c26b 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsService.kt @@ -563,7 +563,7 @@ class MetricsService( key = cmmsEventGroupKey.toName() value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = measurement.timeInterval.toCmmsTimeInterval() + collectionInterval = measurement.timeInterval if (filter != null) { this.filter = RequisitionSpecKt.eventFilter { expression = filter } } @@ -1358,7 +1358,7 @@ class MetricsService( metric = internalMetric { this.cmmsMeasurementConsumerId = cmmsMeasurementConsumerId externalReportingSetId = internalReportingSet.externalReportingSetId - timeInterval = request.metric.timeInterval.toInternal() + timeInterval = request.metric.timeInterval metricSpec = try { request.metric.metricSpec.withDefaults(metricSpecConfig).toInternal() @@ -1392,7 +1392,7 @@ class MetricsService( weight = weightedSubsetUnion.weight measurement = internalMeasurement { this.cmmsMeasurementConsumerId = cmmsMeasurementConsumerId - timeInterval = metric.timeInterval.toInternal() + timeInterval = metric.timeInterval this.primitiveReportingSetBases += weightedSubsetUnion.primitiveReportingSetBasesList.map { primitiveReportingSetBasis -> primitiveReportingSetBasis.copy { filters += metric.filtersList } @@ -1486,7 +1486,7 @@ private fun InternalMetric.toMetric(): Metric { .toName() reportingSet = ReportingSetKey(source.cmmsMeasurementConsumerId, source.externalReportingSetId).toName() - timeInterval = source.timeInterval.toTimeInterval() + timeInterval = source.timeInterval metricSpec = source.metricSpec.toMetricSpec() filters += source.details.filtersList state = source.state diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt index 5bef7afbfb9..da30fcd16e4 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt @@ -17,6 +17,8 @@ package org.wfanet.measurement.reporting.service.api.v2alpha import com.google.protobuf.util.Timestamps +import com.google.type.Interval +import com.google.type.interval import org.wfanet.measurement.api.v2alpha.DifferentialPrivacyParams import org.wfanet.measurement.api.v2alpha.EventGroupKey as CmmsEventGroupKey import org.wfanet.measurement.api.v2alpha.Measurement @@ -24,9 +26,7 @@ import org.wfanet.measurement.api.v2alpha.MeasurementConsumerKey import org.wfanet.measurement.api.v2alpha.MeasurementSpec import org.wfanet.measurement.api.v2alpha.MeasurementSpec.VidSamplingInterval import org.wfanet.measurement.api.v2alpha.MeasurementSpecKt -import org.wfanet.measurement.api.v2alpha.TimeInterval as CmmsTimeInterval import org.wfanet.measurement.api.v2alpha.differentialPrivacyParams -import org.wfanet.measurement.api.v2alpha.timeInterval as cmmsTimeInterval import org.wfanet.measurement.config.reporting.MetricSpecConfig import org.wfanet.measurement.internal.reporting.v2.Measurement as InternalMeasurement import org.wfanet.measurement.internal.reporting.v2.MeasurementKt as InternalMeasurementKt @@ -41,14 +41,12 @@ import org.wfanet.measurement.internal.reporting.v2.StreamReportingSetsRequest import org.wfanet.measurement.internal.reporting.v2.StreamReportingSetsRequestKt import org.wfanet.measurement.internal.reporting.v2.StreamReportsRequest import org.wfanet.measurement.internal.reporting.v2.StreamReportsRequestKt -import org.wfanet.measurement.internal.reporting.v2.TimeInterval as InternalTimeInterval import org.wfanet.measurement.internal.reporting.v2.TimeIntervals as InternalTimeIntervals import org.wfanet.measurement.internal.reporting.v2.metricSpec as internalMetricSpec import org.wfanet.measurement.internal.reporting.v2.periodicTimeInterval as internalPeriodicTimeInterval import org.wfanet.measurement.internal.reporting.v2.streamMetricsRequest import org.wfanet.measurement.internal.reporting.v2.streamReportingSetsRequest import org.wfanet.measurement.internal.reporting.v2.streamReportsRequest -import org.wfanet.measurement.internal.reporting.v2.timeInterval as internalTimeInterval import org.wfanet.measurement.internal.reporting.v2.timeIntervals as internalTimeIntervals import org.wfanet.measurement.reporting.v2alpha.CreateMetricRequest import org.wfanet.measurement.reporting.v2alpha.ListMetricsPageToken @@ -61,14 +59,12 @@ import org.wfanet.measurement.reporting.v2alpha.Report import org.wfanet.measurement.reporting.v2alpha.ReportKt import org.wfanet.measurement.reporting.v2alpha.ReportingSet import org.wfanet.measurement.reporting.v2alpha.ReportingSetKt -import org.wfanet.measurement.reporting.v2alpha.TimeInterval import org.wfanet.measurement.reporting.v2alpha.TimeIntervals import org.wfanet.measurement.reporting.v2alpha.createMetricRequest import org.wfanet.measurement.reporting.v2alpha.metric import org.wfanet.measurement.reporting.v2alpha.metricSpec import org.wfanet.measurement.reporting.v2alpha.periodicTimeInterval import org.wfanet.measurement.reporting.v2alpha.reportingSet -import org.wfanet.measurement.reporting.v2alpha.timeInterval import org.wfanet.measurement.reporting.v2alpha.timeIntervals /** @@ -101,15 +97,6 @@ fun InternalMetricSpec.VidSamplingInterval.toVidSamplingInterval(): MetricSpec.V } } -/** Converts an [InternalTimeInterval] to a [CmmsTimeInterval]. */ -fun InternalTimeInterval.toCmmsTimeInterval(): CmmsTimeInterval { - val source = this - return cmmsTimeInterval { - startTime = source.startTime - endTime = source.endTime - } -} - /** Converts a [MetricSpec.VidSamplingInterval] to an [InternalMetricSpec.VidSamplingInterval]. */ fun MetricSpec.VidSamplingInterval.toInternal(): InternalMetricSpec.VidSamplingInterval { val source = this @@ -119,15 +106,6 @@ fun MetricSpec.VidSamplingInterval.toInternal(): InternalMetricSpec.VidSamplingI } } -/** Converts a public [TimeInterval] to an [InternalTimeInterval]. */ -fun TimeInterval.toInternal(): InternalTimeInterval { - val source = this - return internalTimeInterval { - startTime = source.startTime - endTime = source.endTime - } -} - /** Converts a [MetricSpec] to an [InternalMetricSpec]. */ fun MetricSpec.toInternal(): InternalMetricSpec { val source = this @@ -252,12 +230,12 @@ fun MetricSpec.DifferentialPrivacyParams.toInternal(): } } -/** Convert an [PeriodicTimeInterval] to a list of [TimeInterval]s. */ -fun PeriodicTimeInterval.toTimeIntervalsList(): List { +/** Convert an [PeriodicTimeInterval] to a list of [Interval]s. */ +fun PeriodicTimeInterval.toTimeIntervalsList(): List { val source = this var startTime = checkNotNull(source.startTime) return (0 until source.intervalCount).map { - timeInterval { + interval { this.startTime = startTime this.endTime = Timestamps.add(startTime, source.increment) startTime = this.endTime @@ -316,15 +294,6 @@ fun InternalMetricSpec.DifferentialPrivacyParams.toPrivacyParams(): } } -/** Converts an [InternalTimeInterval] to a public [TimeInterval]. */ -fun InternalTimeInterval.toTimeInterval(): TimeInterval { - val source = this - return timeInterval { - startTime = source.startTime - endTime = source.endTime - } -} - /** Converts an [InternalMetricSpec.DifferentialPrivacyParams] to [DifferentialPrivacyParams]. */ fun InternalMetricSpec.DifferentialPrivacyParams.toCmmsPrivacyParams(): DifferentialPrivacyParams { val source = this @@ -590,17 +559,13 @@ fun InternalPeriodicTimeInterval.toPeriodicTimeInterval(): PeriodicTimeInterval /** Converts an [InternalTimeIntervals] to a [TimeIntervals]. */ fun InternalTimeIntervals.toTimeIntervals(): TimeIntervals { val source = this - return timeIntervals { - this.timeIntervals += source.timeIntervalsList.map { it.toTimeInterval() } - } + return timeIntervals { this.timeIntervals += source.timeIntervalsList } } /** Converts a public [TimeIntervals] to an [InternalTimeIntervals]. */ fun TimeIntervals.toInternal(): InternalTimeIntervals { val source = this - return internalTimeIntervals { - this.timeIntervals += source.timeIntervalsList.map { it.toInternal() } - } + return internalTimeIntervals { this.timeIntervals += source.timeIntervalsList } } /** Converts a public [PeriodicTimeInterval] to an [InternalPeriodicTimeInterval]. */ @@ -627,7 +592,7 @@ fun InternalReport.ReportingMetric.toCreateMetricRequest( source.details.externalReportingSetId ) .toName() - timeInterval = source.details.timeInterval.toTimeInterval() + timeInterval = source.details.timeInterval metricSpec = source.details.metricSpec.toMetricSpec() filters += source.details.filtersList } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsService.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsService.kt index 92f9e8da005..6a59e825433 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsService.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsService.kt @@ -16,6 +16,8 @@ package org.wfanet.measurement.reporting.service.api.v2alpha +import com.google.type.Interval +import com.google.type.copy import io.grpc.Status import io.grpc.StatusException import kotlin.math.min @@ -36,8 +38,6 @@ import org.wfanet.measurement.internal.reporting.v2.Report as InternalReport import org.wfanet.measurement.internal.reporting.v2.ReportKt as InternalReportKt import org.wfanet.measurement.internal.reporting.v2.ReportsGrpcKt.ReportsCoroutineStub import org.wfanet.measurement.internal.reporting.v2.StreamReportsRequest -import org.wfanet.measurement.internal.reporting.v2.TimeInterval as InternalTimeInterval -import org.wfanet.measurement.internal.reporting.v2.copy import org.wfanet.measurement.internal.reporting.v2.createReportRequest as internalCreateReportRequest import org.wfanet.measurement.internal.reporting.v2.getReportRequest as internalGetReportRequest import org.wfanet.measurement.internal.reporting.v2.report as internalReport @@ -81,8 +81,8 @@ class ReportsService( private data class InternalTimeRange( val canBeCumulative: Boolean, - val timeIntervals: List, - val cumulativeTimeIntervals: List + val timeIntervals: List, + val cumulativeTimeIntervals: List ) private data class CreateReportInfo( @@ -464,7 +464,7 @@ class ReportsService( InternalTimeRange( false, - source.timeIntervals.timeIntervalsList.map { it.toInternal() }, + source.timeIntervals.timeIntervalsList, listOf(), ) } @@ -485,8 +485,7 @@ class ReportsService( "PeriodicTimeInterval intervalCount is unspecified." } - val timeIntervals = - source.periodicTimeInterval.toTimeIntervalsList().map { it.toInternal() } + val timeIntervals = source.periodicTimeInterval.toTimeIntervalsList() val cumulativeTimeIntervals = timeIntervals.map { timeInterval -> timeInterval.copy { startTime = timeIntervals.first().startTime } @@ -585,7 +584,7 @@ class ReportsService( "No metric spec in MetricCalculationSpec [${metricCalculationSpec.displayName}] is specified." } - val timeIntervals: List = + val timeIntervals: List = if (metricCalculationSpec.cumulative) { grpcRequire(createReportInfo.internalTimeRange.canBeCumulative) { "Cumulative can only be used with PeriodicTimeInterval." diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/MeasurementsServiceTest.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/MeasurementsServiceTest.kt index 6a38bb7a370..7b6e3d908ce 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/MeasurementsServiceTest.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/MeasurementsServiceTest.kt @@ -19,6 +19,7 @@ package org.wfanet.measurement.reporting.service.internal.testing.v2 import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.ProtoTruth.assertThat import com.google.protobuf.timestamp +import com.google.type.interval import io.grpc.Status import io.grpc.StatusRuntimeException import java.time.Clock @@ -57,7 +58,6 @@ import org.wfanet.measurement.internal.reporting.v2.measurementConsumer import org.wfanet.measurement.internal.reporting.v2.metric import org.wfanet.measurement.internal.reporting.v2.metricSpec import org.wfanet.measurement.internal.reporting.v2.reportingSet -import org.wfanet.measurement.internal.reporting.v2.timeInterval private const val CMMS_MEASUREMENT_CONSUMER_ID = "1234" private const val MAX_BATCH_SIZE = 1000 @@ -1256,7 +1256,7 @@ abstract class MeasurementsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -116,7 +116,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -139,7 +139,7 @@ abstract class MetricsServiceTest { weight = 3 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -187,7 +187,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -217,7 +217,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -240,7 +240,7 @@ abstract class MetricsServiceTest { weight = 3 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -288,7 +288,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -313,7 +313,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -336,7 +336,7 @@ abstract class MetricsServiceTest { weight = 3 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -384,7 +384,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -409,7 +409,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -432,7 +432,7 @@ abstract class MetricsServiceTest { weight = 3 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -480,7 +480,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -505,7 +505,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -545,7 +545,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -575,7 +575,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -598,7 +598,7 @@ abstract class MetricsServiceTest { weight = 3 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -656,7 +656,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -686,7 +686,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -709,7 +709,7 @@ abstract class MetricsServiceTest { weight = 3 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -766,7 +766,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -796,7 +796,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -837,7 +837,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = "1234" - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -867,7 +867,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -941,7 +941,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -982,7 +982,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -998,7 +998,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1041,7 +1041,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1060,7 +1060,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1103,7 +1103,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1151,7 +1151,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID + "2" externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1181,7 +1181,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1222,7 +1222,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1252,7 +1252,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1299,7 +1299,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1329,7 +1329,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1387,7 +1387,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1417,7 +1417,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1484,7 +1484,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1514,7 +1514,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1574,7 +1574,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1604,7 +1604,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1653,7 +1653,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1683,7 +1683,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1731,7 +1731,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1761,7 +1761,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1811,7 +1811,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1841,7 +1841,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1892,7 +1892,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1922,7 +1922,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1972,7 +1972,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -2002,7 +2002,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -2051,7 +2051,7 @@ abstract class MetricsServiceTest { val metric = metric { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -2081,7 +2081,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -2342,7 +2342,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -2632,7 +2632,7 @@ abstract class MetricsServiceTest { val metric = metric { this.cmmsMeasurementConsumerId = cmmsMeasurementConsumerId externalReportingSetId = createdReportingSet.externalReportingSetId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -2656,7 +2656,7 @@ abstract class MetricsServiceTest { weight = 2 measurement = measurement { this.cmmsMeasurementConsumerId = cmmsMeasurementConsumerId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -2679,7 +2679,7 @@ abstract class MetricsServiceTest { weight = 3 measurement = measurement { this.cmmsMeasurementConsumerId = cmmsMeasurementConsumerId - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/ReportsServiceTest.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/ReportsServiceTest.kt index 7641c983ede..eea6be1db45 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/ReportsServiceTest.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/internal/testing/v2/ReportsServiceTest.kt @@ -20,6 +20,7 @@ import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.ProtoTruth.assertThat import com.google.protobuf.duration import com.google.protobuf.timestamp +import com.google.type.interval import io.grpc.Status import io.grpc.StatusRuntimeException import java.time.Clock @@ -57,7 +58,6 @@ import org.wfanet.measurement.internal.reporting.v2.periodicTimeInterval import org.wfanet.measurement.internal.reporting.v2.report import org.wfanet.measurement.internal.reporting.v2.reportingSet import org.wfanet.measurement.internal.reporting.v2.streamReportsRequest -import org.wfanet.measurement.internal.reporting.v2.timeInterval import org.wfanet.measurement.internal.reporting.v2.timeIntervals @RunWith(JUnit4::class) @@ -100,11 +100,11 @@ abstract class ReportsServiceTest { val report = baseReport.copy { timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 300 } endTime = timestamp { seconds = 400 } } @@ -203,7 +203,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -257,7 +257,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -294,11 +294,11 @@ abstract class ReportsServiceTest { reportingMetricEntries[createdReportingSet2.externalReportingSetId] = reportingMetricCalculationSpec2 timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 300 } endTime = timestamp { seconds = 400 } } @@ -397,7 +397,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -477,7 +477,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -531,7 +531,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -615,7 +615,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -825,7 +825,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -880,7 +880,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -918,11 +918,11 @@ abstract class ReportsServiceTest { reportingMetricEntries[createdReportingSet2.externalReportingSetId] = reportingMetricCalculationSpec2 timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 300 } endTime = timestamp { seconds = 400 } } @@ -975,7 +975,7 @@ abstract class ReportsServiceTest { weight = 2 measurement = measurement { cmmsMeasurementConsumerId = CMMS_MEASUREMENT_CONSUMER_ID - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 10 } endTime = timestamp { seconds = 100 } } @@ -1202,7 +1202,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -1233,11 +1233,11 @@ abstract class ReportsServiceTest { } } timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 300 } endTime = timestamp { seconds = 400 } } @@ -1283,7 +1283,7 @@ abstract class ReportsServiceTest { width = 0.5f } } - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } @@ -1326,11 +1326,11 @@ abstract class ReportsServiceTest { } } else { timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 100 } endTime = timestamp { seconds = 200 } } - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 300 } endTime = timestamp { seconds = 400 } } diff --git a/src/main/proto/wfa/measurement/api/v2alpha/BUILD.bazel b/src/main/proto/wfa/measurement/api/v2alpha/BUILD.bazel index 2dc44685e3c..52d79cf9cb7 100644 --- a/src/main/proto/wfa/measurement/api/v2alpha/BUILD.bazel +++ b/src/main/proto/wfa/measurement/api/v2alpha/BUILD.bazel @@ -402,11 +402,11 @@ proto_library( name = "page_token_proto", srcs = ["page_token.proto"], deps = [ + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:timestamp_proto", "@wfa_measurement_proto//src/main/proto/wfa/measurement/api/v2alpha:measurement_proto", "@wfa_measurement_proto//src/main/proto/wfa/measurement/api/v2alpha:model_line_proto", "@wfa_measurement_proto//src/main/proto/wfa/measurement/api/v2alpha:requisition_proto", - "@wfa_measurement_proto//src/main/proto/wfa/measurement/api/v2alpha:time_interval_proto", ], ) diff --git a/src/main/proto/wfa/measurement/api/v2alpha/page_token.proto b/src/main/proto/wfa/measurement/api/v2alpha/page_token.proto index 9aff045a87a..549c51989d9 100644 --- a/src/main/proto/wfa/measurement/api/v2alpha/page_token.proto +++ b/src/main/proto/wfa/measurement/api/v2alpha/page_token.proto @@ -17,10 +17,10 @@ syntax = "proto3"; package wfa.measurement.api.v2alpha; import "google/protobuf/timestamp.proto"; +import "google/type/interval.proto"; import "wfa/measurement/api/v2alpha/measurement.proto"; import "wfa/measurement/api/v2alpha/model_line.proto"; import "wfa/measurement/api/v2alpha/requisition.proto"; -import "wfa/measurement/api/v2alpha/time_interval.proto"; option java_package = "org.wfanet.measurement.api.v2alpha"; option java_multiple_files = true; @@ -134,7 +134,7 @@ message ListModelOutagesPageToken { fixed64 external_model_provider_id = 2; fixed64 external_model_suite_id = 3; fixed64 external_model_line_id = 4; - TimeInterval outage_interval = 5; + google.type.Interval outage_interval = 5; message PreviousPageEnd { fixed64 external_model_provider_id = 1; fixed64 external_model_suite_id = 2; @@ -151,7 +151,7 @@ message ListModelRolloutsPageToken { fixed64 external_model_provider_id = 2; fixed64 external_model_suite_id = 3; fixed64 external_model_line_id = 4; - TimeInterval rollout_period_overlapping = 5; + google.type.Interval rollout_period_overlapping = 5; message PreviousPageEnd { fixed64 external_model_provider_id = 1; fixed64 external_model_suite_id = 2; diff --git a/src/main/proto/wfa/measurement/internal/reporting/v2/BUILD.bazel b/src/main/proto/wfa/measurement/internal/reporting/v2/BUILD.bazel index 50d149dfa5d..c48fa07d6f5 100644 --- a/src/main/proto/wfa/measurement/internal/reporting/v2/BUILD.bazel +++ b/src/main/proto/wfa/measurement/internal/reporting/v2/BUILD.bazel @@ -25,6 +25,7 @@ kt_jvm_grpc_proto_library( proto_and_java_proto_library( name = "time_interval", deps = [ + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:duration_proto", "@com_google_protobuf//:timestamp_proto", ], @@ -38,7 +39,7 @@ proto_and_java_proto_library( name = "measurement", deps = [ ":reporting_set_proto", - ":time_interval_proto", + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:duration_proto", ], ) @@ -75,7 +76,7 @@ proto_and_java_proto_library( name = "metric", deps = [ ":measurement_proto", - ":time_interval_proto", + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:timestamp_proto", ], ) @@ -99,6 +100,7 @@ proto_and_java_proto_library( deps = [ ":metric_proto", ":time_interval_proto", + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:timestamp_proto", ], ) diff --git a/src/main/proto/wfa/measurement/internal/reporting/v2/measurement.proto b/src/main/proto/wfa/measurement/internal/reporting/v2/measurement.proto index e2bdd233790..f2442924e1e 100644 --- a/src/main/proto/wfa/measurement/internal/reporting/v2/measurement.proto +++ b/src/main/proto/wfa/measurement/internal/reporting/v2/measurement.proto @@ -17,8 +17,8 @@ syntax = "proto3"; package wfa.measurement.internal.reporting.v2; import "google/protobuf/duration.proto"; +import "google/type/interval.proto"; import "wfa/measurement/internal/reporting/v2/reporting_set.proto"; -import "wfa/measurement/internal/reporting/v2/time_interval.proto"; option java_package = "org.wfanet.measurement.internal.reporting.v2"; option java_multiple_files = true; @@ -33,7 +33,7 @@ message Measurement { // This is a UUID in string format. See https://www.ietf.org/rfc/rfc4122.txt. string cmms_create_measurement_request_id = 3; - TimeInterval time_interval = 4; + google.type.Interval time_interval = 4; repeated ReportingSet.PrimitiveReportingSetBasis primitive_reporting_set_bases = 5; diff --git a/src/main/proto/wfa/measurement/internal/reporting/v2/metric.proto b/src/main/proto/wfa/measurement/internal/reporting/v2/metric.proto index 7f911999440..e1a86ebd072 100644 --- a/src/main/proto/wfa/measurement/internal/reporting/v2/metric.proto +++ b/src/main/proto/wfa/measurement/internal/reporting/v2/metric.proto @@ -17,8 +17,8 @@ syntax = "proto3"; package wfa.measurement.internal.reporting.v2; import "google/protobuf/timestamp.proto"; +import "google/type/interval.proto"; import "wfa/measurement/internal/reporting/v2/measurement.proto"; -import "wfa/measurement/internal/reporting/v2/time_interval.proto"; option java_package = "org.wfanet.measurement.internal.reporting.v2"; option java_multiple_files = true; @@ -72,7 +72,7 @@ message Metric { string external_reporting_set_id = 4; - TimeInterval time_interval = 5; + google.type.Interval time_interval = 5; MetricSpec metric_spec = 6; diff --git a/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto b/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto index 45649a8d1a3..92e32c4eb43 100644 --- a/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto +++ b/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto @@ -17,6 +17,7 @@ syntax = "proto3"; package wfa.measurement.internal.reporting.v2; import "google/protobuf/timestamp.proto"; +import "google/type/interval.proto"; import "wfa/measurement/internal/reporting/v2/metric.proto"; import "wfa/measurement/internal/reporting/v2/time_interval.proto"; @@ -51,7 +52,7 @@ message Report { message Details { string external_reporting_set_id = 1; MetricSpec metric_spec = 2; - TimeInterval time_interval = 3; + google.type.Interval time_interval = 3; repeated string filters = 4; } diff --git a/src/main/proto/wfa/measurement/internal/reporting/v2/time_interval.proto b/src/main/proto/wfa/measurement/internal/reporting/v2/time_interval.proto index e2239a634ba..4154afd0844 100644 --- a/src/main/proto/wfa/measurement/internal/reporting/v2/time_interval.proto +++ b/src/main/proto/wfa/measurement/internal/reporting/v2/time_interval.proto @@ -18,17 +18,13 @@ package wfa.measurement.internal.reporting.v2; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; +import "google/type/interval.proto"; option java_package = "org.wfanet.measurement.internal.reporting.v2"; option java_multiple_files = true; -message TimeInterval { - google.protobuf.Timestamp start_time = 1; - google.protobuf.Timestamp end_time = 2; -} - message TimeIntervals { - repeated TimeInterval time_intervals = 1; + repeated google.type.Interval time_intervals = 1; } message PeriodicTimeInterval { diff --git a/src/main/proto/wfa/measurement/reporting/v2alpha/BUILD.bazel b/src/main/proto/wfa/measurement/reporting/v2alpha/BUILD.bazel index 89d480ab7a2..c799d1c5b71 100644 --- a/src/main/proto/wfa/measurement/reporting/v2alpha/BUILD.bazel +++ b/src/main/proto/wfa/measurement/reporting/v2alpha/BUILD.bazel @@ -36,9 +36,9 @@ proto_library( srcs = ["metric.proto"], strip_import_prefix = IMPORT_PREFIX, deps = [ - ":time_interval_proto", "@com_google_googleapis//google/api:field_behavior_proto", "@com_google_googleapis//google/api:resource_proto", + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:timestamp_proto", ], ) @@ -63,6 +63,7 @@ proto_library( ":time_interval_proto", "@com_google_googleapis//google/api:field_behavior_proto", "@com_google_googleapis//google/api:resource_proto", + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:timestamp_proto", ], ) @@ -105,6 +106,7 @@ proto_library( strip_import_prefix = IMPORT_PREFIX, deps = [ "@com_google_googleapis//google/api:field_behavior_proto", + "@com_google_googleapis//google/type:interval_proto", "@com_google_protobuf//:duration_proto", "@com_google_protobuf//:timestamp_proto", ], diff --git a/src/main/proto/wfa/measurement/reporting/v2alpha/metric.proto b/src/main/proto/wfa/measurement/reporting/v2alpha/metric.proto index 39085aef06a..5cb513fe38b 100644 --- a/src/main/proto/wfa/measurement/reporting/v2alpha/metric.proto +++ b/src/main/proto/wfa/measurement/reporting/v2alpha/metric.proto @@ -19,7 +19,7 @@ package wfa.measurement.reporting.v2alpha; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; import "google/protobuf/timestamp.proto"; -import "wfa/measurement/reporting/v2alpha/time_interval.proto"; +import "google/type/interval.proto"; option java_package = "org.wfanet.measurement.reporting.v2alpha"; option java_multiple_files = true; @@ -216,6 +216,7 @@ message Metric { type: "reporting.halo-cmm.org/Metric" pattern: "measurementConsumers/{measurement_consumer}/metrics/{metric}" }; + // Resource name string name = 1; @@ -229,7 +230,7 @@ message Metric { ]; // The time over which to calculate the metric cumulatively. - TimeInterval time_interval = 3 [ + google.type.Interval time_interval = 3 [ (google.api.field_behavior) = REQUIRED, (google.api.field_behavior) = IMMUTABLE ]; diff --git a/src/main/proto/wfa/measurement/reporting/v2alpha/report.proto b/src/main/proto/wfa/measurement/reporting/v2alpha/report.proto index cfba9919e35..43880a96a13 100644 --- a/src/main/proto/wfa/measurement/reporting/v2alpha/report.proto +++ b/src/main/proto/wfa/measurement/reporting/v2alpha/report.proto @@ -19,6 +19,7 @@ package wfa.measurement.reporting.v2alpha; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; import "google/protobuf/timestamp.proto"; +import "google/type/interval.proto"; import "wfa/measurement/reporting/v2alpha/metric.proto"; import "wfa/measurement/reporting/v2alpha/time_interval.proto"; @@ -162,7 +163,7 @@ message Report { // is calculated cumulatively from the first start time defined in the // report to the end of this time interval. Otherwise, the result is // calculated cumulatively over this time interval. - TimeInterval time_interval = 3; + google.type.Interval time_interval = 3; // The metric result calculated on the reporting set with the setup in the // attribute. diff --git a/src/main/proto/wfa/measurement/reporting/v2alpha/time_interval.proto b/src/main/proto/wfa/measurement/reporting/v2alpha/time_interval.proto index 525245ab78d..5ca115e0224 100644 --- a/src/main/proto/wfa/measurement/reporting/v2alpha/time_interval.proto +++ b/src/main/proto/wfa/measurement/reporting/v2alpha/time_interval.proto @@ -19,26 +19,16 @@ package wfa.measurement.reporting.v2alpha; import "google/api/field_behavior.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; +import "google/type/interval.proto"; option java_package = "org.wfanet.measurement.reporting.v2alpha"; option java_multiple_files = true; option java_outer_classname = "TimeIntervalProto"; -// A time interval. -message TimeInterval { - // Start of the time interval, inclusive. - google.protobuf.Timestamp start_time = 1 - [(google.api.field_behavior) = REQUIRED]; - // End of the time interval, exclusive. This must be later than the start - // time. - google.protobuf.Timestamp end_time = 2 - [(google.api.field_behavior) = REQUIRED]; -} - // A list of time intervals with different start times and end times. message TimeIntervals { // A list of time intervals. - repeated TimeInterval time_intervals = 1 + repeated google.type.Interval time_intervals = 1 [(google.api.field_behavior) = REQUIRED]; } 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 fd59e66ff22..428db8e6b45 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 @@ -24,6 +24,7 @@ import com.google.protobuf.duration import com.google.protobuf.empty import com.google.protobuf.timestamp import com.google.protobuf.value +import com.google.type.interval import io.grpc.Server import io.grpc.ServerInterceptors import io.grpc.ServerServiceDefinition @@ -163,7 +164,6 @@ import org.wfanet.measurement.api.v2alpha.scheduleModelRolloutFreezeRequest import org.wfanet.measurement.api.v2alpha.setModelLineActiveEndTimeRequest import org.wfanet.measurement.api.v2alpha.setModelLineHoldbackModelLineRequest import org.wfanet.measurement.api.v2alpha.signedData -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.api.v2alpha.updatePublicKeyRequest import org.wfanet.measurement.common.crypto.SigningCerts import org.wfanet.measurement.common.crypto.SigningKeyHandle @@ -295,7 +295,7 @@ private val MODEL_RELEASE = modelRelease { private val MODEL_OUTAGE = modelOutage { name = MODEL_OUTAGE_NAME - outageInterval = timeInterval { + outageInterval = interval { startTime = Instant.parse(MODEL_OUTAGE_ACTIVE_START_TIME).toProtoTime() endTime = Instant.parse(MODEL_OUTAGE_ACTIVE_END_TIME).toProtoTime() } @@ -312,7 +312,7 @@ private val MODEL_SHARD = modelShard { private val MODEL_ROLLOUT = modelRollout { name = MODEL_ROLLOUT_NAME - gradualRolloutPeriod = timeInterval { + gradualRolloutPeriod = interval { startTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_START_TIME).toProtoTime() endTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_END_TIME).toProtoTime() } @@ -322,7 +322,7 @@ private val MODEL_ROLLOUT = modelRollout { private val MODEL_ROLLOUT_WITH_FREEZE_TIME = modelRollout { name = MODEL_ROLLOUT_NAME - gradualRolloutPeriod = timeInterval { + gradualRolloutPeriod = interval { startTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_START_TIME).toProtoTime() endTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_END_TIME).toProtoTime() } @@ -903,7 +903,7 @@ class MeasurementSystemTest { key = "dataProviders/1/eventGroups/1" value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = Instant.parse(TIME_STRING_1).toProtoTime() endTime = Instant.parse(TIME_STRING_2).toProtoTime() } @@ -915,7 +915,7 @@ class MeasurementSystemTest { key = "dataProviders/1/eventGroups/2" value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = Instant.parse(TIME_STRING_3).toProtoTime() endTime = Instant.parse(TIME_STRING_4).toProtoTime() } @@ -950,7 +950,7 @@ class MeasurementSystemTest { key = "dataProviders/2/eventGroups/1" value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = Instant.parse(TIME_STRING_5).toProtoTime() endTime = Instant.parse(TIME_STRING_6).toProtoTime() } @@ -1432,7 +1432,7 @@ class MeasurementSystemTest { createModelOutageRequest { parent = MODEL_LINE_NAME modelOutage = modelOutage { - outageInterval = timeInterval { + outageInterval = interval { startTime = Instant.parse(MODEL_OUTAGE_ACTIVE_START_TIME).toProtoTime() endTime = Instant.parse(MODEL_OUTAGE_ACTIVE_END_TIME).toProtoTime() } @@ -1471,7 +1471,7 @@ class MeasurementSystemTest { showDeleted = true filter = ListModelOutagesRequestKt.filter { - outageIntervalOverlapping = timeInterval { + outageIntervalOverlapping = interval { startTime = Instant.parse(MODEL_OUTAGE_ACTIVE_START_TIME).toProtoTime() endTime = Instant.parse(MODEL_OUTAGE_ACTIVE_END_TIME).toProtoTime() } @@ -1637,7 +1637,7 @@ class MeasurementSystemTest { createModelRolloutRequest { parent = MODEL_LINE_NAME modelRollout = modelRollout { - gradualRolloutPeriod = timeInterval { + gradualRolloutPeriod = interval { startTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_START_TIME).toProtoTime() endTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_END_TIME).toProtoTime() } @@ -1675,7 +1675,7 @@ class MeasurementSystemTest { pageToken = "token" filter = ListModelRolloutsRequestKt.filter { - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_START_TIME).toProtoTime() endTime = Instant.parse(MODEL_ROLLOUT_ACTIVE_END_TIME).toProtoTime() } diff --git a/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapperTest.kt b/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapperTest.kt index 8365bc11dfa..182d767183b 100644 --- a/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapperTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/eventdataprovider/privacybudgetmanagement/api/v2alpha/PrivacyQueryMapperTest.kt @@ -14,6 +14,7 @@ package org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.api.v2alpha import com.google.common.truth.Truth.assertThat +import com.google.type.interval import java.time.LocalDate import org.junit.Test import org.wfanet.measurement.api.v2alpha.MeasurementSpecKt.impression @@ -26,7 +27,6 @@ import org.wfanet.measurement.api.v2alpha.RequisitionSpecKt.eventGroupEntry import org.wfanet.measurement.api.v2alpha.differentialPrivacyParams import org.wfanet.measurement.api.v2alpha.measurementSpec import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.common.OpenEndTimeRange import org.wfanet.measurement.common.toProtoTime import org.wfanet.measurement.eventdataprovider.privacybudgetmanagement.DpCharge @@ -48,7 +48,7 @@ private val REQUISITION_SPEC = requisitionSpec { key = "eventGroups/someEventGroup" value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = TIME_RANGE.start.toProtoTime() endTime = TIME_RANGE.endExclusive.toProtoTime() } diff --git a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelOutagesServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelOutagesServiceTest.kt index 038be0259c4..a55c90ee402 100644 --- a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelOutagesServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelOutagesServiceTest.kt @@ -19,6 +19,7 @@ package org.wfanet.measurement.kingdom.service.api.v2alpha import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.ProtoTruth.assertThat import com.google.protobuf.Timestamp +import com.google.type.interval import io.grpc.Status import io.grpc.StatusRuntimeException import java.time.Instant @@ -49,7 +50,6 @@ import org.wfanet.measurement.api.v2alpha.listModelOutagesPageToken import org.wfanet.measurement.api.v2alpha.listModelOutagesRequest import org.wfanet.measurement.api.v2alpha.listModelOutagesResponse import org.wfanet.measurement.api.v2alpha.modelOutage -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.api.v2alpha.withDataProviderPrincipal import org.wfanet.measurement.api.v2alpha.withDuchyPrincipal import org.wfanet.measurement.api.v2alpha.withMeasurementConsumerPrincipal @@ -122,7 +122,7 @@ private val INTERNAL_MODEL_OUTAGE: InternalModelOutage = internalModelOutage { private val MODEL_OUTAGE: ModelOutage = modelOutage { name = MODEL_OUTAGE_NAME - outageInterval = timeInterval { + outageInterval = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -305,7 +305,7 @@ class ModelOutagesServiceTest { parent = MODEL_LINE_NAME showDeleted = true filter = filter { - outageIntervalOverlapping = timeInterval { + outageIntervalOverlapping = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -355,7 +355,7 @@ class ModelOutagesServiceTest { parent = MODEL_LINE_NAME showDeleted = true filter = filter { - outageIntervalOverlapping = timeInterval { + outageIntervalOverlapping = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -480,7 +480,7 @@ class ModelOutagesServiceTest { externalModelProviderId = 987L externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - outageInterval = timeInterval { + outageInterval = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -507,7 +507,7 @@ class ModelOutagesServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - outageInterval = timeInterval { + outageInterval = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -534,7 +534,7 @@ class ModelOutagesServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - outageInterval = timeInterval { + outageInterval = interval { startTime = Instant.ofEpochSecond(123).toProtoTime() endTime = OUTAGE_END_TIME } @@ -559,7 +559,7 @@ class ModelOutagesServiceTest { pageSize = 2 showDeleted = true filter = filter { - outageIntervalOverlapping = timeInterval { + outageIntervalOverlapping = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -569,7 +569,7 @@ class ModelOutagesServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - outageInterval = timeInterval { + outageInterval = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -598,7 +598,7 @@ class ModelOutagesServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - outageInterval = timeInterval { + outageInterval = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -654,7 +654,7 @@ class ModelOutagesServiceTest { pageSize = 4 showDeleted = false filter = filter { - outageIntervalOverlapping = timeInterval { + outageIntervalOverlapping = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -664,7 +664,7 @@ class ModelOutagesServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - outageInterval = timeInterval { + outageInterval = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -721,7 +721,7 @@ class ModelOutagesServiceTest { parent = MODEL_LINE_NAME showDeleted = false filter = filter { - outageIntervalOverlapping = timeInterval { + outageIntervalOverlapping = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } @@ -731,7 +731,7 @@ class ModelOutagesServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - outageInterval = timeInterval { + outageInterval = interval { startTime = OUTAGE_START_TIME endTime = OUTAGE_END_TIME } diff --git a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelRolloutsServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelRolloutsServiceTest.kt index 31f2018cec2..4fae4620d00 100644 --- a/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelRolloutsServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/kingdom/service/api/v2alpha/ModelRolloutsServiceTest.kt @@ -20,6 +20,7 @@ import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.ProtoTruth.assertThat import com.google.protobuf.Empty import com.google.protobuf.Timestamp +import com.google.type.interval import io.grpc.Status import io.grpc.StatusRuntimeException import java.time.Instant @@ -50,7 +51,6 @@ import org.wfanet.measurement.api.v2alpha.listModelRolloutsRequest import org.wfanet.measurement.api.v2alpha.listModelRolloutsResponse import org.wfanet.measurement.api.v2alpha.modelRollout import org.wfanet.measurement.api.v2alpha.scheduleModelRolloutFreezeRequest -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.api.v2alpha.withDataProviderPrincipal import org.wfanet.measurement.api.v2alpha.withDuchyPrincipal import org.wfanet.measurement.api.v2alpha.withMeasurementConsumerPrincipal @@ -130,7 +130,7 @@ private val INTERNAL_MODEL_ROLLOUT: InternalModelRollout = internalModelRollout private val MODEL_ROLLOUT: ModelRollout = modelRollout { name = MODEL_ROLLOUT_NAME_2 - gradualRolloutPeriod = timeInterval { + gradualRolloutPeriod = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } @@ -751,7 +751,7 @@ class ModelRolloutsServiceTest { val request = listModelRolloutsRequest { parent = MODEL_LINE_NAME filter = filter { - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } @@ -761,7 +761,7 @@ class ModelRolloutsServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_FREEZE_TIME } @@ -795,7 +795,7 @@ class ModelRolloutsServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } @@ -825,7 +825,7 @@ class ModelRolloutsServiceTest { parent = MODEL_LINE_NAME pageSize = 2 filter = filter { - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } @@ -835,7 +835,7 @@ class ModelRolloutsServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } @@ -863,7 +863,7 @@ class ModelRolloutsServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } @@ -917,7 +917,7 @@ class ModelRolloutsServiceTest { parent = MODEL_LINE_NAME pageSize = 4 filter = filter { - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } @@ -927,7 +927,7 @@ class ModelRolloutsServiceTest { externalModelProviderId = EXTERNAL_MODEL_PROVIDER_ID externalModelSuiteId = EXTERNAL_MODEL_SUITE_ID externalModelLineId = EXTERNAL_MODEL_LINE_ID - rolloutPeriodOverlapping = timeInterval { + rolloutPeriodOverlapping = interval { startTime = ROLLOUT_PERIOD_START_TIME endTime = ROLLOUT_PERIOD_END_TIME } diff --git a/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/CsvEventQueryTest.kt b/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/CsvEventQueryTest.kt index 15a5a30a339..b4d00986a1e 100644 --- a/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/CsvEventQueryTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/CsvEventQueryTest.kt @@ -14,6 +14,8 @@ package org.wfanet.measurement.loadtest.dataprovider import com.google.common.truth.Truth.assertThat +import com.google.type.copy +import com.google.type.interval import java.io.File import java.nio.file.Path import java.nio.file.Paths @@ -24,9 +26,7 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.wfanet.measurement.api.v2alpha.RequisitionSpec import org.wfanet.measurement.api.v2alpha.RequisitionSpecKt.eventFilter -import org.wfanet.measurement.api.v2alpha.copy import org.wfanet.measurement.api.v2alpha.event_templates.testing.Person -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.common.getRuntimePath import org.wfanet.measurement.common.toProtoTime @@ -54,7 +54,7 @@ private val EMPTY_EVENT_FILTER = RequisitionSpec.EventFilter.getDefaultInstance( private val FIRST_EVENT_DATE = LocalDate.of(2021, 4, 20) private val LAST_EVENT_DATE = FIRST_EVENT_DATE.plusDays(1) -private val FULL_TIME_INTERVAL = timeInterval { +private val FULL_TIME_INTERVAL = interval { startTime = FIRST_EVENT_DATE.atStartOfDay().toInstant(ZoneOffset.UTC).toProtoTime() // end_time is exclusive, so we specify the start of the day after LAST_EVENT_DATE. endTime = LAST_EVENT_DATE.plusDays(1).atStartOfDay().toInstant(ZoneOffset.UTC).toProtoTime() diff --git a/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt b/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt index b4d8abccf73..2e7f3841757 100644 --- a/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulatorTest.kt @@ -21,6 +21,7 @@ import com.google.common.truth.extensions.proto.ProtoTruth.assertThat import com.google.protobuf.ByteString import com.google.protobuf.kotlin.toByteString import com.google.protobuf.kotlin.toByteStringUtf8 +import com.google.type.interval import java.nio.file.Path import java.nio.file.Paths import java.security.cert.X509Certificate @@ -108,7 +109,6 @@ import org.wfanet.measurement.api.v2alpha.protocolConfig import org.wfanet.measurement.api.v2alpha.refuseRequisitionRequest import org.wfanet.measurement.api.v2alpha.requisition import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.timeInterval import org.wfanet.measurement.common.HexString import org.wfanet.measurement.common.OpenEndTimeRange import org.wfanet.measurement.common.crypto.Hashing @@ -225,7 +225,7 @@ private val REQUISITION_ONE_SPEC = requisitionSpec { key = "eventGroup/name" value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = timeInterval { + collectionInterval = interval { startTime = TIME_RANGE.start.toProtoTime() endTime = TIME_RANGE.endExclusive.toProtoTime() } @@ -281,7 +281,7 @@ class EdpSimulatorTest { private val requisitionFulfillmentServiceMock: RequisitionFulfillmentCoroutineImplBase = mockService() - @get:Rule public val temporaryFolder: TemporaryFolder = TemporaryFolder() + @get:Rule val temporaryFolder: TemporaryFolder = TemporaryFolder() private lateinit var sketchStore: SketchStore diff --git a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsServiceTest.kt index 7e589e93e55..b352a16089d 100644 --- a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v1alpha/ReportsServiceTest.kt @@ -23,6 +23,7 @@ import com.google.protobuf.kotlin.toByteString import com.google.protobuf.kotlin.toByteStringUtf8 import com.google.protobuf.timestamp import com.google.protobuf.util.Timestamps +import com.google.type.interval import io.grpc.Status import io.grpc.StatusException import io.grpc.StatusRuntimeException @@ -98,7 +99,6 @@ import org.wfanet.measurement.api.v2alpha.measurement import org.wfanet.measurement.api.v2alpha.measurementConsumer import org.wfanet.measurement.api.v2alpha.measurementSpec import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.timeInterval as measurementTimeInterval import org.wfanet.measurement.api.v2alpha.withDataProviderPrincipal import org.wfanet.measurement.common.base64UrlEncode import org.wfanet.measurement.common.crypto.Hashing @@ -435,7 +435,7 @@ private val START_TIME = START_INSTANT.toProtoTime() private val TIME_INTERVAL_INCREMENT = Duration.ofDays(1).toProtoDuration() private const val INTERVAL_COUNT = 1 private val END_TIME = END_INSTANT.toProtoTime() -private val MEASUREMENT_TIME_INTERVAL = measurementTimeInterval { +private val MEASUREMENT_TIME_INTERVAL = interval { startTime = START_TIME endTime = END_TIME } diff --git a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsServiceTest.kt index ddeffc25d06..a8a070e093f 100644 --- a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/MetricsServiceTest.kt @@ -18,11 +18,12 @@ package org.wfanet.measurement.reporting.service.api.v2alpha import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.ProtoTruth.assertThat -import com.google.protobuf.Timestamp import com.google.protobuf.duration import com.google.protobuf.kotlin.toByteString import com.google.protobuf.kotlin.toByteStringUtf8 import com.google.protobuf.timestamp +import com.google.type.Interval +import com.google.type.interval import io.grpc.Status import io.grpc.StatusRuntimeException import java.nio.file.Paths @@ -92,8 +93,8 @@ import org.wfanet.measurement.api.v2alpha.measurement import org.wfanet.measurement.api.v2alpha.measurementConsumer import org.wfanet.measurement.api.v2alpha.measurementSpec import org.wfanet.measurement.api.v2alpha.requisitionSpec -import org.wfanet.measurement.api.v2alpha.timeInterval as measurementTimeInterval import org.wfanet.measurement.api.v2alpha.withDataProviderPrincipal +import org.wfanet.measurement.common.OpenEndTimeRange import org.wfanet.measurement.common.base64UrlEncode import org.wfanet.measurement.common.crypto.Hashing import org.wfanet.measurement.common.crypto.PrivateKeyHandle @@ -110,6 +111,7 @@ import org.wfanet.measurement.common.identity.ExternalId import org.wfanet.measurement.common.identity.externalIdToApiId import org.wfanet.measurement.common.readByteString import org.wfanet.measurement.common.testing.verifyProtoArgument +import org.wfanet.measurement.common.toInterval import org.wfanet.measurement.common.toProtoTime import org.wfanet.measurement.config.reporting.MetricSpecConfigKt import org.wfanet.measurement.config.reporting.measurementConsumerConfig @@ -166,7 +168,6 @@ import org.wfanet.measurement.internal.reporting.v2.metric as internalMetric import org.wfanet.measurement.internal.reporting.v2.metricSpec as internalMetricSpec import org.wfanet.measurement.internal.reporting.v2.reportingSet as internalReportingSet import org.wfanet.measurement.internal.reporting.v2.streamMetricsRequest -import org.wfanet.measurement.internal.reporting.v2.timeInterval as internalTimeInterval import org.wfanet.measurement.reporting.service.api.InMemoryEncryptionKeyPairStore import org.wfanet.measurement.reporting.service.api.v2alpha.RequestIdMatcher.Companion.requestIdEq import org.wfanet.measurement.reporting.v2alpha.ListMetricsPageTokenKt.previousPageEnd @@ -191,7 +192,6 @@ import org.wfanet.measurement.reporting.v2alpha.listMetricsResponse import org.wfanet.measurement.reporting.v2alpha.metric import org.wfanet.measurement.reporting.v2alpha.metricResult import org.wfanet.measurement.reporting.v2alpha.metricSpec -import org.wfanet.measurement.reporting.v2alpha.timeInterval private const val MAX_BATCH_SIZE = 1000 private const val DEFAULT_PAGE_SIZE = 50 @@ -527,22 +527,8 @@ private val INTERNAL_INCREMENTAL_REPORTING_SET = internalReportingSet { // Time intervals private val START_INSTANT = Instant.now() -private val END_INSTANT = START_INSTANT.plus(Duration.ofDays(1)) - -private val START_TIME: Timestamp = START_INSTANT.toProtoTime() -private val END_TIME = END_INSTANT.toProtoTime() -private val MEASUREMENT_TIME_INTERVAL = measurementTimeInterval { - startTime = START_TIME - endTime = END_TIME -} -private val INTERNAL_TIME_INTERVAL = internalTimeInterval { - startTime = START_TIME - endTime = END_TIME -} -private val TIME_INTERVAL = timeInterval { - startTime = START_TIME - endTime = END_TIME -} +private val TIME_RANGE = OpenEndTimeRange(START_INSTANT, START_INSTANT.plus(Duration.ofDays(1))) +private val TIME_INTERVAL: Interval = TIME_RANGE.toInterval() // Requisition specs private val REQUISITION_SPECS: Map = @@ -553,7 +539,7 @@ private val REQUISITION_SPECS: Map = key = it.toName() value = RequisitionSpecKt.EventGroupEntryKt.value { - collectionInterval = MEASUREMENT_TIME_INTERVAL + collectionInterval = TIME_INTERVAL filter = RequisitionSpecKt.eventFilter { expression = @@ -612,7 +598,7 @@ private val INTERNAL_PENDING_UNION_ALL_REACH_MEASUREMENT = internalMeasurement { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId cmmsCreateMeasurementRequestId = "UNION_ALL_REACH_MEASUREMENT" cmmsMeasurementId = externalIdToApiId(401L) - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL primitiveReportingSetBases += primitiveReportingSetBasis { externalReportingSetId = INTERNAL_UNION_ALL_REPORTING_SET.externalReportingSetId filters += ALL_FILTERS @@ -624,7 +610,7 @@ private val INTERNAL_PENDING_UNION_ALL_BUT_LAST_PUBLISHER_REACH_MEASUREMENT = in cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId cmmsCreateMeasurementRequestId = "UNION_ALL_BUT_LAST_PUBLISHER_REACH_MEASUREMENT" cmmsMeasurementId = externalIdToApiId(402L) - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL primitiveReportingSetBases += primitiveReportingSetBasis { externalReportingSetId = INTERNAL_UNION_ALL_BUT_LAST_PUBLISHER_REPORTING_SET.externalReportingSetId @@ -651,7 +637,7 @@ private val INTERNAL_PENDING_SINGLE_PUBLISHER_IMPRESSION_MEASUREMENT = internalM cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId cmmsCreateMeasurementRequestId = "SINGLE_PUBLISHER_IMPRESSION_MEASUREMENT" cmmsMeasurementId = externalIdToApiId(403L) - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL primitiveReportingSetBases += primitiveReportingSetBasis { externalReportingSetId = INTERNAL_SINGLE_PUBLISHER_REPORTING_SET.externalReportingSetId filters += METRIC_FILTER @@ -676,7 +662,7 @@ private val INTERNAL_FAILED_SINGLE_PUBLISHER_IMPRESSION_MEASUREMENT = // Internal cross-publisher watch duration measurements private val INTERNAL_REQUESTING_UNION_ALL_WATCH_DURATION_MEASUREMENT = internalMeasurement { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL primitiveReportingSetBases += primitiveReportingSetBasis { externalReportingSetId = INTERNAL_UNION_ALL_REPORTING_SET.externalReportingSetId filters += listOf(METRIC_FILTER, PRIMITIVE_REPORTING_SET_FILTER) @@ -930,7 +916,7 @@ private const val INCREMENTAL_REACH_METRIC_IDEMPOTENCY_KEY = "TEST_INCREMENTAL_R private val INTERNAL_REQUESTING_INCREMENTAL_REACH_METRIC = internalMetric { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId externalReportingSetId = INTERNAL_INCREMENTAL_REPORTING_SET.externalReportingSetId - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL metricSpec = internalMetricSpec { reach = InternalMetricSpecKt.reachParams { @@ -1028,7 +1014,7 @@ private val INTERNAL_SUCCEEDED_INCREMENTAL_REACH_METRIC = private val INTERNAL_REQUESTING_SINGLE_PUBLISHER_IMPRESSION_METRIC = internalMetric { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId externalReportingSetId = INTERNAL_SINGLE_PUBLISHER_REPORTING_SET.externalReportingSetId - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL metricSpec = internalMetricSpec { impressionCount = InternalMetricSpecKt.impressionCountParams { @@ -1091,7 +1077,7 @@ private val INTERNAL_FAILED_SINGLE_PUBLISHER_IMPRESSION_METRIC = private val INTERNAL_REQUESTING_CROSS_PUBLISHER_WATCH_DURATION_METRIC = internalMetric { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId externalReportingSetId = INTERNAL_UNION_ALL_REPORTING_SET.externalReportingSetId - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL metricSpec = internalMetricSpec { watchDuration = InternalMetricSpecKt.watchDurationParams { @@ -2019,7 +2005,7 @@ class MetricsServiceTest { weight = 1 measurement = internalMeasurement { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMERS.keys.first().measurementConsumerId - timeInterval = INTERNAL_TIME_INTERVAL + timeInterval = TIME_INTERVAL primitiveReportingSetBases += primitiveReportingSetBasis { externalReportingSetId = internalSinglePublisherReportingSet.externalReportingSetId } @@ -2565,7 +2551,7 @@ class MetricsServiceTest { metric = REQUESTING_INCREMENTAL_REACH_METRIC.copy { clearTimeInterval() - timeInterval = timeInterval { endTime = timestamp { seconds = 5 } } + timeInterval = interval { endTime = timestamp { seconds = 5 } } } metricId = "metric-id" } @@ -2586,7 +2572,7 @@ class MetricsServiceTest { metric = REQUESTING_INCREMENTAL_REACH_METRIC.copy { clearTimeInterval() - timeInterval = timeInterval { startTime = timestamp { seconds = 5 } } + timeInterval = interval { startTime = timestamp { seconds = 5 } } } metricId = "metric-id" } @@ -2607,7 +2593,7 @@ class MetricsServiceTest { metric = REQUESTING_INCREMENTAL_REACH_METRIC.copy { clearTimeInterval() - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = 5 nanos = 5 diff --git a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt index 52841e7430d..8a264794f9d 100644 --- a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt @@ -20,6 +20,8 @@ import com.google.common.truth.Truth.assertThat import com.google.common.truth.extensions.proto.ProtoTruth.assertThat import com.google.protobuf.duration import com.google.protobuf.timestamp +import com.google.type.Interval +import com.google.type.interval import io.grpc.Status import io.grpc.StatusRuntimeException import java.time.Duration @@ -58,7 +60,6 @@ import org.wfanet.measurement.internal.reporting.v2.ReportKt as InternalReportKt import org.wfanet.measurement.internal.reporting.v2.ReportsGrpcKt.ReportsCoroutineImplBase import org.wfanet.measurement.internal.reporting.v2.ReportsGrpcKt.ReportsCoroutineStub as InternalReportsCoroutineStub import org.wfanet.measurement.internal.reporting.v2.StreamReportsRequestKt -import org.wfanet.measurement.internal.reporting.v2.TimeInterval as InternalTimeInterval import org.wfanet.measurement.internal.reporting.v2.copy import org.wfanet.measurement.internal.reporting.v2.createReportRequest as internalCreateReportRequest import org.wfanet.measurement.internal.reporting.v2.getReportRequest as internalGetReportRequest @@ -66,8 +67,7 @@ import org.wfanet.measurement.internal.reporting.v2.metricSpec as internalMetric import org.wfanet.measurement.internal.reporting.v2.periodicTimeInterval as internalPeriodicTimeInterval import org.wfanet.measurement.internal.reporting.v2.report as internalReport import org.wfanet.measurement.internal.reporting.v2.streamReportsRequest -import org.wfanet.measurement.internal.reporting.v2.timeInterval as internalTimeInterval -import org.wfanet.measurement.internal.reporting.v2.timeIntervals as internalTimeIntervals +import org.wfanet.measurement.internal.reporting.v2.timeIntervals as Intervals import org.wfanet.measurement.reporting.v2alpha.BatchCreateMetricsRequest import org.wfanet.measurement.reporting.v2alpha.BatchGetMetricsRequest import org.wfanet.measurement.reporting.v2alpha.ListReportsPageTokenKt @@ -82,7 +82,6 @@ import org.wfanet.measurement.reporting.v2alpha.Report import org.wfanet.measurement.reporting.v2alpha.ReportKt import org.wfanet.measurement.reporting.v2alpha.ReportingSet import org.wfanet.measurement.reporting.v2alpha.ReportingSetKt -import org.wfanet.measurement.reporting.v2alpha.TimeInterval import org.wfanet.measurement.reporting.v2alpha.batchCreateMetricsRequest import org.wfanet.measurement.reporting.v2alpha.batchCreateMetricsResponse import org.wfanet.measurement.reporting.v2alpha.batchGetMetricsRequest @@ -100,7 +99,6 @@ import org.wfanet.measurement.reporting.v2alpha.metricSpec 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.timeInterval import org.wfanet.measurement.reporting.v2alpha.timeIntervals private const val DEFAULT_PAGE_SIZE = 50 @@ -291,30 +289,30 @@ class ReportsServiceTest { val targetReportingSet = PRIMITIVE_REPORTING_SETS.first() val timeIntervalsList = listOf( - timeInterval { + interval { startTime = START_TIME endTime = END_TIME }, - timeInterval { + interval { startTime = END_TIME endTime = END_INSTANT.plus(Duration.ofDays(1)).toProtoTime() } ) - val internalTimeIntervals = + val intervals = listOf( - internalTimeInterval { + interval { startTime = START_TIME endTime = END_TIME }, - internalTimeInterval { + interval { startTime = END_TIME endTime = END_INSTANT.plus(Duration.ofDays(1)).toProtoTime() } ) val initialReportingMetrics: List = - internalTimeIntervals.map { timeInterval -> + intervals.map { timeInterval -> buildInitialReportingMetric( targetReportingSet.resourceId, timeInterval, @@ -326,7 +324,7 @@ class ReportsServiceTest { val (internalRequestingReport, internalInitialReport, internalPendingReport) = buildInternalReports( MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId, - internalTimeIntervals, + intervals, targetReportingSet.resourceId, initialReportingMetrics, listOf(), @@ -452,12 +450,12 @@ class ReportsServiceTest { val groupingsCartesianProduct: List> = predicates1.flatMap { filter1 -> predicates2.map { filter2 -> listOf(filter1, filter2) } } - val timeInterval = timeInterval { + val timeInterval = interval { startTime = START_TIME endTime = END_TIME } - val internalTimeInterval = internalTimeInterval { + val interval = interval { startTime = START_TIME endTime = END_TIME } @@ -466,7 +464,7 @@ class ReportsServiceTest { groupingsCartesianProduct.map { filters -> buildInitialReportingMetric( targetReportingSet.resourceId, - internalTimeInterval, + interval, INTERNAL_REACH_METRIC_SPEC, filters ) @@ -475,7 +473,7 @@ class ReportsServiceTest { val (internalRequestingReport, internalInitialReport, internalPendingReport) = buildInternalReports( MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId, - listOf(internalTimeInterval), + listOf(interval), targetReportingSet.resourceId, initialReportingMetrics, internalGroupings, @@ -600,29 +598,24 @@ class ReportsServiceTest { val metricSpecs = listOf(REACH_METRIC_SPEC, FREQUENCY_HISTOGRAM_METRIC_SPEC) val internalMetricSpecs = listOf(INTERNAL_REACH_METRIC_SPEC, INTERNAL_FREQUENCY_HISTOGRAM_METRIC_SPEC) - val timeInterval = timeInterval { + val timeInterval = interval { startTime = START_TIME endTime = END_TIME } - val internalTimeInterval = internalTimeInterval { + val interval = interval { startTime = START_TIME endTime = END_TIME } val initialReportingMetrics: List = internalMetricSpecs.map { metricSpec -> - buildInitialReportingMetric( - targetReportingSet.resourceId, - internalTimeInterval, - metricSpec, - listOf() - ) + buildInitialReportingMetric(targetReportingSet.resourceId, interval, metricSpec, listOf()) } val (internalRequestingReport, internalInitialReport, internalPendingReport) = buildInternalReports( MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId, - listOf(internalTimeInterval), + listOf(interval), targetReportingSet.resourceId, initialReportingMetrics, listOf(), @@ -747,22 +740,22 @@ class ReportsServiceTest { // Time intervals val timeIntervalsList = listOf( - timeInterval { + interval { startTime = START_TIME endTime = END_TIME }, - timeInterval { + interval { startTime = END_TIME endTime = END_INSTANT.plus(Duration.ofDays(1)).toProtoTime() } ) - val internalTimeIntervals = + val intervals = listOf( - internalTimeInterval { + interval { startTime = START_TIME endTime = END_TIME }, - internalTimeInterval { + interval { startTime = END_TIME endTime = END_INSTANT.plus(Duration.ofDays(1)).toProtoTime() } @@ -788,7 +781,7 @@ class ReportsServiceTest { data class MetricConfig( val reportingSet: String, val metricSpec: MetricSpec, - val timeInterval: TimeInterval, + val timeInterval: Interval, val filters: List ) val metricConfigs = @@ -803,11 +796,11 @@ class ReportsServiceTest { data class ReportingMetricConfig( val reportingSetId: String, val metricSpec: InternalMetricSpec, - val timeInterval: InternalTimeInterval, + val timeInterval: Interval, val filters: List ) val reportingMetricConfigs = - internalTimeIntervals.flatMap { timeInterval -> + intervals.flatMap { timeInterval -> internalMetricSpecs.flatMap { metricSpec -> groupingsCartesianProduct.map { predicateGroup -> ReportingMetricConfig( @@ -833,7 +826,7 @@ class ReportsServiceTest { val (internalRequestingReport, internalInitialReport, internalPendingReport) = buildInternalReports( MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId, - internalTimeIntervals, + intervals, targetReportingSet.resourceId, initialReportingMetrics, internalGroupings, @@ -951,11 +944,11 @@ class ReportsServiceTest { runBlocking { val displayName = DISPLAY_NAME val targetReportingSets = PRIMITIVE_REPORTING_SETS - val timeInterval = timeInterval { + val timeInterval = interval { startTime = START_TIME endTime = END_TIME } - val internalTimeInterval = internalTimeInterval { + val interval = interval { startTime = START_TIME endTime = END_TIME } @@ -964,7 +957,7 @@ class ReportsServiceTest { targetReportingSets.associateWith { reportingSet -> buildInitialReportingMetric( reportingSet.resourceId, - internalTimeInterval, + interval, INTERNAL_REACH_METRIC_SPEC, listOf() ) @@ -972,7 +965,7 @@ class ReportsServiceTest { val internalRequestingReport = internalReport { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId - timeIntervals = internalTimeIntervals { timeIntervals += internalTimeInterval } + timeIntervals = Intervals { timeIntervals += interval } reportingSetToCreateMetricRequestMap.forEach { (reportingSet, reportingMetric) -> val initialReportingMetrics = listOf(reportingMetric) reportingMetricEntries.putAll( @@ -1148,11 +1141,11 @@ class ReportsServiceTest { runBlocking { val displayName = DISPLAY_NAME val targetReportingSet = PRIMITIVE_REPORTING_SETS.first() - val timeInterval = timeInterval { + val timeInterval = interval { startTime = START_TIME endTime = END_TIME } - val internalTimeInterval = internalTimeInterval { + val interval = interval { startTime = START_TIME endTime = END_TIME } @@ -1165,7 +1158,7 @@ class ReportsServiceTest { InternalReportKt.ReportingMetricKt.details { externalReportingSetId = targetReportingSet.resourceId metricSpec = INTERNAL_REACH_METRIC_SPEC - this.timeInterval = internalTimeInterval + this.timeInterval = interval } } details = @@ -1178,7 +1171,7 @@ class ReportsServiceTest { val internalRequestingReport = internalReport { cmmsMeasurementConsumerId = MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId - timeIntervals = internalTimeIntervals { timeIntervals += internalTimeInterval } + timeIntervals = Intervals { timeIntervals += interval } reportingMetricEntries.putAll( mapOf( targetReportingSet.resourceId to @@ -1364,16 +1357,16 @@ class ReportsServiceTest { } val endTimesList: List = (startSec + incrementSec until startSec + incrementSec + intervalCount).toList() - val internalTimeIntervals: List = + val intervals: List = endTimesList.map { end -> - internalTimeInterval { + interval { startTime = timestamp { seconds = startSec } endTime = timestamp { seconds = end } } } val reportingCreateMetricRequests = - internalTimeIntervals.map { timeInterval -> + intervals.map { timeInterval -> buildInitialReportingMetric( PRIMITIVE_REPORTING_SETS.first().resourceId, timeInterval, @@ -1481,7 +1474,7 @@ class ReportsServiceTest { ) .toName() reportingSet = PRIMITIVE_REPORTING_SETS.first().name - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = startSec } endTime = timestamp { seconds = end } } @@ -1795,7 +1788,7 @@ class ReportsServiceTest { clearCreateTime() clearState() timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = START_TIME endTime = END_TIME } @@ -1861,7 +1854,7 @@ class ReportsServiceTest { clearState() clearTime() timeIntervals = timeIntervals { - timeIntervals += timeInterval { endTime = timestamp { seconds = 5 } } + timeIntervals += interval { endTime = timestamp { seconds = 5 } } } } reportId = "report-id" @@ -1887,7 +1880,7 @@ class ReportsServiceTest { clearState() clearTime() timeIntervals = timeIntervals { - timeIntervals += timeInterval { startTime = timestamp { seconds = 5 } } + timeIntervals += interval { startTime = timestamp { seconds = 5 } } } } reportId = "report-id" @@ -1914,7 +1907,7 @@ class ReportsServiceTest { clearState() clearTime() timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = timestamp { seconds = 5 nanos = 5 @@ -2371,16 +2364,16 @@ class ReportsServiceTest { val endTimesList: List = (startSec + incrementSec until startSec + incrementSec + intervalCount).toList() - val internalTimeIntervals: List = + val intervals: List = endTimesList.map { end -> - internalTimeInterval { + interval { startTime = timestamp { seconds = startSec } endTime = timestamp { seconds = end } } } val reportingCreateMetricRequests = - internalTimeIntervals.map { timeInterval -> + intervals.map { timeInterval -> buildInitialReportingMetric( PRIMITIVE_REPORTING_SETS.first().resourceId, timeInterval, @@ -2445,7 +2438,7 @@ class ReportsServiceTest { ) .toName() reportingSet = PRIMITIVE_REPORTING_SETS.first().name - timeInterval = timeInterval { + timeInterval = interval { startTime = timestamp { seconds = startSec } endTime = timestamp { seconds = end } } @@ -2973,7 +2966,7 @@ class ReportsServiceTest { companion object { private fun buildInitialReportingMetric( reportingSetId: String, - timeInterval: InternalTimeInterval, + timeInterval: Interval, metricSpec: InternalMetricSpec, filters: List, ): InternalReport.ReportingMetric { @@ -3015,7 +3008,7 @@ class ReportsServiceTest { private fun buildInternalReports( cmmsMeasurementConsumerId: String, - timeIntervals: List, + timeIntervals: List, reportingSetId: String, reportingMetrics: List, groupings: List, @@ -3025,7 +3018,7 @@ class ReportsServiceTest { // Internal reports of reach val internalRequestingReport = internalReport { this.cmmsMeasurementConsumerId = cmmsMeasurementConsumerId - this.timeIntervals = internalTimeIntervals { this.timeIntervals += timeIntervals } + this.timeIntervals = Intervals { this.timeIntervals += timeIntervals } reportingMetricEntries.putAll( buildInternalReportingMetricEntryWithOneMetricCalculationSpec( @@ -3289,7 +3282,7 @@ class ReportsServiceTest { private const val WATCH_DURATION_METRIC_ID_BASE_LONG: Long = 320L private val REQUESTING_REACH_METRIC = metric { reportingSet = PRIMITIVE_REPORTING_SETS.first().name - timeInterval = timeInterval { + timeInterval = interval { startTime = START_TIME endTime = END_TIME } @@ -3322,7 +3315,7 @@ class ReportsServiceTest { ) .toName() reportingSet = PRIMITIVE_REPORTING_SETS.first().name - timeInterval = timeInterval { + timeInterval = interval { startTime = START_TIME endTime = END_TIME } @@ -3343,7 +3336,7 @@ class ReportsServiceTest { private val INITIAL_REACH_REPORTING_METRIC = buildInitialReportingMetric( PRIMITIVE_REPORTING_SETS.first().resourceId, - internalTimeInterval { + interval { startTime = START_TIME endTime = END_TIME }, @@ -3355,7 +3348,7 @@ class ReportsServiceTest { buildInternalReports( MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId, listOf( - internalTimeInterval { + interval { startTime = START_TIME endTime = END_TIME } @@ -3368,7 +3361,7 @@ class ReportsServiceTest { private val INITIAL_WATCH_DURATION_REPORTING_METRIC = buildInitialReportingMetric( PRIMITIVE_REPORTING_SETS.first().resourceId, - internalTimeInterval { + interval { startTime = START_TIME endTime = END_TIME }, @@ -3379,7 +3372,7 @@ class ReportsServiceTest { buildInternalReports( MEASUREMENT_CONSUMER_KEYS.first().measurementConsumerId, listOf( - internalTimeInterval { + interval { startTime = START_TIME endTime = END_TIME } @@ -3407,7 +3400,7 @@ class ReportsServiceTest { } } timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = START_TIME endTime = END_TIME } @@ -3449,7 +3442,7 @@ class ReportsServiceTest { } } timeIntervals = timeIntervals { - timeIntervals += timeInterval { + timeIntervals += interval { startTime = START_TIME endTime = END_TIME }