From ef545eb3a18d5d624b5500732fad07afc4288f7c Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Fri, 16 Sep 2022 17:33:42 -0400 Subject: [PATCH] chore: Pass prefix name to Utils for ITs (#8420) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Add required status checks * chore: Fix format for repo settings sync * chore: Make Java 17 Unit required * chore: Remove TEST_ALL_MODULES env_var from presubmits * chore: Cleanup Util classes for ITs * 🦉 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 --- .../presubmit/graalvm-native-17-aiplatform.cfg | 5 ----- .kokoro/presubmit/graalvm-native-17-compute.cfg | 5 ----- .kokoro/presubmit/graalvm-native-aiplatform.cfg | 5 ----- .kokoro/presubmit/graalvm-native-compute.cfg | 5 ----- .../compute/v1/integration/ITAddressesTest.java | 2 +- .../v1/integration/ITSmokeInstancesTest.java | 2 +- .../cloud/compute/v1/integration/Util.java | 16 +++++++--------- java-container/.github/CODEOWNERS | 2 +- java-container/README.md | 4 ++-- .../cloud/container/v1/it/ITSystemTest.java | 5 ++--- .../com/google/cloud/container/v1/it/Util.java | 4 ++-- .../v1beta1/it/ITNotebookServiceClientTest.java | 5 ++--- .../google/cloud/notebooks/v1beta1/it/Util.java | 5 +++-- 13 files changed, 21 insertions(+), 44 deletions(-) diff --git a/.kokoro/presubmit/graalvm-native-17-aiplatform.cfg b/.kokoro/presubmit/graalvm-native-17-aiplatform.cfg index 767a6540e512..af6363393343 100644 --- a/.kokoro/presubmit/graalvm-native-17-aiplatform.cfg +++ b/.kokoro/presubmit/graalvm-native-17-aiplatform.cfg @@ -35,9 +35,4 @@ env_vars: { env_vars: { key: "MAVEN_MODULES" value: "java-aiplatform" -} - -env_vars: { - key: "TEST_ALL_MODULES" - value: "false" } \ No newline at end of file diff --git a/.kokoro/presubmit/graalvm-native-17-compute.cfg b/.kokoro/presubmit/graalvm-native-17-compute.cfg index 90b67771cc9b..5748c3b3955d 100644 --- a/.kokoro/presubmit/graalvm-native-17-compute.cfg +++ b/.kokoro/presubmit/graalvm-native-17-compute.cfg @@ -35,9 +35,4 @@ env_vars: { env_vars: { key: "MAVEN_MODULES" value: "java-compute" -} - -env_vars: { - key: "TEST_ALL_MODULES" - value: "false" } \ No newline at end of file diff --git a/.kokoro/presubmit/graalvm-native-aiplatform.cfg b/.kokoro/presubmit/graalvm-native-aiplatform.cfg index 8b4a6edcddf2..09d38af036d0 100644 --- a/.kokoro/presubmit/graalvm-native-aiplatform.cfg +++ b/.kokoro/presubmit/graalvm-native-aiplatform.cfg @@ -35,9 +35,4 @@ env_vars: { env_vars: { key: "MAVEN_MODULES" value: "java-aiplatform" -} - -env_vars: { - key: "TEST_ALL_MODULES" - value: "false" } \ No newline at end of file diff --git a/.kokoro/presubmit/graalvm-native-compute.cfg b/.kokoro/presubmit/graalvm-native-compute.cfg index 90b67771cc9b..5748c3b3955d 100644 --- a/.kokoro/presubmit/graalvm-native-compute.cfg +++ b/.kokoro/presubmit/graalvm-native-compute.cfg @@ -35,9 +35,4 @@ env_vars: { env_vars: { key: "MAVEN_MODULES" value: "java-compute" -} - -env_vars: { - key: "TEST_ALL_MODULES" - value: "false" } \ No newline at end of file diff --git a/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITAddressesTest.java b/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITAddressesTest.java index f0be10fd076a..5c442ea8fe66 100644 --- a/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITAddressesTest.java +++ b/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITAddressesTest.java @@ -46,7 +46,7 @@ public static void setUp() throws IOException { addresses = new ArrayList<>(); AddressesSettings addressesSettings = AddressesSettings.newBuilder().build(); addressesClient = AddressesClient.create(addressesSettings); - Util.cleanUpComputeAddresses(addressesClient, DEFAULT_PROJECT, DEFAULT_REGION); + Util.cleanUpComputeAddresses(addressesClient, DEFAULT_PROJECT, DEFAULT_REGION, COMPUTE_PREFIX); } @Before diff --git a/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITSmokeInstancesTest.java b/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITSmokeInstancesTest.java index 8fff73baa109..756c097dadbb 100644 --- a/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITSmokeInstancesTest.java +++ b/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITSmokeInstancesTest.java @@ -73,7 +73,7 @@ public static void setUp() throws IOException { InstancesSettings instanceSettings = InstancesSettings.newBuilder().build(); instancesClient = InstancesClient.create(instanceSettings); - Util.cleanUpComputeInstances(instancesClient, DEFAULT_PROJECT, DEFAULT_ZONE); + Util.cleanUpComputeInstances(instancesClient, DEFAULT_PROJECT, DEFAULT_ZONE, COMPUTE_PREFIX); } @Before diff --git a/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/Util.java b/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/Util.java index faae3a0a38cc..50a51a509a19 100644 --- a/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/Util.java +++ b/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/Util.java @@ -1,7 +1,5 @@ package com.google.cloud.compute.v1.integration; -import static com.google.cloud.compute.v1.integration.BaseTest.COMPUTE_PREFIX; - import com.google.cloud.compute.v1.Address; import com.google.cloud.compute.v1.AddressesClient; import com.google.cloud.compute.v1.DeleteInstanceRequest; @@ -20,12 +18,12 @@ public class Util { /** Bring down any instances that are older than 24 hours */ public static void cleanUpComputeInstances( - InstancesClient instancesClient, String project, String zone) { + InstancesClient instancesClient, String project, String zone, String prefix) { ListPagedResponse listPagedResponse = instancesClient.list(project, zone); for (Instance instance : listPagedResponse.iterateAll()) { if (isCreatedBeforeThresholdTime( - ZonedDateTime.parse(instance.getCreationTimestamp()).toInstant()) - && instance.getName().startsWith(BaseTest.COMPUTE_PREFIX)) { + ZonedDateTime.parse(instance.getCreationTimestamp()).toInstant()) + && instance.getName().startsWith(prefix)) { instancesClient.deleteAsync( DeleteInstanceRequest.newBuilder() .setInstance(instance.getName()) @@ -37,12 +35,12 @@ public static void cleanUpComputeInstances( } /** Bring down any addresses that are older than 24 hours */ - public static void cleanUpComputeAddresses(AddressesClient addressesClient, String project, - String region) { + public static void cleanUpComputeAddresses( + AddressesClient addressesClient, String project, String region, String prefix) { AddressesClient.ListPagedResponse listPagedResponse = addressesClient.list(project, region); for (Address address : listPagedResponse.iterateAll()) { - if (isCreatedBeforeThresholdTime(address.getCreationTimestamp()) && address.getName() - .startsWith(COMPUTE_PREFIX)) { + if (isCreatedBeforeThresholdTime(address.getCreationTimestamp()) + && address.getName().startsWith(prefix)) { addressesClient.deleteAsync(project, region, address.getName()); } } diff --git a/java-container/.github/CODEOWNERS b/java-container/.github/CODEOWNERS index cb505e5327ed..8af60d13f06e 100644 --- a/java-container/.github/CODEOWNERS +++ b/java-container/.github/CODEOWNERS @@ -5,7 +5,7 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax # The @googleapis/yoshi-java is the default owner for changes in this repo -* @googleapis/yoshi-java +* @googleapis/yoshi-java @googleapis/yoshi-java # The java-samples-reviewers team is the default owner for samples changes diff --git a/java-container/README.md b/java-container/README.md index 1ae2a2359617..cbd32bacd954 100644 --- a/java-container/README.md +++ b/java-container/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-container' If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-container:2.5.1' +implementation 'com.google.cloud:google-cloud-container:2.5.2' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-container" % "2.5.1" +libraryDependencies += "com.google.cloud" % "google-cloud-container" % "2.5.2" ``` ## Authentication diff --git a/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/ITSystemTest.java b/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/ITSystemTest.java index 15204497712a..86edf8211d18 100644 --- a/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/ITSystemTest.java +++ b/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/ITSystemTest.java @@ -38,14 +38,13 @@ public class ITSystemTest { - protected static final String CONTAINER_PREFIX = "it-test-container"; - private static ClusterManagerClient client; private static Operation operation; private static final Logger LOG = Logger.getLogger(ITSystemTest.class.getName()); private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); private static final String ZONE = "us-central1-a"; + private static final String CONTAINER_PREFIX = "it-test-container"; private static final String CLUSTER_NAME = CONTAINER_PREFIX + "-cluster-" + UUID.randomUUID().toString().substring(0, 8); private static final String NODE_POOL_NAME = @@ -64,7 +63,7 @@ public class ITSystemTest { @BeforeClass public static void beforeClass() throws Exception { client = ClusterManagerClient.create(); - Util.cleanUpExistingInstanceCluster(PROJECT_ID, ZONE, client); + Util.cleanUpExistingInstanceCluster(client, PROJECT_ID, ZONE, CONTAINER_PREFIX); /* create node pool* */ NodePool nodePool = diff --git a/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/Util.java b/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/Util.java index 7a09cf4cc168..5348c06b811e 100644 --- a/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/Util.java +++ b/java-container/google-cloud-container/src/test/java/com/google/cloud/container/v1/it/Util.java @@ -31,14 +31,14 @@ public class Util { /** tear down any clusters that are older than 24 hours * */ public static void cleanUpExistingInstanceCluster( - String projectId, String zone, ClusterManagerClient client) { + ClusterManagerClient client, String projectId, String zone, String prefix) { ListClustersResponse clustersResponse = client.listClusters(projectId, zone); List clusters = clustersResponse.getClustersList(); for (Cluster cluster : clusters) { if (isCreatedBeforeThresholdTime(cluster.getCreateTime()) - && cluster.getName().startsWith(ITSystemTest.CONTAINER_PREFIX)) { + && cluster.getName().startsWith(prefix)) { client.deleteCluster(projectId, zone, cluster.getName()); } } diff --git a/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/ITNotebookServiceClientTest.java b/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/ITNotebookServiceClientTest.java index 0797be1eba2f..a394b48791e8 100644 --- a/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/ITNotebookServiceClientTest.java +++ b/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/ITNotebookServiceClientTest.java @@ -48,13 +48,12 @@ public class ITNotebookServiceClientTest { - protected static final String NOTEBOOK_PREFIX = "it-test-notebook"; - private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); private static final String LOCATION = "us-central1-a"; private static final String PARENT = "projects/" + PROJECT_ID + "/locations/" + LOCATION; private static NotebookServiceClient client; private static final String ID = UUID.randomUUID().toString().substring(0, 8); + private static final String NOTEBOOK_PREFIX = "it-test-notebook"; private static final String NOTEBOOK_INSTANCE_ID = NOTEBOOK_PREFIX + "-instance-id-" + ID; private static final String ENVIRONMENT_ID = NOTEBOOK_PREFIX + "-environment-id-" + ID; private static final String INSTANCE_NAME = PARENT + "/instances/" + NOTEBOOK_INSTANCE_ID; @@ -68,7 +67,7 @@ public class ITNotebookServiceClientTest { public static void setUp() throws IOException, ExecutionException, InterruptedException { // Create Test Notebook Instance client = NotebookServiceClient.create(); - Util.cleanUpNotebookInstances(client, PARENT); + Util.cleanUpNotebookInstances(client, PARENT, NOTEBOOK_PREFIX); ContainerImage containerImage = ContainerImage.newBuilder().setRepository(FieldBehavior.OPTIONAL.name()).build(); diff --git a/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/Util.java b/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/Util.java index 4db68179e7dc..8ad349fa6985 100644 --- a/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/Util.java +++ b/java-notebooks/google-cloud-notebooks/src/test/java/com/google/cloud/notebooks/v1beta1/it/Util.java @@ -15,13 +15,14 @@ public class Util { private static final int DELETION_THRESHOLD_TIME_HOURS = 24; /** Bring down any instances that are older than 24 hours */ - public static void cleanUpNotebookInstances(NotebookServiceClient client, String parent) { + public static void cleanUpNotebookInstances( + NotebookServiceClient client, String parent, String prefix) { ListInstancesPagedResponse listInstancesPagedResponse = client.listInstances(ListInstancesRequest.newBuilder().setParent(parent).build()); for (Instance instance : listInstancesPagedResponse.iterateAll()) { if (isCreatedBeforeThresholdTime( Instant.ofEpochMilli(Timestamps.toMillis(instance.getCreateTime()))) - && instance.getName().startsWith(ITNotebookServiceClientTest.NOTEBOOK_PREFIX)) { + && instance.getName().startsWith(prefix)) { client.deleteInstanceAsync( DeleteInstanceRequest.newBuilder().setName(instance.getName()).build()); }