Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Pass prefix name to Utils for ITs #8420

Merged
merged 10 commits into from
Sep 16, 2022
5 changes: 0 additions & 5 deletions .kokoro/presubmit/graalvm-native-17-aiplatform.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ env_vars: {
env_vars: {
key: "MAVEN_MODULES"
value: "java-aiplatform"
}

env_vars: {
key: "TEST_ALL_MODULES"
value: "false"
}
5 changes: 0 additions & 5 deletions .kokoro/presubmit/graalvm-native-17-compute.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ env_vars: {
env_vars: {
key: "MAVEN_MODULES"
value: "java-compute"
}

env_vars: {
key: "TEST_ALL_MODULES"
value: "false"
}
5 changes: 0 additions & 5 deletions .kokoro/presubmit/graalvm-native-aiplatform.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ env_vars: {
env_vars: {
key: "MAVEN_MODULES"
value: "java-aiplatform"
}

env_vars: {
key: "TEST_ALL_MODULES"
value: "false"
}
5 changes: 0 additions & 5 deletions .kokoro/presubmit/graalvm-native-compute.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ env_vars: {
env_vars: {
key: "MAVEN_MODULES"
value: "java-compute"
}

env_vars: {
key: "TEST_ALL_MODULES"
value: "false"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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())
Expand All @@ -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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion java-container/.github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions java-container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cluster> 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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down