Skip to content

Commit

Permalink
feat: Wire up in-process Reporting integration test with Access serve…
Browse files Browse the repository at this point in the history
…r. (#2019)
  • Loading branch information
SanjayVas authored Feb 6, 2025
1 parent 8a8026d commit 96f0e99
Show file tree
Hide file tree
Showing 17 changed files with 365 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load("@wfa_rules_kotlin_jvm//kotlin:defs.bzl", "kt_jvm_library")

package(default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/access:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/integration:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/access:__subpackages__",
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("//src/main/docker:macros.bzl", "java_image")
package(
default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/access/deploy:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/integration/deploy/gcloud:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/access/deploy:__subpackages__",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@wfa_rules_kotlin_jvm//kotlin:defs.bzl", "kt_jvm_library")
package(
default_testonly = True,
default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/integration/deploy/gcloud:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/access/deploy/gcloud/spanner:__subpackages__",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package(
default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/access/deploy:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/access/service:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/integration:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/access/service:__subpackages__",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package(
default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/access/deploy:__subpackages__",
test_target(":__pkg__"),
"//src/main/kotlin/org/wfanet/measurement/integration/common:__pkg__",
],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2024 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.integration.common

import org.junit.rules.TestRule
import org.wfanet.measurement.access.common.TlsClientPrincipalMapping
import org.wfanet.measurement.access.service.internal.PermissionMapping
import org.wfanet.measurement.access.service.internal.Services as AccessInternalServices

interface AccessServicesFactory : TestRule {
fun create(
permissionMapping: PermissionMapping,
tlsClientMapping: TlsClientPrincipalMapping,
): AccessInternalServices
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("//src/main/proto/wfa/measurement/internal/kingdom:all_protos.bzl", "KINGDO
package(
default_testonly = True,
default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/integration:__subpackages__",
"//src/main/kotlin/org/wfanet/measurement/loadtest:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/integration:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/loadtest:__subpackages__",
Expand Down Expand Up @@ -101,13 +102,15 @@ kt_jvm_library(
"//src/main/k8s/testing/secretfiles:all_der_files",
"//src/main/k8s/testing/secretfiles:all_root_certs.pem",
"//src/main/k8s/testing/secretfiles:all_tink_keysets",
"//src/main/proto/wfa/measurement/reporting/v2alpha:permissions_config.textproto",
],
deps = [
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha:resource_key",
"//src/main/kotlin/org/wfanet/measurement/kingdom/deploy/common:duchy_ids",
"//src/main/kotlin/org/wfanet/measurement/loadtest/resourcesetup:resource_setup",
"//src/main/kotlin/org/wfanet/measurement/populationdataprovider:population_requisition_fulfiller",
"//src/main/proto/wfa/measurement/config:duchy_cert_config_kt_jvm_proto",
"//src/main/proto/wfa/measurement/config/access:permissions_config_kt_jvm_proto",
"//src/main/proto/wfa/measurement/internal/duchy/config:protocols_setup_config_kt_jvm_proto",
"//src/main/proto/wfa/measurement/internal/kingdom:duchy_id_config_kt_jvm_proto",
"//src/main/proto/wfa/measurement/internal/kingdom:protocol_config_config_kt_jvm_proto",
Expand Down Expand Up @@ -255,6 +258,35 @@ kt_jvm_library(
],
)

kt_jvm_library(
name = "access_services_factory",
srcs = ["AccessServicesFactory.kt"],
visibility = [
"//src/main/kotlin/org/wfanet/measurement/integration:__subpackages__",
],
deps = [
"//src/main/kotlin/org/wfanet/measurement/access/common:tls_client_principal_mapping",
"//src/main/kotlin/org/wfanet/measurement/access/service/internal:permission_mapping",
"//src/main/kotlin/org/wfanet/measurement/access/service/internal:services",
"@wfa_common_jvm//imports/java/org/junit",
],
)

kt_jvm_library(
name = "in_process_access",
srcs = ["InProcessAccess.kt"],
visibility = [
"//src/main/kotlin/org/wfanet/measurement/integration:__subpackages__",
],
deps = [
"//src/main/kotlin/org/wfanet/measurement/access/service/internal:services",
"//src/main/kotlin/org/wfanet/measurement/access/service/v1alpha:services",
"@wfa_common_jvm//imports/java/org/junit",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/grpc/testing",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/testing",
],
)

kt_jvm_library(
name = "in_process_life_of_a_measurement_integration_test",
srcs = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.wfanet.measurement.common.parseTextProto
import org.wfanet.measurement.common.readByteString
import org.wfanet.measurement.common.toInstant
import org.wfanet.measurement.common.toJson
import org.wfanet.measurement.config.access.PermissionsConfig
import org.wfanet.measurement.consent.client.common.toEncryptionPublicKey
import org.wfanet.measurement.internal.duchy.config.ProtocolsSetupConfig
import org.wfanet.measurement.internal.kingdom.DuchyIdConfig
Expand All @@ -44,12 +45,10 @@ import org.wfanet.measurement.internal.kingdom.Llv2ProtocolConfigConfig
import org.wfanet.measurement.kingdom.deploy.common.DuchyIds
import org.wfanet.measurement.loadtest.resourcesetup.EntityContent

private const val REPO_NAME = "wfa_measurement_system"

private val SECRET_FILES_PATH: Path =
checkNotNull(
getRuntimePath(
Paths.get("wfa_measurement_system", "src", "main", "k8s", "testing", "secretfiles")
)
)
checkNotNull(getRuntimePath(Paths.get(REPO_NAME, "src", "main", "k8s", "testing", "secretfiles")))

val AGGREGATOR_PROTOCOLS_SETUP_CONFIG: ProtocolsSetupConfig =
loadTextProto(
Expand Down Expand Up @@ -111,6 +110,27 @@ val ALL_DUCHIES =
)
}

val PERMISSIONS_CONFIG: PermissionsConfig =
parseTextProto(
checkNotNull(
getRuntimePath(
Paths.get(
REPO_NAME,
"src",
"main",
"proto",
"wfa",
"measurement",
"reporting",
"v2alpha",
"permissions_config.textproto",
)
)
)
.toFile(),
PermissionsConfig.getDefaultInstance(),
)

val ALL_EDP_WITH_HMSS_CAPABILITIES_DISPLAY_NAMES = listOf("edp1", "edp3")
val ALL_EDP_WITHOUT_HMSS_CAPABILITIES_DISPLAY_NAMES = listOf("edp2")
val ALL_EDP_DISPLAY_NAMES =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024 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.integration.common

import io.grpc.Channel
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
import org.wfanet.measurement.access.service.internal.Services as InternalServices
import org.wfanet.measurement.access.service.v1alpha.Services
import org.wfanet.measurement.common.grpc.testing.GrpcTestServerRule
import org.wfanet.measurement.common.testing.chainRulesSequentially

class InProcessAccess(
verboseGrpcLogging: Boolean,
private val getInternalServices: () -> InternalServices,
) : TestRule {
private val internalAccessServer =
GrpcTestServerRule(logAllRequests = verboseGrpcLogging) {
val services = getInternalServices().toList()
for (service in services) {
addService(service)
}
}

private val accessServer =
GrpcTestServerRule(logAllRequests = verboseGrpcLogging) {
val internalChannel = internalAccessServer.channel
val services = Services.build(internalChannel).toList()
for (service in services) {
addService(service)
}
}

val channel: Channel
get() = accessServer.channel

override fun apply(base: Statement, description: Description): Statement {
return chainRulesSequentially(internalAccessServer, accessServer).apply(base, description)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ kt_jvm_library(
],
deps = [
":in_process_reporting_server",
"//src/main/kotlin/org/wfanet/measurement/access/client/v1alpha:trusted_principal_auth_interceptor",
"//src/main/kotlin/org/wfanet/measurement/api/v2alpha/testing",
"//src/main/kotlin/org/wfanet/measurement/integration/common:access_services_factory",
"//src/main/kotlin/org/wfanet/measurement/integration/common:configs",
"//src/main/kotlin/org/wfanet/measurement/integration/common:in_process_cmms_components",
"//src/main/kotlin/org/wfanet/measurement/integration/common:synthetic_generation_specs",
"//src/main/kotlin/org/wfanet/measurement/integration/common/reporting/v2/identity:reporting_principal_identity",
Expand Down Expand Up @@ -48,6 +51,9 @@ kt_jvm_library(
"//src/main/k8s/testing/secretfiles:secret_files",
],
deps = [
"//src/main/kotlin/org/wfanet/measurement/integration/common:access_services_factory",
"//src/main/kotlin/org/wfanet/measurement/integration/common:configs",
"//src/main/kotlin/org/wfanet/measurement/integration/common:in_process_access",
"//src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats:variances",
"//src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/common/server:internal_reporting_server",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api:cel_env_provider",
Expand Down
Loading

0 comments on commit 96f0e99

Please sign in to comment.