Skip to content

Commit

Permalink
Change in test setup for Java and Privacy on Beam
Browse files Browse the repository at this point in the history
Java DP Lib:
* Migrate usages of `Truth8.assertThat` to equivalent usages of `Truth.assertThat`

Privacy on Beam:
* Use ptest.MainWithDefault for pbeamtest similar to pbeam
* Deprecate pbeamtest usage for enabling test mode in favor of the new PrivacySpec API. Tests and examples now use the new API
* Switch Privacy on Beam tests to the new PrivacySpec API, also includes minor test fixes

ZetaSQL Examples:
* Update dependencies

PiperOrigin-RevId: 605398011
Change-Id: I761849299652918132bad28b67d121de40f8b056
GitOrigin-RevId: cc25bcfe0b9e79d82ae9a07193eaee2bb9e818ba
  • Loading branch information
Differential Privacy Team authored and dibakch committed Feb 12, 2024
1 parent 26b4436 commit e61a5e2
Show file tree
Hide file tree
Showing 18 changed files with 957 additions and 1,383 deletions.
2 changes: 1 addition & 1 deletion examples/zetasql/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
6.5.0
49 changes: 14 additions & 35 deletions examples/zetasql/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,32 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_google_zetasql",
sha256 = "9d3c2149ffe21512fd50f873f718fe663546f2c2ee355af479b06ff31e228b8c",
strip_prefix = "zetasql-2023.03.2",
url = "https://github.com/google/zetasql/archive/refs/tags/2023.03.2.tar.gz",
strip_prefix = "zetasql-2023.11.1",
url = "https://github.com/google/zetasql/archive/refs/tags/2023.11.1.tar.gz",
)

# Transitive dependencies from the ZetaSQL WORKSPACE file:
RULES_JVM_EXTERNAL_TAG = "4.5"

RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"

