Skip to content

Commit

Permalink
Use date range which exists in test data CSV (#954)
Browse files Browse the repository at this point in the history
[synthetic-labelled-events.csv](https://github.com/world-federation-of-advertisers/cross-media-measurement/blob/main/src/main/k8s/testing/data/synthetic-labelled-events.csv) only contains events in the date range [2021-03-04, 2021-03-28].
  • Loading branch information
SanjayVas authored Apr 19, 2023
1 parent ceeec44 commit 35213ba
Showing 1 changed file with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import java.security.cert.CertPathValidatorException
import java.security.cert.X509Certificate
import java.time.Duration
import java.time.LocalDate
import java.time.ZoneOffset
import java.util.logging.Logger
import kotlin.random.Random
import kotlinx.coroutines.time.delay
Expand Down Expand Up @@ -84,6 +83,7 @@ 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.OpenEndTimeRange
import org.wfanet.measurement.common.crypto.PrivateKeyHandle
import org.wfanet.measurement.common.crypto.SigningKeyHandle
import org.wfanet.measurement.common.crypto.authorityKeyIdentifier
Expand All @@ -101,8 +101,6 @@ import org.wfanet.measurement.consent.client.measurementconsumer.verifyResult
import org.wfanet.measurement.loadtest.config.TestIdentifiers
import org.wfanet.measurement.loadtest.storage.SketchStore

private const val DATA_PROVIDER_WILDCARD = "dataProviders/-"

data class MeasurementConsumerData(
// The MC's public API resource name
val name: String,
Expand Down Expand Up @@ -138,24 +136,19 @@ class FrontendSimulator(
logger.info { "Creating reach and frequency Measurement..." }
// Create a new measurement on behalf of the measurement consumer.
val measurementConsumer = getMeasurementConsumer(measurementConsumerData.name)
val createdReachAndFrequencyMeasurement =
val measurement =
createMeasurement(measurementConsumer, runId, ::newReachAndFrequencyMeasurementSpec)
logger.info {
"Created reach and frequency Measurement ${createdReachAndFrequencyMeasurement.name}"
}
logger.info { "Created reach and frequency Measurement ${measurement.name}" }

// Get the CMMS computed result and compare it with the expected result.
val reachAndFrequencyResult: Result = pollForResult {
getReachAndFrequencyResult(createdReachAndFrequencyMeasurement.name)
getReachAndFrequencyResult(measurement.name)
}
logger.info("Got reach and frequency result from Kingdom: $reachAndFrequencyResult")

val liquidLegionV2Protocol =
createdReachAndFrequencyMeasurement.protocolConfig.protocolsList
.first { it.hasLiquidLegionsV2() }
.liquidLegionsV2
val expectedResult =
getExpectedResult(createdReachAndFrequencyMeasurement.name, liquidLegionV2Protocol)
measurement.protocolConfig.protocolsList.first { it.hasLiquidLegionsV2() }.liquidLegionsV2
val expectedResult = getExpectedResult(measurement.name, liquidLegionV2Protocol)
logger.info("Expected result: $expectedResult")

assertDpResultsEqual(
Expand Down Expand Up @@ -687,13 +680,8 @@ class FrontendSimulator(
value =
RequisitionSpecKt.EventGroupEntryKt.value {
collectionInterval = timeInterval {
startTime =
LocalDate.now()
.minusDays(1)
.atStartOfDay()
.toInstant(ZoneOffset.UTC)
.toProtoTime()
endTime = LocalDate.now().atStartOfDay().toInstant(ZoneOffset.UTC).toProtoTime()
startTime = EVENT_RANGE.start.toProtoTime()
endTime = EVENT_RANGE.endExclusive.toProtoTime()
}
filter = eventFilter { expression = eventFilterExpression }
}
Expand Down Expand Up @@ -753,7 +741,18 @@ class FrontendSimulator(
}

companion object {
private const val DATA_PROVIDER_WILDCARD = "dataProviders/-"

/**
* Date range for events.
*
* TODO(@SanjayVas): Make this configurable.
*/
private val EVENT_RANGE =
OpenEndTimeRange.fromClosedDateRange(LocalDate.of(2021, 3, 15)..LocalDate.of(2021, 3, 15))

private val logger: Logger = Logger.getLogger(this::class.java.name)

init {
loadLibrary(
name = "estimators",
Expand Down

0 comments on commit 35213ba

Please sign in to comment.