Skip to content

Commit

Permalink
fix: Enable java-notification integration test (#8742)
Browse files Browse the repository at this point in the history
* 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 <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
burkedavison and gcf-owl-bot[bot] committed Nov 10, 2022
1 parent 0617674 commit e170de2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
13 changes: 6 additions & 7 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -95,7 +92,6 @@ private String formatForTest(String resourceName) {
return resourceName + "-" + NAME_SUFFIX;
}

@Ignore
@Test
public void testNotifications() {
// Use Pubsub to create a Topic.
Expand All @@ -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";
Expand Down

0 comments on commit e170de2

Please sign in to comment.