From e170de25520f45671b5a2fe37d7ff9c277ebdbd2 Mon Sep 17 00:00:00 2001 From: Burke Davison <40617934+burkedavison@users.noreply.github.com> Date: Thu, 10 Nov 2022 10:07:47 -0500 Subject: [PATCH] fix: Enable java-notification integration test (#8742) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Enable java-notification integration test * fix: Terraform job type is now terraform-integration * fix: java-notification: Output full requested policy if setIamPolicy fails * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: java-notification: Include FailedPreconditionException in verbose policy output * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: debug: add log outputs * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: debug: setting other env vars * chore: debug: output names * chore: debug: remove timer * fix: Remove time() wrapper around environment setup. Clean-up debug. * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .kokoro/build.sh | 13 +++++----- .../cloud/notification/it/ITSystemTest.java | 24 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index cf6d82df7d8e..390af7ad4542 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -38,13 +38,12 @@ fi function setup_cloud() { gcloud config set project "$GOOGLE_CLOUD_PROJECT" - time ( - terraform -version && - source ./.cloud/helpers/init.sh "$1" && - source ./.cloud/helpers/plan.sh "$1" && - source ./.cloud/helpers/apply.sh && - source ./.cloud/helpers/populate-env.sh - ) + + terraform -version && + source ./.cloud/helpers/init.sh "$1" && + source ./.cloud/helpers/plan.sh "$1" && + source ./.cloud/helpers/apply.sh && + source ./.cloud/helpers/populate-env.sh destroy() { arguments=$? diff --git a/java-notification/src/test/java/com/google/cloud/notification/it/ITSystemTest.java b/java-notification/src/test/java/com/google/cloud/notification/it/ITSystemTest.java index c9f0715a0311..9c162dee0b82 100644 --- a/java-notification/src/test/java/com/google/cloud/notification/it/ITSystemTest.java +++ b/java-notification/src/test/java/com/google/cloud/notification/it/ITSystemTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import com.google.api.gax.rpc.FailedPreconditionException; import com.google.cloud.ServiceOptions; import com.google.cloud.notification.Notification; import com.google.cloud.notification.NotificationImpl.DefaultNotificationFactory; @@ -33,9 +34,8 @@ import com.google.iam.v1.Binding; import com.google.iam.v1.Policy; import com.google.pubsub.v1.ProjectTopicName; +import io.grpc.StatusRuntimeException; import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -45,14 +45,12 @@ import java.util.logging.Logger; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; public class ITSystemTest { - private static RemoteStorageHelper remoteStorageHelper; private static TopicAdminClient topicAdminClient; private static Notification notificationService; private static Storage storageService; @@ -69,9 +67,8 @@ public class ITSystemTest { @Rule public Timeout globalTimeout = Timeout.seconds(300); @BeforeClass - public static void beforeClass() - throws NoSuchAlgorithmException, InvalidKeySpecException, IOException { - remoteStorageHelper = RemoteStorageHelper.create(); + public static void beforeClass() throws IOException { + RemoteStorageHelper remoteStorageHelper = RemoteStorageHelper.create(); topicAdminClient = TopicAdminClient.create(); storageService = remoteStorageHelper.getOptions().getService(); notificationService = new DefaultNotificationFactory().create(storageService); @@ -95,7 +92,6 @@ private String formatForTest(String resourceName) { return resourceName + "-" + NAME_SUFFIX; } - @Ignore @Test public void testNotifications() { // Use Pubsub to create a Topic. @@ -109,9 +105,15 @@ public void testNotifications() { .setRole("roles/pubsub.publisher") .addMembers(STORAGE_SERVICE_AGENT) .build(); - Policy newPolicy = - topicAdminClient.setIamPolicy( - topic.toString(), policy.toBuilder().addBindings(binding).build()); + Policy modifiedPolicy = policy.toBuilder().addBindings(binding).build(); + Policy newPolicy; + try { + newPolicy = topicAdminClient.setIamPolicy(topic.toString(), modifiedPolicy); + } catch (StatusRuntimeException | FailedPreconditionException ex) { + System.out.println( + "Failed setIamPolicy request for " + topic.toString() + " : " + modifiedPolicy); + throw ex; + } assertTrue(newPolicy.getBindingsList().contains(binding)); String permissionName = "pubsub.topics.get";