http_archive(
name = "rules_jvm_external",
sha256 = RULES_JVM_EXTERNAL_SHA,
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/refs/tags/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

http_archive(
name = "io_grpc_grpc_java",
sha256 = "6c39c5feecda4f1ccafe88d8928d9a0f2a686d9a9a9c03888a2e5ac92f7ee34a",
strip_prefix = "grpc-java-1.43.2",
url = "https://github.com/grpc/grpc-java/archive/v1.43.2.tar.gz",
)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@com_google_zetasql//bazel:zetasql_java_deps.bzl", "zetasql_java_deps")

zetasql_java_deps()

load("@com_google_zetasql//bazel:zetasql_deps_step_1.bzl", "zetasql_deps_step_1")

zetasql_deps_step_1()

load("@com_google_zetasql//bazel:zetasql_deps_step_2.bzl", "zetasql_deps_step_2")

zetasql_deps_step_2()
zetasql_deps_step_2(
java_deps = False,
testing_deps = False,
)

# Only need to load a subset of zetasql_deps_step_3:

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@com_google_zetasql//bazel:zetasql_deps_step_3.bzl", "zetasql_deps_step_3")
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

zetasql_deps_step_3()
grpc_deps()

load("@com_google_zetasql//bazel:zetasql_deps_step_4.bzl", "zetasql_deps_step_4")

Expand Down
6 changes: 3 additions & 3 deletions java/dp_java_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def dp_java_deps():
"com.google.auto.value:auto-value:1.10.4",
"com.google.code.findbugs:jsr305:3.0.2",
"com.google.errorprone:error_prone_annotations:2.23.0",
"com.google.guava:guava:32.1.3-jre",
"com.google.guava:guava:33.0.0-jre",
"com.google.protobuf:protobuf-java:3.25.0",
# artifacts for testing only
"org.mockito:mockito-core:5.7.0",
"junit:junit:4.13.2",
"com.google.truth:truth:1.1.5",
"com.google.truth.extensions:truth-java8-extension:1.1.5",
"com.google.truth:truth:1.4.0",
"com.google.truth.extensions:truth-java8-extension:1.4.0",
"com.google.testparameterinjector:test-parameter-injector:1.15",
],
repositories = [
Expand Down
40 changes: 20 additions & 20 deletions java/maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": -131668409,
"__RESOLVED_ARTIFACTS_HASH": -1554454602,
"__INPUT_ARTIFACTS_HASH": -303031740,
"__RESOLVED_ARTIFACTS_HASH": 903391609,
"conflict_resolution": {
"com.google.errorprone:error_prone_annotations:2.23.0": "com.google.errorprone:error_prone_annotations:2.24.1"
},
"artifacts": {
"com.google.auto.value:auto-value": {
"shasums": {
Expand All @@ -23,21 +26,21 @@
},
"com.google.errorprone:error_prone_annotations": {
"shasums": {
"jar": "ec6f39f068b6ff9ac323c68e28b9299f8c0a80ca512dccb1d4a70f40ac3ec054"
"jar": "19fe2f7155d20ea093168527999da98108103ee546d1e8b726bc4b27c31a3c30"
},
"version": "2.23.0"
"version": "2.24.1"
},
"com.google.guava:failureaccess": {
"shasums": {
"jar": "a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26"
"jar": "8a8f81cf9b359e3f6dfa691a1e776985c061ef2f223c9b2c80753e1b458e8064"
},
"version": "1.0.1"
"version": "1.0.2"
},
"com.google.guava:guava": {
"shasums": {
"jar": "6d4e2b5a118aab62e6e5e29d185a0224eed82c85c40ac3d33cf04a270c3b3744"
"jar": "f4d85c3e4d411694337cb873abea09b242b664bb013320be6105327c45991537"
},
"version": "32.1.3-jre"
"version": "33.0.0-jre"
},
"com.google.guava:listenablefuture": {
"shasums": {
Expand Down Expand Up @@ -65,15 +68,15 @@
},
"com.google.truth.extensions:truth-java8-extension": {
"shasums": {
"jar": "9e3c437ef76c0028d1c87d9f81d599301459333cfb3b50e5bf815ed712745140"
"jar": "293f4e4c59ce48e8b68651321d2d9f2355534412b221369b2af8ff76e6acf381"
},
"version": "1.1.5"
"version": "1.4.0"
},
"com.google.truth:truth": {
"shasums": {
"jar": "7f6d50d6f43a102942ef2c5a05f37a84f77788bb448cf33cceebf86d34e575c0"
"jar": "235c28e96ee6701ab01cc852fb294cb0f34756f636a8154b9aef08fb1215bbc4"
},
"version": "1.1.5"
"version": "1.4.0"
},
"junit:junit": {
"shasums": {
Expand Down Expand Up @@ -101,9 +104,9 @@
},
"org.checkerframework:checker-qual": {
"shasums": {
"jar": "e4ce1376cc2735e1dde220b62ad0913f51297704daad155a33f386bc5db0d9f7"
"jar": "ccaedd33af0b7894d9f2f3b644f4d19e43928e32902e61ac4d10777830f5aac7"
},
"version": "3.37.0"
"version": "3.42.0"
},
"org.hamcrest:hamcrest-core": {
"shasums": {
Expand All @@ -125,9 +128,9 @@
},
"org.ow2.asm:asm": {
"shasums": {
"jar": "b62e84b5980729751b0458c534cf1366f727542bb8d158621335682a460f0353"
"jar": "3c6fac2424db3d4a853b669f4e3d1d9c3c552235e19a319673f887083c2303a1"
},
"version": "9.5"
"version": "9.6"
},
"org.yaml:snakeyaml": {
"shasums": {
Expand Down Expand Up @@ -299,9 +302,6 @@
"com.google.testparameterinjector:test-parameter-injector": [
"com.google.testing.junit.testparameterinjector"
],
"com.google.truth.extensions:truth-java8-extension": [
"com.google.common.truth"
],
"com.google.truth:truth": [
"com.google.common.truth"
],
Expand Down Expand Up @@ -487,7 +487,7 @@
"org.checkerframework.common.reflection.qual",
"org.checkerframework.common.returnsreceiver.qual",
"org.checkerframework.common.subtyping.qual",
"org.checkerframework.common.util.report.qual",
"org.checkerframework.common.util.count.report.qual",
"org.checkerframework.common.value.qual",
"org.checkerframework.dataflow.qual",
"org.checkerframework.framework.qual"
Expand Down
11 changes: 5 additions & 6 deletions java/tests/com/google/privacy/differentialprivacy/CountTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.google.common.truth.Truth8;
import com.google.privacy.differentialprivacy.proto.SummaryOuterClass.CountSummary;
import com.google.privacy.differentialprivacy.proto.SummaryOuterClass.MechanismType;
import com.google.protobuf.InvalidProtocolBufferException;
Expand Down Expand Up @@ -531,7 +530,7 @@ public void computeThresholdedResult_countGreaterThanThreshold_returnsCount() {
// noise) count is equal to 12, which passes the threshold and therefore 12 should be returned.
count.incrementBy(12);
Optional<Long> actualResult = count.computeThresholdedResult(THRESHOLD_DELTA);
Truth8.assertThat(actualResult).hasValue(12);
assertThat(actualResult).hasValue(12);
}

@Test
Expand Down Expand Up @@ -573,8 +572,8 @@ public void computeThresholdedResult_forLaplace_appliesCorrectThreshold() {
count.incrementBy(122);
Optional<Long> ceiledThreshold = count.computeThresholdedResult(0.1);

Truth8.assertThat(flooredThreshold).isEmpty();
Truth8.assertThat(ceiledThreshold).hasValue(122);
assertThat(flooredThreshold).isEmpty();
assertThat(ceiledThreshold).hasValue(122);
}

@Test
Expand Down Expand Up @@ -613,8 +612,8 @@ public void computeThresholdedResult_forGaussian_appliesCorrectThreshold() {
count.incrementBy(72);
Optional<Long> ceiledThreshold = count.computeThresholdedResult(0.1);

Truth8.assertThat(flooredThreshold).isEmpty();
Truth8.assertThat(ceiledThreshold).hasValue(72);
assertThat(flooredThreshold).isEmpty();
assertThat(ceiledThreshold).hasValue(72);
}

private Count.Params.Builder getCountBuilderWithFields() {
Expand Down
Loading

0 comments on commit e61a5e2

Please sign in to comment.