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: Display the IT diff between monorepo and split repos #8466

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class BaseTest {
protected static final String DEFAULT_PROJECT = ServiceOptions.getDefaultProjectId();
protected static final String DEFAULT_ZONE = "us-central1-a";
protected static final String DEFAULT_REGION = "us-west1";
protected static final String COMPUTE_PREFIX = "it-test-compute";
protected static final String COMPUTE_PREFIX = "gapic-";

public static String generateRandomName(String placeholder) {
return COMPUTE_PREFIX + "-" + placeholder + "-" + UUID.randomUUID().toString().substring(0, 8);
return COMPUTE_PREFIX + placeholder + UUID.randomUUID().toString().substring(0, 8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.junit.Ignore;
import org.junit.Test;

@Ignore("Address insertion is flaky. https://github.com/googleapis/google-cloud-java/issues/8552")
public class ITAddressesTest extends BaseTest {

private static List<Address> addresses;
Expand All @@ -58,7 +57,7 @@ public void setUpMethod() {
@AfterClass
public static void tearDown() throws ExecutionException, InterruptedException {
for (Address address : addresses) {
addressesClient.deleteAsync(DEFAULT_PROJECT, DEFAULT_REGION, address.getName());
addressesClient.deleteAsync(DEFAULT_PROJECT, DEFAULT_REGION, address.getName()).get();
}
addressesClient.close();
}
Expand Down Expand Up @@ -124,7 +123,7 @@ private void insertAddress(String description) {
.insertAsync(DEFAULT_PROJECT, DEFAULT_REGION, address)
.get(60, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
fail("Insert operation failed.");
fail("Insert operation failed: " + e.getMessage());
}
addresses.add(address);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public static void setUp() throws IOException {
instances = new ArrayList<>();
InstancesSettings instanceSettings = InstancesSettings.newBuilder().build();
instancesClient = InstancesClient.create(instanceSettings);

Util.cleanUpComputeInstances(instancesClient, DEFAULT_PROJECT, DEFAULT_ZONE, COMPUTE_PREFIX);
}

Expand All @@ -84,7 +83,7 @@ public void setUpMethod() {
@AfterClass
public static void tearDown() throws ExecutionException, InterruptedException {
for (Instance instance : instances) {
instancesClient.deleteAsync(DEFAULT_PROJECT, DEFAULT_ZONE, instance.getName());
instancesClient.deleteAsync(DEFAULT_PROJECT, DEFAULT_ZONE, instance.getName()).get();
}
instancesClient.close();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Google LLC
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.compute.v1.integration;

import com.google.cloud.compute.v1.Address;
Expand All @@ -30,9 +29,9 @@
public class Util {

// Cleans existing test resources if any.
private static final int DELETION_THRESHOLD_TIME_HOURS = 2;
private static final int DELETION_THRESHOLD_TIME_HOURS = 24;

/** Bring down any instances that are older than 2 hours */
/** Bring down any instances that are older than 24 hours */
public static void cleanUpComputeInstances(
InstancesClient instancesClient, String project, String zone, String prefix) {
ListPagedResponse listPagedResponse = instancesClient.list(project, zone);
Expand All @@ -50,7 +49,7 @@ public static void cleanUpComputeInstances(
}
}

/** Bring down any addresses that are older than 2 hours */
/** Bring down any addresses that are older than 24 hours */
public static void cleanUpComputeAddresses(
AddressesClient addressesClient, String project, String region, String prefix) {
AddressesClient.ListPagedResponse listPagedResponse = addressesClient.list(project, region);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.container.v1.ListOperationsResponse;
import com.google.container.v1.NodePool;
import com.google.container.v1.Operation;
import com.google.container.v1.Operation.Status;
import com.google.container.v1.ServerConfig;
import java.util.List;
import java.util.UUID;
Expand All @@ -44,11 +43,10 @@ public class ITSystemTest {
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);
"test-cluster-" + UUID.randomUUID().toString().substring(0, 8);
private static final String NODE_POOL_NAME =
CONTAINER_PREFIX + "-node-pool-" + UUID.randomUUID().toString().substring(0, 8);
"test-node-pool-" + UUID.randomUUID().toString().substring(0, 8);
private static final String DETAIL = "test-detail";
private static final String STATUS_MESSAGE = "test-status-message";
private static final String SELF_LINK =
Expand All @@ -57,15 +55,15 @@ public class ITSystemTest {
+ "/zones/us-central1-a/clusters/"
+ CLUSTER_NAME;
private static final String NODE_POOL_SEL_LINK = SELF_LINK + "/nodePools/" + NODE_POOL_NAME;
private static final String NETWORK = "java-container-network";
private static final String NETWORK = "java-container-network-tests";
private static final int INITIAL_NODE_COUNT = 1;

@BeforeClass
public static void beforeClass() throws Exception {
client = ClusterManagerClient.create();
Util.cleanUpExistingInstanceCluster(client, PROJECT_ID, ZONE, CONTAINER_PREFIX);
Util.cleanUpExistingInstanceCluster(PROJECT_ID, ZONE, client);

/* create node pool* */
/** create node pool* */
NodePool nodePool =
NodePool.newBuilder()
.setInitialNodeCount(INITIAL_NODE_COUNT)
Expand All @@ -74,7 +72,7 @@ public static void beforeClass() throws Exception {
.setStatusMessage(STATUS_MESSAGE)
.build();

/* create cluster */
/** create cluster */
Cluster cluster =
Cluster.newBuilder()
.setName(CLUSTER_NAME)
Expand All @@ -86,20 +84,13 @@ public static void beforeClass() throws Exception {
.setNetwork(NETWORK)
.build();
operation = client.createCluster(PROJECT_ID, ZONE, cluster);

Operation response = client.getOperation(PROJECT_ID, ZONE, operation.getName());
// Busy Wait for one minute at a time until Cluster CREATE operation is complete
while (response.getStatus() != Status.DONE) {
LOG.info(String.format("Cluster CREATE Operation Status: %s", response.getStatus()));
Thread.sleep(TimeUnit.MINUTES.toMillis(1));
response = client.getOperation(PROJECT_ID, ZONE, operation.getName());
}
LOG.info(String.format("%s cluster created successfully.", CLUSTER_NAME));
LOG.info(String.format("%s node pool created successfully.", NODE_POOL_NAME));
}

@AfterClass
public static void afterClass() {
public static void afterClass() throws Exception {
Thread.sleep(TimeUnit.MINUTES.toMillis(5));
client.deleteCluster(PROJECT_ID, ZONE, CLUSTER_NAME);
LOG.info(String.format("%s cluster deleted successfully.", CLUSTER_NAME));
client.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,27 @@
import com.google.cloud.container.v1.ClusterManagerClient;
import com.google.container.v1.Cluster;
import com.google.container.v1.ListClustersResponse;
import java.io.IOException;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.concurrent.ExecutionException;

public class Util {

// Cleans existing test resources if any.
private static final int DELETION_THRESHOLD_TIME_HOURS = 2;
private static final int DELETION_THRESHOLD_TIME_HOURS = 24;

/** tear down any clusters that are older than 2 hours * */
/** tear down any clusters that are older than 24 hours * */
public static void cleanUpExistingInstanceCluster(
ClusterManagerClient client, String projectId, String zone, String prefix) {
String projectId, String zone, ClusterManagerClient client)
throws IOException, ExecutionException, InterruptedException {

ListClustersResponse clustersResponse = client.listClusters(projectId, zone);
List<Cluster> clusters = clustersResponse.getClustersList();

for (Cluster cluster : clusters) {
if (isCreatedBeforeThresholdTime(cluster.getCreateTime())
&& cluster.getName().startsWith(prefix)) {
if (isCreatedBeforeThresholdTime(cluster.getCreateTime())) {
client.deleteCluster(projectId, zone, cluster.getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ public class ITNotebookServiceClientTest {
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 NOTEBOOK_INSTANCE_ID = "test-notebook-instance-id-" + ID;
private static final String ENVIRONMENT_ID = "test-environment-id-" + ID;
private static final String INSTANCE_NAME = PARENT + "/instances/" + NOTEBOOK_INSTANCE_ID;
private static final String ENVIRONMENT_NAME = PARENT + "/environments/" + ENVIRONMENT_ID;
private static Instance expectedNotebookInstance;
Expand All @@ -67,8 +66,6 @@ public class ITNotebookServiceClientTest {
public static void setUp() throws IOException, ExecutionException, InterruptedException {
// Create Test Notebook Instance
client = NotebookServiceClient.create();
Util.cleanUpNotebookInstances(client, PARENT, NOTEBOOK_PREFIX);

ContainerImage containerImage =
ContainerImage.newBuilder().setRepository(FieldBehavior.OPTIONAL.name()).build();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public class ITSystemTest {
private static final String ID = UUID.randomUUID().toString().substring(0, 8);
// GraalVM native-image test uses the project root as working directory, not google-cloud-vision
private static final String RESOURCES =
Files.exists(Paths.get("java-vision", "google-cloud-vision", "src", "test", "resources"))
? "java-vision/google-cloud-vision/src/test/resources/"
Files.exists(Paths.get("google-cloud-vision", "src", "test", "resources"))
? "google-cloud-vision/src/test/resources/"
: "src/test/resources/";

private static final String GCS_BUCKET_ENV_VAR = "GOOGLE_CLOUD_TESTS_VISION_BUCKET";
Expand Down