From 28b98759ef9da5b89680d2d05ef6bb819bacf525 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Mon, 11 Apr 2022 14:23:36 +0530 Subject: [PATCH 001/136] docs(compute-samples): add snippets and tests for windows instance management --- ...eFirewallRuleForWindowsActivationHost.java | 82 +++++++++++ .../CreateRouteToWindowsActivationHost.java | 80 +++++++++++ ...CreateWindowsServerInstanceExternalIp.java | 116 +++++++++++++++ ...CreateWindowsServerInstanceInternalIp.java | 127 +++++++++++++++++ .../GetInstanceSerialPort.java | 51 +++++++ .../CreatingManagingWindowsInstancesIT.java | 132 ++++++++++++++++++ 6 files changed, 588 insertions(+) create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java create mode 100644 compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java new file mode 100644 index 00000000000..fad6b990b5c --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java @@ -0,0 +1,82 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; + +// [START compute_create_egress_rule_windows_activation] + +import com.google.cloud.compute.v1.Allowed; +import com.google.cloud.compute.v1.Firewall; +import com.google.cloud.compute.v1.FirewallsClient; +import com.google.cloud.compute.v1.InsertFirewallRequest; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateFirewallRuleForWindowsActivationHost { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // firewallRuleName - Name of the firewall rule you want to create. + String firewallRuleName = "firewall-rule-name"; + + // networkName - Name of the network you want the new instance to use. + // * For example: "global/networks/default" represents the network + // * named "default", which is created automatically for each project. + String networkName = "global/networks/default"; + + createFirewallRuleForWindowsActivationHost(projectId, firewallRuleName, networkName); + } + + // Creates a new allow egress firewall rule with the highest priority for host + // kms.windows.googlecloud.com (35.190.247.13) for Windows activation. + public static void createFirewallRuleForWindowsActivationHost(String projectId, + String firewallRuleName, String networkName) + throws IOException, ExecutionException, InterruptedException { + + try (FirewallsClient firewallsClient = FirewallsClient.create()) { + + Firewall firewall = Firewall.newBuilder() + .setName(firewallRuleName) + .addAllowed(Allowed.newBuilder() + .setIPProtocol("tcp") + .addPorts("1688") + .build()) + .setDirection("EGRESS") + .setNetwork(networkName) + .addDestinationRanges("35.190.247.13/32") + .setPriority(0) + .build(); + + InsertFirewallRequest request = InsertFirewallRequest.newBuilder() + .setProject(projectId) + .setFirewallResource(firewall) + .build(); + + Operation operation = firewallsClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.println("Firewall rule creation failed ! ! " + operation.getError()); + return; + } + + System.out.printf("Firewall rule created %s", firewallRuleName); + } + } +} +// [END compute_create_egress_rule_windows_activation] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java new file mode 100644 index 00000000000..259030a0b4e --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_create_route_windows_activation] + +import com.google.cloud.compute.v1.InsertRouteRequest; +import com.google.cloud.compute.v1.Operation; +import com.google.cloud.compute.v1.Route; +import com.google.cloud.compute.v1.RoutesClient; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateRouteToWindowsActivationHost { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // routeName - Name of the route you want to create. + String routeName = "route-name"; + + // networkName - Name of the network you want the new instance to use. + // * For example: "global/networks/default" represents the network + // * named "default", which is created automatically for each project. + String networkName = "global/networks/default"; + + createRouteToWindowsActivationHost(projectId, routeName, networkName); + } + + // Creates a new route to kms.windows.googlecloud.com (35.190.247.13) for Windows activation. + public static void createRouteToWindowsActivationHost(String projectId, String routeName, + String networkName) + throws IOException, ExecutionException, InterruptedException { + + try (RoutesClient routesClient = RoutesClient.create()) { + + // If you have Windows instances without external IP addresses, + // you must also enable Private Google Access so that instances + // with only internal IP addresses can send traffic to the external + // IP address for kms.windows.googlecloud.com. + // More infromation: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling + Route route = Route.newBuilder() + .setName(routeName) + .setDestRange("35.190.247.13/32") + .setNetwork(networkName) + .setNextHopGateway( + String.format("project/%s/global/gateways/default-internet-gateway", projectId)) + .build(); + + InsertRouteRequest request = InsertRouteRequest.newBuilder() + .setProject(projectId) + .setRouteResource(route) + .build(); + + Operation operation = routesClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.printf("Error in creating route %s", operation.getError()); + return; + } + + System.out.printf("Route created %s", routeName); + } + } +} +// [END compute_create_route_windows_activation] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java new file mode 100644 index 00000000000..f9742ccd050 --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java @@ -0,0 +1,116 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_create_windows_instance_external_ip] + +import com.google.cloud.compute.v1.AccessConfig; +import com.google.cloud.compute.v1.AttachedDisk; +import com.google.cloud.compute.v1.AttachedDiskInitializeParams; +import com.google.cloud.compute.v1.InsertInstanceRequest; +import com.google.cloud.compute.v1.Instance; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.NetworkInterface; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateWindowsServerInstanceExternalIp { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // zone - Name of the zone you want to use, for example: us-west3-b + String zone = "europe-central2-b"; + + // instanceName - Name of the new machine. + String instanceName = "instance-name"; + + createWindowsServerInstanceExternalIp(projectId, zone, instanceName); + } + + // Creates a new Windows Server instance that has an external IP address. + public static void createWindowsServerInstanceExternalIp(String projectId, String zone, + String instanceName) + throws IOException, ExecutionException, InterruptedException { + + // machineType - Machine type you want to create in following format: + // * "zones/{zone}/machineTypes/{type_name}". For example: + // * "zones/europe-west3-c/machineTypes/f1-micro" + // * You can find the list of available machine types using: + // * https://cloud.google.com/sdk/gcloud/reference/compute/machine-types/list + String machineType = "n1-standard-1"; + // sourceImageFamily - Name of the public image family for Windows Server or SQL Server images. + // * https://cloud.google.com/compute/docs/images#os-compute-support + String sourceImageFamily = "windows-2012-r2"; + + try (InstancesClient instancesClient = InstancesClient.create()) { + + AttachedDisk attachedDisk = AttachedDisk.newBuilder() + // Describe the size and source image of the boot disk to attach to the instance. + .setInitializeParams(AttachedDiskInitializeParams.newBuilder() + .setDiskSizeGb(64) + .setSourceImage( + String.format("projects/windows-cloud/global/images/family/%s", + sourceImageFamily)) + .build()) + .setAutoDelete(true) + .setBoot(true) + .setType(AttachedDisk.Type.PERSISTENT.toString()) + .build(); + + Instance instance = Instance.newBuilder() + .setName(instanceName) + .setMachineType(String.format("zones/%s/machineTypes/%s", zone, machineType)) + .addDisks(attachedDisk) + .addNetworkInterfaces(NetworkInterface.newBuilder() + .addAccessConfigs(AccessConfig.newBuilder() + .setType("ONE_TO_ONE_NAT") + .setName("External NAT") + .build()) + // If you going you use custom VPC network, it must be configured + // to allow access to kms.windows.googlecloud.com. + // https://cloud.google.com/compute/docs/instances/windows/creating-managing-windows-instances#kms-server. + .setName("global/networks/default") + .build()) + // If you chose an image that supports Shielded VM, you can optionally change the + // instance's Shielded VM settings. + // .setShieldedInstanceConfig(ShieldedInstanceConfig.newBuilder() + // .setEnableSecureBoot(true) + // .setEnableVtpm(true) + // .setEnableIntegrityMonitoring(true) + // .build()) + .build(); + + InsertInstanceRequest request = InsertInstanceRequest.newBuilder() + .setProject(projectId) + .setZone(zone) + .setInstanceResource(instance) + .build(); + + Operation operation = instancesClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.printf("Error in creating instance %s", operation.getError()); + return; + } + + System.out.printf("Instance created %s", instanceName); + } + } +} +// [END compute_create_windows_instance_external_ip] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java new file mode 100644 index 00000000000..0142322eec1 --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java @@ -0,0 +1,127 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_create_windows_instance_internal_ip] + +import com.google.cloud.compute.v1.AttachedDisk; +import com.google.cloud.compute.v1.AttachedDiskInitializeParams; +import com.google.cloud.compute.v1.InsertInstanceRequest; +import com.google.cloud.compute.v1.Instance; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.NetworkInterface; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateWindowsServerInstanceInternalIp { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // zone - Name of the zone you want to use, for example: us-west3-b + String zone = "europe-central2-b"; + + // instanceName - Name of the new machine. + String instanceName = "instance-name"; + + // networkLink - Name of the network you want the new instance to use. + // * For example: "global/networks/default" represents the network + // * named "default", which is created automatically for each project. + String networkLink = "global/networks/default"; + + // subnetworkLink - Name of the subnetwork you want the new instance to use. + // * This value uses the following format: + // * "regions/{region}/subnetworks/{subnetwork_name}" + String subnetworkLink = "regions/europe-central2/subnetworks/default"; + + createWindowsServerInstanceInternalIp(projectId, zone, instanceName, networkLink, + subnetworkLink); + } + + // Creates a new Windows Server instance that has only an internal IP address. + public static void createWindowsServerInstanceInternalIp(String projectId, String zone, + String instanceName, String networkLink, String subnetworkLink) + throws IOException, ExecutionException, InterruptedException { + + // machineType - Machine type you want to create in following format: + // * "zones/{zone}/machineTypes/{type_name}". For example: + // * "zones/europe-west3-c/machineTypes/f1-micro" + // * You can find the list of available machine types using: + // * https://cloud.google.com/sdk/gcloud/reference/compute/machine-types/list + String machineType = "n1-standard-1"; + // sourceImageFamily - Name of the public image family for Windows Server or SQL Server images. + // * https://cloud.google.com/compute/docs/images#os-compute-support + String sourceImageFamily = "windows-2012-r2"; + + try (InstancesClient instancesClient = InstancesClient.create()) { + + AttachedDisk attachedDisk = AttachedDisk.newBuilder() + // Describe the size and source image of the boot disk to attach to the instance. + .setInitializeParams(AttachedDiskInitializeParams.newBuilder() + .setDiskSizeGb(64) + .setSourceImage( + String.format("projects/windows-cloud/global/images/family/%s", + sourceImageFamily)) + .build()) + .setAutoDelete(true) + .setBoot(true) + .setType(AttachedDisk.Type.PERSISTENT.toString()) + .build(); + + Instance instance = Instance.newBuilder() + .setName(instanceName) + .setMachineType(String.format("zones/%s/machineTypes/%s", zone, machineType)) + .addDisks(attachedDisk) + .addNetworkInterfaces(NetworkInterface.newBuilder() + // You must verify or configure routes and firewall rules in your VPC network + // to allow access to kms.windows.googlecloud.com. + // More information about access to kms.windows.googlecloud.com: https://cloud.google.com/compute/docs/instances/windows/creating-managing-windows-instances#kms-server + + // Additionally, you must enable Private Google Access for subnets in your VPC network + // that contain Windows instances with only internal IP addresses. + // More information about Private Google Access: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling + .setName(networkLink) + .setSubnetwork(subnetworkLink) + .build()) + // If you chose an image that supports Shielded VM, you can optionally change the + // instance's Shielded VM settings. + // .setShieldedInstanceConfig(ShieldedInstanceConfig.newBuilder() + // .setEnableSecureBoot(true) + // .setEnableVtpm(true) + // .setEnableIntegrityMonitoring(true) + // .build()) + .build(); + + InsertInstanceRequest request = InsertInstanceRequest.newBuilder() + .setProject(projectId) + .setZone(zone) + .setInstanceResource(instance) + .build(); + + Operation operation = instancesClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.printf("Error in creating instance %s", operation.getError()); + return; + } + + System.out.printf("Instance created %s", instanceName); + } + } +} +// [END compute_create_windows_instance_internal_ip] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java new file mode 100644 index 00000000000..d60076f4282 --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java @@ -0,0 +1,51 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_get_instance_serial_port] + +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.SerialPortOutput; +import java.io.IOException; + +public class GetInstanceSerialPort { + + public static void main(String[] args) throws IOException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // zone - Name of the zone you want to check, for example: us-west3-b + String zone = "europe-central2-b"; + + // instanceName - Name of the instance you want to check. + String instanceName = "instance-name"; + + getInstanceSerialPort(projectId, zone, instanceName); + } + + // Prints an instance serial port output. + public static void getInstanceSerialPort(String projectId, String zone, String instanceName) + throws IOException { + + try (InstancesClient instancesClient = InstancesClient.create()) { + + SerialPortOutput serialPortOutput = instancesClient.getSerialPortOutput(projectId, zone, + instanceName); + + System.out.printf("Output from instance serial port %s", serialPortOutput.getContents()); + } + } +} +// [END compute_get_instance_serial_port] \ No newline at end of file diff --git a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java new file mode 100644 index 00000000000..090780f29d9 --- /dev/null +++ b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java @@ -0,0 +1,132 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.cloud.compute.v1.RoutesClient; +import compute.DeleteFirewallRule; +import compute.DeleteInstance; +import compute.Util; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class CreatingManagingWindowsInstancesIT { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String ZONE = "europe-central2-b"; + private static String INSTANCE_NAME_EXTERNAL; + private static String INSTANCE_NAME_INTERNAL; + private static String FIREWALL_RULE_NAME; + private static String NETWORK_NAME; + private static String SUBNETWORK_NAME; + private static String ROUTE_NAME; + + private ByteArrayOutputStream stdOut; + + // Check if the required environment variables are set. + public static void requireEnvVar(String envVarName) { + assertWithMessage(String.format("Missing environment variable '%s' ", envVarName)) + .that(System.getenv(envVarName)).isNotEmpty(); + } + + @BeforeClass + public static void setup() throws IOException, ExecutionException, InterruptedException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + + // Cleanup existing test instances. + Util.cleanUpExistingInstances("windows-test-instance", PROJECT_ID, ZONE); + + String uuid = UUID.randomUUID().toString().split("-")[0]; + INSTANCE_NAME_EXTERNAL = "windows-test-instance-external-" + uuid; + INSTANCE_NAME_INTERNAL = "windows-test-instance-internal-" + uuid; + FIREWALL_RULE_NAME = "windows-test-firewall-" + uuid; + NETWORK_NAME = "global/networks/default-compute"; + SUBNETWORK_NAME = "regions/europe-central2/subnetworks/default-compute"; + ROUTE_NAME = "windows-test-route-" + uuid; + + stdOut.close(); + System.setOut(out); + } + + public static void deleteRoute() throws IOException, ExecutionException, InterruptedException { + try (RoutesClient routesClient = RoutesClient.create()) { + routesClient.deleteAsync(PROJECT_ID, ROUTE_NAME).get(); + } + } + + @Before + public void beforeEach() { + stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + } + + @After + public void afterEach() { + stdOut = null; + System.setOut(null); + } + + @Test + public void testCreateWindowsServerInstanceExternalIp() + throws IOException, ExecutionException, InterruptedException { + // Create Windows server instance with external IP. + CreateWindowsServerInstanceExternalIp.createWindowsServerInstanceExternalIp(PROJECT_ID, ZONE, + INSTANCE_NAME_EXTERNAL); + assertThat(stdOut.toString()).contains("Instance created " + INSTANCE_NAME_EXTERNAL); + + // Delete instance. + DeleteInstance.deleteInstance(PROJECT_ID, ZONE, INSTANCE_NAME_EXTERNAL); + } + + @Test + public void testCreateWindowsServerInstanceInternalIp() + throws IOException, ExecutionException, InterruptedException { + // Create Windows server instance with internal IP and firewall rule. + CreateWindowsServerInstanceInternalIp.createWindowsServerInstanceInternalIp(PROJECT_ID, ZONE, + INSTANCE_NAME_INTERNAL, NETWORK_NAME, SUBNETWORK_NAME); + assertThat(stdOut.toString()).contains("Instance created " + INSTANCE_NAME_INTERNAL); + CreateFirewallRuleForWindowsActivationHost.createFirewallRuleForWindowsActivationHost( + PROJECT_ID, ZONE, NETWORK_NAME); + assertThat(stdOut.toString()).contains( + String.format("Firewall rule created %s", FIREWALL_RULE_NAME)); + CreateRouteToWindowsActivationHost.createRouteToWindowsActivationHost(PROJECT_ID, ROUTE_NAME, + NETWORK_NAME); + assertThat(stdOut.toString()).contains(String.format("Route created %s", ROUTE_NAME)); + + // Delete Route. + deleteRoute(); + // Delete Firewall. + DeleteFirewallRule.deleteFirewallRule(PROJECT_ID, FIREWALL_RULE_NAME); + // Delete Instance. + DeleteInstance.deleteInstance(PROJECT_ID, ZONE, INSTANCE_NAME_INTERNAL); + } +} From 2b2833020e99c2e4529fc950ec4ecdde80131b0c Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Mon, 11 Apr 2022 14:53:53 +0530 Subject: [PATCH 002/136] lint fix --- .../windowsinstances/CreateRouteToWindowsActivationHost.java | 1 + .../windowsinstances/CreateWindowsServerInstanceExternalIp.java | 1 + .../windowsinstances/CreateWindowsServerInstanceInternalIp.java | 1 + .../compute/windows/windowsinstances/GetInstanceSerialPort.java | 1 + 4 files changed, 4 insertions(+) diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java index 259030a0b4e..1d58512626e 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_create_route_windows_activation] import com.google.cloud.compute.v1.InsertRouteRequest; diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java index f9742ccd050..3ba17fa5d87 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_create_windows_instance_external_ip] import com.google.cloud.compute.v1.AccessConfig; diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java index 0142322eec1..eca8eefec29 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_create_windows_instance_internal_ip] import com.google.cloud.compute.v1.AttachedDisk; diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java index d60076f4282..689dabfd207 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_get_instance_serial_port] import com.google.cloud.compute.v1.InstancesClient; From 73c0fd85daac10d17ebee25242c1a0dc8500a2bd Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 12 Apr 2022 17:19:37 +0200 Subject: [PATCH 003/136] fix(deps): update dependency com.google.apis:google-api-services-cloudiot to v1-rev20220330-1.32.1 (#6997) --- iot/api-client/codelab/manager/pom.xml | 2 +- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iot/api-client/codelab/manager/pom.xml b/iot/api-client/codelab/manager/pom.xml index 0f940802a5b..426b2c7a010 100644 --- a/iot/api-client/codelab/manager/pom.xml +++ b/iot/api-client/codelab/manager/pom.xml @@ -67,7 +67,7 @@ com.google.apis google-api-services-cloudiot - v1-rev20211108-1.32.1 + v1-rev20220330-1.32.1 com.google.cloud diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index 12dfc42258e..3099829e679 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -58,7 +58,7 @@ com.google.apis google-api-services-cloudiot - v1-rev20211108-1.32.1 + v1-rev20220330-1.32.1 com.google.cloud diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index 149273c119a..96616ce7950 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -62,7 +62,7 @@ com.google.apis google-api-services-cloudiot - v1-rev20211108-1.32.1 + v1-rev20220330-1.32.1 com.google.cloud From e4ed57e91b863599bab9da36e65974441bd65ee3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 12 Apr 2022 17:44:12 +0200 Subject: [PATCH 004/136] fix(deps): update dependency com.google.cloud:spring-cloud-gcp-dependencies to v3.2.1 (#7005) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:spring-cloud-gcp-dependencies](https://projects.spring.io/spring-cloud/) ([source](https://togithub.com/spring-cloud/spring-cloud-build)) | `3.2.0` -> `3.2.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:spring-cloud-gcp-dependencies/3.2.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:spring-cloud-gcp-dependencies/3.2.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:spring-cloud-gcp-dependencies/3.2.1/compatibility-slim/3.2.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:spring-cloud-gcp-dependencies/3.2.1/confidence-slim/3.2.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- pubsub/spring/pom.xml | 2 +- run/idp-sql/pom.xml | 2 +- run/image-processing/pom.xml | 2 +- spanner/spring-data/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pubsub/spring/pom.xml b/pubsub/spring/pom.xml index 96b0160778b..4f647e074ea 100644 --- a/pubsub/spring/pom.xml +++ b/pubsub/spring/pom.xml @@ -55,7 +55,7 @@ com.google.cloud spring-cloud-gcp-dependencies - 3.2.0 + 3.2.1 pom import diff --git a/run/idp-sql/pom.xml b/run/idp-sql/pom.xml index aff1644e257..37d51a1ec13 100644 --- a/run/idp-sql/pom.xml +++ b/run/idp-sql/pom.xml @@ -45,7 +45,7 @@ limitations under the License. com.google.cloud spring-cloud-gcp-dependencies - 3.2.0 + 3.2.1 pom import diff --git a/run/image-processing/pom.xml b/run/image-processing/pom.xml index c7ee97c2643..75676505988 100644 --- a/run/image-processing/pom.xml +++ b/run/image-processing/pom.xml @@ -44,7 +44,7 @@ limitations under the License. com.google.cloud spring-cloud-gcp-dependencies - 3.2.0 + 3.2.1 pom import diff --git a/spanner/spring-data/pom.xml b/spanner/spring-data/pom.xml index e9692462a47..8f7c71ed594 100644 --- a/spanner/spring-data/pom.xml +++ b/spanner/spring-data/pom.xml @@ -41,7 +41,7 @@ limitations under the License. com.google.cloud spring-cloud-gcp-dependencies - 3.2.0 + 3.2.1 pom import From d0deb04da45c4cd068fb7e4c38bb5408728271a6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 12 Apr 2022 17:55:31 +0200 Subject: [PATCH 005/136] chore(deps): update dependency com.google.cloud:spring-cloud-gcp-pubsub-stream-binder to v3.2.1 (#7003) --- pubsub/spring/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubsub/spring/build.gradle b/pubsub/spring/build.gradle index f69c9f7aae3..09f321a2002 100644 --- a/pubsub/spring/build.gradle +++ b/pubsub/spring/build.gradle @@ -38,7 +38,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web:2.5.7' implementation 'com.google.cloud:spring-cloud-gcp-starter-pubsub:3.2.0' implementation 'org.springframework.integration:spring-integration-core:5.5.10' - implementation 'com.google.cloud:spring-cloud-gcp-pubsub-stream-binder:3.2.0' + implementation 'com.google.cloud:spring-cloud-gcp-pubsub-stream-binder:3.2.1' testImplementation 'junit:junit:4.13.2' testImplementation 'com.google.truth:truth:1.1.3' testImplementation 'org.springframework.boot:spring-boot-test:2.5.7' From 3f76dc85755a9655def5412b00b3d2206d1c7a6c Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 12 Apr 2022 19:58:06 +0200 Subject: [PATCH 006/136] fix(deps): update dependency com.google.http-client:google-http-client-jackson2 to v1.41.7 (#7007) --- storage/xml-api/cmdline-sample/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xml-api/cmdline-sample/pom.xml b/storage/xml-api/cmdline-sample/pom.xml index a152461599a..ea9ce0b895b 100644 --- a/storage/xml-api/cmdline-sample/pom.xml +++ b/storage/xml-api/cmdline-sample/pom.xml @@ -30,7 +30,7 @@ - 1.41.6 + 1.41.7 UTF-8 1.6.0 1.8 From fd475b0175f53494b63465d29ba9355fc805e9dc Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 13 Apr 2022 16:37:06 +0200 Subject: [PATCH 007/136] chore(deps): update dependency com.google.cloud:spring-cloud-gcp-starter-pubsub to v3.2.1 (#7004) --- pubsub/spring/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubsub/spring/build.gradle b/pubsub/spring/build.gradle index 09f321a2002..0d14e609040 100644 --- a/pubsub/spring/build.gradle +++ b/pubsub/spring/build.gradle @@ -36,7 +36,7 @@ java.sourceCompatibility = JavaVersion.VERSION_1_8 dependencies { implementation 'com.github.spotbugs:spotbugs-annotations:4.6.0' implementation 'org.springframework.boot:spring-boot-starter-web:2.5.7' - implementation 'com.google.cloud:spring-cloud-gcp-starter-pubsub:3.2.0' + implementation 'com.google.cloud:spring-cloud-gcp-starter-pubsub:3.2.1' implementation 'org.springframework.integration:spring-integration-core:5.5.10' implementation 'com.google.cloud:spring-cloud-gcp-pubsub-stream-binder:3.2.1' testImplementation 'junit:junit:4.13.2' From dc960c65772437601cfd1a66808f808da37aaeb1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 13 Apr 2022 16:37:50 +0200 Subject: [PATCH 008/136] fix(deps): update dependency redis.clients:jedis to v4.2.2 (#7008) --- memorystore/redis/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memorystore/redis/pom.xml b/memorystore/redis/pom.xml index 3a043ceac69..522bf78dd04 100644 --- a/memorystore/redis/pom.xml +++ b/memorystore/redis/pom.xml @@ -49,7 +49,7 @@ redis.clients jedis - 4.2.1 + 4.2.2 From 52d2de19aa28e85d01cd2a9251e956679f99dc6a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 18:13:36 +0200 Subject: [PATCH 009/136] fix(deps): update dependency net.logstash.logback:logstash-logback-encoder to v7.1 (#7009) --- run/idp-sql/pom.xml | 2 +- run/logging-manual/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/run/idp-sql/pom.xml b/run/idp-sql/pom.xml index 37d51a1ec13..e597df4fa43 100644 --- a/run/idp-sql/pom.xml +++ b/run/idp-sql/pom.xml @@ -80,7 +80,7 @@ limitations under the License. net.logstash.logback logstash-logback-encoder - 7.0.1 + 7.1 ch.qos.logback.contrib diff --git a/run/logging-manual/pom.xml b/run/logging-manual/pom.xml index 7a492e3b549..3697a8d8365 100644 --- a/run/logging-manual/pom.xml +++ b/run/logging-manual/pom.xml @@ -44,7 +44,7 @@ limitations under the License. net.logstash.logback logstash-logback-encoder - 7.0.1 + 7.1 ch.qos.logback From 7cfe472e84377c84d45c920a006ebd892652f872 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Thu, 14 Apr 2022 09:15:51 -0700 Subject: [PATCH 010/136] chore(functions/hello-error): update product name (#7011) --- .../hello-error/src/main/java/functions/HelloError.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/helloworld/hello-error/src/main/java/functions/HelloError.java b/functions/helloworld/hello-error/src/main/java/functions/HelloError.java index 9325791f24d..f12c3ce9631 100644 --- a/functions/helloworld/hello-error/src/main/java/functions/HelloError.java +++ b/functions/helloworld/hello-error/src/main/java/functions/HelloError.java @@ -31,11 +31,11 @@ public class HelloError implements HttpFunction { @Override public void service(HttpRequest request, HttpResponse response) throws IOException { - // These will NOT be reported to Stackdriver error reporting + // These will NOT be reported to Error Reporting System.err.println("I failed you"); logger.severe("I failed you"); - // This WILL be reported to Stackdriver error reporting + // This WILL be reported to Error Reporting throw new RuntimeException("I failed you"); } } From 10bc32f34bd82d17cd515afe473e34661179f88b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 18:40:11 +0200 Subject: [PATCH 011/136] chore(deps): update micronaut packages to v3.4.2 (#7012) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [io.micronaut:micronaut-validation](http://micronaut.io) ([source](https://togithub.com/micronaut-projects/micronaut-core)) | `3.4.1` -> `3.4.2` | [![age](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-validation/3.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-validation/3.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-validation/3.4.2/compatibility-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-validation/3.4.2/confidence-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | | [io.micronaut:micronaut-inject-java](http://micronaut.io) ([source](https://togithub.com/micronaut-projects/micronaut-core)) | `3.4.1` -> `3.4.2` | [![age](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject-java/3.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject-java/3.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject-java/3.4.2/compatibility-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject-java/3.4.2/confidence-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | | [io.micronaut:micronaut-http-server-netty](http://micronaut.io) ([source](https://togithub.com/micronaut-projects/micronaut-core)) | `3.4.1` -> `3.4.2` | [![age](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-server-netty/3.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-server-netty/3.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-server-netty/3.4.2/compatibility-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-server-netty/3.4.2/confidence-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | | [io.micronaut:micronaut-http-client](http://micronaut.io) ([source](https://togithub.com/micronaut-projects/micronaut-core)) | `3.4.1` -> `3.4.2` | [![age](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-client/3.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-client/3.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-client/3.4.2/compatibility-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-http-client/3.4.2/confidence-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | | [io.micronaut:micronaut-runtime](http://micronaut.io) ([source](https://togithub.com/micronaut-projects/micronaut-core)) | `3.4.1` -> `3.4.2` | [![age](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-runtime/3.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-runtime/3.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-runtime/3.4.2/compatibility-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-runtime/3.4.2/confidence-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | | [io.micronaut:micronaut-inject](http://micronaut.io) ([source](https://togithub.com/micronaut-projects/micronaut-core)) | `3.4.1` -> `3.4.2` | [![age](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject/3.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject/3.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject/3.4.2/compatibility-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.micronaut:micronaut-inject/3.4.2/confidence-slim/3.4.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
micronaut-projects/micronaut-core ### [`v3.4.2`](https://togithub.com/micronaut-projects/micronaut-core/releases/v3.4.2) [Compare Source](https://togithub.com/micronaut-projects/micronaut-core/compare/v3.4.1...v3.4.2) ##### Bug Fixes - fix: handle [@​ConfigurationProperties](https://togithub.com/ConfigurationProperties) nested in [@​EachProperty](https://togithub.com/EachProperty) properly [@​Paullo612](https://togithub.com/Paullo612) ([#​7211](https://togithub.com/micronaut-projects/micronaut-core/issues/7211)) - Requires bean property with default interface method fix [@​GavrilovSV](https://togithub.com/GavrilovSV) ([#​7200](https://togithub.com/micronaut-projects/micronaut-core/issues/7200)) - Properly proceed in filter processing when request is replaced [@​yawkat](https://togithub.com/yawkat) ([#​7174](https://togithub.com/micronaut-projects/micronaut-core/issues/7174)) - Don't use custom BeanPropertyWriter for xml module [@​yawkat](https://togithub.com/yawkat) ([#​7170](https://togithub.com/micronaut-projects/micronaut-core/issues/7170)) - Fix BeanProvider's find method [@​Paullo612](https://togithub.com/Paullo612) ([#​7133](https://togithub.com/micronaut-projects/micronaut-core/issues/7133)) - Support absolute-form URI in HTTP requests [@​yawkat](https://togithub.com/yawkat) ([#​7201](https://togithub.com/micronaut-projects/micronaut-core/issues/7201)) ##### Dependency Upgrades - upgrade to Netty 4.1.76.Final [@​graemerocher](https://togithub.com/graemerocher) ([#​7213](https://togithub.com/micronaut-projects/micronaut-core/issues/7213)) - build: bump up AWS to 3.2.3 [@​sdelamo](https://togithub.com/sdelamo) ([#​7212](https://togithub.com/micronaut-projects/micronaut-core/issues/7212)) - Bump micronaut-email to 1.2.1 [@​micronaut-build](https://togithub.com/micronaut-build) ([#​7184](https://togithub.com/micronaut-projects/micronaut-core/issues/7184)) - build: bump micronaut-aot to 1.0.3 [@​micronaut-build](https://togithub.com/micronaut-build) ([#​7181](https://togithub.com/micronaut-projects/micronaut-core/issues/7181)) - Bump micronaut-maven-plugin to 3.2.3 [@​micronaut-build](https://togithub.com/micronaut-build) ([#​7185](https://togithub.com/micronaut-projects/micronaut-core/issues/7185)) - Bump micronaut-micrometer to 4.2.1 [@​micronaut-build](https://togithub.com/micronaut-build) ([#​7203](https://togithub.com/micronaut-projects/micronaut-core/issues/7203)) ##### Docs - Fix links [@​alvarosanchez](https://togithub.com/alvarosanchez) ([#​7194](https://togithub.com/micronaut-projects/micronaut-core/issues/7194)) - update Gradle native image command and directory [@​burtbeckwith](https://togithub.com/burtbeckwith) ([#​7187](https://togithub.com/micronaut-projects/micronaut-core/issues/7187)) - javadoc: Adds missing javadoc [@​sdelamo](https://togithub.com/sdelamo) ([#​7216](https://togithub.com/micronaut-projects/micronaut-core/issues/7216)) ##### CI - ci: setup-java to [@​v3](https://togithub.com/v3) [@​micronaut-build](https://togithub.com/micronaut-build) ([#​7209](https://togithub.com/micronaut-projects/micronaut-core/issues/7209)) - \[core] Update common files for branch 3.4.x [@​micronaut-build](https://togithub.com/micronaut-build) ([#​7168](https://togithub.com/micronaut-projects/micronaut-core/issues/7168)) ##### TEST - test: how qualifiers and scopes resolved in factories [@​sdelamo](https://togithub.com/sdelamo) ([#​7208](https://togithub.com/micronaut-projects/micronaut-core/issues/7208)) ##### Contributors [@​GavrilovSV](https://togithub.com/GavrilovSV), [@​Paullo612](https://togithub.com/Paullo612), [@​alvarosanchez](https://togithub.com/alvarosanchez), [@​burtbeckwith](https://togithub.com/burtbeckwith), [@​graemerocher](https://togithub.com/graemerocher), [@​micronaut-build](https://togithub.com/micronaut-build), [@​sdelamo](https://togithub.com/sdelamo) and [@​yawkat](https://togithub.com/yawkat)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java11/micronaut-helloworld/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/micronaut-helloworld/pom.xml b/appengine-java11/micronaut-helloworld/pom.xml index 700a87ae77f..22f7a0435d2 100644 --- a/appengine-java11/micronaut-helloworld/pom.xml +++ b/appengine-java11/micronaut-helloworld/pom.xml @@ -33,7 +33,7 @@ com.example.appengine.Application 11 11 - 3.4.1 + 3.4.2
From 68b30c53a80458c4bac193abe661d2fd12ac0696 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 18:40:15 +0200 Subject: [PATCH 012/136] fix(deps): update dependency com.google.oauth-client:google-oauth-client-servlet to v1.33.3 (#7014) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.oauth-client:google-oauth-client-servlet](https://togithub.com/googleapis/google-oauth-java-client) | `1.33.2` -> `1.33.3` | [![age](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client-servlet/1.33.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client-servlet/1.33.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client-servlet/1.33.3/compatibility-slim/1.33.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client-servlet/1.33.3/confidence-slim/1.33.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-oauth-java-client ### [`v1.33.3`](https://togithub.com/googleapis/google-oauth-java-client/blob/HEAD/CHANGELOG.md#​1333-httpsgithubcomgoogleapisgoogle-oauth-java-clientcomparev1332v1333-2022-04-13) [Compare Source](https://togithub.com/googleapis/google-oauth-java-client/compare/v1.33.2...v1.33.3)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java11/oauth2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/oauth2/pom.xml b/appengine-java11/oauth2/pom.xml index fd4179456d3..72a50c34a18 100644 --- a/appengine-java11/oauth2/pom.xml +++ b/appengine-java11/oauth2/pom.xml @@ -64,7 +64,7 @@ com.google.oauth-client google-oauth-client-servlet - 1.33.2 + 1.33.3 provided From 4e13a71d58d620427fdb3ab9db3b5e35037df09a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 18:42:11 +0200 Subject: [PATCH 013/136] fix(deps): update dependency com.google.oauth-client:google-oauth-client to v1.33.3 (#7013) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.oauth-client:google-oauth-client](https://togithub.com/googleapis/google-oauth-java-client) | `1.33.2` -> `1.33.3` | [![age](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client/1.33.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client/1.33.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client/1.33.3/compatibility-slim/1.33.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.oauth-client:google-oauth-client/1.33.3/confidence-slim/1.33.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-oauth-java-client ### [`v1.33.3`](https://togithub.com/googleapis/google-oauth-java-client/blob/HEAD/CHANGELOG.md#​1333-httpsgithubcomgoogleapisgoogle-oauth-java-clientcomparev1332v1333-2022-04-13) [Compare Source](https://togithub.com/googleapis/google-oauth-java-client/compare/v1.33.2...v1.33.3)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java11/oauth2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/oauth2/pom.xml b/appengine-java11/oauth2/pom.xml index 72a50c34a18..07632b1e102 100644 --- a/appengine-java11/oauth2/pom.xml +++ b/appengine-java11/oauth2/pom.xml @@ -57,7 +57,7 @@ com.google.oauth-client google-oauth-client - 1.33.2 + 1.33.3 provided From 5e426679bd443839d7c00ca29ccf1ee309bbae10 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 18:42:16 +0200 Subject: [PATCH 014/136] fix(deps): update dependency com.google.api-client:google-api-client-gson to v1.34.0 (#7020) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api-client:google-api-client-gson](https://togithub.com/googleapis/google-api-java-client) | `1.33.4` -> `1.34.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.0/compatibility-slim/1.33.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.0/confidence-slim/1.33.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-api-java-client ### [`v1.34.0`](https://togithub.com/googleapis/google-api-java-client/blob/HEAD/CHANGELOG.md#​1340-httpsgithubcomgoogleapisgoogle-api-java-clientcomparev1334v1340-2022-04-12) [Compare Source](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.4...v1.34.0) ##### Features - deprecate OOB auth flow in GooglePromptReceiver ([#​2034](https://togithub.com/googleapis/google-api-java-client/issues/2034)) ([334d8d6](https://togithub.com/googleapis/google-api-java-client/commit/334d8d68a455e41be137ed27dab50df7915b3992)) ##### Bug Fixes - **deps:** update dependency com.google.api-client:google-api-client to v1.33.4 ([#​2022](https://togithub.com/googleapis/google-api-java-client/issues/2022)) ([582bde1](https://togithub.com/googleapis/google-api-java-client/commit/582bde1f48c892b5856d0c51d8e051be6d20321e)) - **deps:** update dependency com.google.cloud:libraries-bom to v25.1.0 ([#​2025](https://togithub.com/googleapis/google-api-java-client/issues/2025)) ([ba36a44](https://togithub.com/googleapis/google-api-java-client/commit/ba36a44e27f97edc5a6aa6921b43b753f51af569)) - **deps:** update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.2 ([#​2033](https://togithub.com/googleapis/google-api-java-client/issues/2033)) ([fed93e3](https://togithub.com/googleapis/google-api-java-client/commit/fed93e3a3db2396d7a4bf4c565864ce1e39dc3ba)) ##### Dependencies - revert protobuf to 3.19 ([#​2035](https://togithub.com/googleapis/google-api-java-client/issues/2035)) ([00eabeb](https://togithub.com/googleapis/google-api-java-client/commit/00eabeb293fc6978a7667fbdc695b81add7d700a)) ##### [1.33.4](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.3...v1.33.4) (2022-03-28) ##### Dependencies - update dependency org.sonatype.plugins:nexus-staging-maven-plugin to v1.6.12 ([#​2019](https://togithub.com/googleapis/google-api-java-client/issues/2019)) ([f1e0909](https://togithub.com/googleapis/google-api-java-client/commit/f1e09099f2954df68e8d476f142db7c4b7388917)) ##### [1.33.3](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.2...v1.33.3) (2022-03-25) ##### Bug Fixes - **deps:** update dependency com.google.api-client:google-api-client to v1.33.2 ([#​1985](https://togithub.com/googleapis/google-api-java-client/issues/1985)) ([191850a](https://togithub.com/googleapis/google-api-java-client/commit/191850a33a562300325ee7809e68fca89feeb5f3)) - **deps:** update dependency com.google.appengine:appengine-api-1.0-sdk to v2.0.4 ([#​2010](https://togithub.com/googleapis/google-api-java-client/issues/2010)) ([b4c64a0](https://togithub.com/googleapis/google-api-java-client/commit/b4c64a0365ed8656bd116763318e975c036551b7)) - **deps:** update dependency com.google.cloud:libraries-bom to v24.3.0 ([#​1987](https://togithub.com/googleapis/google-api-java-client/issues/1987)) ([1620e8f](https://togithub.com/googleapis/google-api-java-client/commit/1620e8f6fe69d1af46afb9838ab16594c6c486b5)) - **deps:** update dependency com.google.cloud:libraries-bom to v24.4.0 ([#​2007](https://togithub.com/googleapis/google-api-java-client/issues/2007)) ([cba8dd2](https://togithub.com/googleapis/google-api-java-client/commit/cba8dd246c455c0f857d31f94f465b0d92b01829)) - **deps:** update dependency com.google.cloud:libraries-bom to v25 ([#​2014](https://togithub.com/googleapis/google-api-java-client/issues/2014)) ([43bd4a1](https://togithub.com/googleapis/google-api-java-client/commit/43bd4a13aa4d74e99b138491674e690ea4db8eb0)) - **deps:** update dependency com.google.guava:guava to v31.1-jre ([#​2004](https://togithub.com/googleapis/google-api-java-client/issues/2004)) ([eac0e77](https://togithub.com/googleapis/google-api-java-client/commit/eac0e77e8ac9ab1b784ff7c7c4c7f2f8c3095797)) - **deps:** update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.1 ([#​1986](https://togithub.com/googleapis/google-api-java-client/issues/1986)) ([b8376f1](https://togithub.com/googleapis/google-api-java-client/commit/b8376f15284adab2684e3622af4f3d960bb32387)) ##### [1.33.2](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.1...v1.33.2) (2022-02-08) ##### Dependencies - **java:** update actions/github-script action to v5 ([#​1339](https://togithub.com/googleapis/google-api-java-client/issues/1339)) ([#​1972](https://togithub.com/googleapis/google-api-java-client/issues/1972)) ([b1d8c16](https://togithub.com/googleapis/google-api-java-client/commit/b1d8c167ea05735a08149681c61e30eb5b160368)) ##### [1.33.1](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.0...v1.33.1) (2022-01-21) ##### Bug Fixes - library should released as 1.33.1 ([#​1966](https://togithub.com/googleapis/google-api-java-client/issues/1966)) ([44bb1c5](https://togithub.com/googleapis/google-api-java-client/commit/44bb1c52372bf8de03fe1c05b835f5f04c3a0c85))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- compute/cmdline/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/cmdline/pom.xml b/compute/cmdline/pom.xml index 0991e948111..b35aec203f6 100644 --- a/compute/cmdline/pom.xml +++ b/compute/cmdline/pom.xml @@ -50,7 +50,7 @@ limitations under the License. com.google.api-client google-api-client-gson - 1.33.4 + 1.34.0
From d86f5d4b2444bc389189214f5745a450bca79690 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 18:44:13 +0200 Subject: [PATCH 015/136] fix(deps): update dependency com.google.api-client:google-api-client-appengine to v1.34.0 (#7018) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api-client:google-api-client-appengine](https://togithub.com/googleapis/google-api-java-client) | `1.33.4` -> `1.34.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.0/compatibility-slim/1.33.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.0/confidence-slim/1.33.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-api-java-client ### [`v1.34.0`](https://togithub.com/googleapis/google-api-java-client/blob/HEAD/CHANGELOG.md#​1340-httpsgithubcomgoogleapisgoogle-api-java-clientcomparev1334v1340-2022-04-12) [Compare Source](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.4...v1.34.0) ##### Features - deprecate OOB auth flow in GooglePromptReceiver ([#​2034](https://togithub.com/googleapis/google-api-java-client/issues/2034)) ([334d8d6](https://togithub.com/googleapis/google-api-java-client/commit/334d8d68a455e41be137ed27dab50df7915b3992)) ##### Bug Fixes - **deps:** update dependency com.google.api-client:google-api-client to v1.33.4 ([#​2022](https://togithub.com/googleapis/google-api-java-client/issues/2022)) ([582bde1](https://togithub.com/googleapis/google-api-java-client/commit/582bde1f48c892b5856d0c51d8e051be6d20321e)) - **deps:** update dependency com.google.cloud:libraries-bom to v25.1.0 ([#​2025](https://togithub.com/googleapis/google-api-java-client/issues/2025)) ([ba36a44](https://togithub.com/googleapis/google-api-java-client/commit/ba36a44e27f97edc5a6aa6921b43b753f51af569)) - **deps:** update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.2 ([#​2033](https://togithub.com/googleapis/google-api-java-client/issues/2033)) ([fed93e3](https://togithub.com/googleapis/google-api-java-client/commit/fed93e3a3db2396d7a4bf4c565864ce1e39dc3ba)) ##### Dependencies - revert protobuf to 3.19 ([#​2035](https://togithub.com/googleapis/google-api-java-client/issues/2035)) ([00eabeb](https://togithub.com/googleapis/google-api-java-client/commit/00eabeb293fc6978a7667fbdc695b81add7d700a)) ##### [1.33.4](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.3...v1.33.4) (2022-03-28) ##### Dependencies - update dependency org.sonatype.plugins:nexus-staging-maven-plugin to v1.6.12 ([#​2019](https://togithub.com/googleapis/google-api-java-client/issues/2019)) ([f1e0909](https://togithub.com/googleapis/google-api-java-client/commit/f1e09099f2954df68e8d476f142db7c4b7388917)) ##### [1.33.3](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.2...v1.33.3) (2022-03-25) ##### Bug Fixes - **deps:** update dependency com.google.api-client:google-api-client to v1.33.2 ([#​1985](https://togithub.com/googleapis/google-api-java-client/issues/1985)) ([191850a](https://togithub.com/googleapis/google-api-java-client/commit/191850a33a562300325ee7809e68fca89feeb5f3)) - **deps:** update dependency com.google.appengine:appengine-api-1.0-sdk to v2.0.4 ([#​2010](https://togithub.com/googleapis/google-api-java-client/issues/2010)) ([b4c64a0](https://togithub.com/googleapis/google-api-java-client/commit/b4c64a0365ed8656bd116763318e975c036551b7)) - **deps:** update dependency com.google.cloud:libraries-bom to v24.3.0 ([#​1987](https://togithub.com/googleapis/google-api-java-client/issues/1987)) ([1620e8f](https://togithub.com/googleapis/google-api-java-client/commit/1620e8f6fe69d1af46afb9838ab16594c6c486b5)) - **deps:** update dependency com.google.cloud:libraries-bom to v24.4.0 ([#​2007](https://togithub.com/googleapis/google-api-java-client/issues/2007)) ([cba8dd2](https://togithub.com/googleapis/google-api-java-client/commit/cba8dd246c455c0f857d31f94f465b0d92b01829)) - **deps:** update dependency com.google.cloud:libraries-bom to v25 ([#​2014](https://togithub.com/googleapis/google-api-java-client/issues/2014)) ([43bd4a1](https://togithub.com/googleapis/google-api-java-client/commit/43bd4a13aa4d74e99b138491674e690ea4db8eb0)) - **deps:** update dependency com.google.guava:guava to v31.1-jre ([#​2004](https://togithub.com/googleapis/google-api-java-client/issues/2004)) ([eac0e77](https://togithub.com/googleapis/google-api-java-client/commit/eac0e77e8ac9ab1b784ff7c7c4c7f2f8c3095797)) - **deps:** update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.1 ([#​1986](https://togithub.com/googleapis/google-api-java-client/issues/1986)) ([b8376f1](https://togithub.com/googleapis/google-api-java-client/commit/b8376f15284adab2684e3622af4f3d960bb32387)) ##### [1.33.2](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.1...v1.33.2) (2022-02-08) ##### Dependencies - **java:** update actions/github-script action to v5 ([#​1339](https://togithub.com/googleapis/google-api-java-client/issues/1339)) ([#​1972](https://togithub.com/googleapis/google-api-java-client/issues/1972)) ([b1d8c16](https://togithub.com/googleapis/google-api-java-client/commit/b1d8c167ea05735a08149681c61e30eb5b160368)) ##### [1.33.1](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.0...v1.33.1) (2022-01-21) ##### Bug Fixes - library should released as 1.33.1 ([#​1966](https://togithub.com/googleapis/google-api-java-client/issues/1966)) ([44bb1c5](https://togithub.com/googleapis/google-api-java-client/commit/44bb1c52372bf8de03fe1c05b835f5f04c3a0c85))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java8/firebase-tictactoe/pom.xml | 2 +- flexible/cloudsql/pom.xml | 2 +- flexible/postgres/pom.xml | 2 +- unittests/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appengine-java8/firebase-tictactoe/pom.xml b/appengine-java8/firebase-tictactoe/pom.xml index de27b3b757f..11ceca52975 100644 --- a/appengine-java8/firebase-tictactoe/pom.xml +++ b/appengine-java8/firebase-tictactoe/pom.xml @@ -72,7 +72,7 @@ com.google.api-client google-api-client-appengine - 1.33.4 + 1.34.0 diff --git a/flexible/cloudsql/pom.xml b/flexible/cloudsql/pom.xml index dd7ee4cbd63..ab5e618f5fd 100644 --- a/flexible/cloudsql/pom.xml +++ b/flexible/cloudsql/pom.xml @@ -61,7 +61,7 @@ com.google.api-client google-api-client-appengine - 1.33.4 + 1.34.0 com.google.api-client diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index 33162025558..72e64e1c1cb 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -61,7 +61,7 @@ com.google.api-client google-api-client-appengine - 1.33.4 + 1.34.0 com.google.api-client diff --git a/unittests/pom.xml b/unittests/pom.xml index 3966f3e2663..bb5f910806c 100644 --- a/unittests/pom.xml +++ b/unittests/pom.xml @@ -71,7 +71,7 @@ com.google.api-client google-api-client-appengine - 1.33.4 + 1.34.0 test From 490744c8689dfee2954e4d850da71aed153509ac Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 18:59:58 +0200 Subject: [PATCH 016/136] fix(deps): update dependency com.google.api-client:google-api-client-appengine to v1.34.0 (#7019) --- storage/xml-api/serviceaccount-appengine-sample/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xml-api/serviceaccount-appengine-sample/pom.xml b/storage/xml-api/serviceaccount-appengine-sample/pom.xml index 8b67732495f..b0cf2659dfb 100644 --- a/storage/xml-api/serviceaccount-appengine-sample/pom.xml +++ b/storage/xml-api/serviceaccount-appengine-sample/pom.xml @@ -35,7 +35,7 @@ 1.8 1.8 - 1.33.4 + 1.34.0 ${project.build.directory}/${project.build.finalName} UTF-8 From 99b02dfc3f48756fd871a17ae551c553c878058e Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 19:00:41 +0200 Subject: [PATCH 017/136] fix(deps): update vertx packages to v4.2.7 (#7016) --- appengine-java11/vertx-helloworld/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appengine-java11/vertx-helloworld/pom.xml b/appengine-java11/vertx-helloworld/pom.xml index 3c1c96882b5..254a13d2810 100644 --- a/appengine-java11/vertx-helloworld/pom.xml +++ b/appengine-java11/vertx-helloworld/pom.xml @@ -41,17 +41,17 @@ limitations under the License. io.vertx vertx-core - 4.2.6 + 4.2.7 io.vertx vertx-web - 4.2.6 + 4.2.7 io.vertx vertx-web-client - 4.2.6 + 4.2.7 @@ -68,7 +68,7 @@ limitations under the License. io.vertx vertx-unit - 4.2.6 + 4.2.7 From 79c2c7c7b50c59bd71772a6b89f402d7fac3c080 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 19:00:44 +0200 Subject: [PATCH 018/136] fix(deps): update dependency com.google.api-client:google-api-client-jackson2 to v1.34.0 (#7021) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api-client:google-api-client-jackson2](https://togithub.com/googleapis/google-api-java-client) | `1.33.4` -> `1.34.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.0/compatibility-slim/1.33.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.0/confidence-slim/1.33.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-api-java-client ### [`v1.34.0`](https://togithub.com/googleapis/google-api-java-client/blob/HEAD/CHANGELOG.md#​1340-httpsgithubcomgoogleapisgoogle-api-java-clientcomparev1334v1340-2022-04-12) [Compare Source](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.4...v1.34.0) ##### Features - deprecate OOB auth flow in GooglePromptReceiver ([#​2034](https://togithub.com/googleapis/google-api-java-client/issues/2034)) ([334d8d6](https://togithub.com/googleapis/google-api-java-client/commit/334d8d68a455e41be137ed27dab50df7915b3992)) ##### Bug Fixes - **deps:** update dependency com.google.api-client:google-api-client to v1.33.4 ([#​2022](https://togithub.com/googleapis/google-api-java-client/issues/2022)) ([582bde1](https://togithub.com/googleapis/google-api-java-client/commit/582bde1f48c892b5856d0c51d8e051be6d20321e)) - **deps:** update dependency com.google.cloud:libraries-bom to v25.1.0 ([#​2025](https://togithub.com/googleapis/google-api-java-client/issues/2025)) ([ba36a44](https://togithub.com/googleapis/google-api-java-client/commit/ba36a44e27f97edc5a6aa6921b43b753f51af569)) - **deps:** update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.2 ([#​2033](https://togithub.com/googleapis/google-api-java-client/issues/2033)) ([fed93e3](https://togithub.com/googleapis/google-api-java-client/commit/fed93e3a3db2396d7a4bf4c565864ce1e39dc3ba)) ##### Dependencies - revert protobuf to 3.19 ([#​2035](https://togithub.com/googleapis/google-api-java-client/issues/2035)) ([00eabeb](https://togithub.com/googleapis/google-api-java-client/commit/00eabeb293fc6978a7667fbdc695b81add7d700a)) ##### [1.33.4](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.3...v1.33.4) (2022-03-28) ##### Dependencies - update dependency org.sonatype.plugins:nexus-staging-maven-plugin to v1.6.12 ([#​2019](https://togithub.com/googleapis/google-api-java-client/issues/2019)) ([f1e0909](https://togithub.com/googleapis/google-api-java-client/commit/f1e09099f2954df68e8d476f142db7c4b7388917)) ##### [1.33.3](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.2...v1.33.3) (2022-03-25) ##### Bug Fixes - **deps:** update dependency com.google.api-client:google-api-client to v1.33.2 ([#​1985](https://togithub.com/googleapis/google-api-java-client/issues/1985)) ([191850a](https://togithub.com/googleapis/google-api-java-client/commit/191850a33a562300325ee7809e68fca89feeb5f3)) - **deps:** update dependency com.google.appengine:appengine-api-1.0-sdk to v2.0.4 ([#​2010](https://togithub.com/googleapis/google-api-java-client/issues/2010)) ([b4c64a0](https://togithub.com/googleapis/google-api-java-client/commit/b4c64a0365ed8656bd116763318e975c036551b7)) - **deps:** update dependency com.google.cloud:libraries-bom to v24.3.0 ([#​1987](https://togithub.com/googleapis/google-api-java-client/issues/1987)) ([1620e8f](https://togithub.com/googleapis/google-api-java-client/commit/1620e8f6fe69d1af46afb9838ab16594c6c486b5)) - **deps:** update dependency com.google.cloud:libraries-bom to v24.4.0 ([#​2007](https://togithub.com/googleapis/google-api-java-client/issues/2007)) ([cba8dd2](https://togithub.com/googleapis/google-api-java-client/commit/cba8dd246c455c0f857d31f94f465b0d92b01829)) - **deps:** update dependency com.google.cloud:libraries-bom to v25 ([#​2014](https://togithub.com/googleapis/google-api-java-client/issues/2014)) ([43bd4a1](https://togithub.com/googleapis/google-api-java-client/commit/43bd4a13aa4d74e99b138491674e690ea4db8eb0)) - **deps:** update dependency com.google.guava:guava to v31.1-jre ([#​2004](https://togithub.com/googleapis/google-api-java-client/issues/2004)) ([eac0e77](https://togithub.com/googleapis/google-api-java-client/commit/eac0e77e8ac9ab1b784ff7c7c4c7f2f8c3095797)) - **deps:** update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.1 ([#​1986](https://togithub.com/googleapis/google-api-java-client/issues/1986)) ([b8376f1](https://togithub.com/googleapis/google-api-java-client/commit/b8376f15284adab2684e3622af4f3d960bb32387)) ##### [1.33.2](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.1...v1.33.2) (2022-02-08) ##### Dependencies - **java:** update actions/github-script action to v5 ([#​1339](https://togithub.com/googleapis/google-api-java-client/issues/1339)) ([#​1972](https://togithub.com/googleapis/google-api-java-client/issues/1972)) ([b1d8c16](https://togithub.com/googleapis/google-api-java-client/commit/b1d8c167ea05735a08149681c61e30eb5b160368)) ##### [1.33.1](https://togithub.com/googleapis/google-api-java-client/compare/v1.33.0...v1.33.1) (2022-01-21) ##### Bug Fixes - library should released as 1.33.1 ([#​1966](https://togithub.com/googleapis/google-api-java-client/issues/1966)) ([44bb1c5](https://togithub.com/googleapis/google-api-java-client/commit/44bb1c52372bf8de03fe1c05b835f5f04c3a0c85))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index 3099829e679..dec3e7d3529 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -88,7 +88,7 @@ com.google.api-client google-api-client-jackson2 - 1.33.4 + 1.34.0 com.google.http-client diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index 96616ce7950..a9b277e52f9 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -97,7 +97,7 @@ com.google.api-client google-api-client-jackson2 - 1.33.4 + 1.34.0 com.google.http-client From 0c29237434ce4b3b0647b1a442e12f6444dc9785 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 19:01:05 +0200 Subject: [PATCH 019/136] fix(deps): update dependency com.slack.api:slack-app-backend to v1.21.2 (#7015) --- functions/slack/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/slack/pom.xml b/functions/slack/pom.xml index 065e0240812..7242258ff55 100644 --- a/functions/slack/pom.xml +++ b/functions/slack/pom.xml @@ -77,7 +77,7 @@ com.slack.api slack-app-backend - 1.21.1 + 1.21.2 From 61026b83a44eb6d363c5f24996d3f6e697d86933 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 19:01:41 +0200 Subject: [PATCH 020/136] fix(deps): update dependency com.google.http-client:google-http-client-jackson2 to v1.41.7 (#7006) --- appengine-java11/oauth2/pom.xml | 2 +- cloud-sql/mysql/client-side-encryption/pom.xml | 2 +- cloud-sql/postgres/client-side-encryption/pom.xml | 2 +- cloud-sql/sqlserver/client-side-encryption/pom.xml | 2 +- functions/slack/pom.xml | 2 +- healthcare/v1/pom.xml | 2 +- iam/api-client/pom.xml | 2 +- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- jobs/v3/pom.xml | 2 +- jobs/v4/pom.xml | 2 +- mlengine/online-prediction/pom.xml | 2 +- trace/pom.xml | 2 +- vision/face-detection/pom.xml | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/appengine-java11/oauth2/pom.xml b/appengine-java11/oauth2/pom.xml index 07632b1e102..1ee5425b799 100644 --- a/appengine-java11/oauth2/pom.xml +++ b/appengine-java11/oauth2/pom.xml @@ -77,7 +77,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/cloud-sql/mysql/client-side-encryption/pom.xml b/cloud-sql/mysql/client-side-encryption/pom.xml index 2aee127445c..d4cae51ac5a 100644 --- a/cloud-sql/mysql/client-side-encryption/pom.xml +++ b/cloud-sql/mysql/client-side-encryption/pom.xml @@ -57,7 +57,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 com.google.cloud.sql diff --git a/cloud-sql/postgres/client-side-encryption/pom.xml b/cloud-sql/postgres/client-side-encryption/pom.xml index 7e57de941ea..1baee566e35 100644 --- a/cloud-sql/postgres/client-side-encryption/pom.xml +++ b/cloud-sql/postgres/client-side-encryption/pom.xml @@ -57,7 +57,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 com.google.cloud.sql diff --git a/cloud-sql/sqlserver/client-side-encryption/pom.xml b/cloud-sql/sqlserver/client-side-encryption/pom.xml index bf94bc91e9f..1a9521ae7bc 100644 --- a/cloud-sql/sqlserver/client-side-encryption/pom.xml +++ b/cloud-sql/sqlserver/client-side-encryption/pom.xml @@ -57,7 +57,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 com.google.cloud.sql diff --git a/functions/slack/pom.xml b/functions/slack/pom.xml index 7242258ff55..0ea896ae4d4 100644 --- a/functions/slack/pom.xml +++ b/functions/slack/pom.xml @@ -66,7 +66,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/healthcare/v1/pom.xml b/healthcare/v1/pom.xml index 98dbbcde3f2..98b9411ccb7 100644 --- a/healthcare/v1/pom.xml +++ b/healthcare/v1/pom.xml @@ -75,7 +75,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 com.google.apis diff --git a/iam/api-client/pom.xml b/iam/api-client/pom.xml index cb236ec8029..0949fd37bc7 100644 --- a/iam/api-client/pom.xml +++ b/iam/api-client/pom.xml @@ -50,7 +50,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index dec3e7d3529..ca9e3f9881a 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -93,7 +93,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index a9b277e52f9..afaa83c13b1 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -102,7 +102,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/jobs/v3/pom.xml b/jobs/v3/pom.xml index f5fb8d29bb6..cdcf3762f37 100644 --- a/jobs/v3/pom.xml +++ b/jobs/v3/pom.xml @@ -42,7 +42,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/jobs/v4/pom.xml b/jobs/v4/pom.xml index b3f80b9d0ab..49108e5b209 100644 --- a/jobs/v4/pom.xml +++ b/jobs/v4/pom.xml @@ -55,7 +55,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/mlengine/online-prediction/pom.xml b/mlengine/online-prediction/pom.xml index 9409f14e9f4..ff6191fd93f 100644 --- a/mlengine/online-prediction/pom.xml +++ b/mlengine/online-prediction/pom.xml @@ -76,7 +76,7 @@ limitations under the License. com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 diff --git a/trace/pom.xml b/trace/pom.xml index 5dd8061347e..543187a4321 100644 --- a/trace/pom.xml +++ b/trace/pom.xml @@ -95,7 +95,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 test diff --git a/vision/face-detection/pom.xml b/vision/face-detection/pom.xml index 24a037bc9fe..c97da1378c6 100644 --- a/vision/face-detection/pom.xml +++ b/vision/face-detection/pom.xml @@ -56,7 +56,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.6 + 1.41.7 From 49febbec268175bbed155f46ae04662ff154b325 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 14 Apr 2022 19:01:55 +0200 Subject: [PATCH 021/136] fix(deps): update dependency com.google.api-client:google-api-client to v1.34.0 (#7017) --- cloud-sql/mysql/client-side-encryption/pom.xml | 2 +- cloud-sql/postgres/client-side-encryption/pom.xml | 2 +- cloud-sql/sqlserver/client-side-encryption/pom.xml | 2 +- flexible/cloudsql/pom.xml | 2 +- flexible/postgres/pom.xml | 2 +- healthcare/v1/pom.xml | 2 +- iot/api-client/codelab/manager/pom.xml | 2 +- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- pubsublite/streaming-analytics/build.gradle | 2 +- pubsublite/streaming-analytics/pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cloud-sql/mysql/client-side-encryption/pom.xml b/cloud-sql/mysql/client-side-encryption/pom.xml index d4cae51ac5a..6e864fad006 100644 --- a/cloud-sql/mysql/client-side-encryption/pom.xml +++ b/cloud-sql/mysql/client-side-encryption/pom.xml @@ -48,7 +48,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 diff --git a/cloud-sql/postgres/client-side-encryption/pom.xml b/cloud-sql/postgres/client-side-encryption/pom.xml index 1baee566e35..3edc0a2b115 100644 --- a/cloud-sql/postgres/client-side-encryption/pom.xml +++ b/cloud-sql/postgres/client-side-encryption/pom.xml @@ -48,7 +48,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 diff --git a/cloud-sql/sqlserver/client-side-encryption/pom.xml b/cloud-sql/sqlserver/client-side-encryption/pom.xml index 1a9521ae7bc..2086d392ede 100644 --- a/cloud-sql/sqlserver/client-side-encryption/pom.xml +++ b/cloud-sql/sqlserver/client-side-encryption/pom.xml @@ -48,7 +48,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 diff --git a/flexible/cloudsql/pom.xml b/flexible/cloudsql/pom.xml index ab5e618f5fd..3cb1b535ed0 100644 --- a/flexible/cloudsql/pom.xml +++ b/flexible/cloudsql/pom.xml @@ -56,7 +56,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 com.google.api-client diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index 72e64e1c1cb..f5fdf97e7b2 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -56,7 +56,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 com.google.api-client diff --git a/healthcare/v1/pom.xml b/healthcare/v1/pom.xml index 98b9411ccb7..405b73e4066 100644 --- a/healthcare/v1/pom.xml +++ b/healthcare/v1/pom.xml @@ -85,7 +85,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 com.google.auth diff --git a/iot/api-client/codelab/manager/pom.xml b/iot/api-client/codelab/manager/pom.xml index 426b2c7a010..bc7004c2ba5 100644 --- a/iot/api-client/codelab/manager/pom.xml +++ b/iot/api-client/codelab/manager/pom.xml @@ -87,7 +87,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 commons-cli diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index ca9e3f9881a..9458095b054 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -78,7 +78,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 commons-cli diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index afaa83c13b1..0e2151930af 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -87,7 +87,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 commons-cli diff --git a/pubsublite/streaming-analytics/build.gradle b/pubsublite/streaming-analytics/build.gradle index 55efe9e55bd..eed0d99b113 100644 --- a/pubsublite/streaming-analytics/build.gradle +++ b/pubsublite/streaming-analytics/build.gradle @@ -44,7 +44,7 @@ dependencies { implementation "org.apache.beam:beam-examples-java:${beamVersion}" runtimeOnly "org.apache.beam:beam-runners-direct-java:${beamVersion}" runtimeOnly "org.apache.beam:beam-runners-google-cloud-dataflow-java:${beamVersion}" - testImplementation 'com.google.api-client:google-api-client:1.33.4' + testImplementation 'com.google.api-client:google-api-client:1.34.0' testImplementation 'com.google.apis:google-api-services-dataflow:v1b3-rev20210825-1.32.1' testImplementation 'com.google.cloud:google-cloud-core:2.3.2' testImplementation 'com.google.cloud:google-cloud-storage:2.6.0' diff --git a/pubsublite/streaming-analytics/pom.xml b/pubsublite/streaming-analytics/pom.xml index 2423980be93..0e7250228de 100644 --- a/pubsublite/streaming-analytics/pom.xml +++ b/pubsublite/streaming-analytics/pom.xml @@ -131,7 +131,7 @@ com.google.api-client google-api-client - 1.33.4 + 1.34.0 From 506ee4de4c87496269a5c2d1f602a3639df61d91 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Mon, 18 Apr 2022 08:51:18 -0700 Subject: [PATCH 022/136] fix: Update env var and log filter (#7023) * fix: Update env var and log filter * lint --- .../main/java/com/example/JobsExample.java | 19 ++++++++++++++----- .../com/example/JobsIntegrationTests.java | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/run/jobs/src/main/java/com/example/JobsExample.java b/run/jobs/src/main/java/com/example/JobsExample.java index 7b5c1488c48..e81dad0e8fa 100644 --- a/run/jobs/src/main/java/com/example/JobsExample.java +++ b/run/jobs/src/main/java/com/example/JobsExample.java @@ -14,13 +14,17 @@ * limitations under the License. */ +// [START cloudrun_jobs_quickstart] + package com.example; abstract class JobsExample { // [START cloudrun_jobs_env_vars] // These values are provided automatically by the Cloud Run Jobs runtime. - private static String TASK_NUM = System.getenv().getOrDefault("TASK_NUM", "0"); - private static String ATTEMPT_NUM = System.getenv().getOrDefault("ATTEMPT_NUM", "0"); + private static String CLOUD_RUN_TASK_INDEX = + System.getenv().getOrDefault("CLOUD_RUN_TASK_INDEX", "0"); + private static String CLOUD_RUN_TASK_ATTEMPT = + System.getenv().getOrDefault("CLOUD_RUN_TASK_ATTEMPT", "0"); // User-provided environment variables private static int SLEEP_MS = Integer.parseInt(System.getenv().getOrDefault("SLEEP_MS", "0")); @@ -30,11 +34,15 @@ abstract class JobsExample { // Start script public static void main(String[] args) { - System.out.println(String.format("Starting Task #%s, Attempt #%s...", TASK_NUM, ATTEMPT_NUM)); + System.out.println( + String.format( + "Starting Task #%s, Attempt #%s...", CLOUD_RUN_TASK_INDEX, CLOUD_RUN_TASK_ATTEMPT)); try { runTask(SLEEP_MS, FAIL_RATE); } catch (RuntimeException | InterruptedException e) { - System.err.println(String.format("Task #%s, Attempt #%s failed.", TASK_NUM, ATTEMPT_NUM)); + System.err.println( + String.format( + "Task #%s, Attempt #%s failed.", CLOUD_RUN_TASK_INDEX, CLOUD_RUN_TASK_ATTEMPT)); // [START cloudrun_jobs_exit_process] // Catch error and denote process-level failure to retry Task System.exit(1); @@ -59,6 +67,7 @@ static void runTask(int sleepTime, float failureRate) throws InterruptedExceptio if (Math.random() < failureRate) { throw new RuntimeException("Task Failed."); } - System.out.println(String.format("Completed Task #%s", TASK_NUM)); + System.out.println(String.format("Completed Task #%s", CLOUD_RUN_TASK_INDEX)); } } +// [END cloudrun_jobs_quickstart] diff --git a/run/jobs/src/test/java/com/example/JobsIntegrationTests.java b/run/jobs/src/test/java/com/example/JobsIntegrationTests.java index 4d9ded0e1e6..41ade762402 100644 --- a/run/jobs/src/test/java/com/example/JobsIntegrationTests.java +++ b/run/jobs/src/test/java/com/example/JobsIntegrationTests.java @@ -95,8 +95,8 @@ public void generatesLogs() throws Exception { calendar.add(Calendar.MINUTE, -5); DateFormat rfc3339 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); String logFilter = - "resource.type = \"cloud_run_revision\"" - + " resource.labels.service_name = \"" + "resource.type = \"cloud_run_job\"" + + " resource.labels.job_name = \"" + service + "\" resource.labels.location = \"us-central1\"" + " timestamp>=\"" From 9a75128b3be4b15b9e4ffa1fbba345a76536da19 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 17:51:31 +0200 Subject: [PATCH 023/136] fix(deps): update dependency com.google.cloud:google-cloud-kms to v2.4.3 (#6992) --- kms/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kms/pom.xml b/kms/pom.xml index 2b90b4d7ffa..95c32887deb 100644 --- a/kms/pom.xml +++ b/kms/pom.xml @@ -25,7 +25,7 @@ com.google.cloud google-cloud-kms - 2.4.2 + 2.4.3 From 4dece7dd5daa21db5cda69bde17851adc8335deb Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Mon, 18 Apr 2022 21:23:19 +0530 Subject: [PATCH 024/136] docs(compute-samples): added snippets for suspend resume instance (#7010) * docs(compute-samples): added VM suspend and resume samples and test * lint fix and changed debian version to suspend supported VM --- compute/cloud-client/pom.xml | 4 +- .../src/main/java/compute/CreateInstance.java | 21 ++++-- .../src/main/java/compute/ResumeInstance.java | 75 +++++++++++++++++++ .../main/java/compute/SuspendInstance.java | 66 ++++++++++++++++ .../src/test/java/compute/SnippetsIT.java | 15 +++- 5 files changed, 171 insertions(+), 10 deletions(-) create mode 100644 compute/cloud-client/src/main/java/compute/ResumeInstance.java create mode 100644 compute/cloud-client/src/main/java/compute/SuspendInstance.java diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 93922c625be..46f262fc7ab 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -23,7 +23,7 @@ google-cloud-compute com.google.cloud - 1.7.0 + 1.8.1 google-cloud-storage @@ -63,7 +63,7 @@ com.google.cloud import pom - 25.0.0 + 25.1.0 diff --git a/compute/cloud-client/src/main/java/compute/CreateInstance.java b/compute/cloud-client/src/main/java/compute/CreateInstance.java index 15ff1196a73..bc45d1ac6d4 100644 --- a/compute/cloud-client/src/main/java/compute/CreateInstance.java +++ b/compute/cloud-client/src/main/java/compute/CreateInstance.java @@ -46,13 +46,16 @@ public static void main(String[] args) public static void createInstance(String project, String zone, String instanceName) throws IOException, InterruptedException, ExecutionException { // Below are sample values that can be replaced. - // machineType: machine type of the VM being created. This value uses the format zones/{zone}/machineTypes/{type_name}. For a list of machine types, see https://cloud.google.com/compute/docs/machine-types - // sourceImage: path to the operating system image to mount. For details about images you can mount, see https://cloud.google.com/compute/docs/images + // machineType: machine type of the VM being created. + // * This value uses the format zones/{zone}/machineTypes/{type_name}. + // * For a list of machine types, see https://cloud.google.com/compute/docs/machine-types + // sourceImage: path to the operating system image to mount. + // * For details about images you can mount, see https://cloud.google.com/compute/docs/images // diskSizeGb: storage size of the boot disk to attach to the instance. // networkName: network interface to associate with the instance. String machineType = String.format("zones/%s/machineTypes/n1-standard-1", zone); String sourceImage = String - .format("projects/debian-cloud/global/images/family/%s", "debian-10"); + .format("projects/debian-cloud/global/images/family/%s", "debian-11"); long diskSizeGb = 10L; String networkName = "default"; @@ -69,12 +72,15 @@ public static void createInstance(String project, String zone, String instanceNa .setType(Type.PERSISTENT.toString()) .setDeviceName("disk-1") .setInitializeParams( - AttachedDiskInitializeParams.newBuilder().setSourceImage(sourceImage) - .setDiskSizeGb(diskSizeGb).build()) + AttachedDiskInitializeParams.newBuilder() + .setSourceImage(sourceImage) + .setDiskSizeGb(diskSizeGb) + .build()) .build(); // Use the network interface provided in the networkName argument. - NetworkInterface networkInterface = NetworkInterface.newBuilder().setName(networkName) + NetworkInterface networkInterface = NetworkInterface.newBuilder() + .setName(networkName) .build(); // Bind `instanceName`, `machineType`, `disk`, and `networkInterface` to an instance. @@ -92,7 +98,8 @@ public static void createInstance(String project, String zone, String instanceNa InsertInstanceRequest insertInstanceRequest = InsertInstanceRequest.newBuilder() .setProject(project) .setZone(zone) - .setInstanceResource(instanceResource).build(); + .setInstanceResource(instanceResource) + .build(); OperationFuture operation = instancesClient.insertAsync( insertInstanceRequest); diff --git a/compute/cloud-client/src/main/java/compute/ResumeInstance.java b/compute/cloud-client/src/main/java/compute/ResumeInstance.java new file mode 100644 index 00000000000..314e7e0c12f --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/ResumeInstance.java @@ -0,0 +1,75 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package compute; + +// [START compute_resume_instance] + +import com.google.cloud.compute.v1.Instance.Status; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public class ResumeInstance { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException, TimeoutException { + // TODO(developer): Replace these variables before running the sample. + // project: project ID or project number of the Cloud project your instance belongs to. + // zone: name of the zone your instance belongs to. + // instanceName: name of the instance your want to resume. + + String project = "your-project-id"; + String zone = "zone-name"; + String instanceName = "instance-name"; + + resumeInstance(project, zone, instanceName); + } + + // Resume a suspended Google Compute Engine instance (with unencrypted disks). + // Instance state changes to RUNNING, if successfully resumed. + public static void resumeInstance(String project, String zone, String instanceName) + throws IOException, ExecutionException, InterruptedException, TimeoutException { + // Instantiates a client. + try (InstancesClient instancesClient = InstancesClient.create()) { + + String currentInstanceState = instancesClient.get(project, zone, instanceName).getStatus(); + + // Check if the instance is currently suspended. + if (!currentInstanceState.equalsIgnoreCase(Status.SUSPENDED.toString())) { + throw new RuntimeException( + String.format("Only suspended instances can be resumed. Instance %s is in %s state.", + instanceName, currentInstanceState)); + } + + Operation operation = instancesClient.resumeAsync(project, zone, instanceName) + .get(300, TimeUnit.SECONDS); + + if (operation.hasError() || !instancesClient.get(project, zone, instanceName).getStatus() + .equalsIgnoreCase( + Status.RUNNING.toString())) { + System.out.println("Cannot resume instance. Try again!"); + return; + } + + System.out.printf("Instance resumed successfully ! %s", instanceName); + } + } +} +// [END compute_resume_instance] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/SuspendInstance.java b/compute/cloud-client/src/main/java/compute/SuspendInstance.java new file mode 100644 index 00000000000..458b83680bd --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/SuspendInstance.java @@ -0,0 +1,66 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package compute; + +// [START compute_suspend_instance] + +import com.google.cloud.compute.v1.Instance.Status; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public class SuspendInstance { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException, TimeoutException { + // TODO(developer): Replace these variables before running the sample. + // project: project ID or project number of the Cloud project your instance belongs to. + // zone: name of the zone your instance belongs to. + // instanceName: name of the instance your want to suspend. + + String project = "your-project-id"; + String zone = "zone-name"; + String instanceName = "instance-name"; + + suspendInstance(project, zone, instanceName); + } + + // Suspend a running Google Compute Engine instance. + // For limitations and compatibility on which instances can be suspended, + // see: https://cloud.google.com/compute/docs/instances/suspend-resume-instance#limitations + public static void suspendInstance(String project, String zone, String instanceName) + throws IOException, ExecutionException, InterruptedException, TimeoutException { + // Instantiates a client. + try (InstancesClient instancesClient = InstancesClient.create()) { + + Operation operation = instancesClient.suspendAsync(project, zone, instanceName) + .get(300, TimeUnit.SECONDS); + + if (operation.hasError() || !instancesClient.get(project, zone, instanceName).getStatus() + .equalsIgnoreCase(Status.SUSPENDED.toString())) { + System.out.println("Cannot suspend instance. Try again!"); + return; + } + + System.out.printf("Instance suspended successfully ! %s", instanceName); + } + } +} +// [END compute_suspend_instance] \ No newline at end of file diff --git a/compute/cloud-client/src/test/java/compute/SnippetsIT.java b/compute/cloud-client/src/test/java/compute/SnippetsIT.java index af353c65662..673f9fc446d 100644 --- a/compute/cloud-client/src/test/java/compute/SnippetsIT.java +++ b/compute/cloud-client/src/test/java/compute/SnippetsIT.java @@ -48,6 +48,7 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.stream.IntStream; import org.junit.After; import org.junit.AfterClass; @@ -490,7 +491,19 @@ public void testListImagesByPage() throws IOException { @Test public void testInstanceOperations() - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { + Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.RUNNING.toString()); + + // Suspending the instance. + // Once the machine is running, give it some time to fully start all processes + // before trying to suspend it. + TimeUnit.SECONDS.sleep(45); + SuspendInstance.suspendInstance(PROJECT_ID, ZONE, MACHINE_NAME); + TimeUnit.SECONDS.sleep(10); + Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.SUSPENDED.toString()); + + // Resuming the instance. + ResumeInstance.resumeInstance(PROJECT_ID, ZONE, MACHINE_NAME); Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.RUNNING.toString()); // Stopping the instance. From a17f8bef40a2321cc29c267d3ea8fe6f5e5269f8 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 20:01:02 +0200 Subject: [PATCH 025/136] fix(deps): update dependency com.google.cloud:google-cloud-monitoring to v3.2.8 (#7028) --- appengine-java8/bigquery/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java8/bigquery/pom.xml b/appengine-java8/bigquery/pom.xml index 9ce1b14361a..87be6735cfe 100644 --- a/appengine-java8/bigquery/pom.xml +++ b/appengine-java8/bigquery/pom.xml @@ -57,7 +57,7 @@ com.google.cloud google-cloud-monitoring - 3.2.7 + 3.2.8 From fccdb4fa67d9424dc49a69ef57730da00c084f31 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 20:01:14 +0200 Subject: [PATCH 026/136] fix(deps): update dependency com.google.cloud:google-cloud-language to v2.1.11 (#7027) --- language/cloud-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/cloud-client/pom.xml b/language/cloud-client/pom.xml index a603ff7a4c1..15411b15e89 100644 --- a/language/cloud-client/pom.xml +++ b/language/cloud-client/pom.xml @@ -39,7 +39,7 @@ com.google.cloud google-cloud-language - 2.1.10 + 2.1.11 com.google.guava From a06b97c91c6c3745eee42e59d4ee6aa3af44fac6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 20:02:37 +0200 Subject: [PATCH 027/136] chore(deps): update dependency com.google.cloud.tools:appengine-maven-plugin to v2.4.2 (#7026) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.tools:appengine-maven-plugin](https://togithub.com/GoogleCloudPlatform/app-maven-plugin) | `2.4.1` -> `2.4.2` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/compatibility-slim/2.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/confidence-slim/2.4.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
GoogleCloudPlatform/app-maven-plugin ### [`v2.4.2`](https://togithub.com/GoogleCloudPlatform/app-maven-plugin/blob/HEAD/CHANGELOG.md#​242-SNAPSHOT) [Compare Source](https://togithub.com/GoogleCloudPlatform/app-maven-plugin/compare/v2.4.1...v2.4.2) ##### Changed - Update to appengine-plugins-core 0.9.7 allowing Java 17 jar deployment.
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- endpoints/multiple-versions/pom.xml | 2 +- flexible/analytics/pom.xml | 2 +- flexible/async-rest/pom.xml | 2 +- flexible/cloudstorage/pom.xml | 2 +- flexible/cron/pom.xml | 2 +- flexible/datastore/pom.xml | 2 +- flexible/disk/pom.xml | 2 +- flexible/errorreporting/pom.xml | 2 +- flexible/extending-runtime/pom.xml | 2 +- flexible/helloworld/pom.xml | 2 +- flexible/memcache/pom.xml | 2 +- flexible/pubsub/pom.xml | 2 +- flexible/sparkjava/pom.xml | 2 +- flexible/static-files/pom.xml | 2 +- flexible/twilio/pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/endpoints/multiple-versions/pom.xml b/endpoints/multiple-versions/pom.xml index 898870feb3b..4c9ef0d3bb5 100644 --- a/endpoints/multiple-versions/pom.xml +++ b/endpoints/multiple-versions/pom.xml @@ -38,7 +38,7 @@ 2.6 - 2.4.1 + 2.4.2 9.4.44.v20210927 false diff --git a/flexible/analytics/pom.xml b/flexible/analytics/pom.xml index b7f1de664a4..3716a167766 100644 --- a/flexible/analytics/pom.xml +++ b/flexible/analytics/pom.xml @@ -34,7 +34,7 @@ 1.8 1.8 - 2.4.1 + 2.4.2 9.4.44.v20210927 false
diff --git a/flexible/async-rest/pom.xml b/flexible/async-rest/pom.xml index 2ad87d89c1f..e3601dcee01 100644 --- a/flexible/async-rest/pom.xml +++ b/flexible/async-rest/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 1.8 diff --git a/flexible/cloudstorage/pom.xml b/flexible/cloudstorage/pom.xml index 181bb8dbf8e..7309b52e8da 100644 --- a/flexible/cloudstorage/pom.xml +++ b/flexible/cloudstorage/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/cron/pom.xml b/flexible/cron/pom.xml index ea1ab71f2ff..f0c9467d44a 100644 --- a/flexible/cron/pom.xml +++ b/flexible/cron/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/datastore/pom.xml b/flexible/datastore/pom.xml index 2434fc683ea..192b2e362d6 100644 --- a/flexible/datastore/pom.xml +++ b/flexible/datastore/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/disk/pom.xml b/flexible/disk/pom.xml index a79a98c97cd..1972caa1c3a 100644 --- a/flexible/disk/pom.xml +++ b/flexible/disk/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/errorreporting/pom.xml b/flexible/errorreporting/pom.xml index 5ff163b77a2..a191342fe11 100644 --- a/flexible/errorreporting/pom.xml +++ b/flexible/errorreporting/pom.xml @@ -31,7 +31,7 @@ - 2.4.1 + 2.4.2 1.8 1.8 false diff --git a/flexible/extending-runtime/pom.xml b/flexible/extending-runtime/pom.xml index 1af24568690..3b4b9044b7f 100644 --- a/flexible/extending-runtime/pom.xml +++ b/flexible/extending-runtime/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/helloworld/pom.xml b/flexible/helloworld/pom.xml index ae7b54a1dc2..267a03862b0 100644 --- a/flexible/helloworld/pom.xml +++ b/flexible/helloworld/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/memcache/pom.xml b/flexible/memcache/pom.xml index 8b67bb7bd22..8988c82fcc3 100644 --- a/flexible/memcache/pom.xml +++ b/flexible/memcache/pom.xml @@ -37,7 +37,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/pubsub/pom.xml b/flexible/pubsub/pom.xml index 8098406a014..94a80271da8 100644 --- a/flexible/pubsub/pom.xml +++ b/flexible/pubsub/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/sparkjava/pom.xml b/flexible/sparkjava/pom.xml index 0cd0620f6fd..5c000f99a31 100644 --- a/flexible/sparkjava/pom.xml +++ b/flexible/sparkjava/pom.xml @@ -36,7 +36,7 @@ limitations under the License. 1.8 1.8 - 2.4.1 + 2.4.2 ${project.build.directory}/spark-1.0-jar-with-dependencies.jar diff --git a/flexible/static-files/pom.xml b/flexible/static-files/pom.xml index f96aa3e3073..a7782a0cbb6 100644 --- a/flexible/static-files/pom.xml +++ b/flexible/static-files/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 diff --git a/flexible/twilio/pom.xml b/flexible/twilio/pom.xml index a94f49ee9ff..cc136211ae8 100644 --- a/flexible/twilio/pom.xml +++ b/flexible/twilio/pom.xml @@ -36,7 +36,7 @@ false - 2.4.1 + 2.4.2 9.4.44.v20210927 From ad6a8ec935881ed08934d9c116e784de96642f2a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 20:04:36 +0200 Subject: [PATCH 028/136] fix(deps): update dependency org.projectlombok:lombok to v1.18.24 (#7031) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.projectlombok:lombok](https://projectlombok.org) ([source](https://togithub.com/projectlombok/lombok)) | `1.18.22` -> `1.18.24` | [![age](https://badges.renovateapi.com/packages/maven/org.projectlombok:lombok/1.18.24/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.projectlombok:lombok/1.18.24/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.projectlombok:lombok/1.18.24/compatibility-slim/1.18.22)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.projectlombok:lombok/1.18.24/confidence-slim/1.18.22)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
projectlombok/lombok ### [`v1.18.24`](https://togithub.com/projectlombok/lombok/compare/v1.18.22...v1.18.24) [Compare Source](https://togithub.com/projectlombok/lombok/compare/v1.18.22...v1.18.24)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- container-registry/vulnerability-notification-function/pom.xml | 2 +- run/idp-sql/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/container-registry/vulnerability-notification-function/pom.xml b/container-registry/vulnerability-notification-function/pom.xml index 676a1d17b93..988b260aac7 100644 --- a/container-registry/vulnerability-notification-function/pom.xml +++ b/container-registry/vulnerability-notification-function/pom.xml @@ -55,7 +55,7 @@ org.projectlombok lombok - 1.18.22 + 1.18.24 diff --git a/run/idp-sql/pom.xml b/run/idp-sql/pom.xml index e597df4fa43..bf350832b2e 100644 --- a/run/idp-sql/pom.xml +++ b/run/idp-sql/pom.xml @@ -106,7 +106,7 @@ limitations under the License. org.projectlombok lombok - 1.18.22 + 1.18.24 com.squareup.okhttp3 From 8452f3d42dba96f26ec130e4566d97586fb9feda Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 20:06:12 +0200 Subject: [PATCH 029/136] fix(deps): update dependency org.postgresql:postgresql to v42.3.4 (#7030) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.postgresql:postgresql](https://jdbc.postgresql.org) ([source](https://togithub.com/pgjdbc/pgjdbc)) | `42.3.3` -> `42.3.4` | [![age](https://badges.renovateapi.com/packages/maven/org.postgresql:postgresql/42.3.4/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.postgresql:postgresql/42.3.4/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.postgresql:postgresql/42.3.4/compatibility-slim/42.3.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.postgresql:postgresql/42.3.4/confidence-slim/42.3.3)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- cloud-sql/postgres/client-side-encryption/pom.xml | 2 +- cloud-sql/postgres/servlet/pom.xml | 2 +- flexible/postgres/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud-sql/postgres/client-side-encryption/pom.xml b/cloud-sql/postgres/client-side-encryption/pom.xml index 3edc0a2b115..24eaf38e7d2 100644 --- a/cloud-sql/postgres/client-side-encryption/pom.xml +++ b/cloud-sql/postgres/client-side-encryption/pom.xml @@ -67,7 +67,7 @@ org.postgresql postgresql - 42.3.3 + 42.3.4 com.google.crypto.tink diff --git a/cloud-sql/postgres/servlet/pom.xml b/cloud-sql/postgres/servlet/pom.xml index c36d134efe7..df1884ea85e 100644 --- a/cloud-sql/postgres/servlet/pom.xml +++ b/cloud-sql/postgres/servlet/pom.xml @@ -52,7 +52,7 @@ org.postgresql postgresql - 42.3.3 + 42.3.4 com.google.cloud.sql diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index f5fdf97e7b2..8e858c4c6b7 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -79,7 +79,7 @@ org.postgresql postgresql - 42.3.3 + 42.3.4 From 8a67c79d861574b593d4ecbac26ae6497a0c1d6a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 20:14:11 +0200 Subject: [PATCH 030/136] chore(deps): update dependency com.google.cloud.tools:appengine-maven-plugin to v2.4.2 (#7025) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.tools:appengine-maven-plugin](https://togithub.com/GoogleCloudPlatform/app-maven-plugin) | `2.4.1` -> `2.4.2` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/compatibility-slim/2.4.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.tools:appengine-maven-plugin/2.4.2/confidence-slim/2.4.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
GoogleCloudPlatform/app-maven-plugin ### [`v2.4.2`](https://togithub.com/GoogleCloudPlatform/app-maven-plugin/blob/HEAD/CHANGELOG.md#​242-SNAPSHOT) [Compare Source](https://togithub.com/GoogleCloudPlatform/app-maven-plugin/compare/v2.4.1...v2.4.2) ##### Changed - Update to appengine-plugins-core 0.9.7 allowing Java 17 jar deployment.
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java11-bundled-services/datastore/pom.xml | 2 +- appengine-java11/cloudsql/pom.xml | 2 +- appengine-java11/gaeinfo/pom.xml | 2 +- appengine-java11/guestbook-cloud-firestore/pom.xml | 2 +- appengine-java11/helloworld-servlet/pom.xml | 2 +- appengine-java11/http-server/pom.xml | 2 +- appengine-java11/kotlin-ktor/pom.xml | 2 +- appengine-java11/micronaut-helloworld/pom.xml | 2 +- appengine-java11/oauth2/pom.xml | 2 +- appengine-java11/quarkus-helloworld/pom.xml | 2 +- appengine-java11/spanner/pom.xml | 2 +- appengine-java11/sparkjava-helloworld/pom.xml | 2 +- appengine-java11/springboot-helloworld/pom.xml | 2 +- appengine-java11/tasks-handler/pom.xml | 2 +- appengine-java11/vertx-helloworld/pom.xml | 2 +- appengine-java8/analytics/pom.xml | 2 +- appengine-java8/appidentity/pom.xml | 2 +- appengine-java8/bigquery/pom.xml | 2 +- appengine-java8/bigtable/pom.xml | 2 +- appengine-java8/datastore-indexes-exploding/pom.xml | 2 +- appengine-java8/datastore-indexes-perfect/pom.xml | 2 +- appengine-java8/datastore-indexes/pom.xml | 2 +- appengine-java8/datastore-schedule-export/pom.xml | 2 +- appengine-java8/datastore/pom.xml | 2 +- appengine-java8/endpoints-v2-backend/pom.xml | 2 +- appengine-java8/endpoints-v2-guice/pom.xml | 2 +- appengine-java8/endpoints-v2-migration/pom.xml | 2 +- appengine-java8/endpoints-v2-skeleton/pom.xml | 2 +- appengine-java8/firebase-backend/pom.xml | 2 +- appengine-java8/firebase-event-proxy/pom.xml | 2 +- appengine-java8/firebase-tictactoe/pom.xml | 2 +- appengine-java8/gaeinfo/pom.xml | 2 +- appengine-java8/guestbook-cloud-datastore/pom.xml | 2 +- appengine-java8/helloworld/pom.xml | 2 +- appengine-java8/iap/pom.xml | 2 +- appengine-java8/images/pom.xml | 2 +- appengine-java8/mail/pom.xml | 2 +- appengine-java8/mailgun/pom.xml | 2 +- appengine-java8/mailjet/pom.xml | 2 +- appengine-java8/memcache/pom.xml | 2 +- appengine-java8/metadata/pom.xml | 2 +- appengine-java8/multitenancy/pom.xml | 2 +- appengine-java8/oauth2/pom.xml | 2 +- appengine-java8/pubsub/pom.xml | 2 +- appengine-java8/remote-server/pom.xml | 2 +- appengine-java8/requests/pom.xml | 2 +- appengine-java8/search/pom.xml | 2 +- appengine-java8/sendgrid/pom.xml | 2 +- appengine-java8/spanner/pom.xml | 2 +- appengine-java8/sparkjava-helloworld/pom.xml | 2 +- appengine-java8/springboot-helloworld/pom.xml | 2 +- appengine-java8/static-files/pom.xml | 2 +- appengine-java8/taskqueues-deferred/pom.xml | 2 +- appengine-java8/taskqueues-pull/pom.xml | 2 +- appengine-java8/taskqueues-push/pom.xml | 2 +- appengine-java8/tasks/app/pom.xml | 2 +- appengine-java8/tasks/quickstart/pom.xml | 2 +- appengine-java8/translate-pubsub/pom.xml | 2 +- appengine-java8/twilio/pom.xml | 2 +- appengine-java8/urlfetch/pom.xml | 2 +- appengine-java8/users/pom.xml | 2 +- cloud-sql/mysql/servlet/pom.xml | 2 +- cloud-sql/postgres/servlet/pom.xml | 2 +- cloud-sql/r2dbc/pom.xml | 2 +- cloud-sql/sqlserver/servlet/pom.xml | 2 +- endpoints/getting-started/pom.xml | 2 +- flexible/cloudsql/pom.xml | 2 +- flexible/gaeinfo/pom.xml | 2 +- flexible/helloworld-springboot/pom.xml | 2 +- flexible/postgres/pom.xml | 2 +- flexible/websocket-jetty/pom.xml | 2 +- flexible/websocket-jsr356/pom.xml | 2 +- memorystore/redis/pom.xml | 2 +- storage/xml-api/serviceaccount-appengine-sample/pom.xml | 2 +- unittests/pom.xml | 2 +- 75 files changed, 75 insertions(+), 75 deletions(-) diff --git a/appengine-java11-bundled-services/datastore/pom.xml b/appengine-java11-bundled-services/datastore/pom.xml index 6b05b4830b5..1c9d5ec64be 100644 --- a/appengine-java11-bundled-services/datastore/pom.xml +++ b/appengine-java11-bundled-services/datastore/pom.xml @@ -129,7 +129,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java11/cloudsql/pom.xml b/appengine-java11/cloudsql/pom.xml index 06be5c6ba5a..4227cfdc2a7 100644 --- a/appengine-java11/cloudsql/pom.xml +++ b/appengine-java11/cloudsql/pom.xml @@ -156,7 +156,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG cloudsql diff --git a/appengine-java11/gaeinfo/pom.xml b/appengine-java11/gaeinfo/pom.xml index 0b05b4ca69c..d73205a3363 100644 --- a/appengine-java11/gaeinfo/pom.xml +++ b/appengine-java11/gaeinfo/pom.xml @@ -84,7 +84,7 @@ Copyright 2019 Google LLC com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG gaeinfo diff --git a/appengine-java11/guestbook-cloud-firestore/pom.xml b/appengine-java11/guestbook-cloud-firestore/pom.xml index cc659d64be1..493914abf5b 100644 --- a/appengine-java11/guestbook-cloud-firestore/pom.xml +++ b/appengine-java11/guestbook-cloud-firestore/pom.xml @@ -94,7 +94,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG guestbook diff --git a/appengine-java11/helloworld-servlet/pom.xml b/appengine-java11/helloworld-servlet/pom.xml index 7fd26821f8d..a944824994f 100644 --- a/appengine-java11/helloworld-servlet/pom.xml +++ b/appengine-java11/helloworld-servlet/pom.xml @@ -70,7 +70,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG helloworld diff --git a/appengine-java11/http-server/pom.xml b/appengine-java11/http-server/pom.xml index 4a8724776d2..53a51c8dcbc 100644 --- a/appengine-java11/http-server/pom.xml +++ b/appengine-java11/http-server/pom.xml @@ -38,7 +38,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG http-server diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index f459f8ee62d..76f14cb0266 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -180,7 +180,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG kotlin-ktor diff --git a/appengine-java11/micronaut-helloworld/pom.xml b/appengine-java11/micronaut-helloworld/pom.xml index 22f7a0435d2..226c2801201 100644 --- a/appengine-java11/micronaut-helloworld/pom.xml +++ b/appengine-java11/micronaut-helloworld/pom.xml @@ -86,7 +86,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG micronaut-helloworld diff --git a/appengine-java11/oauth2/pom.xml b/appengine-java11/oauth2/pom.xml index 1ee5425b799..0b3d5956b7a 100644 --- a/appengine-java11/oauth2/pom.xml +++ b/appengine-java11/oauth2/pom.xml @@ -104,7 +104,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG oauth2 diff --git a/appengine-java11/quarkus-helloworld/pom.xml b/appengine-java11/quarkus-helloworld/pom.xml index 8841535d0a8..6e8a5bcbb5f 100644 --- a/appengine-java11/quarkus-helloworld/pom.xml +++ b/appengine-java11/quarkus-helloworld/pom.xml @@ -92,7 +92,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG quarkus-helloworld diff --git a/appengine-java11/spanner/pom.xml b/appengine-java11/spanner/pom.xml index b908c9b7846..d14382d263e 100644 --- a/appengine-java11/spanner/pom.xml +++ b/appengine-java11/spanner/pom.xml @@ -108,7 +108,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG spanner diff --git a/appengine-java11/sparkjava-helloworld/pom.xml b/appengine-java11/sparkjava-helloworld/pom.xml index 6969e3e012f..6cbfa144f30 100644 --- a/appengine-java11/sparkjava-helloworld/pom.xml +++ b/appengine-java11/sparkjava-helloworld/pom.xml @@ -101,7 +101,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG ${project.build.directory}/sparkjava-helloworld-1.0-jar-with-dependencies.jar diff --git a/appengine-java11/springboot-helloworld/pom.xml b/appengine-java11/springboot-helloworld/pom.xml index a186992352a..7abe625b9ef 100644 --- a/appengine-java11/springboot-helloworld/pom.xml +++ b/appengine-java11/springboot-helloworld/pom.xml @@ -92,7 +92,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG diff --git a/appengine-java8/endpoints-v2-guice/pom.xml b/appengine-java8/endpoints-v2-guice/pom.xml index abc997c222e..f4a55ac8e2a 100644 --- a/appengine-java8/endpoints-v2-guice/pom.xml +++ b/appengine-java8/endpoints-v2-guice/pom.xml @@ -99,7 +99,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG diff --git a/appengine-java8/endpoints-v2-migration/pom.xml b/appengine-java8/endpoints-v2-migration/pom.xml index 4ab47a77d67..11aa141c06c 100644 --- a/appengine-java8/endpoints-v2-migration/pom.xml +++ b/appengine-java8/endpoints-v2-migration/pom.xml @@ -71,7 +71,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG diff --git a/appengine-java8/endpoints-v2-skeleton/pom.xml b/appengine-java8/endpoints-v2-skeleton/pom.xml index d22847a5603..3efa3b52ce9 100644 --- a/appengine-java8/endpoints-v2-skeleton/pom.xml +++ b/appengine-java8/endpoints-v2-skeleton/pom.xml @@ -85,7 +85,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG diff --git a/appengine-java8/firebase-backend/pom.xml b/appengine-java8/firebase-backend/pom.xml index 7c0e8f7335b..73d28403472 100644 --- a/appengine-java8/firebase-backend/pom.xml +++ b/appengine-java8/firebase-backend/pom.xml @@ -116,7 +116,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/firebase-event-proxy/pom.xml b/appengine-java8/firebase-event-proxy/pom.xml index 5e5625d4e4a..d8f67e9c1fe 100644 --- a/appengine-java8/firebase-event-proxy/pom.xml +++ b/appengine-java8/firebase-event-proxy/pom.xml @@ -98,7 +98,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/firebase-tictactoe/pom.xml b/appengine-java8/firebase-tictactoe/pom.xml index 11ceca52975..7ce4e3c8207 100644 --- a/appengine-java8/firebase-tictactoe/pom.xml +++ b/appengine-java8/firebase-tictactoe/pom.xml @@ -121,7 +121,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/gaeinfo/pom.xml b/appengine-java8/gaeinfo/pom.xml index fd32e8fda75..00f1417fb5b 100644 --- a/appengine-java8/gaeinfo/pom.xml +++ b/appengine-java8/gaeinfo/pom.xml @@ -97,7 +97,7 @@ Copyright 2017 Google Inc. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/guestbook-cloud-datastore/pom.xml b/appengine-java8/guestbook-cloud-datastore/pom.xml index b3771dac67d..55fd8ab29e7 100644 --- a/appengine-java8/guestbook-cloud-datastore/pom.xml +++ b/appengine-java8/guestbook-cloud-datastore/pom.xml @@ -112,7 +112,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/helloworld/pom.xml b/appengine-java8/helloworld/pom.xml index 4e205977492..f7b8a247fb0 100644 --- a/appengine-java8/helloworld/pom.xml +++ b/appengine-java8/helloworld/pom.xml @@ -99,7 +99,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 myProjectId diff --git a/appengine-java8/iap/pom.xml b/appengine-java8/iap/pom.xml index 5525362fd6c..875731117e6 100644 --- a/appengine-java8/iap/pom.xml +++ b/appengine-java8/iap/pom.xml @@ -56,7 +56,7 @@ Copyright 2017 Google Inc. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/images/pom.xml b/appengine-java8/images/pom.xml index 28f47c5c7af..5648bc416a5 100644 --- a/appengine-java8/images/pom.xml +++ b/appengine-java8/images/pom.xml @@ -64,7 +64,7 @@ Copyright 2015 Google Inc. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/mail/pom.xml b/appengine-java8/mail/pom.xml index f1901e67467..f81a458d171 100644 --- a/appengine-java8/mail/pom.xml +++ b/appengine-java8/mail/pom.xml @@ -62,7 +62,7 @@ Copyright 2016 Google Inc. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/mailgun/pom.xml b/appengine-java8/mailgun/pom.xml index 6b142ccbae6..e7d76db1d72 100644 --- a/appengine-java8/mailgun/pom.xml +++ b/appengine-java8/mailgun/pom.xml @@ -68,7 +68,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/mailjet/pom.xml b/appengine-java8/mailjet/pom.xml index fbd00e18fd7..7d1de1b5f50 100644 --- a/appengine-java8/mailjet/pom.xml +++ b/appengine-java8/mailjet/pom.xml @@ -74,7 +74,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/memcache/pom.xml b/appengine-java8/memcache/pom.xml index 2173c0efc34..42e19904cad 100644 --- a/appengine-java8/memcache/pom.xml +++ b/appengine-java8/memcache/pom.xml @@ -64,7 +64,7 @@ Copyright 2015 Google Inc. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/metadata/pom.xml b/appengine-java8/metadata/pom.xml index b9d247f8f06..24153495676 100644 --- a/appengine-java8/metadata/pom.xml +++ b/appengine-java8/metadata/pom.xml @@ -92,7 +92,7 @@ Copyright 2017 Google Inc. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/multitenancy/pom.xml b/appengine-java8/multitenancy/pom.xml index d6031c0c2e2..5d5c4dc60c0 100644 --- a/appengine-java8/multitenancy/pom.xml +++ b/appengine-java8/multitenancy/pom.xml @@ -119,7 +119,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/oauth2/pom.xml b/appengine-java8/oauth2/pom.xml index eaf2167fbc0..72e838463e5 100644 --- a/appengine-java8/oauth2/pom.xml +++ b/appengine-java8/oauth2/pom.xml @@ -63,7 +63,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/pubsub/pom.xml b/appengine-java8/pubsub/pom.xml index 1d1a7b19465..f4bd15fd5f2 100644 --- a/appengine-java8/pubsub/pom.xml +++ b/appengine-java8/pubsub/pom.xml @@ -84,7 +84,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG diff --git a/appengine-java8/remote-server/pom.xml b/appengine-java8/remote-server/pom.xml index 0de916d1bc3..19f4711f7ce 100644 --- a/appengine-java8/remote-server/pom.xml +++ b/appengine-java8/remote-server/pom.xml @@ -64,7 +64,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/requests/pom.xml b/appengine-java8/requests/pom.xml index c39efea3a79..a253467d482 100644 --- a/appengine-java8/requests/pom.xml +++ b/appengine-java8/requests/pom.xml @@ -103,7 +103,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/search/pom.xml b/appengine-java8/search/pom.xml index 560c9595359..9676590e213 100644 --- a/appengine-java8/search/pom.xml +++ b/appengine-java8/search/pom.xml @@ -93,7 +93,7 @@ Copyright 2015 Google Inc. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/sendgrid/pom.xml b/appengine-java8/sendgrid/pom.xml index b1086e8dc6f..ef71be0d232 100644 --- a/appengine-java8/sendgrid/pom.xml +++ b/appengine-java8/sendgrid/pom.xml @@ -59,7 +59,7 @@ Copyright 2018 Google LLC com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/spanner/pom.xml b/appengine-java8/spanner/pom.xml index 19e01c23449..c3831740be2 100644 --- a/appengine-java8/spanner/pom.xml +++ b/appengine-java8/spanner/pom.xml @@ -99,7 +99,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/appengine-java8/sparkjava-helloworld/pom.xml b/appengine-java8/sparkjava-helloworld/pom.xml index 1ac2d9ccb02..2ec84155392 100644 --- a/appengine-java8/sparkjava-helloworld/pom.xml +++ b/appengine-java8/sparkjava-helloworld/pom.xml @@ -124,7 +124,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 myProjectId diff --git a/appengine-java8/springboot-helloworld/pom.xml b/appengine-java8/springboot-helloworld/pom.xml index fb6c574db11..1f1d724e5df 100644 --- a/appengine-java8/springboot-helloworld/pom.xml +++ b/appengine-java8/springboot-helloworld/pom.xml @@ -91,7 +91,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index 8e858c4c6b7..ec8d5245b44 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -105,7 +105,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/flexible/websocket-jetty/pom.xml b/flexible/websocket-jetty/pom.xml index 683d8dfb51a..9bf42d13c07 100644 --- a/flexible/websocket-jetty/pom.xml +++ b/flexible/websocket-jetty/pom.xml @@ -76,7 +76,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/flexible/websocket-jsr356/pom.xml b/flexible/websocket-jsr356/pom.xml index efe25e579a8..ddadb45b464 100644 --- a/flexible/websocket-jsr356/pom.xml +++ b/flexible/websocket-jsr356/pom.xml @@ -73,7 +73,7 @@ limitations under the License. com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG GCLOUD_CONFIG diff --git a/memorystore/redis/pom.xml b/memorystore/redis/pom.xml index 522bf78dd04..87b5af307c1 100644 --- a/memorystore/redis/pom.xml +++ b/memorystore/redis/pom.xml @@ -69,7 +69,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 diff --git a/storage/xml-api/serviceaccount-appengine-sample/pom.xml b/storage/xml-api/serviceaccount-appengine-sample/pom.xml index b0cf2659dfb..4c748d48656 100644 --- a/storage/xml-api/serviceaccount-appengine-sample/pom.xml +++ b/storage/xml-api/serviceaccount-appengine-sample/pom.xml @@ -71,7 +71,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG gaeinfo diff --git a/unittests/pom.xml b/unittests/pom.xml index bb5f910806c..ae2dc445efd 100644 --- a/unittests/pom.xml +++ b/unittests/pom.xml @@ -98,7 +98,7 @@ com.google.cloud.tools appengine-maven-plugin - 2.4.1 + 2.4.2 GCLOUD_CONFIG gaeinfo From eebc1d1f109f30d0333aad099abf1fa0a101d30c Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 18 Apr 2022 22:20:11 +0200 Subject: [PATCH 031/136] fix(deps): update dependency com.google.cloud:google-cloud-bigtable to v2.6.2 (#7034) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-bigtable](https://togithub.com/googleapis/java-bigtable) | `2.6.1` -> `2.6.2` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigtable/2.6.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigtable/2.6.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigtable/2.6.2/compatibility-slim/2.6.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigtable/2.6.2/confidence-slim/2.6.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-bigtable ### [`v2.6.2`](https://togithub.com/googleapis/java-bigtable/blob/HEAD/CHANGELOG.md#​262-httpsgithubcomgoogleapisjava-bigtablecomparev261v262-2022-04-15) [Compare Source](https://togithub.com/googleapis/java-bigtable/compare/v2.6.1...v2.6.2)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- bigtable/beam/bulk-data-generator/pom.xml | 2 +- bigtable/cassandra-migration-codelab/pom.xml | 2 +- bigtable/hbase/snippets/pom.xml | 2 +- bigtable/memorystore/pom.xml | 2 +- bigtable/scheduled-backups/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bigtable/beam/bulk-data-generator/pom.xml b/bigtable/beam/bulk-data-generator/pom.xml index c19ae8c9496..0bf5192dbe5 100644 --- a/bigtable/beam/bulk-data-generator/pom.xml +++ b/bigtable/beam/bulk-data-generator/pom.xml @@ -71,7 +71,7 @@ com.google.cloud google-cloud-bigtable - 2.6.1 + 2.6.2 diff --git a/bigtable/cassandra-migration-codelab/pom.xml b/bigtable/cassandra-migration-codelab/pom.xml index 6437c4ae136..9c714a17f69 100644 --- a/bigtable/cassandra-migration-codelab/pom.xml +++ b/bigtable/cassandra-migration-codelab/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-bigtable - 2.6.1 + 2.6.2 diff --git a/bigtable/hbase/snippets/pom.xml b/bigtable/hbase/snippets/pom.xml index 57d6c5af130..691e63ef1b2 100644 --- a/bigtable/hbase/snippets/pom.xml +++ b/bigtable/hbase/snippets/pom.xml @@ -45,7 +45,7 @@ com.google.cloud google-cloud-bigtable - 2.6.1 + 2.6.2 diff --git a/bigtable/memorystore/pom.xml b/bigtable/memorystore/pom.xml index 65f86e2dd1b..36b10b71abf 100644 --- a/bigtable/memorystore/pom.xml +++ b/bigtable/memorystore/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-bigtable - 2.6.1 + 2.6.2 diff --git a/bigtable/scheduled-backups/pom.xml b/bigtable/scheduled-backups/pom.xml index 1918efaa6ba..190e5417a90 100644 --- a/bigtable/scheduled-backups/pom.xml +++ b/bigtable/scheduled-backups/pom.xml @@ -51,7 +51,7 @@ limitations under the License. com.google.cloud google-cloud-bigtable - 2.6.1 + 2.6.2 com.fasterxml.jackson.core From eb0aa94d09d06bc73123fe71da86fbfad6461140 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Tue, 19 Apr 2022 22:11:17 +0530 Subject: [PATCH 032/136] added mvn surefire plugin --- compute/cloud-client/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index fba2d952da7..54d69154b49 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -65,6 +65,13 @@ pom 25.0.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M6 + maven-plugin + From 2fe9b4a0080cc81df19237cdf85679fe4898ca6a Mon Sep 17 00:00:00 2001 From: Ludovic Champenois Date: Wed, 20 Apr 2022 12:30:20 -0400 Subject: [PATCH 033/136] Add one Java17 bundled services sample, and generic README. (#6909) * Add one Java17 bundled services sample, and generic instructions to use the other java8 samples. * doc: add the mvn appengine:deployIndex step for deploying the datastore index file. doc: add the mvn appengine:deployIndex step for deploying the datastore index file. * Update README.md * Use symlinks to unchanged code from the Java8 sample. * Make symlinks ot unchanged code and fixed documentation and pom files. * ->java17 runtime. * Use symlinks to java8 files. --- appengine-java11-bundled-services/README.md | 26 ++- .../datastore/README.md | 5 +- appengine-java17-bundled-services/README.md | 92 +++++++++ .../datastore/README.md | 47 +++++ .../datastore/pom.xml | 175 ++++++++++++++++++ .../example/appengine/AbstractGuestbook.java | 1 + .../appengine/AbstractGuestbookServlet.java | 1 + .../java/com/example/appengine/Greeting.java | 1 + .../java/com/example/appengine/Guestbook.java | 1 + .../example/appengine/GuestbookServlet.java | 1 + .../example/appengine/GuestbookStrong.java | 1 + .../appengine/GuestbookStrongServlet.java | 1 + .../example/appengine/ListPeopleServlet.java | 1 + .../example/appengine/ProjectionServlet.java | 1 + .../com/example/appengine/StartupServlet.java | 1 + .../com/example/appengine/StatsServlet.java | 1 + .../src/main/java/com/example/time/Clock.java | 1 + .../java/com/example/time/SystemClock.java | 1 + .../com/example/time/testing/FakeClock.java | 1 + .../src/main/webapp/WEB-INF/appengine-web.xml | 17 ++ .../main/webapp/WEB-INF/datastore-indexes.xml | 1 + .../datastore/src/main/webapp/WEB-INF/web.xml | 1 + .../datastore/src/main/webapp/guestbook.jsp | 1 + .../com/example/appengine/EntitiesTest.java | 1 + .../appengine/GuestbookStrongTest.java | 1 + .../com/example/appengine/GuestbookTest.java | 1 + .../com/example/appengine/IndexesTest.java | 1 + .../appengine/ListPeopleServletTest.java | 1 + .../appengine/MetadataEntityGroupTest.java | 1 + .../example/appengine/MetadataKindsTest.java | 1 + .../appengine/MetadataNamespacesTest.java | 1 + .../appengine/MetadataPropertiesTest.java | 1 + .../appengine/ProjectionServletTest.java | 1 + .../com/example/appengine/ProjectionTest.java | 1 + .../com/example/appengine/QueriesTest.java | 1 + .../com/example/appengine/ReadPolicyTest.java | 1 + .../example/appengine/StartupServletTest.java | 1 + .../example/appengine/TransactionsTest.java | 1 + 38 files changed, 376 insertions(+), 18 deletions(-) create mode 100644 appengine-java17-bundled-services/README.md create mode 100644 appengine-java17-bundled-services/datastore/README.md create mode 100644 appengine-java17-bundled-services/datastore/pom.xml create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbook.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbookServlet.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Greeting.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Guestbook.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookServlet.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrong.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrongServlet.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ListPeopleServlet.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ProjectionServlet.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StartupServlet.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StatsServlet.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/time/Clock.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/time/SystemClock.java create mode 120000 appengine-java17-bundled-services/datastore/src/main/java/com/example/time/testing/FakeClock.java create mode 100644 appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/appengine-web.xml create mode 120000 appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/datastore-indexes.xml create mode 120000 appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/web.xml create mode 120000 appengine-java17-bundled-services/datastore/src/main/webapp/guestbook.jsp create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/EntitiesTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookStrongTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/IndexesTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ListPeopleServletTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataEntityGroupTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataKindsTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataNamespacesTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataPropertiesTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionServletTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/QueriesTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ReadPolicyTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/StartupServletTest.java create mode 120000 appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/TransactionsTest.java diff --git a/appengine-java11-bundled-services/README.md b/appengine-java11-bundled-services/README.md index e07e46db7c9..dfd651aced4 100644 --- a/appengine-java11-bundled-services/README.md +++ b/appengine-java11-bundled-services/README.md @@ -49,10 +49,8 @@ where you need to define the Java11 runtime and declare you need the App Engine ``` -While the Java11 runtime is in Beta, in order to deploy the application, you can use the `beta` value for the `gcloudMode` Cloud SDK parameter like: - ```shell - mvn appengine:deploy -Dapp.deploy.gcloudMode=beta + mvn appengine:deploy ``` @@ -72,17 +70,17 @@ This sample demonstrates how to use the App Engine Datastore APIs in a Java11 we You can execute the following steps to transform the java8 appengine-web.xml file to a java11 appengine-web.xml file: - ```shell - git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git - cd java-docs-samples - cp -pr appengine-java8 /tmp/java11-samples - cd /tmp/java11-samples - # On Linux: - shopt -s globstar dotglob - for f in **/appengine-web.xml; do sed -i 's.java8.java11true.' ${f}; done - # on MacOS - for f in **/appengine-web.xml; do sed -i'' -e 's.java8.java11true.' ${f}; done - ``` +```shell +git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git +cd java-docs-samples +cp -pr appengine-java8 /tmp/java11-samples +cd /tmp/java11-samples +# On Linux: +shopt -s globstar dotglob +for f in **/appengine-web.xml; do sed -i 's.java8.java11true.' ${f}; done +# on MacOS +for f in **/appengine-web.xml; do sed -i'' -e 's.java8.java11true.' ${f}; done + ``` You will see in the `tmp/java11` directory all the correct code samples to compile and deploy to the Java11 AppEngine runtime, with bundled services. Just follow the same documentation as the [Java8 samples][java8-samples]. diff --git a/appengine-java11-bundled-services/datastore/README.md b/appengine-java11-bundled-services/datastore/README.md index 38fe704b9f8..bbf66ef0e81 100644 --- a/appengine-java11-bundled-services/datastore/README.md +++ b/appengine-java11-bundled-services/datastore/README.md @@ -39,10 +39,7 @@ To see the results of the sample application, open ## Deploying -In the following command, replace YOUR-PROJECT-ID with your -[Google Cloud Project ID](https://developers.google.com/console/help/new/#projectnumber) -and SOME-VERSION with a valid version number. - ```sh mvn clean package appengine:deploy +mvn appengine:deployIndex ``` diff --git a/appengine-java17-bundled-services/README.md b/appengine-java17-bundled-services/README.md new file mode 100644 index 00000000000..1997d076b92 --- /dev/null +++ b/appengine-java17-bundled-services/README.md @@ -0,0 +1,92 @@ +# Google App Engine Standard Environment Samples for Java 17 Bundled Services + +This is a repository that contains Java code samples for [Google App Engine +standard environment Java 17 Bundled Services][ae-docs]. +The Google App Engine standard environment Java 17 Bundled Services is an environment +as close as possible as the original Google App Engine standard environment Java 8 +which is using WAR packaging, GAE APIs and configured via appengine-web.xml instead of app.yaml + +[ae-docs]: https://cloud.google.com/appengine/docs/standard/java-gen2/services/access + +## Prerequisites + +### Download Maven + +These samples use the [Apache Maven][maven] build system. Before getting +started, be sure to [download][maven-download] and [install][maven-install] it. +When you use Maven as described here, it will automatically download the needed +client libraries. + +[maven]: https://maven.apache.org +[maven-download]: https://maven.apache.org/download.cgi +[maven-install]: https://maven.apache.org/install.html +[java8-samples]: https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/appengine-java8#readme + +### Create a Project in the Google Cloud Platform Console + +If you haven't already created a project, create one now. Projects enable you to +manage all Google Cloud Platform resources for your app, including deployment, +access control, billing, and services. + +1. Open the [Cloud Platform Console][cloud-console]. +1. In the drop-down menu at the top, select **Create a project**. +1. Give your project a name. +1. Make a note of the project ID, which might be different from the project + name. The project ID is used in commands and in configurations. + +[cloud-console]: https://console.cloud.google.com/ + + +## Development differences between App Engine Java8 and Java17 Bundled Services + +The only difference between a Java8 application and a Java17 application is in the `appengine-web.xml` file +where you need to define the Java17 runtime and declare you need the App Engine APIs: + +```XML + + java17 + true + +``` + +While the Java17 runtime is in Beta, in order to deploy the application, you can use the `beta` value for the `gcloudMode` Cloud SDK parameter like: + +```shell + mvn appengine:deploy -Dapp.deploy.gcloudMode=beta + mvn appengine:deployIndex +``` + + +Everything else should remain the same in terms of App Engine APIs access, WAR project packaging, and deployment. +This way, it should be easy to migrate your existing GAE Java8 applications to GAE Java17. + +## Samples + +### App Engine Datastore with Java17 + +This sample demonstrates how to use the App Engine Datastore APIs in a Java17 web application on Google App Engine Java17. + +- [Documentation][ae-docs] +- [Code](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/appengine-standard-java11-bunded-services/datastore) + +### How to change an App Engine Java 8 application to App Engine Java17 bundled services + +You can execute the following steps to transform the java8 appengine-web.xml file to a java17 appengine-web.xml file: + +```shell +git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git +cd java-docs-samples +cp -pr appengine-java8 /tmp/java17-samples +cd /tmp/java17-samples +# On Linux: +shopt -s globstar dotglob +for f in **/appengine-web.xml; do sed -i 's.java8.java17true.' ${f}; done +# on MacOS +for f in **/appengine-web.xml; do sed -i'' -e 's.java8.java17true.' ${f}; done +``` + +You will see in the `tmp/java17` directory all the correct code samples to compile and deploy to the Java17 AppEngine runtime, with bundled services. +Just follow the same documentation as the [Java8 samples][java8-samples]. + + + diff --git a/appengine-java17-bundled-services/datastore/README.md b/appengine-java17-bundled-services/datastore/README.md new file mode 100644 index 00000000000..908cb6f6dd2 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/README.md @@ -0,0 +1,47 @@ +# Google Cloud Datastore Sample for App Engine Standard Java17 Bundled Services + + +Open in Cloud Shell + +This sample demonstrates how to use [Google Cloud Datastore][java-datastore] +from [Google App Engine standard Java17 bundled services environment][ae-docs]. + +[java-datastore]: https://cloud.google.com/appengine/docs/java/datastore/ +[ae-docs]: https://cloud.google.com/appengine/docs/standard/java-gen2/services/access + +## Difference between App Engine Java8 and Java17 Bundled Services + +The only difference between a Java8 application and a Java17 application is in the `appengine-web.xml` file +where you need to define the Java17 runtime and declare you need the App Engine APIs: + +```XML + + java17 + true + +``` + +Everything else should remain the same in terms of App Engine APIs access, WAR project packaging, and deployment. +This way, it should be easy to migrate your existing GAE Java8 applications to GAE Java17. + +## Running locally + +This example uses the +[Cloud SDK Maven plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven). +To run this sample locally: + +```sh +mvn package appengine:run +``` +To see the results of the sample application, open +[localhost:8080](http://localhost:8080) in a web browser. + + +## Deploying + + +```sh +mvn clean package appengine:deploy -Dapp.deploy.gcloudMode=beta +mvn appengine:deployIndex + +``` \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/pom.xml b/appengine-java17-bundled-services/datastore/pom.xml new file mode 100644 index 00000000000..82e42a8afe3 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/pom.xml @@ -0,0 +1,175 @@ + + + + 4.0.0 + war + 1.0-SNAPSHOT + com.example.appengine + appengine-datastore-j17 + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 11 + 11 + + + + + com.google.appengine + appengine-api-1.0-sdk + 2.0.4 + + + + javax.servlet + javax.servlet-api + 3.1.0 + jar + provided + + + + com.google.auto.value + auto-value + 1.9 + provided + + + + com.google.auto.value + auto-value-annotations + 1.9 + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + + com.google.guava + guava + 31.0.1-jre + + + + joda-time + joda-time + 2.10.13 + + + + + junit + junit + 4.13.2 + test + + + org.mockito + mockito-all + 1.10.19 + test + + + + com.google.appengine + appengine-testing + 2.0.4 + test + + + com.google.appengine + appengine-api-stubs + 2.0.4 + test + + + com.google.appengine + appengine-tools-sdk + 2.0.4 + test + + + com.google.truth + truth + 1.1.3 + test + + + + + + ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + + maven-war-plugin + 3.3.1 + + + default-war + package + + war + + + + + + com.google.cloud.tools + appengine-maven-plugin + 2.4.1 + + GCLOUD_CONFIG + GCLOUD_CONFIG + beta + true + true + + + + + maven-compiler-plugin + 3.8.1 + + + + com.google.auto.value + auto-value + 1.9 + + + + + + org.eclipse.jetty + jetty-maven-plugin + 9.4.44.v20210927 + + + + diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbook.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbook.java new file mode 120000 index 00000000000..59b8bfc0057 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbook.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/AbstractGuestbook.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbookServlet.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbookServlet.java new file mode 120000 index 00000000000..a91e7e09658 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/AbstractGuestbookServlet.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/AbstractGuestbookServlet.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Greeting.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Greeting.java new file mode 120000 index 00000000000..9c59e2047b8 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Greeting.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/Greeting.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Guestbook.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Guestbook.java new file mode 120000 index 00000000000..2e3d8e4b664 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/Guestbook.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/Guestbook.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookServlet.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookServlet.java new file mode 120000 index 00000000000..752427a8057 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookServlet.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/GuestbookServlet.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrong.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrong.java new file mode 120000 index 00000000000..fef89e36ba8 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrong.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/GuestbookStrong.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrongServlet.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrongServlet.java new file mode 120000 index 00000000000..f2d53752473 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/GuestbookStrongServlet.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/GuestbookStrongServlet.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ListPeopleServlet.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ListPeopleServlet.java new file mode 120000 index 00000000000..fc42fbc3dcd --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ListPeopleServlet.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/ListPeopleServlet.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ProjectionServlet.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ProjectionServlet.java new file mode 120000 index 00000000000..ceb105b6acf --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/ProjectionServlet.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/ProjectionServlet.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StartupServlet.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StartupServlet.java new file mode 120000 index 00000000000..eae75ba9016 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StartupServlet.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/StartupServlet.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StatsServlet.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StatsServlet.java new file mode 120000 index 00000000000..6502647321e --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StatsServlet.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/appengine/StatsServlet.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/Clock.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/Clock.java new file mode 120000 index 00000000000..2413e2ddc58 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/Clock.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/time/Clock.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/SystemClock.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/SystemClock.java new file mode 120000 index 00000000000..4193c4824ac --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/SystemClock.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/main/java/com/example/time/SystemClock.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/testing/FakeClock.java b/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/testing/FakeClock.java new file mode 120000 index 00000000000..b963230e3c4 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/java/com/example/time/testing/FakeClock.java @@ -0,0 +1 @@ +../../../../../../../../../appengine-java8/datastore/src/main/java/com/example/time/testing/FakeClock.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/appengine-web.xml b/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/appengine-web.xml new file mode 100644 index 00000000000..d934ac71f3a --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/appengine-web.xml @@ -0,0 +1,17 @@ + + + + java17 + true + diff --git a/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/datastore-indexes.xml b/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/datastore-indexes.xml new file mode 120000 index 00000000000..73f343b36e4 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/datastore-indexes.xml @@ -0,0 +1 @@ +../../../../../../appengine-java8/datastore/src/main/webapp/WEB-INF/datastore-indexes.xml \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/web.xml b/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/web.xml new file mode 120000 index 00000000000..6c846cab2a4 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1 @@ +../../../../../../appengine-java8/datastore/src/main/webapp/WEB-INF/web.xml \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/main/webapp/guestbook.jsp b/appengine-java17-bundled-services/datastore/src/main/webapp/guestbook.jsp new file mode 120000 index 00000000000..dc4c9b4a240 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/main/webapp/guestbook.jsp @@ -0,0 +1 @@ +../../../../../appengine-java8/datastore/src/main/webapp/guestbook.jsp \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/EntitiesTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/EntitiesTest.java new file mode 120000 index 00000000000..6acecc301aa --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/EntitiesTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/EntitiesTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookStrongTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookStrongTest.java new file mode 120000 index 00000000000..3541f8f82bb --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookStrongTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/GuestbookStrongTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookTest.java new file mode 120000 index 00000000000..015e621216b --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/GuestbookTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/GuestbookTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/IndexesTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/IndexesTest.java new file mode 120000 index 00000000000..2530a9646f2 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/IndexesTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/IndexesTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ListPeopleServletTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ListPeopleServletTest.java new file mode 120000 index 00000000000..e32bdc25149 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ListPeopleServletTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/ListPeopleServletTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataEntityGroupTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataEntityGroupTest.java new file mode 120000 index 00000000000..97be437f7c1 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataEntityGroupTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/MetadataEntityGroupTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataKindsTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataKindsTest.java new file mode 120000 index 00000000000..aedd248bc2b --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataKindsTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/MetadataKindsTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataNamespacesTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataNamespacesTest.java new file mode 120000 index 00000000000..02eea767d46 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataNamespacesTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/MetadataNamespacesTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataPropertiesTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataPropertiesTest.java new file mode 120000 index 00000000000..d94057bf260 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/MetadataPropertiesTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/MetadataPropertiesTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionServletTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionServletTest.java new file mode 120000 index 00000000000..f442793b9c6 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionServletTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/ProjectionServletTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionTest.java new file mode 120000 index 00000000000..99cd3ef139a --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ProjectionTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/ProjectionTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/QueriesTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/QueriesTest.java new file mode 120000 index 00000000000..2b4c7b4c7fc --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/QueriesTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/QueriesTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ReadPolicyTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ReadPolicyTest.java new file mode 120000 index 00000000000..84a38cfa093 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/ReadPolicyTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/ReadPolicyTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/StartupServletTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/StartupServletTest.java new file mode 120000 index 00000000000..cc898f78bbb --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/StartupServletTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/StartupServletTest.java \ No newline at end of file diff --git a/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/TransactionsTest.java b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/TransactionsTest.java new file mode 120000 index 00000000000..8c3e828ead3 --- /dev/null +++ b/appengine-java17-bundled-services/datastore/src/test/java/com/example/appengine/TransactionsTest.java @@ -0,0 +1 @@ +../../../../../../../../appengine-java8/datastore/src/test/java/com/example/appengine/TransactionsTest.java \ No newline at end of file From 7bf11e10712dab3d4e36efffa49eada3c94735d0 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 18:16:00 +0200 Subject: [PATCH 034/136] chore(deps): update kotlin.version to v1.6.21 (#7035) --- functions/helloworld/kotlin-hello-pubsub/pom.xml | 2 +- functions/helloworld/kotlin-helloworld/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/helloworld/kotlin-hello-pubsub/pom.xml b/functions/helloworld/kotlin-hello-pubsub/pom.xml index c92ed4359ff..27960306fd6 100644 --- a/functions/helloworld/kotlin-hello-pubsub/pom.xml +++ b/functions/helloworld/kotlin-hello-pubsub/pom.xml @@ -34,7 +34,7 @@ 11 11 UTF-8 - 1.6.20 + 1.6.21 diff --git a/functions/helloworld/kotlin-helloworld/pom.xml b/functions/helloworld/kotlin-helloworld/pom.xml index 6906a675618..d5a34a7f53f 100644 --- a/functions/helloworld/kotlin-helloworld/pom.xml +++ b/functions/helloworld/kotlin-helloworld/pom.xml @@ -37,7 +37,7 @@ 11 11 UTF-8 - 1.6.20 + 1.6.21 From d8d210ed1f69c2454908da494226661f15382396 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 18:16:14 +0200 Subject: [PATCH 035/136] chore(deps): update quarkus.version to v2.8.1.final (#7036) --- appengine-java11/quarkus-helloworld/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/quarkus-helloworld/pom.xml b/appengine-java11/quarkus-helloworld/pom.xml index 6e8a5bcbb5f..0fbe6c580dd 100644 --- a/appengine-java11/quarkus-helloworld/pom.xml +++ b/appengine-java11/quarkus-helloworld/pom.xml @@ -32,7 +32,7 @@ limitations under the License. 2.22.2 11 11 - 2.8.0.Final + 2.8.1.Final UTF-8 From 817086524e20e6060938f0468f4068a03aae2288 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 18:56:15 +0200 Subject: [PATCH 036/136] fix(deps): update dependency com.google.cloud:google-cloud-policy-troubleshooter to v1.0.4 (#7045) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-policy-troubleshooter](https://togithub.com/googleapis/java-policy-troubleshooter) | `1.0.3` -> `1.0.4` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-policy-troubleshooter/1.0.4/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-policy-troubleshooter/1.0.4/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-policy-troubleshooter/1.0.4/compatibility-slim/1.0.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-policy-troubleshooter/1.0.4/confidence-slim/1.0.3)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-policy-troubleshooter ### [`v1.0.4`](https://togithub.com/googleapis/java-policy-troubleshooter/blob/HEAD/CHANGELOG.md#​104-httpsgithubcomgoogleapisjava-policy-troubleshootercomparev103v104-2022-04-15) [Compare Source](https://togithub.com/googleapis/java-policy-troubleshooter/compare/v1.0.3...v1.0.4)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- iam/api-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iam/api-client/pom.xml b/iam/api-client/pom.xml index 0949fd37bc7..a4a41613434 100644 --- a/iam/api-client/pom.xml +++ b/iam/api-client/pom.xml @@ -71,7 +71,7 @@ com.google.cloud google-cloud-policy-troubleshooter - 1.0.3 + 1.0.4 From 28ba2bb55aa85e3a11ea015250f69cd4e79ffc2d Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 18:58:14 +0200 Subject: [PATCH 037/136] fix(deps): update dependency com.google.cloud:google-cloud-tasks to v2.1.11 (#7047) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-tasks](https://togithub.com/googleapis/java-tasks) | `2.1.10` -> `2.1.11` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-tasks/2.1.11/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-tasks/2.1.11/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-tasks/2.1.11/compatibility-slim/2.1.10)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-tasks/2.1.11/confidence-slim/2.1.10)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-tasks ### [`v2.1.11`](https://togithub.com/googleapis/java-tasks/blob/HEAD/CHANGELOG.md#​2111-httpsgithubcomgoogleapisjava-taskscomparev2110v2111-2022-04-15) [Compare Source](https://togithub.com/googleapis/java-tasks/compare/v2.1.10...v2.1.11)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java8/tasks/app/pom.xml | 2 +- appengine-java8/tasks/quickstart/pom.xml | 2 +- appengine-java8/tasks/snippets/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appengine-java8/tasks/app/pom.xml b/appengine-java8/tasks/app/pom.xml index ab11fc138ab..fd63ab96d42 100644 --- a/appengine-java8/tasks/app/pom.xml +++ b/appengine-java8/tasks/app/pom.xml @@ -50,7 +50,7 @@ Copyright 2019 Google LLC com.google.cloud google-cloud-tasks - 2.1.10 + 2.1.11 diff --git a/appengine-java8/tasks/quickstart/pom.xml b/appengine-java8/tasks/quickstart/pom.xml index 8974144e17a..9da543949dc 100644 --- a/appengine-java8/tasks/quickstart/pom.xml +++ b/appengine-java8/tasks/quickstart/pom.xml @@ -52,7 +52,7 @@ Copyright 2018 Google LLC com.google.cloud google-cloud-tasks - 2.1.10 + 2.1.11 commons-cli diff --git a/appengine-java8/tasks/snippets/pom.xml b/appengine-java8/tasks/snippets/pom.xml index 5e0c5d7d402..ab710c00020 100644 --- a/appengine-java8/tasks/snippets/pom.xml +++ b/appengine-java8/tasks/snippets/pom.xml @@ -44,7 +44,7 @@ Copyright 2019 Google LLC com.google.cloud google-cloud-tasks - 2.1.10 + 2.1.11 com.google.protobuf From 3052a44c9921ee41ec59c5bac0363c6c34662cb1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 18:58:18 +0200 Subject: [PATCH 038/136] fix(deps): update dependency com.google.cloud:google-cloud-workflow-executions to v2.1.7 (#7048) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-workflow-executions](https://togithub.com/googleapis/java-workflow-executions) | `2.1.6` -> `2.1.7` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflow-executions/2.1.7/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflow-executions/2.1.7/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflow-executions/2.1.7/compatibility-slim/2.1.6)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-workflow-executions/2.1.7/confidence-slim/2.1.6)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-workflow-executions ### [`v2.1.7`](https://togithub.com/googleapis/java-workflow-executions/blob/HEAD/CHANGELOG.md#​217-httpsgithubcomgoogleapisjava-workflow-executionscomparev216v217-2022-04-15) [Compare Source](https://togithub.com/googleapis/java-workflow-executions/compare/v2.1.6...v2.1.7)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- workflows/cloud-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflows/cloud-client/pom.xml b/workflows/cloud-client/pom.xml index de3aee2e25a..80d75224b57 100644 --- a/workflows/cloud-client/pom.xml +++ b/workflows/cloud-client/pom.xml @@ -59,7 +59,7 @@ limitations under the License. com.google.cloud google-cloud-workflow-executions - 2.1.6 + 2.1.7 From d8606f869b9470123977450bda1d329c2c25c630 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 19:00:18 +0200 Subject: [PATCH 039/136] fix(deps): update dependency com.google.cloud:google-cloud-dialogflow-cx to v0.12.1 (#7043) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-dialogflow-cx](https://togithub.com/googleapis/java-dialogflow-cx) | `0.12.0` -> `0.12.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-dialogflow-cx/0.12.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-dialogflow-cx/0.12.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-dialogflow-cx/0.12.1/compatibility-slim/0.12.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-dialogflow-cx/0.12.1/confidence-slim/0.12.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-dialogflow-cx ### [`v0.12.1`](https://togithub.com/googleapis/java-dialogflow-cx/blob/HEAD/CHANGELOG.md#​0121-httpsgithubcomgoogleapisjava-dialogflow-cxcomparev0120v0121-2022-04-18) [Compare Source](https://togithub.com/googleapis/java-dialogflow-cx/compare/v0.12.0...v0.12.1)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- dialogflow/basic-webhook/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dialogflow/basic-webhook/pom.xml b/dialogflow/basic-webhook/pom.xml index b6c67f0e10e..08d0a0e5b35 100644 --- a/dialogflow/basic-webhook/pom.xml +++ b/dialogflow/basic-webhook/pom.xml @@ -35,7 +35,7 @@ com.google.cloud google-cloud-dialogflow-cx - 0.12.0 + 0.12.1 com.google.code.gson From 80b17d82852a2950202f24ef15d05b400d788ed6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 19:14:39 +0200 Subject: [PATCH 040/136] fix(deps): update dependency com.google.cloud:google-cloud-pubsub to v1.116.4 (#7046) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-pubsub](https://togithub.com/googleapis/java-pubsub) | `1.116.3` -> `1.116.4` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-pubsub/1.116.4/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-pubsub/1.116.4/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-pubsub/1.116.4/compatibility-slim/1.116.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-pubsub/1.116.4/confidence-slim/1.116.3)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-pubsub ### [`v1.116.4`](https://togithub.com/googleapis/java-pubsub/blob/HEAD/CHANGELOG.md#​11164-httpsgithubcomgoogleapisjava-pubsubcomparev11163v11164-2022-04-19) [Compare Source](https://togithub.com/googleapis/java-pubsub/compare/v1.116.3...v1.116.4)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- flexible/pubsub/pom.xml | 2 +- iot/api-client/codelab/manager/pom.xml | 2 +- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flexible/pubsub/pom.xml b/flexible/pubsub/pom.xml index 94a80271da8..d484f2d649b 100644 --- a/flexible/pubsub/pom.xml +++ b/flexible/pubsub/pom.xml @@ -64,7 +64,7 @@ com.google.cloud google-cloud-pubsub - 1.116.3 + 1.116.4 com.google.cloud diff --git a/iot/api-client/codelab/manager/pom.xml b/iot/api-client/codelab/manager/pom.xml index bc7004c2ba5..5ca3aae1e17 100644 --- a/iot/api-client/codelab/manager/pom.xml +++ b/iot/api-client/codelab/manager/pom.xml @@ -72,7 +72,7 @@ com.google.cloud google-cloud-pubsub - 1.116.3 + 1.116.4 com.google.cloud diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index 9458095b054..1ece8f1ccfd 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -63,7 +63,7 @@ com.google.cloud google-cloud-pubsub - 1.116.3 + 1.116.4 com.google.auth diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index 0e2151930af..abc1525861a 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -67,7 +67,7 @@ com.google.cloud google-cloud-pubsub - 1.116.3 + 1.116.4 com.google.cloud From 15873c3e71f141bd61a60d89c2e3bf84e7a41896 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 19:51:49 +0200 Subject: [PATCH 041/136] chore(deps): update dependency org.jetbrains.kotlin:kotlin-maven-plugin to v1.6.21 (#7039) --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index 76f14cb0266..437d9cb5fd2 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -123,7 +123,7 @@ limitations under the License. kotlin-maven-plugin org.jetbrains.kotlin - 1.6.20 + 1.6.21 compile From cf7ecde6f21ea5ffb265be3b8eae12b1db7eee70 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 19:52:04 +0200 Subject: [PATCH 042/136] chore(deps): update dependency org.mockito:mockito-core to v4.5.1 (#7050) --- appengine-java11/cloudsql/pom.xml | 2 +- appengine-java8/analytics/pom.xml | 2 +- appengine-java8/bigquery/pom.xml | 2 +- appengine-java8/helloworld/pom.xml | 2 +- appengine-java8/taskqueues-deferred/pom.xml | 2 +- cloud-sql/mysql/servlet/pom.xml | 2 +- cloud-sql/postgres/servlet/pom.xml | 2 +- cloud-sql/sqlserver/servlet/pom.xml | 2 +- .../vulnerability-notification-function/pom.xml | 2 +- dialogflow/basic-webhook/pom.xml | 2 +- functions/concepts/after-timeout/pom.xml | 2 +- functions/concepts/env-vars/pom.xml | 2 +- functions/concepts/execution-count/pom.xml | 4 ++-- functions/concepts/file-system/pom.xml | 2 +- functions/concepts/lazy-fields/pom.xml | 2 +- functions/concepts/retry-pubsub/pom.xml | 2 +- functions/concepts/retry-timeout/pom.xml | 2 +- functions/concepts/scopes/pom.xml | 2 +- functions/firebase/firestore-reactive/pom.xml | 2 +- functions/helloworld/groovy-helloworld/pom.xml | 2 +- functions/helloworld/hello-http-gradle/build.gradle | 2 +- functions/helloworld/hello-http/pom.xml | 2 +- functions/helloworld/helloworld-gradle/build.gradle | 2 +- functions/helloworld/helloworld/pom.xml | 2 +- functions/helloworld/kotlin-helloworld/pom.xml | 2 +- functions/helloworld/scala-helloworld/pom.xml | 2 +- functions/http/cors-enabled-auth/pom.xml | 2 +- functions/http/cors-enabled/pom.xml | 2 +- functions/http/http-form-data/pom.xml | 2 +- functions/http/http-method/pom.xml | 2 +- functions/http/parse-content-type/pom.xml | 2 +- functions/http/parse-xml/pom.xml | 2 +- functions/http/send-http-request/pom.xml | 2 +- functions/pubsub/publish-message/pom.xml | 2 +- functions/slack/pom.xml | 2 +- functions/spanner/pom.xml | 2 +- 36 files changed, 37 insertions(+), 37 deletions(-) diff --git a/appengine-java11/cloudsql/pom.xml b/appengine-java11/cloudsql/pom.xml index 4227cfdc2a7..491217afb1d 100644 --- a/appengine-java11/cloudsql/pom.xml +++ b/appengine-java11/cloudsql/pom.xml @@ -92,7 +92,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/appengine-java8/analytics/pom.xml b/appengine-java8/analytics/pom.xml index 5995c98599d..34b087b0986 100644 --- a/appengine-java8/analytics/pom.xml +++ b/appengine-java8/analytics/pom.xml @@ -87,7 +87,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/appengine-java8/bigquery/pom.xml b/appengine-java8/bigquery/pom.xml index 89cabb5ba25..2a0faba1d38 100644 --- a/appengine-java8/bigquery/pom.xml +++ b/appengine-java8/bigquery/pom.xml @@ -94,7 +94,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/appengine-java8/helloworld/pom.xml b/appengine-java8/helloworld/pom.xml index f7b8a247fb0..cab223542d5 100644 --- a/appengine-java8/helloworld/pom.xml +++ b/appengine-java8/helloworld/pom.xml @@ -87,7 +87,7 @@ limitations under the License. org.mockito mockito-core - 4.4.0 + 4.5.1 test
diff --git a/appengine-java8/taskqueues-deferred/pom.xml b/appengine-java8/taskqueues-deferred/pom.xml index c647c23e5b0..6dc18ce4cc8 100644 --- a/appengine-java8/taskqueues-deferred/pom.xml +++ b/appengine-java8/taskqueues-deferred/pom.xml @@ -66,7 +66,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 com.google.appengine diff --git a/cloud-sql/mysql/servlet/pom.xml b/cloud-sql/mysql/servlet/pom.xml index 0ffc5709b88..6568a0d8408 100644 --- a/cloud-sql/mysql/servlet/pom.xml +++ b/cloud-sql/mysql/servlet/pom.xml @@ -77,7 +77,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/cloud-sql/postgres/servlet/pom.xml b/cloud-sql/postgres/servlet/pom.xml index c4db05901f2..348a6c4dad6 100644 --- a/cloud-sql/postgres/servlet/pom.xml +++ b/cloud-sql/postgres/servlet/pom.xml @@ -67,7 +67,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/cloud-sql/sqlserver/servlet/pom.xml b/cloud-sql/sqlserver/servlet/pom.xml index d52efad4e60..2d6a7fe46f4 100644 --- a/cloud-sql/sqlserver/servlet/pom.xml +++ b/cloud-sql/sqlserver/servlet/pom.xml @@ -67,7 +67,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/container-registry/vulnerability-notification-function/pom.xml b/container-registry/vulnerability-notification-function/pom.xml index 988b260aac7..3c96669e0b7 100644 --- a/container-registry/vulnerability-notification-function/pom.xml +++ b/container-registry/vulnerability-notification-function/pom.xml @@ -68,7 +68,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test
diff --git a/dialogflow/basic-webhook/pom.xml b/dialogflow/basic-webhook/pom.xml index 08d0a0e5b35..b9221fc6139 100644 --- a/dialogflow/basic-webhook/pom.xml +++ b/dialogflow/basic-webhook/pom.xml @@ -62,7 +62,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/after-timeout/pom.xml b/functions/concepts/after-timeout/pom.xml index fe9bcabda2e..a04d890f70f 100644 --- a/functions/concepts/after-timeout/pom.xml +++ b/functions/concepts/after-timeout/pom.xml @@ -61,7 +61,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/env-vars/pom.xml b/functions/concepts/env-vars/pom.xml index ea1d4137b33..6135b52d424 100644 --- a/functions/concepts/env-vars/pom.xml +++ b/functions/concepts/env-vars/pom.xml @@ -55,7 +55,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/execution-count/pom.xml b/functions/concepts/execution-count/pom.xml index dccb3e8e926..cf1ec5853b1 100644 --- a/functions/concepts/execution-count/pom.xml +++ b/functions/concepts/execution-count/pom.xml @@ -55,7 +55,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test @@ -68,7 +68,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/file-system/pom.xml b/functions/concepts/file-system/pom.xml index 650fb337137..10032288559 100644 --- a/functions/concepts/file-system/pom.xml +++ b/functions/concepts/file-system/pom.xml @@ -55,7 +55,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/lazy-fields/pom.xml b/functions/concepts/lazy-fields/pom.xml index c37ff0980f3..b446a676772 100644 --- a/functions/concepts/lazy-fields/pom.xml +++ b/functions/concepts/lazy-fields/pom.xml @@ -55,7 +55,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/retry-pubsub/pom.xml b/functions/concepts/retry-pubsub/pom.xml index 2dded79704c..bd80719ebc7 100644 --- a/functions/concepts/retry-pubsub/pom.xml +++ b/functions/concepts/retry-pubsub/pom.xml @@ -69,7 +69,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/retry-timeout/pom.xml b/functions/concepts/retry-timeout/pom.xml index c9316662539..3b71aa15f3f 100644 --- a/functions/concepts/retry-timeout/pom.xml +++ b/functions/concepts/retry-timeout/pom.xml @@ -68,7 +68,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/concepts/scopes/pom.xml b/functions/concepts/scopes/pom.xml index 6d6163373d5..65068856812 100644 --- a/functions/concepts/scopes/pom.xml +++ b/functions/concepts/scopes/pom.xml @@ -55,7 +55,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/firebase/firestore-reactive/pom.xml b/functions/firebase/firestore-reactive/pom.xml index 389615da5f8..50df17981d8 100644 --- a/functions/firebase/firestore-reactive/pom.xml +++ b/functions/firebase/firestore-reactive/pom.xml @@ -71,7 +71,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/helloworld/groovy-helloworld/pom.xml b/functions/helloworld/groovy-helloworld/pom.xml index 763ee431026..90109716056 100644 --- a/functions/helloworld/groovy-helloworld/pom.xml +++ b/functions/helloworld/groovy-helloworld/pom.xml @@ -61,7 +61,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/helloworld/hello-http-gradle/build.gradle b/functions/helloworld/hello-http-gradle/build.gradle index 0b5f8ae154b..ccb1333c222 100644 --- a/functions/helloworld/hello-http-gradle/build.gradle +++ b/functions/helloworld/hello-http-gradle/build.gradle @@ -32,7 +32,7 @@ dependencies { testImplementation 'com.google.cloud.functions:functions-framework-api:1.0.4' testImplementation 'junit:junit:4.13.2' testImplementation 'com.google.truth:truth:1.1.3' - testImplementation 'org.mockito:mockito-core:4.4.0' + testImplementation 'org.mockito:mockito-core:4.5.1' } jar { diff --git a/functions/helloworld/hello-http/pom.xml b/functions/helloworld/hello-http/pom.xml index 0beb1ce7e0b..cbc8c0228ae 100644 --- a/functions/helloworld/hello-http/pom.xml +++ b/functions/helloworld/hello-http/pom.xml @@ -89,7 +89,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/helloworld/helloworld-gradle/build.gradle b/functions/helloworld/helloworld-gradle/build.gradle index e1987d1e70d..a3741bf10a9 100644 --- a/functions/helloworld/helloworld-gradle/build.gradle +++ b/functions/helloworld/helloworld-gradle/build.gradle @@ -38,7 +38,7 @@ dependencies { testImplementation 'com.google.cloud.functions:functions-framework-api:1.0.4' testImplementation 'junit:junit:4.13.2' testImplementation 'com.google.truth:truth:1.1.3' - testImplementation 'org.mockito:mockito-core:4.4.0' + testImplementation 'org.mockito:mockito-core:4.5.1' // [START functions_example_pom_dependencies] // [START functions_gradle_add_dependencies] diff --git a/functions/helloworld/helloworld/pom.xml b/functions/helloworld/helloworld/pom.xml index 3acecf97f7a..cfefa22fa7c 100644 --- a/functions/helloworld/helloworld/pom.xml +++ b/functions/helloworld/helloworld/pom.xml @@ -71,7 +71,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/helloworld/kotlin-helloworld/pom.xml b/functions/helloworld/kotlin-helloworld/pom.xml index d5a34a7f53f..8489013a09d 100644 --- a/functions/helloworld/kotlin-helloworld/pom.xml +++ b/functions/helloworld/kotlin-helloworld/pom.xml @@ -65,7 +65,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/helloworld/scala-helloworld/pom.xml b/functions/helloworld/scala-helloworld/pom.xml index abc76c2bc65..be052ba5bcf 100644 --- a/functions/helloworld/scala-helloworld/pom.xml +++ b/functions/helloworld/scala-helloworld/pom.xml @@ -59,7 +59,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/http/cors-enabled-auth/pom.xml b/functions/http/cors-enabled-auth/pom.xml index 6165450d449..03e978b70a2 100644 --- a/functions/http/cors-enabled-auth/pom.xml +++ b/functions/http/cors-enabled-auth/pom.xml @@ -61,7 +61,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/http/cors-enabled/pom.xml b/functions/http/cors-enabled/pom.xml index 1c3fb440c5d..ba979ff1843 100644 --- a/functions/http/cors-enabled/pom.xml +++ b/functions/http/cors-enabled/pom.xml @@ -61,7 +61,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/http/http-form-data/pom.xml b/functions/http/http-form-data/pom.xml index 139612e1e8b..74f569067c9 100644 --- a/functions/http/http-form-data/pom.xml +++ b/functions/http/http-form-data/pom.xml @@ -67,7 +67,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/http/http-method/pom.xml b/functions/http/http-method/pom.xml index baaa94f8b5e..05aeb2fa008 100644 --- a/functions/http/http-method/pom.xml +++ b/functions/http/http-method/pom.xml @@ -60,7 +60,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/http/parse-content-type/pom.xml b/functions/http/parse-content-type/pom.xml index e047f5a7b8a..550c7bf9cad 100644 --- a/functions/http/parse-content-type/pom.xml +++ b/functions/http/parse-content-type/pom.xml @@ -66,7 +66,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/http/parse-xml/pom.xml b/functions/http/parse-xml/pom.xml index 10b16049dbe..1dd5d139718 100644 --- a/functions/http/parse-xml/pom.xml +++ b/functions/http/parse-xml/pom.xml @@ -66,7 +66,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/http/send-http-request/pom.xml b/functions/http/send-http-request/pom.xml index 4a44b13fa4b..27e57ea0c8b 100644 --- a/functions/http/send-http-request/pom.xml +++ b/functions/http/send-http-request/pom.xml @@ -61,7 +61,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/pubsub/publish-message/pom.xml b/functions/pubsub/publish-message/pom.xml index 85cf7a03847..3ca6c722a13 100644 --- a/functions/pubsub/publish-message/pom.xml +++ b/functions/pubsub/publish-message/pom.xml @@ -83,7 +83,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/slack/pom.xml b/functions/slack/pom.xml index 0ea896ae4d4..e94d08f85d9 100644 --- a/functions/slack/pom.xml +++ b/functions/slack/pom.xml @@ -90,7 +90,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test diff --git a/functions/spanner/pom.xml b/functions/spanner/pom.xml index 224db35bb44..8f8049c3899 100644 --- a/functions/spanner/pom.xml +++ b/functions/spanner/pom.xml @@ -66,7 +66,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.1 test From f39b1cc1c5ff2fd0783072dadec1619e016854e5 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 21 Apr 2022 19:52:16 +0200 Subject: [PATCH 043/136] fix(deps): update apache beam packages to v2.38.0 (#7051) --- bigtable/beam/bulk-data-generator/pom.xml | 2 +- bigtable/beam/helloworld/pom.xml | 2 +- bigtable/beam/keyviz-art/pom.xml | 2 +- bigtable/beam/workload-generator/pom.xml | 2 +- dataflow/encryption-keys/pom.xml | 2 +- dataflow/flex-templates/kafka_to_bigquery/pom.xml | 2 +- dataflow/flex-templates/streaming_beam_sql/pom.xml | 2 +- dataflow/spanner-io/pom.xml | 2 +- dataflow/templates/pom.xml | 2 +- pubsub/streaming-analytics/build.gradle | 2 +- pubsub/streaming-analytics/pom.xml | 2 +- pubsublite/streaming-analytics/build.gradle | 2 +- pubsublite/streaming-analytics/pom.xml | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bigtable/beam/bulk-data-generator/pom.xml b/bigtable/beam/bulk-data-generator/pom.xml index 0bf5192dbe5..2806128fd92 100644 --- a/bigtable/beam/bulk-data-generator/pom.xml +++ b/bigtable/beam/bulk-data-generator/pom.xml @@ -26,7 +26,7 @@ 8 8 - 2.37.0 + 2.38.0 If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- iam/api-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iam/api-client/pom.xml b/iam/api-client/pom.xml index a4a41613434..7b2aad23ffc 100644 --- a/iam/api-client/pom.xml +++ b/iam/api-client/pom.xml @@ -56,7 +56,7 @@ com.google.apis google-api-services-iam - v1-rev20220331-1.32.1 + v1-rev20220413-1.32.1 From 58de7485d9f39f88584db24e06208cb70eac9282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Fri, 22 Apr 2022 18:20:52 +0200 Subject: [PATCH 048/136] deps: use libraries bom for Spanner JDBC samples (#7052) --- spanner/jdbc/pom.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/spanner/jdbc/pom.xml b/spanner/jdbc/pom.xml index 51ed06262d3..cba5528504d 100644 --- a/spanner/jdbc/pom.xml +++ b/spanner/jdbc/pom.xml @@ -28,7 +28,7 @@ com.google.cloud libraries-bom - 25.0.0 + 25.1.0 pom import @@ -41,12 +41,6 @@ com.google.cloud google-cloud-spanner-jdbc - 2.5.11 - - - com.google.cloud - google-cloud-spanner - 6.17.3 From 6391fbae3307338e7991e801479601dabf461deb Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Mon, 25 Apr 2022 22:16:45 +0530 Subject: [PATCH 049/136] updated mvn surefire config --- compute/cloud-client/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 54d69154b49..c09c0feb7ba 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -71,6 +71,11 @@ maven-surefire-plugin 3.0.0-M6 maven-plugin + + + *IT.java + + From 05288ff3720fac2105874d8fe97d32b43e26b731 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Mon, 25 Apr 2022 22:18:42 +0530 Subject: [PATCH 050/136] updated mvn surefire config --- compute/cloud-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index c09c0feb7ba..c7f2b83abfe 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -73,7 +73,7 @@ maven-plugin - *IT.java + **/*IT.java From f5a473b48429baae1838bfac0d55bca831c0d920 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Mon, 25 Apr 2022 22:25:10 +0530 Subject: [PATCH 051/136] updated mvn surefire plugin --- compute/cloud-client/pom.xml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index c7f2b83abfe..17fcddaaa9d 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -65,18 +65,6 @@ pom 25.0.0 - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M6 - maven-plugin - - - **/*IT.java - - - @@ -100,4 +88,19 @@ 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M6 + + + **/*IT.java + + + + + + From e1665d4569e5eb71f5ba970bdd612f7f8fd02250 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Mon, 25 Apr 2022 11:02:11 -0700 Subject: [PATCH 052/136] chore: update to ktor 2.0 (#7053) Fixes #issue > It's a good idea to open an issue first for discussion. - [ ] I have followed [Sample Format Guide](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md) - [ ] `pom.xml` parent set to latest `shared-configuration` - [ ] Appropriate changes to README are included in PR - [ ] API's need to be enabled to test (tell us) - [ ] Environment Variables need to be set (ask us to set them) - [ ] **Tests** pass: `mvn clean verify` **required** - [ ] **Lint** passes: `mvn -P lint checkstyle:check` **required** - [ ] **Static Analysis**: `mvn -P lint clean compile pmd:cpd-check spotbugs:check` **advisory only** - [ ] Please **merge** this PR for me once it is approved. --- appengine-java11/kotlin-ktor/app.yaml | 1 - appengine-java11/kotlin-ktor/pom.xml | 212 ++++++++---------- .../com/example/appengine}/Application.kt | 22 +- .../src/main/resources/application.conf | 26 +++ .../src/main/resources/logback.xml | 12 + .../kotlin-ktor/src/test/ApplicationTest.kt | 35 +++ 6 files changed, 178 insertions(+), 130 deletions(-) rename appengine-java11/kotlin-ktor/src/{ => main/kotlin/com/example/appengine}/Application.kt (67%) create mode 100644 appengine-java11/kotlin-ktor/src/main/resources/application.conf create mode 100644 appengine-java11/kotlin-ktor/src/main/resources/logback.xml create mode 100644 appengine-java11/kotlin-ktor/src/test/ApplicationTest.kt diff --git a/appengine-java11/kotlin-ktor/app.yaml b/appengine-java11/kotlin-ktor/app.yaml index 7d200ea8834..ad7258b8290 100644 --- a/appengine-java11/kotlin-ktor/app.yaml +++ b/appengine-java11/kotlin-ktor/app.yaml @@ -13,4 +13,3 @@ # limitations under the License. runtime: java11 -entrypoint: 'java -jar target/kotlin-ktor-0.0.1-jar-with-dependencies.jar' diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index 703f2df60fb..9013f81622c 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -31,151 +31,133 @@ limitations under the License. + 11 + 11 + 2.0.0 official + 1.6.21 + 1.2.3 UTF-8 true - io.ktor.server.netty.EngineMain - 11 - 11 + com.example.appengine.ApplicationKt - repo1 - https://jcenter.bintray.com - true - false - - - repo2 - https://kotlin.bintray.com/ktor - true - false + ktor_eap + https://maven.pkg.jetbrains.space/public/p/ktor/eap + + true + + + true + - - - - io.ktor - ktor-bom - 1.6.8 - pom - import - - - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - 1.6.21 - - - io.ktor - ktor-server-netty - - - ch.qos.logback - logback-classic - 1.3.0-alpha11 + io.ktor + ktor-server-core-jvm + ${ktor_version} - io.ktor - ktor-server-core + io.ktor + ktor-server-netty-jvm + ${ktor_version} - io.ktor - ktor-server-host-common + ch.qos.logback + logback-classic + ${logback_version} - io.ktor - ktor-server-tests - test + io.ktor + ktor-server-tests-jvm + ${ktor_version} + test - org.jetbrains.kotlin - kotlin-test-junit - 1.6.21 - test + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin_version} + test - - - - - ${project.basedir}/src - ${project.basedir}/test + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin - - ${project.basedir}/resources - + + ${project.basedir}/src/main/resources + + - - org.apache.maven.plugins - maven-surefire-plugin - - - maven-compiler-plugin - 1.81.8 - - - kotlin-maven-plugin - org.jetbrains.kotlin - 1.6.21 - - - compile - compile + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin_version} - enable + 1.8 - - - test-compile - test-compile + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + java + + + - enable + ${main.class} - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.2 - - - - true - ${main.class} - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.3.0 - - - make-assembly - package - single + + + org.apache.maven.plugins + maven-assembly-plugin + 2.6 - - - ${main.class} - - - - jar-with-dependencies - + + jar-with-dependencies + + + + true + ${main.class} + + - - - + + + assemble-all + package + + single + + + +
com.google.cloud.tools diff --git a/appengine-java11/kotlin-ktor/src/Application.kt b/appengine-java11/kotlin-ktor/src/main/kotlin/com/example/appengine/Application.kt similarity index 67% rename from appengine-java11/kotlin-ktor/src/Application.kt rename to appengine-java11/kotlin-ktor/src/main/kotlin/com/example/appengine/Application.kt index c5d623b1cba..3325d31456c 100644 --- a/appengine-java11/kotlin-ktor/src/Application.kt +++ b/appengine-java11/kotlin-ktor/src/main/kotlin/com/example/appengine/Application.kt @@ -14,22 +14,16 @@ package com.example.appengine -import io.ktor.application.Application -import io.ktor.application.call -import io.ktor.application.install import io.ktor.http.ContentType -import io.ktor.response.respondText -import io.ktor.routing.get -import io.ktor.routing.routing -import io.ktor.server.engine.ShutDownUrl -import io.ktor.server.netty.EngineMain +import io.ktor.server.application.* +import io.ktor.server.engine.* +import io.ktor.server.response.* +import io.ktor.server.routing.* -fun main(args: Array): Unit = EngineMain.main(args) +fun main(args: Array): Unit = io.ktor.server.netty.EngineMain.main(args) -@Suppress("unused") // Referenced in application.conf -@kotlin.jvm.JvmOverloads -fun Application.module(testing: Boolean = false) { - install(ShutDownUrl.ApplicationCallFeature) { +fun Application.module() { + install(ShutDownUrl.ApplicationCallPlugin) { // The URL that will be intercepted. You can also use the // application.conf's ktor.deployment.shutdown.url key. shutDownUrl = "/_ah/stop" @@ -37,10 +31,10 @@ fun Application.module(testing: Boolean = false) { // A function that will be executed to get the exit code of the process exitCodeSupplier = { 0 } // ApplicationCall.() -> Int } - routing { get("/") { call.respondText("Hello World!", contentType = ContentType.Text.Plain) } } } + diff --git a/appengine-java11/kotlin-ktor/src/main/resources/application.conf b/appengine-java11/kotlin-ktor/src/main/resources/application.conf new file mode 100644 index 00000000000..4cd0bfa8317 --- /dev/null +++ b/appengine-java11/kotlin-ktor/src/main/resources/application.conf @@ -0,0 +1,26 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ktor { + deployment { + port = 8080 + port = ${?PORT} + + shutdown.url = "/_ah/stop" + } + application { + modules = [ com.example.appengine.ApplicationKt.module ] + } +} + diff --git a/appengine-java11/kotlin-ktor/src/main/resources/logback.xml b/appengine-java11/kotlin-ktor/src/main/resources/logback.xml new file mode 100644 index 00000000000..bdbb64ec4ba --- /dev/null +++ b/appengine-java11/kotlin-ktor/src/main/resources/logback.xml @@ -0,0 +1,12 @@ + + + + %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/appengine-java11/kotlin-ktor/src/test/ApplicationTest.kt b/appengine-java11/kotlin-ktor/src/test/ApplicationTest.kt new file mode 100644 index 00000000000..9450ef165bd --- /dev/null +++ b/appengine-java11/kotlin-ktor/src/test/ApplicationTest.kt @@ -0,0 +1,35 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.example.appengine + +import io.ktor.server.http.HttpMethod +import io.ktor.server.http.HttpStatusCode +import io.ktor.server.testing.handleRequest +import io.ktor.server.testing.withTestApplication +import kotlin.test.Test +import kotlin.test.assertEquals + +class ApplicationTest { + @Test + fun testRoot() { + withTestApplication({ module(testing = true) }) { + handleRequest(HttpMethod.Get, "/").apply { + assertEquals(HttpStatusCode.OK, response.status()) + assertEquals("Hello World!", response.content) + } + } + } +} + From e1be27499bf8ea2199fa2db48205a429c06495df Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Tue, 26 Apr 2022 00:38:14 +0530 Subject: [PATCH 053/136] updated comments --- .../CreateFirewallRuleForWindowsActivationHost.java | 5 ++++- .../CreateRouteToWindowsActivationHost.java | 7 ++++--- .../CreateWindowsServerInstanceExternalIp.java | 2 ++ .../CreateWindowsServerInstanceInternalIp.java | 2 ++ .../windows/windowsinstances/GetInstanceSerialPort.java | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java index fad6b990b5c..1c5f0b6d748 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java @@ -48,11 +48,13 @@ public static void main(String[] args) public static void createFirewallRuleForWindowsActivationHost(String projectId, String firewallRuleName, String networkName) throws IOException, ExecutionException, InterruptedException { - + // Instantiates a client. try (FirewallsClient firewallsClient = FirewallsClient.create()) { Firewall firewall = Firewall.newBuilder() .setName(firewallRuleName) + // These are the default values for kms.windows.googlecloud.com + // See, https://cloud.google.com/compute/docs/instances/windows/creating-managing-windows-instances#firewall_rule_requirements .addAllowed(Allowed.newBuilder() .setIPProtocol("tcp") .addPorts("1688") @@ -68,6 +70,7 @@ public static void createFirewallRuleForWindowsActivationHost(String projectId, .setFirewallResource(firewall) .build(); + // Wait for the operation to complete. Operation operation = firewallsClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java index 1d58512626e..cd2169bce03 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java @@ -46,20 +46,20 @@ public static void main(String[] args) public static void createRouteToWindowsActivationHost(String projectId, String routeName, String networkName) throws IOException, ExecutionException, InterruptedException { - + // Instantiates a client. try (RoutesClient routesClient = RoutesClient.create()) { // If you have Windows instances without external IP addresses, // you must also enable Private Google Access so that instances // with only internal IP addresses can send traffic to the external // IP address for kms.windows.googlecloud.com. - // More infromation: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling + // More information: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling Route route = Route.newBuilder() .setName(routeName) .setDestRange("35.190.247.13/32") .setNetwork(networkName) .setNextHopGateway( - String.format("project/%s/global/gateways/default-internet-gateway", projectId)) + String.format("projects/%s/global/gateways/default-internet-gateway", projectId)) .build(); InsertRouteRequest request = InsertRouteRequest.newBuilder() @@ -67,6 +67,7 @@ public static void createRouteToWindowsActivationHost(String projectId, String r .setRouteResource(route) .build(); + // Wait for the operation to complete. Operation operation = routesClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java index 3ba17fa5d87..237b741abdd 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java @@ -59,6 +59,7 @@ public static void createWindowsServerInstanceExternalIp(String projectId, Strin // * https://cloud.google.com/compute/docs/images#os-compute-support String sourceImageFamily = "windows-2012-r2"; + // Instantiates a client. try (InstancesClient instancesClient = InstancesClient.create()) { AttachedDisk attachedDisk = AttachedDisk.newBuilder() @@ -103,6 +104,7 @@ public static void createWindowsServerInstanceExternalIp(String projectId, Strin .setInstanceResource(instance) .build(); + // Wait for the operation to complete. Operation operation = instancesClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java index eca8eefec29..8338f7bd72d 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java @@ -69,6 +69,7 @@ public static void createWindowsServerInstanceInternalIp(String projectId, Strin // * https://cloud.google.com/compute/docs/images#os-compute-support String sourceImageFamily = "windows-2012-r2"; + // Instantiates a client. try (InstancesClient instancesClient = InstancesClient.create()) { AttachedDisk attachedDisk = AttachedDisk.newBuilder() @@ -114,6 +115,7 @@ public static void createWindowsServerInstanceInternalIp(String projectId, Strin .setInstanceResource(instance) .build(); + // Wait for the operation to complete. Operation operation = instancesClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java index 689dabfd207..6a60d644003 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java @@ -39,7 +39,7 @@ public static void main(String[] args) throws IOException { // Prints an instance serial port output. public static void getInstanceSerialPort(String projectId, String zone, String instanceName) throws IOException { - + // Instantiates a client. try (InstancesClient instancesClient = InstancesClient.create()) { SerialPortOutput serialPortOutput = instancesClient.getSerialPortOutput(projectId, zone, From 71fbf039eb99d80f03a2cef2bfc4981b25e16d97 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Tue, 26 Apr 2022 00:38:39 +0530 Subject: [PATCH 054/136] modified param value --- .../CreatingManagingWindowsInstancesIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java index 090780f29d9..566b293b5cb 100644 --- a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java +++ b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java @@ -69,8 +69,8 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx INSTANCE_NAME_EXTERNAL = "windows-test-instance-external-" + uuid; INSTANCE_NAME_INTERNAL = "windows-test-instance-internal-" + uuid; FIREWALL_RULE_NAME = "windows-test-firewall-" + uuid; - NETWORK_NAME = "global/networks/default-compute"; - SUBNETWORK_NAME = "regions/europe-central2/subnetworks/default-compute"; + NETWORK_NAME = "global/networks/default"; + SUBNETWORK_NAME = "regions/europe-central2/subnetworks/default"; ROUTE_NAME = "windows-test-route-" + uuid; stdOut.close(); @@ -115,7 +115,7 @@ public void testCreateWindowsServerInstanceInternalIp() INSTANCE_NAME_INTERNAL, NETWORK_NAME, SUBNETWORK_NAME); assertThat(stdOut.toString()).contains("Instance created " + INSTANCE_NAME_INTERNAL); CreateFirewallRuleForWindowsActivationHost.createFirewallRuleForWindowsActivationHost( - PROJECT_ID, ZONE, NETWORK_NAME); + PROJECT_ID, FIREWALL_RULE_NAME, NETWORK_NAME); assertThat(stdOut.toString()).contains( String.format("Firewall rule created %s", FIREWALL_RULE_NAME)); CreateRouteToWindowsActivationHost.createRouteToWindowsActivationHost(PROJECT_ID, ROUTE_NAME, From cfd0de6e28e56de977ff56ba5f1427427d715777 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 19:51:50 +0200 Subject: [PATCH 055/136] fix(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-1.x to v2.1.1 (#7060) --- bigtable/hbase/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigtable/hbase/snippets/pom.xml b/bigtable/hbase/snippets/pom.xml index 691e63ef1b2..ad17bb2c1d8 100644 --- a/bigtable/hbase/snippets/pom.xml +++ b/bigtable/hbase/snippets/pom.xml @@ -51,7 +51,7 @@ com.google.cloud.bigtable bigtable-hbase-1.x - 2.1.0 + 2.1.1 From 66e7c9d5d0f6d8f129cd84aa12f89b2936506ca1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 19:52:00 +0200 Subject: [PATCH 056/136] fix(deps): update dependency ch.qos.logback:logback-classic to v1.2.11 (#7059) --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index 9013f81622c..ec2eb906a88 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -36,7 +36,7 @@ limitations under the License. 2.0.0 official 1.6.21 - 1.2.3 + 1.2.11 UTF-8 true com.example.appengine.ApplicationKt From 28191a40bff9dada6210efac7f3e9bb3919f3d6d Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 19:52:10 +0200 Subject: [PATCH 057/136] chore(deps): update quarkus.version to v2.8.2.final (#7058) --- appengine-java11/quarkus-helloworld/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/quarkus-helloworld/pom.xml b/appengine-java11/quarkus-helloworld/pom.xml index 0fbe6c580dd..1660212f092 100644 --- a/appengine-java11/quarkus-helloworld/pom.xml +++ b/appengine-java11/quarkus-helloworld/pom.xml @@ -32,7 +32,7 @@ limitations under the License. 2.22.2 11 11 - 2.8.1.Final + 2.8.2.Final UTF-8 From b9bcfe2b834f367beecf079d6be2add20f40a741 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 19:52:20 +0200 Subject: [PATCH 058/136] chore(deps): update ktor_version to v2.0.1-eap-377 (#7057) --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index ec2eb906a88..5296b8c0990 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -33,7 +33,7 @@ limitations under the License. 11 11 - 2.0.0 + 2.0.1-eap-377 official 1.6.21 1.2.11 From f576ba8c87ea4228b0fc24f3faf6a13fb469d055 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 19:52:42 +0200 Subject: [PATCH 059/136] fix(deps): update dependency com.google.cloud:google-cloud-kms to v2.4.4 (#7044) --- kms/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kms/pom.xml b/kms/pom.xml index 95c32887deb..39cf7c9b92a 100644 --- a/kms/pom.xml +++ b/kms/pom.xml @@ -25,7 +25,7 @@ com.google.cloud google-cloud-kms - 2.4.3 + 2.4.4 From 023cec0b7bd1945de55f34e58cacfe74af40362e Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:00:07 +0200 Subject: [PATCH 060/136] chore(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-2.x-hadoop to v2.1.1 (#7056) * chore(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-2.x-hadoop to v2.1.1 * test: fix jobs test Fixes #7024 Co-authored-by: Emily Ball --- bigtable/spark/build.sbt | 2 +- jobs/v3/src/test/java/SampleTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bigtable/spark/build.sbt b/bigtable/spark/build.sbt index fff2e974c37..016f5e59190 100644 --- a/bigtable/spark/build.sbt +++ b/bigtable/spark/build.sbt @@ -22,7 +22,7 @@ version := "0.1" // https://cloud.google.com/dataproc/docs/concepts/versioning/dataproc-release-1.4 scalaVersion := "2.11.12" val sparkVersion = "2.4.8" -val bigtableVersion = "2.1.0" +val bigtableVersion = "2.1.1" val hbaseVersion = "2.4.9" libraryDependencies ++= Seq( diff --git a/jobs/v3/src/test/java/SampleTests.java b/jobs/v3/src/test/java/SampleTests.java index 48099d514da..287f9c8eac4 100644 --- a/jobs/v3/src/test/java/SampleTests.java +++ b/jobs/v3/src/test/java/SampleTests.java @@ -54,7 +54,7 @@ public void autoCompleteSampleTest() throws Exception { assertThat(bout.toString()) .containsMatch( ".*completionResults.*\"suggestion\":" - + "\"Google Search\",\"type\":\"COMPANY_NAME\"}.*\n" + + "\"Google.*\",\"type\":\"COMPANY_NAME\"}.*\n" + ".*completionResults.*\"suggestion\"" + ":\"Software Engineer\",\"type\":\"JOB_TITLE\".*\n" + ".*completionResults.*\"suggestion\"" From a5421d8b5bd115f06b795c2d22da87c1a987a370 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:00:16 +0200 Subject: [PATCH 061/136] fix(deps): update dependency com.google.cloud:google-cloud-monitoring to v3.2.9 (#7063) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-monitoring](https://togithub.com/googleapis/java-monitoring) | `3.2.8` -> `3.2.9` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-monitoring/3.2.9/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-monitoring/3.2.9/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-monitoring/3.2.9/compatibility-slim/3.2.8)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-monitoring/3.2.9/confidence-slim/3.2.8)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-monitoring ### [`v3.2.9`](https://togithub.com/googleapis/java-monitoring/blob/HEAD/CHANGELOG.md#​329-httpsgithubcomgoogleapisjava-monitoringcomparev328v329-2022-04-22) [Compare Source](https://togithub.com/googleapis/java-monitoring/compare/v3.2.8...v3.2.9)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java8/bigquery/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java8/bigquery/pom.xml b/appengine-java8/bigquery/pom.xml index 2a0faba1d38..2a24e6d5022 100644 --- a/appengine-java8/bigquery/pom.xml +++ b/appengine-java8/bigquery/pom.xml @@ -57,7 +57,7 @@ com.google.cloud google-cloud-monitoring - 3.2.8 + 3.2.9 From b7fe7f0421c57ab81a7b36cbadf1395483c99793 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:00:20 +0200 Subject: [PATCH 062/136] fix(deps): update dependency org.springdoc:springdoc-openapi-ui to v1.6.8 (#7067) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.springdoc:springdoc-openapi-ui](https://springdoc.org/) ([source](https://togithub.com/springdoc/springdoc-openapi)) | `1.6.7` -> `1.6.8` | [![age](https://badges.renovateapi.com/packages/maven/org.springdoc:springdoc-openapi-ui/1.6.8/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.springdoc:springdoc-openapi-ui/1.6.8/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.springdoc:springdoc-openapi-ui/1.6.8/compatibility-slim/1.6.7)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.springdoc:springdoc-openapi-ui/1.6.8/confidence-slim/1.6.7)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
springdoc/springdoc-openapi ### [`v1.6.8`](https://togithub.com/springdoc/springdoc-openapi/blob/HEAD/CHANGELOG.md#​168---2022-04-22) [Compare Source](https://togithub.com/springdoc/springdoc-openapi/compare/v1.6.7...v1.6.8) ##### Added - [#​1616](https://togithub.com/springdoc/springdoc-openapi/issues/1616) - Add global customizer and filters - [#​1620](https://togithub.com/springdoc/springdoc-openapi/issues/1620) - Allow ComposedSchemas to replace non-composed so we can respect polymorphic links discovered in later methods - [#​1579](https://togithub.com/springdoc/springdoc-openapi/issues/1579) - Updated class and method javadoc handling ##### Changed - upgrade to spring-boot 2.6.7 - [#​1603](https://togithub.com/springdoc/springdoc-openapi/issues/1603) - Update swagger-ui path from /swaggerui to /swagger-ui when using management port (actuator) . - Prefer ComposedSchemas over non-composed so that method name order doesn't prevent polymorphic links generating into the spec ##### Fixed - [#​1621](https://togithub.com/springdoc/springdoc-openapi/issues/1621) - Redirection to UI broken with query-config-enabled when any other boolean parameter is defined. - [#​1617](https://togithub.com/springdoc/springdoc-openapi/issues/1617) - spring cloud stream crashes at startup. - [#​1605](https://togithub.com/springdoc/springdoc-openapi/issues/1605) - spring-native NullPointerException due to missing TypeHint
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- run/endpoints-v2-backend/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/endpoints-v2-backend/pom.xml b/run/endpoints-v2-backend/pom.xml index 1513c7d953a..db48b1ce74f 100755 --- a/run/endpoints-v2-backend/pom.xml +++ b/run/endpoints-v2-backend/pom.xml @@ -58,7 +58,7 @@ limitations under the License. org.springdoc springdoc-openapi-ui - 1.6.7 + 1.6.8 org.springframework.boot From f06baeeba4bc856022ef23258ecdad3c76acecad Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:00:24 +0200 Subject: [PATCH 063/136] chore(deps): update artifact (#7068) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [io.grpc:protoc-gen-grpc-java](https://togithub.com/grpc/grpc-java) | `1.45.1` -> `1.46.0` | [![age](https://badges.renovateapi.com/packages/maven/io.grpc:protoc-gen-grpc-java/1.46.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/io.grpc:protoc-gen-grpc-java/1.46.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/io.grpc:protoc-gen-grpc-java/1.46.0/compatibility-slim/1.45.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/io.grpc:protoc-gen-grpc-java/1.46.0/confidence-slim/1.45.1)](https://docs.renovatebot.com/merge-confidence/) | | [com.google.protobuf:protoc](https://developers.google.com/protocol-buffers/) ([source](https://togithub.com/protocolbuffers/protobuf)) | `3.20.0` -> `3.20.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protoc/3.20.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protoc/3.20.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protoc/3.20.1/compatibility-slim/3.20.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protoc/3.20.1/confidence-slim/3.20.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
grpc/grpc-java ### [`v1.46.0`](https://togithub.com/grpc/grpc-java/compare/v1.45.1...v1.46.0)
protocolbuffers/protobuf ### [`v3.20.1`](https://togithub.com/protocolbuffers/protobuf/releases/v3.20.1) ### PHP - Fix building packaged PHP extension ([#​9727](https://togithub.com/protocolbuffers/protobuf/issues/9727)) - Fixed composer.json to only advertise compatibility with PHP 7.0+. ([#​9819](https://togithub.com/protocolbuffers/protobuf/issues/9819)) ### Ruby - Disable the aarch64 build on macOS until it can be fixed. ([#​9816](https://togithub.com/protocolbuffers/protobuf/issues/9816)) ### Other - Fix versioning issues in 3.20.0
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- endpoints/bookstore-grpc/api/build.gradle | 4 ++-- endpoints/getting-started-grpc/api/build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/endpoints/bookstore-grpc/api/build.gradle b/endpoints/bookstore-grpc/api/build.gradle index 34811d7a609..42c2fe40874 100644 --- a/endpoints/bookstore-grpc/api/build.gradle +++ b/endpoints/bookstore-grpc/api/build.gradle @@ -38,12 +38,12 @@ dependencies { protobuf { protoc { - artifact = 'com.google.protobuf:protoc:3.20.0' + artifact = 'com.google.protobuf:protoc:3.20.1' } plugins { grpc { - artifact = 'io.grpc:protoc-gen-grpc-java:1.45.1' + artifact = 'io.grpc:protoc-gen-grpc-java:1.46.0' } } generateProtoTasks { diff --git a/endpoints/getting-started-grpc/api/build.gradle b/endpoints/getting-started-grpc/api/build.gradle index 1421f3a4096..68d6d057665 100644 --- a/endpoints/getting-started-grpc/api/build.gradle +++ b/endpoints/getting-started-grpc/api/build.gradle @@ -40,7 +40,7 @@ dependencies { protobuf { protoc { - artifact = 'com.google.protobuf:protoc:3.20.0' + artifact = 'com.google.protobuf:protoc:3.20.1' } plugins { From 399a4c798b1f009e935e0848093f7163dd2255bd Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:02:14 +0200 Subject: [PATCH 064/136] fix(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-1.x-hadoop to v2.1.1 (#7061) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.bigtable:bigtable-hbase-1.x-hadoop](https://cloud.google.com/bigtable/) ([source](https://togithub.com/googleapis/java-bigtable-hbase)) | `2.1.0` -> `2.1.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x-hadoop/2.1.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x-hadoop/2.1.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x-hadoop/2.1.1/compatibility-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x-hadoop/2.1.1/confidence-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-bigtable-hbase ### [`v2.1.1`](https://togithub.com/googleapis/java-bigtable-hbase/blob/HEAD/CHANGELOG.md#​211-httpsgithubcomgoogleapisjava-bigtable-hbasecomparev210v211-2022-04-20) [Compare Source](https://togithub.com/googleapis/java-bigtable-hbase/compare/v2.1.0...v2.1.1)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java8/bigtable/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java8/bigtable/pom.xml b/appengine-java8/bigtable/pom.xml index 6064836f567..f360c44e112 100644 --- a/appengine-java8/bigtable/pom.xml +++ b/appengine-java8/bigtable/pom.xml @@ -47,7 +47,7 @@ limitations under the License. com.google.cloud.bigtable bigtable-hbase-1.x-hadoop - 2.1.0 + 2.1.1
From 42f2fd5d12198f07fbf3cbafc96fff813f0277a1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:02:18 +0200 Subject: [PATCH 065/136] fix(deps): update dependency mysql:mysql-connector-java to v8.0.29 (#7066) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [mysql:mysql-connector-java](http://dev.mysql.com/doc/connector-j/en/) ([source](https://togithub.com/mysql/mysql-connector-j)) | `8.0.28` -> `8.0.29` | [![age](https://badges.renovateapi.com/packages/maven/mysql:mysql-connector-java/8.0.29/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/mysql:mysql-connector-java/8.0.29/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/mysql:mysql-connector-java/8.0.29/compatibility-slim/8.0.28)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/mysql:mysql-connector-java/8.0.29/confidence-slim/8.0.28)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
mysql/mysql-connector-j ### [`v8.0.29`](https://togithub.com/mysql/mysql-connector-j/compare/8.0.28...8.0.29) [Compare Source](https://togithub.com/mysql/mysql-connector-j/compare/8.0.28...8.0.29)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java11/cloudsql/pom.xml | 2 +- cloud-sql/mysql/client-side-encryption/pom.xml | 2 +- cloud-sql/mysql/servlet/pom.xml | 2 +- flexible/cloudsql/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appengine-java11/cloudsql/pom.xml b/appengine-java11/cloudsql/pom.xml index 491217afb1d..dbb0d5ad878 100644 --- a/appengine-java11/cloudsql/pom.xml +++ b/appengine-java11/cloudsql/pom.xml @@ -73,7 +73,7 @@ mysql mysql-connector-java - 8.0.28 + 8.0.29 provided diff --git a/cloud-sql/mysql/client-side-encryption/pom.xml b/cloud-sql/mysql/client-side-encryption/pom.xml index 6e864fad006..a04568f3ead 100644 --- a/cloud-sql/mysql/client-side-encryption/pom.xml +++ b/cloud-sql/mysql/client-side-encryption/pom.xml @@ -67,7 +67,7 @@ mysql mysql-connector-java - 8.0.28 + 8.0.29 com.google.crypto.tink diff --git a/cloud-sql/mysql/servlet/pom.xml b/cloud-sql/mysql/servlet/pom.xml index 6568a0d8408..84a97e25647 100644 --- a/cloud-sql/mysql/servlet/pom.xml +++ b/cloud-sql/mysql/servlet/pom.xml @@ -52,7 +52,7 @@ mysql mysql-connector-java - 8.0.28 + 8.0.29 com.google.cloud.sql diff --git a/flexible/cloudsql/pom.xml b/flexible/cloudsql/pom.xml index 17b45efeec9..082d881b242 100644 --- a/flexible/cloudsql/pom.xml +++ b/flexible/cloudsql/pom.xml @@ -79,7 +79,7 @@ mysql mysql-connector-java - 8.0.28 + 8.0.29 com.google.cloud.sql From 2a98fd32a500f00a033b78b268f71ebaaf3f54f7 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:04:10 +0200 Subject: [PATCH 066/136] fix(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-beam to v2.1.1 (#7062) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.bigtable:bigtable-hbase-beam](https://cloud.google.com/bigtable/) ([source](https://togithub.com/googleapis/java-bigtable-hbase)) | `2.1.0` -> `2.1.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.1.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.1.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.1.1/compatibility-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.1.1/confidence-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-bigtable-hbase ### [`v2.1.1`](https://togithub.com/googleapis/java-bigtable-hbase/blob/HEAD/CHANGELOG.md#​211-httpsgithubcomgoogleapisjava-bigtable-hbasecomparev210v211-2022-04-20) [Compare Source](https://togithub.com/googleapis/java-bigtable-hbase/compare/v2.1.0...v2.1.1)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- bigtable/beam/bulk-data-generator/pom.xml | 2 +- bigtable/beam/helloworld/pom.xml | 2 +- bigtable/beam/keyviz-art/pom.xml | 2 +- bigtable/beam/workload-generator/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bigtable/beam/bulk-data-generator/pom.xml b/bigtable/beam/bulk-data-generator/pom.xml index 2806128fd92..3b7e8fe5ce0 100644 --- a/bigtable/beam/bulk-data-generator/pom.xml +++ b/bigtable/beam/bulk-data-generator/pom.xml @@ -65,7 +65,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.0 + 2.1.1 diff --git a/bigtable/beam/helloworld/pom.xml b/bigtable/beam/helloworld/pom.xml index fff21d13c71..f58fd38216d 100644 --- a/bigtable/beam/helloworld/pom.xml +++ b/bigtable/beam/helloworld/pom.xml @@ -63,7 +63,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.0 + 2.1.1 diff --git a/bigtable/beam/keyviz-art/pom.xml b/bigtable/beam/keyviz-art/pom.xml index 9fd7f0b8dc2..da05665f1c4 100644 --- a/bigtable/beam/keyviz-art/pom.xml +++ b/bigtable/beam/keyviz-art/pom.xml @@ -61,7 +61,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.0 + 2.1.1 diff --git a/bigtable/beam/workload-generator/pom.xml b/bigtable/beam/workload-generator/pom.xml index 07b649d2503..1914d089e9a 100644 --- a/bigtable/beam/workload-generator/pom.xml +++ b/bigtable/beam/workload-generator/pom.xml @@ -104,7 +104,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.0 + 2.1.1 From 39d67054cb0af810fca9302d98a368554d5da042 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 26 Apr 2022 20:04:37 +0200 Subject: [PATCH 067/136] chore(deps): update dependency com.google.cloud:google-cloud-spanner to v6.23.1 (#6789) Co-authored-by: Emily Ball --- spanner/opencensus/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spanner/opencensus/pom.xml b/spanner/opencensus/pom.xml index d331883aedc..47fe2191c34 100644 --- a/spanner/opencensus/pom.xml +++ b/spanner/opencensus/pom.xml @@ -82,7 +82,7 @@ com.google.cloud google-cloud-spanner - 6.16.0 + 6.23.1 test From c6b191573da47c905730da394b80c59d662b0a0d Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Wed, 27 Apr 2022 00:50:50 +0530 Subject: [PATCH 068/136] updated parallel config --- compute/cloud-client/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 17fcddaaa9d..eb8a2ff4cfb 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -95,6 +95,7 @@ maven-surefire-plugin 3.0.0-M6 + all **/*IT.java From 538f4ff5d98d4ca84f518a50e996da1ff81677b0 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Wed, 27 Apr 2022 00:59:54 +0530 Subject: [PATCH 069/136] updated parallel config --- compute/cloud-client/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index eb8a2ff4cfb..11099c73300 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -96,6 +96,7 @@ 3.0.0-M6 all + true **/*IT.java From dd9d0c06bf267e5452266be6951aea3e4cfafd07 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Wed, 27 Apr 2022 01:18:09 +0530 Subject: [PATCH 070/136] added forkcount for multi-module testing --- compute/cloud-client/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 11099c73300..291868df466 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -97,6 +97,7 @@ all true + 2.5C **/*IT.java From 294ebbbc60641bd7b8f0b1a055a72ab5aacb4e2c Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Wed, 27 Apr 2022 01:50:25 +0530 Subject: [PATCH 071/136] reverted sysout null in cleanup to enable parallel testing --- .../src/test/java/compute/InstanceTemplatesIT.java | 6 ++++-- compute/cloud-client/src/test/java/compute/SnippetsIT.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java b/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java index 0fb8b4bef49..c8ee01e7f01 100644 --- a/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java +++ b/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java @@ -61,6 +61,7 @@ public static void requireEnvVar(String envVarName) { @BeforeClass public static void setup() throws IOException, ExecutionException, InterruptedException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); @@ -113,11 +114,12 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx Assert.assertEquals( getInstance(DEFAULT_ZONE, MACHINE_NAME_CR_TEMPLATE_OR).getDisksCount(), 2); stdOut.close(); - System.setOut(null); + System.setOut(out); } @AfterClass public static void cleanup() throws IOException, ExecutionException, InterruptedException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); // Delete instances. @@ -135,7 +137,7 @@ public static void cleanup() throws IOException, ExecutionException, Interrupted assertThat(stdOut.toString()) .contains("Instance template deletion operation status for " + TEMPLATE_NAME_WITH_SUBNET); stdOut.close(); - System.setOut(null); + System.setOut(out); } public static Instance getInstance(String zone, String instanceName) throws IOException { diff --git a/compute/cloud-client/src/test/java/compute/SnippetsIT.java b/compute/cloud-client/src/test/java/compute/SnippetsIT.java index af353c65662..442a780fe2f 100644 --- a/compute/cloud-client/src/test/java/compute/SnippetsIT.java +++ b/compute/cloud-client/src/test/java/compute/SnippetsIT.java @@ -94,6 +94,7 @@ public static void requireEnvVar(String envVarName) { @BeforeClass public static void setUp() throws IOException, InterruptedException, ExecutionException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); @@ -160,12 +161,13 @@ public static void setUp() throws IOException, InterruptedException, ExecutionEx storage.create(BucketInfo.of(BUCKET_NAME)); stdOut.close(); - System.setOut(null); + System.setOut(out); } @AfterClass public static void cleanup() throws IOException, InterruptedException, ExecutionException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); // Delete all instances created for testing. @@ -196,7 +198,7 @@ public static void cleanup() throws IOException, InterruptedException, Execution bucket.delete(); stdOut.close(); - System.setOut(null); + System.setOut(out); } private static Image getActiveDebian() From a69eaeee1b2fefc02f2dabe221962092d2706326 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Wed, 27 Apr 2022 02:23:55 +0530 Subject: [PATCH 072/136] parallel testing only methods in a single class --- compute/cloud-client/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 291868df466..e64ffa760d7 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -95,9 +95,10 @@ maven-surefire-plugin 3.0.0-M6 - all + methods true 2.5C + false **/*IT.java From 4f28743da12313c6235446aece0daf7a9ac1895a Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Wed, 27 Apr 2022 02:57:10 +0530 Subject: [PATCH 073/136] Update pom.xml --- compute/cloud-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index e64ffa760d7..6463781c007 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -95,7 +95,7 @@ maven-surefire-plugin 3.0.0-M6 - methods + classes true 2.5C false From 87645331594f3a0cffe91d9d30a2b8b60482df41 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 27 Apr 2022 01:50:11 +0200 Subject: [PATCH 074/136] fix(deps): update dependency com.google.protobuf:protobuf-java to v3.20.1 (#7064) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.protobuf:protobuf-java](https://developers.google.com/protocol-buffers/) ([source](https://togithub.com/protocolbuffers/protobuf)) | `3.20.0` -> `3.20.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protobuf-java/3.20.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protobuf-java/3.20.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protobuf-java/3.20.1/compatibility-slim/3.20.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.protobuf:protobuf-java/3.20.1/confidence-slim/3.20.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
protocolbuffers/protobuf ### [`v3.20.1`](https://togithub.com/protocolbuffers/protobuf/releases/v3.20.1) [Compare Source](https://togithub.com/protocolbuffers/protobuf/compare/v3.20.0...v3.20.1) ##### PHP - Fix building packaged PHP extension ([#​9727](https://togithub.com/protocolbuffers/protobuf/issues/9727)) - Fixed composer.json to only advertise compatibility with PHP 7.0+. ([#​9819](https://togithub.com/protocolbuffers/protobuf/issues/9819)) ##### Ruby - Disable the aarch64 build on macOS until it can be fixed. ([#​9816](https://togithub.com/protocolbuffers/protobuf/issues/9816)) ##### Other - Fix versioning issues in 3.20.0
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java8/tasks/snippets/pom.xml | 2 +- kms/pom.xml | 2 +- spanner/opencensus/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appengine-java8/tasks/snippets/pom.xml b/appengine-java8/tasks/snippets/pom.xml index ab710c00020..f1cad895322 100644 --- a/appengine-java8/tasks/snippets/pom.xml +++ b/appengine-java8/tasks/snippets/pom.xml @@ -49,7 +49,7 @@ Copyright 2019 Google LLC com.google.protobuf protobuf-java - 3.20.0 + 3.20.1 diff --git a/kms/pom.xml b/kms/pom.xml index 39cf7c9b92a..07582115704 100644 --- a/kms/pom.xml +++ b/kms/pom.xml @@ -37,7 +37,7 @@ com.google.protobuf protobuf-java - 3.20.0 + 3.20.1 diff --git a/spanner/opencensus/pom.xml b/spanner/opencensus/pom.xml index 47fe2191c34..5818cde1d15 100644 --- a/spanner/opencensus/pom.xml +++ b/spanner/opencensus/pom.xml @@ -53,7 +53,7 @@ com.google.protobuf protobuf-java - 3.20.0 + 3.20.1 io.opencensus From e28d8bb27114e847df16869bb9a14563f5a90b12 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Wed, 27 Apr 2022 17:12:31 +0530 Subject: [PATCH 075/136] added junit jupiter engine to run beforeeach and aftereach methods in parallel with mvn surefire tests --- compute/cloud-client/pom.xml | 23 ++++++++++++++++++- .../java/compute/InstanceTemplatesIT.java | 18 +++++++-------- .../src/test/java/compute/SnippetsIT.java | 18 +++++++-------- .../CustomHostnameInstanceIT.java | 18 +++++++-------- .../deleteprotection/DeleteProtectionIT.java | 18 +++++++-------- .../compute/preemptible/PreemptibleIT.java | 18 +++++++-------- .../CreatingManagingWindowsInstancesIT.java | 14 +++++------ 7 files changed, 74 insertions(+), 53 deletions(-) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 291868df466..82d74974879 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -54,6 +54,25 @@ test 4.13.2 + + + + org.junit.jupiter + junit-jupiter-api + 5.8.2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test + @@ -95,9 +114,11 @@ maven-surefire-plugin 3.0.0-M6 + all true - 2.5C + 5C + true **/*IT.java diff --git a/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java b/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java index c8ee01e7f01..46c65744bff 100644 --- a/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java +++ b/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java @@ -27,12 +27,12 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -59,7 +59,7 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass + @BeforeAll public static void setup() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -117,7 +117,7 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - @AfterClass + @AfterAll public static void cleanup() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -146,13 +146,13 @@ public static Instance getInstance(String zone, String instanceName) throws IOEx } } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); diff --git a/compute/cloud-client/src/test/java/compute/SnippetsIT.java b/compute/cloud-client/src/test/java/compute/SnippetsIT.java index 442a780fe2f..ad58ce40a25 100644 --- a/compute/cloud-client/src/test/java/compute/SnippetsIT.java +++ b/compute/cloud-client/src/test/java/compute/SnippetsIT.java @@ -49,12 +49,12 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -92,7 +92,7 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass + @BeforeAll public static void setUp() throws IOException, InterruptedException, ExecutionException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -165,7 +165,7 @@ public static void setUp() throws IOException, InterruptedException, ExecutionEx } - @AfterClass + @AfterAll public static void cleanup() throws IOException, InterruptedException, ExecutionException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -355,13 +355,13 @@ public static String getInstanceStatus(String instanceName) throws IOException { } } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); diff --git a/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java b/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java index 770b4e2aca6..160cf3038bf 100644 --- a/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java +++ b/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java @@ -25,11 +25,11 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -49,7 +49,7 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass + @BeforeAll public static void setup() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -70,7 +70,7 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -80,13 +80,13 @@ public static void cleanUp() throws IOException, ExecutionException, Interrupted System.setOut(out); } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); diff --git a/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java b/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java index 7ccda634cb1..02af9e57f91 100644 --- a/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java +++ b/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java @@ -26,12 +26,12 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -50,7 +50,7 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass + @BeforeAll public static void setup() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -72,7 +72,7 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -88,13 +88,13 @@ public static void cleanUp() throws IOException, ExecutionException, Interrupted System.setOut(out); } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); diff --git a/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java b/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java index 5e33c314b99..8c5fba2bee2 100644 --- a/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java +++ b/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java @@ -28,11 +28,11 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -51,7 +51,7 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass + @BeforeAll public static void setup() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -73,7 +73,7 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -85,13 +85,13 @@ public static void cleanUp() throws IOException, ExecutionException, Interrupted System.setOut(out); } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); diff --git a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java index 566b293b5cb..68938cddb14 100644 --- a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java +++ b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java @@ -26,10 +26,10 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -53,7 +53,7 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass + @BeforeAll public static void setup() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -83,13 +83,13 @@ public static void deleteRoute() throws IOException, ExecutionException, Interru } } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); From 8fbb00eb08c9bf36e2e5072da16b65917a82a204 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 27 Apr 2022 17:06:17 +0200 Subject: [PATCH 076/136] chore(deps): update dependency com.google.cloud:google-cloud-storage to v2.6.1 (#7033) --- media/transcoder/pom.xml | 2 +- pubsublite/streaming-analytics/build.gradle | 2 +- storage-transfer/pom.xml | 2 +- storage/cloud-client/pom.xml | 2 +- storage/s3-sdk/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/media/transcoder/pom.xml b/media/transcoder/pom.xml index 3d1e735778c..80c808fa033 100644 --- a/media/transcoder/pom.xml +++ b/media/transcoder/pom.xml @@ -76,7 +76,7 @@ com.google.cloud google-cloud-storage - 2.6.0 + 2.6.1 \ No newline at end of file diff --git a/pubsublite/streaming-analytics/build.gradle b/pubsublite/streaming-analytics/build.gradle index 4097a8e8205..771babcda6b 100644 --- a/pubsublite/streaming-analytics/build.gradle +++ b/pubsublite/streaming-analytics/build.gradle @@ -47,7 +47,7 @@ dependencies { testImplementation 'com.google.api-client:google-api-client:1.34.0' testImplementation 'com.google.apis:google-api-services-dataflow:v1b3-rev20210825-1.32.1' testImplementation 'com.google.cloud:google-cloud-core:2.3.2' - testImplementation 'com.google.cloud:google-cloud-storage:2.6.0' + testImplementation 'com.google.cloud:google-cloud-storage:2.6.1' testImplementation 'com.google.truth:truth:1.1.3' testImplementation 'org.hamcrest:hamcrest-all:1.3' } diff --git a/storage-transfer/pom.xml b/storage-transfer/pom.xml index aa7b073f43e..7d6fa67172a 100644 --- a/storage-transfer/pom.xml +++ b/storage-transfer/pom.xml @@ -92,7 +92,7 @@ com.google.cloud google-cloud-storage - 2.6.0 + 2.6.1 test diff --git a/storage/cloud-client/pom.xml b/storage/cloud-client/pom.xml index 37cba9379ca..0469ef1fb11 100644 --- a/storage/cloud-client/pom.xml +++ b/storage/cloud-client/pom.xml @@ -39,7 +39,7 @@ com.google.cloud google-cloud-storage - 2.6.0 + 2.6.1 diff --git a/storage/s3-sdk/pom.xml b/storage/s3-sdk/pom.xml index a6a544e98f1..e1407fee304 100644 --- a/storage/s3-sdk/pom.xml +++ b/storage/s3-sdk/pom.xml @@ -56,7 +56,7 @@ com.google.cloud google-cloud-storage - 2.6.0 + 2.6.1 test From a1c99964a87d27a09aa1487cbcda3fe58771c4b0 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 27 Apr 2022 17:06:29 +0200 Subject: [PATCH 077/136] chore(deps): update ktor_version to v2.0.1-eap-378 (#7069) --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index 5296b8c0990..149bffc58a6 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -33,7 +33,7 @@ limitations under the License. 11 11 - 2.0.1-eap-377 + 2.0.1-eap-378 official 1.6.21 1.2.11 From f7c23f35c06fc13dd484031715107c5526c54049 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Wed, 27 Apr 2022 20:59:10 +0530 Subject: [PATCH 078/136] docs(compute-samples): added region tags (#7070) * docs(compute-samples): added region tags * updated comment --- .../src/main/java/compute/CreateInstanceTemplate.java | 4 +++- .../src/main/java/compute/DeleteInstanceTemplate.java | 5 ++++- .../src/main/java/compute/GetInstanceTemplate.java | 7 +++++-- .../src/main/java/compute/ListInstanceTemplates.java | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java b/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java index 9bc0db60222..b9bca07fcad 100644 --- a/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java +++ b/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java @@ -16,6 +16,7 @@ package compute; +// [START compute_template_create] import com.google.cloud.compute.v1.AccessConfig; import com.google.cloud.compute.v1.AccessConfig.NetworkTier; import com.google.cloud.compute.v1.AttachedDisk; @@ -132,4 +133,5 @@ public static void createInstanceTemplateWithDiskType(String projectId, String t .printf("Instance Template Operation Status %s: %s", templateName, response.getStatus()); } } -} \ No newline at end of file +} +// [END compute_template_create] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java b/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java index 604c4f6d1f6..2ade4bf7612 100644 --- a/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java +++ b/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java @@ -16,6 +16,8 @@ package compute; +// [START compute_template_delete] + import com.google.cloud.compute.v1.DeleteInstanceTemplateRequest; import com.google.cloud.compute.v1.InstanceTemplatesClient; import com.google.cloud.compute.v1.Operation; @@ -54,4 +56,5 @@ public static void deleteInstanceTemplate(String projectId, String templateName) response.getStatus()); } } -} \ No newline at end of file +} +// [END compute_template_delete] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/GetInstanceTemplate.java b/compute/cloud-client/src/main/java/compute/GetInstanceTemplate.java index d08f2752b38..f82476cfc2e 100644 --- a/compute/cloud-client/src/main/java/compute/GetInstanceTemplate.java +++ b/compute/cloud-client/src/main/java/compute/GetInstanceTemplate.java @@ -16,6 +16,8 @@ package compute; +// [START compute_template_get] + import com.google.cloud.compute.v1.GetInstanceTemplateRequest; import com.google.cloud.compute.v1.InstanceTemplate; import com.google.cloud.compute.v1.InstanceTemplatesClient; @@ -26,7 +28,7 @@ public class GetInstanceTemplate { public static void main(String[] args) throws IOException { // TODO(developer): Replace these variables before running the sample. // projectId: project ID or project number of the Cloud project you use. - // templateName: name of the new template to retrieve. + // templateName: name of the template to retrieve. String projectId = "your-project-id"; String templateName = "template-name"; getInstanceTemplate(projectId, templateName); @@ -46,4 +48,5 @@ public static void getInstanceTemplate(String projectId, String templateName) th System.out.println("Instance Template retrieved: " + instanceTemplate.getName()); } } -} \ No newline at end of file +} +// [END compute_template_get] diff --git a/compute/cloud-client/src/main/java/compute/ListInstanceTemplates.java b/compute/cloud-client/src/main/java/compute/ListInstanceTemplates.java index c029d8acd4a..917311ac98e 100644 --- a/compute/cloud-client/src/main/java/compute/ListInstanceTemplates.java +++ b/compute/cloud-client/src/main/java/compute/ListInstanceTemplates.java @@ -16,6 +16,8 @@ package compute; +// [START compute_template_list] + import com.google.cloud.compute.v1.InstanceTemplate; import com.google.cloud.compute.v1.InstanceTemplatesClient; import com.google.cloud.compute.v1.InstanceTemplatesClient.ListPagedResponse; @@ -42,4 +44,5 @@ public static ListPagedResponse listInstanceTemplates(String projectId) throws I return templates; } } -} \ No newline at end of file +} +// [END compute_template_list] \ No newline at end of file From 1cea1307be922edbdf4fa12c36a3efc6b6a8adea Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 29 Apr 2022 16:36:07 +0200 Subject: [PATCH 079/136] chore(deps): update ktor_version to v2.0.1-eap-384 (#7075) --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index 149bffc58a6..ab13b3976de 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -33,7 +33,7 @@ limitations under the License. 11 11 - 2.0.1-eap-378 + 2.0.1-eap-384 official 1.6.21 1.2.11 From 72818b5799c9bb666777ce2205c3a526213beb62 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 29 Apr 2022 16:36:47 +0200 Subject: [PATCH 080/136] chore(deps): update dependency org.seleniumhq.selenium:selenium-chrome-driver to v4.1.4 (#7074) --- session-handling/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session-handling/pom.xml b/session-handling/pom.xml index 75f5678814f..01f63bcbb69 100644 --- a/session-handling/pom.xml +++ b/session-handling/pom.xml @@ -85,7 +85,7 @@ Copyright 2019 Google LLC org.seleniumhq.selenium selenium-chrome-driver - 4.1.3 + 4.1.4 test From 7d52ad5d4ddddf80195a8a9ba4673415e0c59204 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 29 Apr 2022 21:28:27 +0200 Subject: [PATCH 081/136] fix(deps): update dependency com.google.apis:google-api-services-iam to v1-rev20220421-1.32.1 (#7076) --- iam/api-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iam/api-client/pom.xml b/iam/api-client/pom.xml index 7b2aad23ffc..224b4f82b3d 100644 --- a/iam/api-client/pom.xml +++ b/iam/api-client/pom.xml @@ -56,7 +56,7 @@ com.google.apis google-api-services-iam - v1-rev20220413-1.32.1 + v1-rev20220421-1.32.1 From 8be829e263cf5bf253b7cceea0446ab659f1e257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Mon, 2 May 2022 18:05:36 +0200 Subject: [PATCH 082/136] feat: samples for Spanner PostgreSQL JDBC (#6920) * feat: samples for Spanner PostgreSQL JDBC * fix: remove catalog from expected output * fix: remove comment regarding catalog * fix: remove catalog from comparison * fix: add regex to ignore catalog * fix: remove assertion for information_schema Removing the assertion for information_schema, as there is no consensus yet on what the table_catalog value should be. * chore: address review comments * chore: address review comments * fix: remove trailing '.' in license headers --- .../spanner/jdbc/PgBatchDmlSample.java | 68 +++++++ .../spanner/jdbc/PgCaseSensitivitySample.java | 128 ++++++++++++ .../spanner/jdbc/PgCastDataTypeSample.java | 75 +++++++ .../jdbc/PgConnectToDatabaseSample.java | 55 +++++ .../jdbc/PgCreateInterleavedTableSample.java | 69 +++++++ .../jdbc/PgDmlWithParametersSample.java | 59 ++++++ .../spanner/jdbc/PgFunctionsSample.java | 62 ++++++ .../jdbc/PgInformationSchemaSample.java | 104 ++++++++++ .../spanner/jdbc/PgNumericDataTypeSample.java | 159 +++++++++++++++ .../spanner/jdbc/PgOrderNullsSample.java | 127 ++++++++++++ .../spanner/jdbc/PgPartitionedDmlSample.java | 58 ++++++ .../spanner/jdbc/PgQueryParameterSample.java | 69 +++++++ .../spanner/jdbc/BaseJdbcPgExamplesIT.java | 190 ++++++++++++++++++ .../spanner/jdbc/PgBatchDmlSampleIT.java | 40 ++++ .../jdbc/PgCaseInsensitivitySampleIT.java | 36 ++++ .../spanner/jdbc/PgCastDataTypeSampleIT.java | 42 ++++ .../jdbc/PgConnectToDatabaseSampleIT.java | 35 ++++ .../PgCreateInterleavedTableSampleIT.java | 35 ++++ .../jdbc/PgDmlWithParametersSampleIT.java | 40 ++++ .../spanner/jdbc/PgFunctionsSampleIT.java | 35 ++++ .../jdbc/PgInformationSchemaSampleIT.java | 35 ++++ .../jdbc/PgNumericDataTypeSampleIT.java | 52 +++++ .../spanner/jdbc/PgOrderNullsSampleIT.java | 39 ++++ .../jdbc/PgPartitionedDmlSampleIT.java | 40 ++++ .../jdbc/PgQueryParameterSampleIT.java | 42 ++++ 25 files changed, 1694 insertions(+) create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgBatchDmlSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCaseSensitivitySample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCastDataTypeSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgConnectToDatabaseSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCreateInterleavedTableSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgDmlWithParametersSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgFunctionsSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgInformationSchemaSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgNumericDataTypeSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgOrderNullsSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgPartitionedDmlSample.java create mode 100644 spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgQueryParameterSample.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/BaseJdbcPgExamplesIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgBatchDmlSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCaseInsensitivitySampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCastDataTypeSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgConnectToDatabaseSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCreateInterleavedTableSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgDmlWithParametersSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgFunctionsSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgInformationSchemaSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgNumericDataTypeSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgOrderNullsSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgPartitionedDmlSampleIT.java create mode 100644 spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgQueryParameterSampleIT.java diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgBatchDmlSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgBatchDmlSample.java new file mode 100644 index 00000000000..e1c5cc6395e --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgBatchDmlSample.java @@ -0,0 +1,68 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Arrays; + +class PgBatchDmlSample { + + static void pgBatchDml() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgBatchDml(projectId, instanceId, databaseId); + } + + static void pgBatchDml(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + // Spanner PostgreSQL supports BatchDML statements. This will batch multiple DML statements + // into one request, which reduces the number of round trips that is needed for multiple DML + // statements. Use the standard JDBC PreparedStatement batching feature to batch multiple DML + // statements together. + try (PreparedStatement statement = + connection.prepareStatement( + "INSERT INTO Singers (SingerId, FirstName, LastName) " + "VALUES (?, ?, ?)")) { + statement.setLong(1, 10L); + statement.setString(2, "Alice"); + statement.setString(3, "Henderson"); + statement.addBatch(); + + statement.setLong(1, 11L); + statement.setString(2, "Bruce"); + statement.setString(3, "Allison"); + statement.addBatch(); + + int[] updateCounts = statement.executeBatch(); + int totalUpdateCount = Arrays.stream(updateCounts).sum(); + System.out.printf("Inserted %d singers\n", totalUpdateCount); + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCaseSensitivitySample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCaseSensitivitySample.java new file mode 100644 index 00000000000..caa496b8832 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCaseSensitivitySample.java @@ -0,0 +1,128 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import com.google.cloud.spanner.Mutation; +import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collections; + +class PgCaseSensitivitySample { + + static void pgCaseSensitivity() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgCaseSensitivity(projectId, instanceId, databaseId); + } + + static void pgCaseSensitivity(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + + // Spanner PostgreSQL follows the case sensitivity rules of PostgreSQL. This means that: + // 1. Identifiers that are not double-quoted are folded to lower case. + // 2. Identifiers that are double-quoted retain their case and are case-sensitive. + // See https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS + // for more information. + + connection + .createStatement() + .execute( + "CREATE TABLE Singers (" + // SingerId will be folded to `singerid`. + + " SingerId bigint NOT NULL PRIMARY KEY," + // FirstName and LastName are double-quoted and will therefore retain their + // mixed case and are case-sensitive. This means that any statement that + // references any of these columns must use double quotes. + + " \"FirstName\" varchar(1024) NOT NULL," + + " \"LastName\" varchar(1024) NOT NULL" + + ")"); + + connection + .unwrap(CloudSpannerJdbcConnection.class) + .write( + Collections.singleton( + Mutation.newInsertBuilder("Singers") + .set("singerid") + .to(1L) + // Column names in mutations are always case-insensitive, regardless whether + // the columns were double-quoted or not during creation. + .set("firstname") + .to("Bruce") + .set("lastname") + .to("Allison") + .build())); + + try (ResultSet singers = connection + .createStatement() + .executeQuery("SELECT SingerId, \"FirstName\", \"LastName\" FROM Singers")) { + while (singers.next()) { + System.out.printf( + "SingerId: %d, FirstName: %s, LastName: %s\n", + // SingerId is automatically folded to lower case. Accessing the column by its name in + // a result set must therefore use all lower-case letters. + singers.getLong("singerid"), + // FirstName and LastName were double-quoted during creation, and retain their mixed + // case when returned in a result set. + singers.getString("FirstName"), + singers.getString("LastName")); + } + } + + // Aliases are also identifiers, and specifying an alias in double quotes will make the alias + // retain its case. + try (ResultSet singers = + connection + .createStatement() + .executeQuery( + "SELECT " + + "singerid AS \"SingerId\", " + + "\"FirstName\" || ' ' || \"LastName\" AS \"FullName\" " + + "FROM Singers")) { + while (singers.next()) { + System.out.printf( + "SingerId: %d, FullName: %s\n", + // The aliases are double-quoted and therefore retains their mixed case. + singers.getLong("SingerId"), singers.getString("FullName")); + } + } + + // DML statements must also follow the PostgreSQL case rules. + try (PreparedStatement statement = + connection.prepareStatement( + "INSERT INTO Singers (SingerId, \"FirstName\", \"LastName\") " + + "VALUES (?, ?, ?)")) { + statement.setLong(1, 2L); + statement.setString(2, "Alice"); + statement.setString(3, "Bruxelles"); + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCastDataTypeSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCastDataTypeSample.java new file mode 100644 index 00000000000..5b3036dc135 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCastDataTypeSample.java @@ -0,0 +1,75 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.util.Base64; + +class PgCastDataTypeSample { + + static void pgCastDataType() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgCastDataType(projectId, instanceId, databaseId); + } + + static void pgCastDataType(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + // The `::` cast operator can be used to cast from one data type to another. + try (ResultSet resultSet = + connection + .createStatement() + .executeQuery( + "select 1::varchar as str, '2'::bigint as bigint, 3::numeric as num," + + "'4'::bytea as bytes, 5::float as float, 'true'::bool as bool, " + + "'2021-11-03T09:35:01UTC'::timestamptz as timestamp, " + + "'2022-04-25'::date as date")) { + while (resultSet.next()) { + System.out.printf("String: %s\n", resultSet.getString("str")); + System.out.printf("Bigint: %d\n", resultSet.getLong("bigint")); + System.out.printf("Numeric: %s\n", resultSet.getBigDecimal("num")); + System.out.printf( + "Bytes: %s\n", Base64.getEncoder().encodeToString(resultSet.getBytes("bytes"))); + System.out.printf("Float: %f\n", resultSet.getDouble("float")); + System.out.printf("Bool: %s\n", resultSet.getBoolean("bool")); + System.out.printf( + "Timestamp: %s\n", + OffsetDateTime.ofInstant( + Instant.ofEpochMilli(resultSet.getTimestamp("timestamp").getTime()), + ZoneId.of("UTC"))); + System.out.printf("Date: %s\n", resultSet.getDate("date")); + } + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgConnectToDatabaseSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgConnectToDatabaseSample.java new file mode 100644 index 00000000000..27e930af85e --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgConnectToDatabaseSample.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; + +class PgConnectToDatabaseSample { + + static void pgConnectToDatabase() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgConnectToDatabase(projectId, instanceId, databaseId); + } + + // Creates a JDBC connection to a Cloud Spanner database with the PostgreSQL dialect. + static void pgConnectToDatabase(String projectId, String instanceId, String databaseId) + throws SQLException { + // Connecting to a Cloud Spanner PostgreSQL database using the Spanner JDBC driver uses the same + // JDBC URL as for normal Spanner databases. The JDBC driver will automatically detect the + // dialect that is used by the underlying database. A connection can be reused to execute + // multiple statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + try (ResultSet rs = connection.createStatement().executeQuery("SELECT now()")) { + while (rs.next()) { + System.out.printf( + "Connected to Cloud Spanner PostgreSQL at [%s]%n", rs.getTimestamp(1).toString()); + } + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCreateInterleavedTableSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCreateInterleavedTableSample.java new file mode 100644 index 00000000000..4a0a3f63cae --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgCreateInterleavedTableSample.java @@ -0,0 +1,69 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; + +class PgCreateInterleavedTableSample { + + static void pgCreateInterleavedTable() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgCreateInterleavedTable(projectId, instanceId, databaseId); + } + + static void pgCreateInterleavedTable(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + try (Statement statement = connection.createStatement()) { + // The Spanner PostgreSQL dialect extends the PostgreSQL dialect with certain Spanner + // specific features, such as interleaved tables. + // See + // https://cloud.google.com/spanner/docs/postgresql/data-definition-language#create_table + // for the full CREATE TABLE syntax. The tables are created in one batch by adding the + // individual DDL statements to a JDBC batch and then executed as a single batch. + statement.addBatch( + "CREATE TABLE Singers (" + + " SingerId bigint NOT NULL PRIMARY KEY," + + " FirstName varchar(1024) NOT NULL," + + " LastName varchar(1024) NOT NULL" + + ")"); + statement.addBatch( + "CREATE TABLE Albums (" + + " SingerId bigint NOT NULL," + + " AlbumId bigint NOT NULL," + + " Title varchar(1024) NOT NULL," + + " PRIMARY KEY (SingerId, AlbumId)" + + ") INTERLEAVE IN PARENT Singers ON DELETE CASCADE"); + statement.executeBatch(); + System.out.println("Created Singers and Albums tables"); + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgDmlWithParametersSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgDmlWithParametersSample.java new file mode 100644 index 00000000000..d03187c03ed --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgDmlWithParametersSample.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +class PgDmlWithParametersSample { + + static void pgDmlWithParameters() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgDmlWithParameters(projectId, instanceId, databaseId); + } + + static void pgDmlWithParameters(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + try (PreparedStatement statement = + connection.prepareStatement( + "INSERT INTO Singers (SingerId, FirstName, LastName) " + + "VALUES (?, ?, ?), (?, ?, ?)")) { + statement.setLong(1, 10L); + statement.setString(2, "Alice"); + statement.setString(3, "Henderson"); + statement.setLong(4, 11L); + statement.setString(5, "Bruce"); + statement.setString(6, "Allison"); + int updateCount = statement.executeUpdate(); + System.out.printf("Inserted %d singers\n", updateCount); + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgFunctionsSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgFunctionsSample.java new file mode 100644 index 00000000000..77209c7f211 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgFunctionsSample.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; + +class PgFunctionsSample { + + static void pgFunctions() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgFunctions(projectId, instanceId, databaseId); + } + + static void pgFunctions(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + // Use the PostgreSQL `to_timestamp` function to convert a number of seconds since epoch to a + // timestamp. 1284352323 seconds = Monday, September 13, 2010 4:32:03 AM. + try (ResultSet resultSet = + connection.createStatement().executeQuery("SELECT to_timestamp(1284352323) AS t")) { + while (resultSet.next()) { + Timestamp timestamp = resultSet.getTimestamp("t"); + System.out.printf( + "1284352323 seconds after epoch is %s\n", + OffsetDateTime.ofInstant( + Instant.ofEpochMilli(timestamp.getTime()), ZoneId.of("UTC"))); + } + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgInformationSchemaSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgInformationSchemaSample.java new file mode 100644 index 00000000000..a6b3988d234 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgInformationSchemaSample.java @@ -0,0 +1,104 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; + +class PgInformationSchemaSample { + + static void pgInformationSchema() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgInformationSchema(projectId, instanceId, databaseId); + } + + static void pgInformationSchema(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + connection + .createStatement() + .execute( + "CREATE TABLE Venues (" + + " VenueId bigint NOT NULL PRIMARY KEY," + + " Name varchar(1024) NOT NULL," + + " Revenues numeric," + + " Picture bytea" + + ")"); + + // The Spanner INFORMATION_SCHEMA tables can be used to query the metadata of tables and + // columns of PostgreSQL databases. The returned results will include additional PostgreSQL + // metadata columns. + + // Get all the user tables in the database. PostgreSQL uses the `public` schema for user + // tables. + try (ResultSet tables = + connection + .createStatement() + .executeQuery( + "SELECT table_catalog, table_schema, table_name, " + // The following columns are only available for PostgreSQL databases. + + "user_defined_type_catalog, " + + "user_defined_type_schema, " + + "user_defined_type_name " + + "FROM INFORMATION_SCHEMA.tables " + + "WHERE table_schema='public'")) { + while (tables.next()) { + String catalog = tables.getString("table_catalog"); + String schema = tables.getString("table_schema"); + String table = tables.getString("table_name"); + String userDefinedTypeCatalog = tables.getString("user_defined_type_catalog"); + String userDefinedTypeSchema = tables.getString("user_defined_type_schema"); + String userDefinedTypeName = tables.getString("user_defined_type_name"); + String userDefinedType = + userDefinedTypeName == null + ? null + : String.format( + "%s.%s.%s", + userDefinedTypeCatalog, userDefinedTypeSchema, userDefinedTypeName); + System.out.printf( + "Table: %s.%s.%s (User defined type: %s)\n", catalog, schema, table, userDefinedType); + } + } + + // The java.sql.DatabaseMetaData of the JDBC connection can also be used to retrieve + // information about tables, columns, indexes etc. These methods return the metadata as if it + // was a normal Spanner database. + try (ResultSet tables = + connection.getMetaData().getTables(null, null, null, new String[] {"TABLE"})) { + while (tables.next()) { + // Catalog and schema are empty. + String catalog = tables.getString("TABLE_CAT"); + String schema = tables.getString("TABLE_SCHEM"); + String table = tables.getString("TABLE_NAME"); + System.out.printf("Table in JDBC metadata: %s.%s.%s\n", catalog, schema, table); + } + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgNumericDataTypeSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgNumericDataTypeSample.java new file mode 100644 index 00000000000..9aa75821a24 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgNumericDataTypeSample.java @@ -0,0 +1,159 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import com.google.cloud.spanner.Mutation; +import com.google.cloud.spanner.Value; +import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.sql.Types; +import java.util.Arrays; + +class PgNumericDataTypeSample { + + static void pgNumericDataType() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgNumericDataType(projectId, instanceId, databaseId); + } + + static void pgNumericDataType(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + // Create a table that includes a column with data type NUMERIC. As the database has been + // created with the PostgreSQL dialect, the data type that is used will be the PostgreSQL + // NUMERIC / DECIMAL data type. + connection + .createStatement() + .execute( + "CREATE TABLE Venues (" + + " VenueId bigint NOT NULL PRIMARY KEY," + + " Name varchar(1024) NOT NULL," + + " Revenues numeric" + + ")"); + System.out.print("Created Venues table\n"); + + // Insert a Venue using DML. + try (PreparedStatement statement = + connection.prepareStatement( + "INSERT INTO Venues (VenueId, Name, Revenues) " + "VALUES (?, ?, ?)")) { + statement.setLong(1, 1L); + statement.setString(2, "Venue 1"); + statement.setBigDecimal(3, new BigDecimal("3150.25")); + int updateCount = statement.executeUpdate(); + System.out.printf("Inserted %d venues\n", updateCount); + } + + // Insert a Venue with a NULL value for the Revenues column. + try (PreparedStatement statement = + connection.prepareStatement( + "INSERT INTO Venues (VenueId, Name, Revenues) " + "VALUES (?, ?, ?)")) { + statement.setLong(1, 2L); + statement.setString(2, "Venue 2"); + statement.setNull(3, Types.NUMERIC); + int updateCount = statement.executeUpdate(); + System.out.printf("Inserted %d venues with NULL revenues\n", updateCount); + } + + // Insert a Venue with a NaN (Not a Number) value for the Revenues column. + try (PreparedStatement statement = + connection.prepareStatement( + "INSERT INTO Venues (VenueId, Name, Revenues) " + "VALUES (?, ?, ?)")) { + statement.setLong(1, 3L); + statement.setString(2, "Venue 3"); + // Not a Number (NaN) can be set both using the Double.NaN constant or the String 'NaN'. + statement.setDouble(3, Double.NaN); + int updateCount = statement.executeUpdate(); + System.out.printf("Inserted %d venues with NaN revenues\n", updateCount); + } + + // Get all Venues and inspect the Revenues values. + try (ResultSet venues = + connection.createStatement().executeQuery("SELECT Name, Revenues FROM Venues")) { + while (venues.next()) { + String name = venues.getString("name"); + // Getting a PostgreSQL NUMERIC value as a Value is always supported, regardless whether + // the value is a number, NULL or NaN. + Value revenuesAsValue = venues.getObject("revenues", Value.class); + System.out.printf("Revenues of %s: %s\n", name, revenuesAsValue); + + // Getting a PostgreSQL NUMERIC value as a double is supported for all possible values. If + // the value is NULL, this method will return 0 and the wasNull() method will return true. + double revenuesAsDouble = venues.getDouble("revenues"); + boolean wasNull = venues.wasNull(); + if (wasNull) { + System.out.printf("\tRevenues of %s as double: null\n", name); + } else { + System.out.printf("\tRevenues of %s as double: %f\n", name, revenuesAsDouble); + } + + // Getting a PostgreSQL NUMERIC as a BigDecimal is supported for both NULL and non-NULL + // values, but not for NaN, as there is no BigDecimal representation of NaN. + if (!Double.valueOf(revenuesAsDouble).isNaN()) { + BigDecimal revenuesAsBigDecimal = venues.getBigDecimal("revenues"); + System.out.printf("\tRevenues of %s as BigDecimal: %s\n", name, revenuesAsBigDecimal); + } + + // A PostgreSQL NUMERIC value may also be retrieved as a String. + String revenuesAsString = venues.getString("revenues"); + System.out.printf("\tRevenues of %s as String: %s\n", name, revenuesAsString); + } + } + + // Mutations can also be used to insert/update NUMERIC values, including NaN values. + // Mutations can be used with the JDBC driver by unwrapping the + // com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection interface from the connection. + CloudSpannerJdbcConnection cloudSpannerJdbcConnection = + connection.unwrap(CloudSpannerJdbcConnection.class); + cloudSpannerJdbcConnection.write( + Arrays.asList( + Mutation.newInsertBuilder("Venues") + .set("VenueId") + .to(4L) + .set("Name") + .to("Venue 4") + .set("Revenues") + .to(Value.pgNumeric("125.10")) + .build(), + Mutation.newInsertBuilder("Venues") + .set("VenueId") + .to(5L) + .set("Name") + .to("Venue 5") + .set("Revenues") + .to(Value.pgNumeric(Value.NAN)) + .build())); + Timestamp commitTimestamp = cloudSpannerJdbcConnection.getCommitTimestamp(); + System.out.printf("Inserted 2 Venues using mutations at %s\n", commitTimestamp); + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgOrderNullsSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgOrderNullsSample.java new file mode 100644 index 00000000000..92ebc36c719 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgOrderNullsSample.java @@ -0,0 +1,127 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import com.google.cloud.spanner.Mutation; +import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; + +class PgOrderNullsSample { + + static void pgOrderNulls() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgOrderNulls(projectId, instanceId, databaseId); + } + + static void pgOrderNulls(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + + // Spanner PostgreSQL follows the ORDER BY rules for NULL values of PostgreSQL. This means + // that: + // 1. NULL values are ordered last by default when a query result is ordered in ascending + // order. + // 2. NULL values are ordered first by default when a query result is ordered in descending + // order. + // 3. NULL values can be order first or last by specifying NULLS FIRST or NULLS LAST in the + // ORDER BY clause. + connection + .createStatement() + .execute( + "CREATE TABLE Singers (" + + " SingerId bigint NOT NULL PRIMARY KEY," + + " Name varchar(1024)" + + ")"); + + connection + .unwrap(CloudSpannerJdbcConnection.class) + .write( + Arrays.asList( + Mutation.newInsertBuilder("Singers") + .set("SingerId") + .to(1L) + .set("Name") + .to("Alice") + .build(), + Mutation.newInsertBuilder("Singers") + .set("SingerId") + .to(2L) + .set("Name") + .to("Bruce") + .build(), + Mutation.newInsertBuilder("Singers") + .set("SingerId") + .to(3L) + .set("Name") + .to((String) null) + .build())); + + // This returns the singers in order Alice, Bruce, null + System.out.println("Singers ORDER BY Name"); + try (ResultSet singers = + connection.createStatement().executeQuery("SELECT * FROM Singers ORDER BY Name")) { + printSingerNames(singers); + } + + // This returns the singers in order null, Bruce, Alice + System.out.println("Singers ORDER BY Name DESC"); + try (ResultSet singers = + connection.createStatement().executeQuery("SELECT * FROM Singers ORDER BY Name DESC")) { + printSingerNames(singers); + } + + // This returns the singers in order null, Alice, Bruce + System.out.println("Singers ORDER BY Name NULLS FIRST"); + try (ResultSet singers = + connection + .createStatement() + .executeQuery("SELECT * FROM Singers ORDER BY Name NULLS FIRST")) { + printSingerNames(singers); + } + + // This returns the singers in order Bruce, Alice, null + System.out.println("Singers ORDER BY Name DESC NULLS LAST"); + try (ResultSet singers = + connection + .createStatement() + .executeQuery("SELECT * FROM Singers ORDER BY Name DESC NULLS LAST")) { + printSingerNames(singers); + } + } + } + + static void printSingerNames(ResultSet singers) throws SQLException { + while (singers.next()) { + System.out.printf( + "\t%s\n", singers.getString("name") == null ? "" : singers.getString("name")); + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgPartitionedDmlSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgPartitionedDmlSample.java new file mode 100644 index 00000000000..bd3b41bd6f3 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgPartitionedDmlSample.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +class PgPartitionedDmlSample { + + static void pgPartitionedDml() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgPartitionedDml(projectId, instanceId, databaseId); + } + + static void pgPartitionedDml(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + // Spanner PostgreSQL has the same transaction limits as normal Spanner. This includes a + // maximum of 20,000 mutations in a single read/write transaction. Large update operations can + // be executed using Partitioned DML. This is also supported on Spanner PostgreSQL. + // See https://cloud.google.com/spanner/docs/dml-partitioned for more information. + + // Switch to Partitioned DML. Note that we must prefix all Spanner specific session statements + // with `SPANNER.`. + connection.createStatement() + .execute("SET SPANNER.AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'"); + // Execute the DML statement. + int deletedCount = connection.createStatement().executeUpdate("DELETE FROM Singers"); + // The returned update count is the lower bound of the number of records that was deleted. + System.out.printf("Deleted at least %d singers\n", deletedCount); + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgQueryParameterSample.java b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgQueryParameterSample.java new file mode 100644 index 00000000000..7568dbd34a0 --- /dev/null +++ b/spanner/jdbc/src/main/java/com/example/spanner/jdbc/PgQueryParameterSample.java @@ -0,0 +1,69 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +class PgQueryParameterSample { + + static void pgQueryParameter() throws SQLException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + pgQueryParameter(projectId, instanceId, databaseId); + } + + static void pgQueryParameter(String projectId, String instanceId, String databaseId) + throws SQLException { + // Create a JDBC connection to the database. A connection can be reused to execute multiple + // statements. After completing all of your statements, call the "close" method on the + // connection to safely clean up any remaining resources. + try (Connection connection = + DriverManager.getConnection( + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + projectId, instanceId, databaseId))) { + try (PreparedStatement statement = + connection.prepareStatement( + "SELECT SingerId, FirstName, LastName " + + "FROM Singers " + + "WHERE LastName LIKE ?")) { + statement.setString(1, "A%"); + System.out.print("Listing all singers with a last name that starts with 'A'\n"); + try (ResultSet resultSet = statement.executeQuery()) { + while (resultSet.next()) { + // Note that the PostgreSQL dialect will return all column names in lower case, unless + // the + // columns have been created with case-sensitive column names. See + // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS + // for more information on PostgreSQL identifiers. + System.out.printf( + "%d %s %s%n", + resultSet.getLong("singerid"), + resultSet.getString("firstname"), + resultSet.getString("lastname")); + } + } + } + } + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/BaseJdbcPgExamplesIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/BaseJdbcPgExamplesIT.java new file mode 100644 index 00000000000..cc273c13795 --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/BaseJdbcPgExamplesIT.java @@ -0,0 +1,190 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import com.google.cloud.ServiceOptions; +import com.google.cloud.spanner.Database; +import com.google.cloud.spanner.DatabaseAdminClient; +import com.google.cloud.spanner.DatabaseId; +import com.google.cloud.spanner.Dialect; +import com.google.cloud.spanner.Instance; +import com.google.cloud.spanner.Mutation; +import com.google.cloud.spanner.Spanner; +import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.connection.ConnectionOptions; +import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Integration tests for Cloud Spanner PostgreSQL JDBC examples. */ +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:AbbreviationAsWordInName") +public abstract class BaseJdbcPgExamplesIT { + // The instance needs to exist for tests to pass. + protected static String instanceId = System.getProperty("spanner.test.instance"); + protected static final String databaseId = + formatForTest(System.getProperty("spanner.sample.pgdatabase", "mypgsample")); + protected static DatabaseId dbId; + private static DatabaseAdminClient dbClient; + private boolean testTableCreated; + + protected interface JdbcRunnable { + void run() throws Exception; + } + + protected String runExample(JdbcRunnable example) { + PrintStream stdOut = System.out; + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + PrintStream out = new PrintStream(bout); + System.setOut(out); + try { + example.run(); + } catch (Exception e) { + e.printStackTrace(); + } + System.setOut(stdOut); + return bout.toString(); + } + + @BeforeClass + public static void createTestDatabase() throws Exception { + SpannerOptions options = SpannerOptions.newBuilder().build(); + Spanner spanner = options.getService(); + dbClient = spanner.getDatabaseAdminClient(); + if (instanceId == null) { + Iterator iterator = + spanner.getInstanceAdminClient().listInstances().iterateAll().iterator(); + if (iterator.hasNext()) { + instanceId = iterator.next().getId().getInstance(); + } + } + dbId = DatabaseId.of(options.getProjectId(), instanceId, databaseId); + dbClient.dropDatabase(dbId.getInstanceId().getInstance(), dbId.getDatabase()); + Database database = dbClient.newDatabaseBuilder(dbId).setDialect(Dialect.POSTGRESQL).build(); + dbClient.createDatabase(database, Collections.emptyList()).get(); + } + + @AfterClass + public static void dropTestDatabase() { + ConnectionOptions.closeSpanner(); + dbClient.dropDatabase(dbId.getInstanceId().getInstance(), dbId.getDatabase()); + } + + static class Singer { + final long singerId; + final String firstName; + final String lastName; + final BigDecimal revenues; + + Singer(long singerId, String firstName, String lastName, BigDecimal revenues) { + this.singerId = singerId; + this.firstName = firstName; + this.lastName = lastName; + this.revenues = revenues; + } + } + + static final List TEST_SINGERS = + Arrays.asList( + new Singer(1, "Marc", "Richards", new BigDecimal("104100.00")), + new Singer(2, "Catalina", "Smith", new BigDecimal("9880.99")), + new Singer(3, "Alice", "Trentor", new BigDecimal("300183")), + new Singer(4, "Lea", "Martin", new BigDecimal("20118.12")), + new Singer(5, "David", "Lomond", new BigDecimal("311399.26")), + new Singer(6, "Bruce", "Allison", null), + new Singer(7, "Alice", "Bruxelles", null)); + + protected boolean createTestTable() { + return false; + } + + @Before + public void insertTestData() throws SQLException { + if (createTestTable()) { + String connectionUrl = + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + ServiceOptions.getDefaultProjectId(), instanceId, databaseId); + try (Connection connection = DriverManager.getConnection(connectionUrl)) { + if (!testTableCreated) { + connection + .createStatement() + .execute( + "CREATE TABLE Singers (\n" + + " SingerId BIGINT NOT NULL PRIMARY KEY,\n" + + " FirstName VARCHAR(1024),\n" + + " LastName VARCHAR(1024),\n" + + " SingerInfo BYTEA,\n" + + " Revenues NUMERIC\n" + + ")\n"); + testTableCreated = true; + } + CloudSpannerJdbcConnection spannerConnection = + connection.unwrap(CloudSpannerJdbcConnection.class); + spannerConnection.setAutoCommit(false); + for (Singer singer : TEST_SINGERS) { + spannerConnection.bufferedWrite( + Mutation.newInsertBuilder("Singers") + .set("SingerId") + .to(singer.singerId) + .set("FirstName") + .to(singer.firstName) + .set("LastName") + .to(singer.lastName) + .set("Revenues") + .to(singer.revenues) + .build()); + } + connection.commit(); + } + } + } + + @After + public void removeTestData() throws SQLException { + if (createTestTable()) { + String connectionUrl = + String.format( + "jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", + ServiceOptions.getDefaultProjectId(), instanceId, databaseId); + try (Connection connection = DriverManager.getConnection(connectionUrl); + Statement statement = connection.createStatement()) { + statement.execute("DELETE FROM Singers WHERE 1=1"); + } + } + } + + static String formatForTest(String name) { + return name + "-" + UUID.randomUUID().toString().substring(0, 18); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgBatchDmlSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgBatchDmlSampleIT.java new file mode 100644 index 00000000000..1c72bdbd5aa --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgBatchDmlSampleIT.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgBatchDmlSampleIT extends BaseJdbcPgExamplesIT { + + @Override + protected boolean createTestTable() { + return true; + } + + @Test + public void testPgBatchDml() { + String out = + runExample( + () -> + PgBatchDmlSample.pgBatchDml( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out.contains("Inserted 2 singers")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCaseInsensitivitySampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCaseInsensitivitySampleIT.java new file mode 100644 index 00000000000..c81ed068a99 --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCaseInsensitivitySampleIT.java @@ -0,0 +1,36 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgCaseInsensitivitySampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testCaseInsensitivity() { + String out = + runExample( + () -> + PgCaseSensitivitySample.pgCaseSensitivity( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out, out.contains("SingerId: 1, FirstName: Bruce, LastName: Allison")); + assertTrue(out, out.contains("SingerId: 1, FullName: Bruce Allison")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCastDataTypeSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCastDataTypeSampleIT.java new file mode 100644 index 00000000000..3fe04b2572b --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCastDataTypeSampleIT.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgCastDataTypeSampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testPgCastDataType() { + String out = + runExample( + () -> + PgCastDataTypeSample.pgCastDataType( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out, out.contains("String: 1")); + assertTrue(out, out.contains("Bigint: 2")); + assertTrue(out, out.contains("Numeric: 3")); + assertTrue(out, out.contains("Bytes: NA==")); + assertTrue(out, out.contains("Float: 5.000000")); + assertTrue(out, out.contains("Bool: true")); + assertTrue(out, out.contains("Timestamp: 2021-11-03T09:35:01Z")); + assertTrue(out, out.contains("Date: 2022-04-25")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgConnectToDatabaseSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgConnectToDatabaseSampleIT.java new file mode 100644 index 00000000000..09f2fa0adb7 --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgConnectToDatabaseSampleIT.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgConnectToDatabaseSampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testPgConnectToDatabase() { + String out = + runExample( + () -> + PgConnectToDatabaseSample.pgConnectToDatabase( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out.contains("Connected to Cloud Spanner PostgreSQL at [")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCreateInterleavedTableSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCreateInterleavedTableSampleIT.java new file mode 100644 index 00000000000..cf2ff3704ff --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgCreateInterleavedTableSampleIT.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgCreateInterleavedTableSampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testCreateInterleavedTable() { + String out = + runExample( + () -> + PgCreateInterleavedTableSample.pgCreateInterleavedTable( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out.contains("Created Singers and Albums tables")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgDmlWithParametersSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgDmlWithParametersSampleIT.java new file mode 100644 index 00000000000..86f0d6785e3 --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgDmlWithParametersSampleIT.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgDmlWithParametersSampleIT extends BaseJdbcPgExamplesIT { + + @Override + protected boolean createTestTable() { + return true; + } + + @Test + public void testPgDmlWithParameters() { + String out = + runExample( + () -> + PgDmlWithParametersSample.pgDmlWithParameters( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out.contains("Inserted 2 singers")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgFunctionsSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgFunctionsSampleIT.java new file mode 100644 index 00000000000..1f1b94f0706 --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgFunctionsSampleIT.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgFunctionsSampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testPgFunctions() { + String out = + runExample( + () -> + PgFunctionsSample.pgFunctions( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out, out.contains("1284352323 seconds after epoch is 2010-09-13T04:32:03Z")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgInformationSchemaSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgInformationSchemaSampleIT.java new file mode 100644 index 00000000000..98c130ded99 --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgInformationSchemaSampleIT.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgInformationSchemaSampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testPgInformationSchema() { + String out = + runExample( + () -> + PgInformationSchemaSample.pgInformationSchema( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out, out.contains("public.venues (User defined type: null)")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgNumericDataTypeSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgNumericDataTypeSampleIT.java new file mode 100644 index 00000000000..4ca48e8243e --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgNumericDataTypeSampleIT.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgNumericDataTypeSampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testNumericDataType() { + String out = + runExample( + () -> + PgNumericDataTypeSample.pgNumericDataType( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + + assertTrue(out, out.contains("Revenues of Venue 1: 3150.25")); + assertTrue(out, out.contains("Revenues of Venue 1 as double: 3150.25")); + assertTrue(out, out.contains("Revenues of Venue 1 as BigDecimal: 3150.25")); + assertTrue(out, out.contains("Revenues of Venue 1 as String: 3150.25")); + + assertTrue(out, out.contains("Revenues of Venue 2: null")); + assertTrue(out, out.contains("Revenues of Venue 2 as double: null")); + assertTrue(out, out.contains("Revenues of Venue 2 as BigDecimal: null")); + assertTrue(out, out.contains("Revenues of Venue 2 as String: null")); + + assertTrue(out, out.contains("Revenues of Venue 3: NaN")); + assertTrue(out, out.contains("Revenues of Venue 3 as double: NaN")); + assertFalse(out, out.contains("Revenues of Venue 3 as BigDecimal:")); + assertTrue(out, out.contains("Revenues of Venue 3 as String: NaN")); + + assertTrue(out, out.contains("Inserted 2 Venues using mutations")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgOrderNullsSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgOrderNullsSampleIT.java new file mode 100644 index 00000000000..22b3b1a1c3a --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgOrderNullsSampleIT.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgOrderNullsSampleIT extends BaseJdbcPgExamplesIT { + + @Test + public void testOrderNulls() { + String out = + runExample( + () -> + PgOrderNullsSample.pgOrderNulls( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out, out.contains("Singers ORDER BY Name\n\tAlice\n\tBruce\n\t")); + assertTrue(out, out.contains("Singers ORDER BY Name DESC\n\t\n\tBruce\n\tAlice")); + assertTrue(out, out.contains("Singers ORDER BY Name NULLS FIRST\n\t\n\tAlice\n\tBruce")); + assertTrue( + out, out.contains("Singers ORDER BY Name DESC NULLS LAST\n\tBruce\n\tAlice\n\t")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgPartitionedDmlSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgPartitionedDmlSampleIT.java new file mode 100644 index 00000000000..8fffa1b837c --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgPartitionedDmlSampleIT.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgPartitionedDmlSampleIT extends BaseJdbcPgExamplesIT { + + @Override + protected boolean createTestTable() { + return true; + } + + @Test + public void testPgPartitionedDml() { + String out = + runExample( + () -> + PgPartitionedDmlSample.pgPartitionedDml( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out.contains("Deleted at least 7 singers")); + } +} \ No newline at end of file diff --git a/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgQueryParameterSampleIT.java b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgQueryParameterSampleIT.java new file mode 100644 index 00000000000..0d7c7c285d3 --- /dev/null +++ b/spanner/jdbc/src/test/java/com/example/spanner/jdbc/PgQueryParameterSampleIT.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner.jdbc; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.ServiceOptions; +import org.junit.Test; + +public class PgQueryParameterSampleIT extends BaseJdbcPgExamplesIT { + + @Override + protected boolean createTestTable() { + return true; + } + + @Test + public void testPgQueryParameter() { + String out = + runExample( + () -> + PgQueryParameterSample.pgQueryParameter( + ServiceOptions.getDefaultProjectId(), instanceId, databaseId)); + assertTrue(out.contains("6 Bruce Allison")); + assertFalse(out.contains("7 Alice Bruxelles")); + } +} \ No newline at end of file From 4f932d78909d85ba969362751b754cb457b9ce5c Mon Sep 17 00:00:00 2001 From: Weihan Kong Date: Mon, 2 May 2022 15:36:12 -0400 Subject: [PATCH 083/136] Update README.md (#7084) --- bigtable/beam/bulk-data-generator/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigtable/beam/bulk-data-generator/README.md b/bigtable/beam/bulk-data-generator/README.md index 12c1088e647..24b9d868e69 100644 --- a/bigtable/beam/bulk-data-generator/README.md +++ b/bigtable/beam/bulk-data-generator/README.md @@ -20,8 +20,8 @@ REGION=us-central1 3. Run the command ``` -mvn compile exec:java -Dexec.mainClass=BulkWrite \ +mvn compile exec:java -Dexec.mainClass=bigtable.BulkWrite \ "-Dexec.args=--bigtableInstanceId=$INSTANCE_ID \ --runner=dataflow --project=$GOOGLE_CLOUD_PROJECT \ --bigtableSize=$BIGTABLE_SIZE --region=$REGION" -``` \ No newline at end of file +``` From 60d1699bf9c67c0e9b5ac7d3eaac09feff141fbb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 2 May 2022 22:02:25 +0200 Subject: [PATCH 084/136] chore(deps): update ktor_version to v2.0.2-eap-386 (#7081) --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index ab13b3976de..6fb90800432 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -33,7 +33,7 @@ limitations under the License. 11 11 - 2.0.1-eap-384 + 2.0.2-eap-386 official 1.6.21 1.2.11 From e1d9fa0152b420a55b80d791e9c94f7639d82646 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 2 May 2022 22:02:49 +0200 Subject: [PATCH 085/136] chore(deps): update micronaut packages to v3.4.3 (#7082) --- appengine-java11/micronaut-helloworld/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/micronaut-helloworld/pom.xml b/appengine-java11/micronaut-helloworld/pom.xml index 226c2801201..8faafbed2aa 100644 --- a/appengine-java11/micronaut-helloworld/pom.xml +++ b/appengine-java11/micronaut-helloworld/pom.xml @@ -33,7 +33,7 @@ com.example.appengine.Application 11 11 - 3.4.2 + 3.4.3 From 66103ab42a39d44d017a31e5a9937f507f689000 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 2 May 2022 22:02:55 +0200 Subject: [PATCH 086/136] fix(deps): update opencensus packages to v0.31.1 (#7083) --- opencensus/pom.xml | 2 +- session-handling/pom.xml | 2 +- spanner/opencensus/pom.xml | 2 +- trace/pom.xml | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/opencensus/pom.xml b/opencensus/pom.xml index c73107e926b..f9140f04ee9 100644 --- a/opencensus/pom.xml +++ b/opencensus/pom.xml @@ -36,7 +36,7 @@ 1.8 1.8 UTF-8 - 0.31.0 + 0.31.1 diff --git a/session-handling/pom.xml b/session-handling/pom.xml index 01f63bcbb69..d14286e2516 100644 --- a/session-handling/pom.xml +++ b/session-handling/pom.xml @@ -66,7 +66,7 @@ Copyright 2019 Google LLC io.opencensus opencensus-contrib-http-util - 0.31.0 + 0.31.1 diff --git a/spanner/opencensus/pom.xml b/spanner/opencensus/pom.xml index 5818cde1d15..209a55d7c5b 100644 --- a/spanner/opencensus/pom.xml +++ b/spanner/opencensus/pom.xml @@ -8,7 +8,7 @@ 1.8 1.8 - 0.31.0 + 0.31.1 6.13.0 diff --git a/trace/pom.xml b/trace/pom.xml index 543187a4321..14ad99a6bb4 100644 --- a/trace/pom.xml +++ b/trace/pom.xml @@ -43,12 +43,12 @@ io.opencensus opencensus-api - 0.31.0 + 0.31.1 io.opencensus opencensus-exporter-trace-stackdriver - 0.31.0 + 0.31.1 io.grpc @@ -59,7 +59,7 @@ io.opencensus opencensus-impl - 0.31.0 + 0.31.1 runtime From f63f25808af52ccaf8b4843d8b38debc2aba9738 Mon Sep 17 00:00:00 2001 From: Shubha Rajan Date: Mon, 2 May 2022 16:17:51 -0700 Subject: [PATCH 087/136] feat: Update Cloud SQL MySQL samples to include more connection methods (#7054) * update mysql sample to include new region tags * add license header * move connection code for TCP and connector to separate files * add functions sample * add missing license headers * Update region tag * reformat code * fix function sample * get function working * update instructions for deploying to Functions * Update cloud-sql/mysql/servlet/.env.yaml Co-authored-by: Jack Wotherspoon * add imports and environment variables to sample * Update README.md * Update ConnectorConnectionPoolFactory.java * formatting * Update cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> * Update TcpConnectionPoolFactory.java * Update cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TemplateData.java Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> * Factor out common methods in servlet and cloud function * combine DatabaseSetup and InputValidator classes * refactor cloud function to use initialization on demand * formatting * Update ConnectorConnectionPoolFactory.java * Update ConnectorConnectionPoolFactory.java * Update TcpConnectionPoolFactory.java Co-authored-by: Jack Wotherspoon Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> --- cloud-sql/mysql/servlet/.env.yaml | 7 + cloud-sql/mysql/servlet/README.md | 69 ++++++++- cloud-sql/mysql/servlet/pom.xml | 28 ++++ .../ConnectionPoolContextListener.java | 106 +------------ .../cloudsql/ConnectionPoolFactory.java | 57 +++++++ .../ConnectorConnectionPoolFactory.java | 86 +++++++++++ .../com/example/cloudsql/IndexServlet.java | 85 +---------- .../cloudsql/TcpConnectionPoolFactory.java | 91 +++++++++++ .../com/example/cloudsql/TemplateData.java | 88 +++++++++++ .../main/java/com/example/cloudsql/Utils.java | 56 +++++++ .../com/example/cloudsql/functions/Main.java | 142 ++++++++++++++++++ .../test/java/com/TestIndexServletMysql.java | 1 - 12 files changed, 634 insertions(+), 182 deletions(-) create mode 100644 cloud-sql/mysql/servlet/.env.yaml create mode 100644 cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java create mode 100644 cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java create mode 100644 cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java create mode 100644 cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TemplateData.java create mode 100644 cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/Utils.java create mode 100644 cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/functions/Main.java diff --git a/cloud-sql/mysql/servlet/.env.yaml b/cloud-sql/mysql/servlet/.env.yaml new file mode 100644 index 00000000000..7978d8d71b7 --- /dev/null +++ b/cloud-sql/mysql/servlet/.env.yaml @@ -0,0 +1,7 @@ +INSTANCE_CONNECTION_NAME: ::INSTANCE-NAME> +INSTANCE_UNIX_SOCKET: /cloudsql/::INSTANCE-NAME> +INSTANCE_HOST: '127.0.0.1' +DB_PORT: 3306 +DB_USER: +DB_PASS: +DB_NAME: diff --git a/cloud-sql/mysql/servlet/README.md b/cloud-sql/mysql/servlet/README.md index 8b510b28d14..915f0e13fdf 100644 --- a/cloud-sql/mysql/servlet/README.md +++ b/cloud-sql/mysql/servlet/README.md @@ -29,6 +29,56 @@ export DB_NAME='my_db' Note: Saving credentials in environment variables is convenient, but not secure - consider a more secure solution such as [Cloud KMS](https://cloud.google.com/kms/) or [Secret Manager](https://cloud.google.com/secret-manager/) to help keep secrets safe. +## Configure SSL Certificates +For deployments that connect directly to a Cloud SQL instance with TCP, +without using the Cloud SQL Proxy, +configuring SSL certificates will ensure the connection is encrypted. +1. Use the gcloud CLI to [download the server certificate](https://cloud.google.com/sql/docs/mysql/configure-ssl-instance#server-certs) for your Cloud SQL instance. + - Get information about the service certificate: + ``` + gcloud beta sql ssl server-ca-certs list --instance=INSTANCE_NAME + ``` + - Create a server certificate: + ``` + gcloud beta sql ssl server-ca-certs create --instance=INSTANCE_NAME + ``` + - Download the certificate information to a local PEM file + ``` + gcloud beta sql ssl server-ca-certs list \ + --format="value(cert)" \ + --instance=INSTANCE_NAME > \ + server-ca.pem + ``` + +1. Use the gcloud CLI to [create and download a client public key certificate and client private key](https://cloud.google.com/sql/docs/mysql/configure-ssl-instance#client-certs) + - Create a client certificate using the ssl client-certs create command: + ``` + gcloud sql ssl client-certs create CERT_NAME client-key.pem --instance=INSTANCE_NAME + ``` + - Retrieve the public key for the certificate you just created and copy it into the client-cert.pem file with the ssl client-certs describe command: + ``` + gcloud sql ssl client-certs describe CERT_NAME \ + --instance=INSTANCE_NAME \ + --format="value(cert)" > client-cert.pem + ``` +1. [Import the server certificate into a custom Java truststore](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html) using `keytool`: + ``` + keytool -importcert -alias MySQLCACert -file server-ca.pem \ + -keystore -storepass + ``` +1. Set the `TRUST_CERT_KEYSTORE_PATH` and `TRUST_CERT_KEYSTORE_PASSWD` environment variables to the values used in the previous step. +1. [Import the client certificate and key into a custom Java keystore](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html) using `openssl` and `keytool`: + - Convert the client key and certificate files to a PKCS #12 archive: + ``` + openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem \ + -name "mysqlclient" -passout pass:mypassword -out client-keystore.p12 + ``` + - Import the client key and certificate into a Java keystore: + ``` + keytool -importkeystore -srckeystore client-keystore.p12 -srcstoretype pkcs12 \ + -srcstorepass -destkeystore -deststoretype JKS -deststorepass + ``` +1. Set the `CLIENT_CERT_KEYSTORE_PATH` and `CLIENT_CERT_KEYSTORE_PASSWD` environment variables to the values used in the previous step. ## Deploying locally To run this application locally, run the following command inside the project folder: @@ -48,13 +98,19 @@ and verify that has been added in your build section as a plugin. -### Development Server +### App Engine Development Server The following command will run the application locally in the the GAE-development server: ```bash mvn appengine:run ``` +### Cloud Functions Development Server +To run the application locally as a Cloud Function, run the following command: +``` +mvn function:run -Drun.functionTarget=com.example.cloudsql.functions.Main +``` + ### Deploy to Google App Engine First, update `src/main/webapp/WEB-INF/appengine-web.xml` with the correct values to pass the @@ -120,3 +176,14 @@ mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \ For more details about using Cloud Run see http://cloud.run. Review other [Java on Cloud Run samples](../../../run/). + +### Deploy to Google Cloud Functions + +To deploy the application to Cloud Functions, first fill in the values for required environment variables in `.env.yaml`. Then run the following command +``` +gcloud functions deploy mysql-sample \ + --trigger-http \ + --entry-point com.example.cloudsql.functions.Main \ + --runtime java11 \ + --env-vars-file .env.yaml +``` diff --git a/cloud-sql/mysql/servlet/pom.xml b/cloud-sql/mysql/servlet/pom.xml index 84a97e25647..13616c0b3a4 100644 --- a/cloud-sql/mysql/servlet/pom.xml +++ b/cloud-sql/mysql/servlet/pom.xml @@ -92,6 +92,17 @@ 1.1.3 test + + com.google.cloud.functions.invoker + java-function-invoker + 1.0.1 + + + com.google.cloud.functions + functions-framework-api + 1.0.4 + provided + @@ -114,6 +125,23 @@ GCLOUD_CONFIG
+ + + com.google.cloud.functions + function-maven-plugin + 0.10.0 + + com.example.cloudsql.functions.Main + + diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java index aa994574207..db3373071a0 100644 --- a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java @@ -16,11 +16,8 @@ package com.example.cloudsql; -import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.sql.Connection; -import java.sql.PreparedStatement; import java.sql.SQLException; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; @@ -34,101 +31,6 @@ @WebListener("Creates a connection pool that is stored in the Servlet's context for later use.") public class ConnectionPoolContextListener implements ServletContextListener { - // Saving credentials in environment variables is convenient, but not secure - consider a more - // secure solution such as https://cloud.google.com/kms/ to help keep secrets safe. - private static final String INSTANCE_CONNECTION_NAME = - System.getenv("INSTANCE_CONNECTION_NAME"); - private static final String DB_USER = System.getenv("DB_USER"); - private static final String DB_PASS = System.getenv("DB_PASS"); - private static final String DB_NAME = System.getenv("DB_NAME"); - - @SuppressFBWarnings( - value = "USBR_UNNECESSARY_STORE_BEFORE_RETURN", - justification = "Necessary for sample region tag.") - private DataSource createConnectionPool() { - // [START cloud_sql_mysql_servlet_create] - // Note: For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections - // which is preferred to using the Cloud SQL Proxy with Unix sockets. - // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details. - - // The configuration object specifies behaviors for the connection pool. - HikariConfig config = new HikariConfig(); - - // The following URL is equivalent to setting the config options below: - // jdbc:mysql:///?cloudSqlInstance=& - // socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=&password= - // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory - // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url - - // Configure which instance and what database user to connect with. - config.setJdbcUrl(String.format("jdbc:mysql:///%s", DB_NAME)); - config.setUsername(DB_USER); // e.g. "root", "mysql" - config.setPassword(DB_PASS); // e.g. "my-password" - - config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.mysql.SocketFactory"); - config.addDataSourceProperty("cloudSqlInstance", INSTANCE_CONNECTION_NAME); - - // The ipTypes argument can be used to specify a comma delimited list of preferred IP types - // for connecting to a Cloud SQL instance. The argument ipTypes=PRIVATE will force the - // SocketFactory to connect with an instance's associated private IP. - config.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE"); - - // ... Specify additional connection properties here. - // [START_EXCLUDE] - - // [START cloud_sql_mysql_servlet_limit] - // maximumPoolSize limits the total number of concurrent connections this pool will keep. Ideal - // values for this setting are highly variable on app design, infrastructure, and database. - config.setMaximumPoolSize(5); - // minimumIdle is the minimum number of idle connections Hikari maintains in the pool. - // Additional connections will be established to meet this value unless the pool is full. - config.setMinimumIdle(5); - // [END cloud_sql_mysql_servlet_limit] - - // [START cloud_sql_mysql_servlet_timeout] - // setConnectionTimeout is the maximum number of milliseconds to wait for a connection checkout. - // Any attempt to retrieve a connection from this pool that exceeds the set limit will throw an - // SQLException. - config.setConnectionTimeout(10000); // 10 seconds - // idleTimeout is the maximum amount of time a connection can sit in the pool. Connections that - // sit idle for this many milliseconds are retried if minimumIdle is exceeded. - config.setIdleTimeout(600000); // 10 minutes - // [END cloud_sql_mysql_servlet_timeout] - - // [START cloud_sql_mysql_servlet_backoff] - // Hikari automatically delays between failed connection attempts, eventually reaching a - // maximum delay of `connectionTimeout / 2` between attempts. - // [END cloud_sql_mysql_servlet_backoff] - - // [START cloud_sql_mysql_servlet_lifetime] - // maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that - // live longer than this many milliseconds will be closed and reestablished between uses. This - // value should be several minutes shorter than the database's timeout value to avoid unexpected - // terminations. - config.setMaxLifetime(1800000); // 30 minutes - // [END cloud_sql_mysql_servlet_lifetime] - - // [END_EXCLUDE] - - // Initialize the connection pool using the configuration object. - DataSource pool = new HikariDataSource(config); - // [END cloud_sql_mysql_servlet_create] - return pool; - } - - private void createTable(DataSource pool) throws SQLException { - // Safely attempt to create the table schema. - try (Connection conn = pool.getConnection()) { - String stmt = - "CREATE TABLE IF NOT EXISTS votes ( " - + "vote_id SERIAL NOT NULL, time_cast timestamp NOT NULL, candidate CHAR(6) NOT NULL," - + " PRIMARY KEY (vote_id) );"; - try (PreparedStatement createTableStatement = conn.prepareStatement(stmt);) { - createTableStatement.execute(); - } - } - } - @Override public void contextDestroyed(ServletContextEvent event) { // This function is called when the Servlet is destroyed. @@ -145,11 +47,15 @@ public void contextInitialized(ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); DataSource pool = (DataSource) servletContext.getAttribute("my-pool"); if (pool == null) { - pool = createConnectionPool(); + if (System.getenv("INSTANCE_HOST") != null) { + pool = TcpConnectionPoolFactory.createConnectionPool(); + } else { + pool = ConnectorConnectionPoolFactory.createConnectionPool(); + } servletContext.setAttribute("my-pool", pool); } try { - createTable(pool); + Utils.createTable(pool); } catch (SQLException ex) { throw new RuntimeException( "Unable to verify table schema. Please double check the steps" diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java new file mode 100644 index 00000000000..a9f51330483 --- /dev/null +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import com.zaxxer.hikari.HikariConfig; + +public class ConnectionPoolFactory { + + public static HikariConfig configureConnectionPool(HikariConfig config) { + // [START cloud_sql_mysql_servlet_limit] + // maximumPoolSize limits the total number of concurrent connections this pool will keep. Ideal + // values for this setting are highly variable on app design, infrastructure, and database. + config.setMaximumPoolSize(5); + // minimumIdle is the minimum number of idle connections Hikari maintains in the pool. + // Additional connections will be established to meet this value unless the pool is full. + config.setMinimumIdle(5); + // [END cloud_sql_mysql_servlet_limit] + + // [START cloud_sql_mysql_servlet_timeout] + // setConnectionTimeout is the maximum number of milliseconds to wait for a connection checkout. + // Any attempt to retrieve a connection from this pool that exceeds the set limit will throw an + // SQLException. + config.setConnectionTimeout(10000); // 10 seconds + // idleTimeout is the maximum amount of time a connection can sit in the pool. Connections that + // sit idle for this many milliseconds are retried if minimumIdle is exceeded. + config.setIdleTimeout(600000); // 10 minutes + // [END cloud_sql_mysql_servlet_timeout] + + // [START cloud_sql_mysql_servlet_backoff] + // Hikari automatically delays between failed connection attempts, eventually reaching a + // maximum delay of `connectionTimeout / 2` between attempts. + // [END cloud_sql_mysql_servlet_backoff] + + // [START cloud_sql_mysql_servlet_lifetime] + // maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that + // live longer than this many milliseconds will be closed and reestablished between uses. This + // value should be several minutes shorter than the database's timeout value to avoid unexpected + // terminations. + config.setMaxLifetime(1800000); // 30 minutes + // [END cloud_sql_mysql_servlet_lifetime] + return config; + } +} diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java new file mode 100644 index 00000000000..bc34c6c06cb --- /dev/null +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java @@ -0,0 +1,86 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +// [START cloud_sql_mysql_servlet_connect_connector] +// [START cloud_sql_mysql_servlet_connect_unix] + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; + +public class ConnectorConnectionPoolFactory extends ConnectionPoolFactory { + + // Note: Saving credentials in environment variables is convenient, but not + // secure - consider a more secure solution such as + // Cloud Secret Manager (https://cloud.google.com/secret-manager) to help + // keep secrets safe. + private static final String INSTANCE_CONNECTION_NAME = + System.getenv("INSTANCE_CONNECTION_NAME"); + private static final String INSTANCE_UNIX_SOCKET = System.getenv("INSTANCE_UNIX_SOCKET"); + private static final String DB_USER = System.getenv("DB_USER"); + private static final String DB_PASS = System.getenv("DB_PASS"); + private static final String DB_NAME = System.getenv("DB_NAME"); + + public static DataSource createConnectionPool() { + // The configuration object specifies behaviors for the connection pool. + HikariConfig config = new HikariConfig(); + + // The following URL is equivalent to setting the config options below: + // jdbc:mysql:///?cloudSqlInstance=& + // socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=&password= + // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory + // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url + + // Configure which instance and what database user to connect with. + config.setJdbcUrl(String.format("jdbc:mysql:///%s", DB_NAME)); + config.setUsername(DB_USER); // e.g. "root", "mysql" + config.setPassword(DB_PASS); // e.g. "my-password" + + config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.mysql.SocketFactory"); + config.addDataSourceProperty("cloudSqlInstance", INSTANCE_CONNECTION_NAME); + + // [END cloud_sql_mysql_servlet_connect_connector] + // Unix sockets are not natively supported in Java, so it is necessary to use the Cloud SQL + // Java Connector to connect. When setting INSTANCE_UNIX_SOCKET, the connector will + // call an external package that will enable Unix socket connections. + // Note: For Java users, the Cloud SQL Java Connector can provide authenticated connections + // which is usually preferable to using the Cloud SQL Proxy with Unix sockets. + // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details. + if (INSTANCE_UNIX_SOCKET != null) { + config.addDataSourceProperty("unixSocketPath", INSTANCE_UNIX_SOCKET); + } + // [START cloud_sql_mysql_servlet_connect_connector] + + // [END cloud_sql_mysql_servlet_connect_unix] + // The ipTypes argument can be used to specify a comma delimited list of preferred IP types + // for connecting to a Cloud SQL instance. The argument ipTypes=PRIVATE will force the + // SocketFactory to connect with an instance's associated private IP. + config.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE"); + // [START cloud_sql_mysql_servlet_connect_unix] + + // ... Specify additional connection properties here. + // [START_EXCLUDE] + configureConnectionPool(config); + // [END_EXCLUDE] + + // Initialize the connection pool using the configuration object. + return new HikariDataSource(config); + } +} +// [END cloud_sql_mysql_servlet_connect_connector] +// [END cloud_sql_mysql_servlet_connect_unix] diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/IndexServlet.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/IndexServlet.java index 7f43bf811cd..6551d57e899 100644 --- a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/IndexServlet.java +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/IndexServlet.java @@ -20,16 +20,11 @@ import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.Date; -import java.util.List; -import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nullable; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; @@ -38,7 +33,6 @@ import javax.sql.DataSource; - @SuppressFBWarnings( value = {"SE_NO_SERIALVERSIONID", "WEM_WEAK_EXCEPTION_MESSAGING"}, justification = "Not needed for IndexServlet, Exception adds context") @@ -47,67 +41,12 @@ public class IndexServlet extends HttpServlet { private static final Logger LOGGER = Logger.getLogger(IndexServlet.class.getName()); - class TemplateData { - - public int tabCount; - public int spaceCount; - public List recentVotes; - - public TemplateData(int tabCount, int spaceCount, List recentVotes) { - this.tabCount = tabCount; - this.spaceCount = spaceCount; - this.recentVotes = recentVotes; - } - } - - public TemplateData getTemplateData(DataSource pool) throws ServletException { - - int tabCount = 0; - int spaceCount = 0; - List recentVotes = new ArrayList<>(); - try (Connection conn = pool.getConnection()) { - // PreparedStatements are compiled by the database immediately and executed at a later date. - // Most databases cache previously compiled queries, which improves efficiency. - String stmt1 = "SELECT candidate, time_cast FROM votes ORDER BY time_cast DESC LIMIT 5"; - try (PreparedStatement voteStmt = conn.prepareStatement(stmt1);) { - // Execute the statement - ResultSet voteResults = voteStmt.executeQuery(); - // Convert a ResultSet into Vote objects - while (voteResults.next()) { - String candidate = voteResults.getString(1); - Timestamp timeCast = voteResults.getTimestamp(2); - recentVotes.add(new Vote(candidate, timeCast)); - } - } - - // PreparedStatements can also be executed multiple times with different arguments. This can - // improve efficiency, and project a query from being vulnerable to an SQL injection. - String stmt2 = "SELECT COUNT(vote_id) FROM votes WHERE candidate=?"; - try (PreparedStatement voteCountStmt = conn.prepareStatement(stmt2);) { - voteCountStmt.setString(1, "TABS"); - ResultSet tabResult = voteCountStmt.executeQuery(); - if (tabResult.next()) { // Move to the first result - tabCount = tabResult.getInt(1); - } - - voteCountStmt.setString(1, "SPACES"); - ResultSet spaceResult = voteCountStmt.executeQuery(); - if (spaceResult.next()) { // Move to the first result - spaceCount = spaceResult.getInt(1); - } - } + TemplateData getTemplateData(DataSource pool) throws ServletException { + try { + return TemplateData.getTemplateData(pool); } catch (SQLException ex) { - // If something goes wrong, the application needs to react appropriately. This might mean - // getting a new connection and executing the query again, or it might mean redirecting the - // user to a different page to let them know something went wrong. - throw new ServletException( - "Unable to successfully connect to the database. Please check the " - + "steps in the README and try again.", - ex); + throw new ServletException(ex); } - TemplateData templateData = new TemplateData(tabCount, spaceCount, recentVotes); - - return templateData; } @Override @@ -126,27 +65,13 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) req.getRequestDispatcher("/index.jsp").forward(req, resp); } - // Used to validate user input. All user provided data should be validated and sanitized before - // being used something like a SQL query. Returns null if invalid. - @Nullable - private String validateTeam(String input) { - if (input != null) { - input = input.toUpperCase(Locale.ENGLISH); - // Must be either "TABS" or "SPACES" - if (!"TABS".equals(input) && !"SPACES".equals(input)) { - return null; - } - } - return input; - } - @SuppressFBWarnings( value = {"SERVLET_PARAMETER", "XSS_SERVLET"}, justification = "Input is validated and sanitized.") @Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { // Get the team from the request and record the time of the vote. - String team = validateTeam(req.getParameter("team")); + String team = Utils.validateTeam(req.getParameter("team")); Timestamp now = new Timestamp(new Date().getTime()); if (team == null) { resp.setStatus(400); diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java new file mode 100644 index 00000000000..fec50bb8d8b --- /dev/null +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java @@ -0,0 +1,91 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +// [START cloud_sql_mysql_servlet_connect_tcp] +// [START cloud_sql_mysql_servlet_connect_tcp_sslcerts] + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; + +public class TcpConnectionPoolFactory extends ConnectionPoolFactory { + + // Saving credentials in environment variables is convenient, but not secure - consider a more + // secure solution such as https://cloud.google.com/secret-manager/ to help keep secrets safe. + private static final String DB_USER = System.getenv("DB_USER"); + private static final String DB_PASS = System.getenv("DB_PASS"); + private static final String DB_NAME = System.getenv("DB_NAME"); + + private static final String INSTANCE_HOST = System.getenv("INSTANCE_HOST"); + private static final String DB_PORT = System.getenv("DB_PORT"); + + // [END cloud_sql_mysql_servlet_connect_tcp] + private static final String TRUST_CERT_KEYSTORE_PATH = System.getenv( + "TRUST_CERT_KEYSTORE_PATH"); + private static final String TRUST_CERT_KEYSTORE_PASSWD = System.getenv( + "TRUST_CERT_KEYSTORE_PASSWD"); + private static final String CLIENT_CERT_KEYSTORE_PATH = System.getenv( + "CLIENT_CERT_KEYSTORE_PATH"); + private static final String CLIENT_CERT_KEYSTORE_PASSWD = System.getenv( + "CLIENT_CERT_KEYSTORE_PASSWD"); + // [START cloud_sql_mysql_servlet_connect_tcp] + + public static DataSource createConnectionPool() { + // The configuration object specifies behaviors for the connection pool. + HikariConfig config = new HikariConfig(); + + // The following URL is equivalent to setting the config options below: + // jdbc:mysql://:/?user=&password= + // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory + // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url + + // Configure which instance and what database user to connect with. + config.setJdbcUrl(String.format("jdbc:mysql://%s:%s/%s", INSTANCE_HOST, DB_PORT, DB_NAME)); + config.setUsername(DB_USER); // e.g. "root", "mysql" + config.setPassword(DB_PASS); // e.g. "my-password" + + // [END cloud_sql_mysql_servlet_connect_tcp] + // (OPTIONAL) Configure SSL certificates + // For deployments that connect directly to a Cloud SQL instance without + // using the Cloud SQL Proxy, configuring SSL certificates will ensure the + // connection is encrypted. + // See the link below for more information on how to configure SSL Certificates for use with + // MySQL Connector/J + // https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html + if (CLIENT_CERT_KEYSTORE_PATH != null && TRUST_CERT_KEYSTORE_PATH != null) { + config.addDataSourceProperty("trustCertificateKeyStoreUrl", + String.format("file:%s", TRUST_CERT_KEYSTORE_PATH)); + config.addDataSourceProperty("trustCertificateKeyStorePassword", TRUST_CERT_KEYSTORE_PASSWD); + config.addDataSourceProperty("clientCertificateKeyStoreUrl", + String.format("file:%s", CLIENT_CERT_KEYSTORE_PATH)); + config.addDataSourceProperty("clientCertificateKeyStorePassword", + CLIENT_CERT_KEYSTORE_PASSWD); + } + // [START cloud_sql_mysql_servlet_connect_tcp] + + // ... Specify additional connection properties here. + // [START_EXCLUDE] + configureConnectionPool(config); + // [END_EXCLUDE] + + // Initialize the connection pool using the configuration object. + return new HikariDataSource(config); + } +} +// [END cloud_sql_mysql_servlet_connect_tcp] +// [END cloud_sql_mysql_servlet_connect_tcp_sslcerts] diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TemplateData.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TemplateData.java new file mode 100644 index 00000000000..693da207de4 --- /dev/null +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/TemplateData.java @@ -0,0 +1,88 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import javax.sql.DataSource; + +public class TemplateData { + + public int tabCount; + public int spaceCount; + public List recentVotes; + + public TemplateData(int tabCount, int spaceCount, List recentVotes) { + this.tabCount = tabCount; + this.spaceCount = spaceCount; + this.recentVotes = recentVotes; + } + + public static TemplateData getTemplateData(DataSource pool) throws SQLException { + int tabCount = 0; + int spaceCount = 0; + List recentVotes = new ArrayList<>(); + try (Connection conn = pool.getConnection()) { + // PreparedStatements are compiled by the database immediately and executed at a later date. + // Most databases cache previously compiled queries, which improves efficiency. + String stmt1 = "SELECT candidate, time_cast FROM votes ORDER BY time_cast DESC LIMIT 5"; + try (PreparedStatement voteStmt = conn.prepareStatement(stmt1);) { + // Execute the statement + ResultSet voteResults = voteStmt.executeQuery(); + // Convert a ResultSet into Vote objects + while (voteResults.next()) { + String candidate = voteResults.getString(1); + Timestamp timeCast = voteResults.getTimestamp(2); + recentVotes.add(new Vote(candidate, timeCast)); + } + } + + // PreparedStatements can also be executed multiple times with different arguments. This can + // improve efficiency, and project a query from being vulnerable to an SQL injection. + String stmt2 = "SELECT COUNT(vote_id) FROM votes WHERE candidate=?"; + try (PreparedStatement voteCountStmt = conn.prepareStatement(stmt2);) { + voteCountStmt.setString(1, "TABS"); + ResultSet tabResult = voteCountStmt.executeQuery(); + if (tabResult.next()) { // Move to the first result + tabCount = tabResult.getInt(1); + } + + voteCountStmt.setString(1, "SPACES"); + ResultSet spaceResult = voteCountStmt.executeQuery(); + if (spaceResult.next()) { // Move to the first result + spaceCount = spaceResult.getInt(1); + } + } + } catch (SQLException ex) { + // If something goes wrong, the application needs to react appropriately. This might mean + // getting a new connection and executing the query again, or it might mean redirecting the + // user to a different page to let them know something went wrong. + throw new SQLException( + "Unable to successfully connect to the database. Please check the " + + "steps in the README and try again.", + ex); + } + TemplateData templateData = new TemplateData(tabCount, spaceCount, recentVotes); + + return templateData; + } +} diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/Utils.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/Utils.java new file mode 100644 index 00000000000..a6da84573dd --- /dev/null +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/Utils.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Locale; +import javax.annotation.Nullable; +import javax.sql.DataSource; + +public class Utils { + + // Used to validate user input. All user provided data should be validated and sanitized before + // being used something like a SQL query. Returns null if invalid. + @Nullable + public static String validateTeam(String input) { + if (input != null) { + input = input.toUpperCase(Locale.ENGLISH); + // Must be either "TABS" or "SPACES" + if (!"TABS".equals(input) && !"SPACES".equals(input)) { + return null; + } + } + return input; + } + + public static void createTable(DataSource pool) throws SQLException { + // Safely attempt to create the table schema. + try (Connection conn = pool.getConnection()) { + String stmt = + "CREATE TABLE IF NOT EXISTS votes ( " + + "vote_id SERIAL NOT NULL, time_cast timestamp NOT NULL, candidate CHAR(6) NOT NULL," + + " PRIMARY KEY (vote_id) );"; + try (PreparedStatement createTableStatement = conn.prepareStatement(stmt);) { + createTableStatement.execute(); + } + } + } + + +} diff --git a/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/functions/Main.java b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/functions/Main.java new file mode 100644 index 00000000000..e42f4ce7128 --- /dev/null +++ b/cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/functions/Main.java @@ -0,0 +1,142 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql.functions; + +import com.example.cloudsql.ConnectorConnectionPoolFactory; +import com.example.cloudsql.TcpConnectionPoolFactory; +import com.example.cloudsql.TemplateData; +import com.example.cloudsql.Utils; +import com.google.cloud.functions.HttpFunction; +import com.google.cloud.functions.HttpRequest; +import com.google.cloud.functions.HttpResponse; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.Date; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.sql.DataSource; + +public class Main implements HttpFunction { + + private Logger logger = Logger.getLogger(Main.class.getName()); + private static final Gson gson = new Gson(); + + // Declared at cold-start, but only initialized if/when the function executes + // Uses the "initialization-on-demand holder" idiom + // More information: https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom + private static class PoolHolder { + + // Making the default constructor private prohibits instantiation of this class + private PoolHolder() { + } + + // This value is initialized only if (and when) the getInstance() function below is called + private static final DataSource INSTANCE = setupPool(); + + private static DataSource setupPool() { + DataSource pool; + if (System.getenv("INSTANCE_HOST") != null) { + pool = TcpConnectionPoolFactory.createConnectionPool(); + } else { + pool = ConnectorConnectionPoolFactory.createConnectionPool(); + } + try { + Utils.createTable(pool); + } catch (SQLException ex) { + throw new RuntimeException( + "Unable to verify table schema. Please double check the steps" + + "in the README and try again.", + ex); + } + return pool; + } + + private static DataSource getInstance() { + return PoolHolder.INSTANCE; + } + } + + private void returnVoteCounts(HttpRequest req, HttpResponse resp) + throws SQLException, IOException { + DataSource pool = PoolHolder.getInstance(); + TemplateData templateData = TemplateData.getTemplateData(pool); + JsonObject respContent = new JsonObject(); + + // Return JSON Data + respContent.addProperty("tabCount", templateData.tabCount); + respContent.addProperty("spaceCount", templateData.spaceCount); + respContent.addProperty("recentVotes", gson.toJson(templateData.recentVotes)); + resp.getWriter().write(respContent.toString()); + resp.setStatusCode(HttpURLConnection.HTTP_OK); + } + + private void submitVote(HttpRequest req, HttpResponse resp) throws IOException { + DataSource pool = PoolHolder.getInstance(); + Timestamp now = new Timestamp(new Date().getTime()); + JsonObject body = gson.fromJson(req.getReader(), JsonObject.class); + String team = Utils.validateTeam(body.get("team").getAsString()); + if (team == null) { + resp.setStatusCode(400); + resp.getWriter().append("Invalid team specified."); + return; + } + try (Connection conn = pool.getConnection()) { + // PreparedStatements can be more efficient and project against injections. + String stmt = "INSERT INTO votes (time_cast, candidate) VALUES (?, ?);"; + try (PreparedStatement voteStmt = conn.prepareStatement(stmt);) { + voteStmt.setTimestamp(1, now); + voteStmt.setString(2, team); + + // Finally, execute the statement. If it fails, an error will be thrown. + voteStmt.execute(); + } + } catch (SQLException ex) { + // If something goes wrong, handle the error in this section. This might involve retrying or + // adjusting parameters depending on the situation. + logger.log(Level.WARNING, "Error while attempting to submit vote.", ex); + resp.setStatusCode(500); + resp.getWriter() + .write( + "Unable to successfully cast vote! Please check the application " + + "logs for more details."); + } + } + + @Override + public void service(HttpRequest req, HttpResponse resp) throws IOException, SQLException { + + String method = req.getMethod(); + switch (method) { + case "GET": + returnVoteCounts(req, resp); + break; + case "POST": + submitVote(req, resp); + break; + default: + resp.setStatusCode(HttpURLConnection.HTTP_BAD_METHOD); + resp.getWriter().write(String.format("HTTP Method %s is not supported", method)); + break; + } + } +} diff --git a/cloud-sql/mysql/servlet/src/test/java/com/TestIndexServletMysql.java b/cloud-sql/mysql/servlet/src/test/java/com/TestIndexServletMysql.java index abc81dfc142..57b624ba526 100644 --- a/cloud-sql/mysql/servlet/src/test/java/com/TestIndexServletMysql.java +++ b/cloud-sql/mysql/servlet/src/test/java/com/TestIndexServletMysql.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.example.cloudsql.IndexServlet.TemplateData; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import java.io.PrintWriter; From 99a76e68298d4b8f1f58be8bb1ac23eaa4124a7a Mon Sep 17 00:00:00 2001 From: Shubha Rajan Date: Mon, 2 May 2022 17:44:38 -0700 Subject: [PATCH 088/136] chore: add Kokoro build configs for JDK 17 (#7085) * chore: add Kokoro build configs for JDK 17 * update license headers --- .kokoro/java17/common.cfg | 45 ++++++++++++++++++++++++++++++++++ .kokoro/java17/continuous.cfg | 27 ++++++++++++++++++++ .kokoro/java17/periodic.cfg | 22 +++++++++++++++++ .kokoro/java17/presubmit.cfg | 26 ++++++++++++++++++++ .kokoro/tests/run_test_java.sh | 2 +- 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 .kokoro/java17/common.cfg create mode 100644 .kokoro/java17/continuous.cfg create mode 100644 .kokoro/java17/periodic.cfg create mode 100644 .kokoro/java17/presubmit.cfg diff --git a/.kokoro/java17/common.cfg b/.kokoro/java17/common.cfg new file mode 100644 index 00000000000..0ee5c4bf978 --- /dev/null +++ b/.kokoro/java17/common.cfg @@ -0,0 +1,45 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Build timeout of 5 hours +timeout_mins: 360 + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-docs-samples/.kokoro/trampoline.sh" + +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Set the JAVA VERSION env var. +env_vars: { + key: "JAVA_VERSION" + value: "1.8,11,17" +} + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java17" +} + +# Access btlr binaries used in the tests +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/btlr" diff --git a/.kokoro/java17/continuous.cfg b/.kokoro/java17/continuous.cfg new file mode 100644 index 00000000000..d9a8c1bffdc --- /dev/null +++ b/.kokoro/java17/continuous.cfg @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Tell trampoline which tests to run. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-docs-samples/.kokoro/tests/run_tests.sh" +} + +# Only diff from previous commit +env_vars: { + key: "GIT_DIFF" + value: "HEAD~.. ." +} diff --git a/.kokoro/java17/periodic.cfg b/.kokoro/java17/periodic.cfg new file mode 100644 index 00000000000..65cbde07819 --- /dev/null +++ b/.kokoro/java17/periodic.cfg @@ -0,0 +1,22 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Tell the trampoline which build file to use. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-docs-samples/.kokoro/tests/run_tests.sh" +} + diff --git a/.kokoro/java17/presubmit.cfg b/.kokoro/java17/presubmit.cfg new file mode 100644 index 00000000000..f642ed9fdf6 --- /dev/null +++ b/.kokoro/java17/presubmit.cfg @@ -0,0 +1,26 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Format: //devtools/kokoro/config/proto/build.proto + +# Tell the trampoline which build file to use. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-docs-samples/.kokoro/tests/run_tests.sh" +} +# Only diff from main +env_vars: { + key: "GIT_DIFF" + value: "origin/main... ." +} diff --git a/.kokoro/tests/run_test_java.sh b/.kokoro/tests/run_test_java.sh index 39cf1f78775..f645e881171 100755 --- a/.kokoro/tests/run_test_java.sh +++ b/.kokoro/tests/run_test_java.sh @@ -18,7 +18,7 @@ SCRIPT_DIR="$(dirname $0)/" # Fail the tests if no Java version was found. POM_JAVA=$(grep -oP '(?<=).*?(?=)' pom.xml) -ALLOWED_VERSIONS=("1.8" "11") +ALLOWED_VERSIONS=("1.8" "11" "17") # shellcheck disable=SC2199 # shellcheck disable=SC2076 if [[ "$POM_JAVA" = "" ]] || [[ ! "${ALLOWED_VERSIONS[@]}" =~ "${POM_JAVA}" ]]; then From b864fcd317f5048805fb39501faa5b7c5530a6a8 Mon Sep 17 00:00:00 2001 From: Shubha Rajan Date: Tue, 3 May 2022 23:55:11 -0700 Subject: [PATCH 089/136] chore: require Java 17 CI check (#7097) * chore: require Java 17 CI check * add repo to safe directories --- .github/sync-repo-settings.yaml | 1 + .kokoro/tests/run_tests.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 7c20f065f48..12d9f01d7b7 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -7,6 +7,7 @@ branchProtectionRules: requiredStatusCheckContexts: - 'Kokoro CI - Java 11' - 'Kokoro CI - Java 8' + - 'Kokoro CI - Java 17' - 'Kokoro CI - Lint' - 'cla/google' requiredApprovingReviewCount: 1 diff --git a/.kokoro/tests/run_tests.sh b/.kokoro/tests/run_tests.sh index 73f3690fbf8..a7d7071d0d3 100755 --- a/.kokoro/tests/run_tests.sh +++ b/.kokoro/tests/run_tests.sh @@ -45,6 +45,8 @@ if [[ "$SCRIPT_DEBUG" != "true" ]]; then # Update `gcloud` and log versioning for debugging apt update && apt -y upgrade google-cloud-sdk + echo "********** GIT INFO ***********" + git version echo "********** GCLOUD INFO ***********" gcloud -v echo "********** MAVEN INFO ***********" @@ -115,6 +117,8 @@ fi echo -e "\n******************** TESTING PROJECTS ********************" test_prog="$PWD/.kokoro/tests/run_test_java.sh" +git config --global --add safe.directory $PWD + # Use btlr to run all the tests in each folder echo "btlr" "${btlr_args[@]}" -- "${test_prog}" btlr "${btlr_args[@]}" -- "${test_prog}" From 0d0097a818eb48492002c90d63d6b3db0fe23b92 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 5 May 2022 18:22:18 +0200 Subject: [PATCH 090/136] fix(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-1.x to v2.2.0 (#7108) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.bigtable:bigtable-hbase-1.x](https://cloud.google.com/bigtable/) ([source](https://togithub.com/googleapis/java-bigtable-hbase)) | `2.1.1` -> `2.2.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x/2.2.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x/2.2.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x/2.2.0/compatibility-slim/2.1.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-1.x/2.2.0/confidence-slim/2.1.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-bigtable-hbase ### [`v2.2.0`](https://togithub.com/googleapis/java-bigtable-hbase/blob/HEAD/CHANGELOG.md#​220-httpsgithubcomgoogleapisjava-bigtable-hbasecomparev211v220-2022-05-03) [Compare Source](https://togithub.com/googleapis/java-bigtable-hbase/compare/v2.1.1...v2.2.0) ##### Features - log version and settings on startup ([#​3601](https://togithub.com/googleapis/java-bigtable-hbase/issues/3601)) ([109023a](https://togithub.com/googleapis/java-bigtable-hbase/commit/109023aa980aaf26229544f271ca348466eac5fe)) - next release from main branch is 2.2.0 ([#​3593](https://togithub.com/googleapis/java-bigtable-hbase/issues/3593)) ([58a6ce4](https://togithub.com/googleapis/java-bigtable-hbase/commit/58a6ce47f0990260a097b9d2f641f74745a9f163)) ##### Bug Fixes - disabling incompatible mutation metrics for HBase 1.3 or lower ([#​3599](https://togithub.com/googleapis/java-bigtable-hbase/issues/3599)) ([9a693e8](https://togithub.com/googleapis/java-bigtable-hbase/commit/9a693e823a683542acef9932d042778a32495769)) - published dependencies of bigtable-beam-import ([#​3600](https://togithub.com/googleapis/java-bigtable-hbase/issues/3600)) ([0dfb130](https://togithub.com/googleapis/java-bigtable-hbase/commit/0dfb13089c6afa56dc1f8f7eddfb63c1d33e483a)) ##### Dependencies - update dependency net.bytebuddy:byte-buddy to v1.12.10 ([#​3597](https://togithub.com/googleapis/java-bigtable-hbase/issues/3597)) ([283cef8](https://togithub.com/googleapis/java-bigtable-hbase/commit/283cef872a6c08771cd5e5b9f760d386b07e97c8)) ##### [2.1.1](https://togithub.com/googleapis/java-bigtable-hbase/compare/v2.1.0...v2.1.1) (2022-04-20) ##### Bug Fixes - \[hbase-cbt-replication] use instance/project URI in log ([#​3575](https://togithub.com/googleapis/java-bigtable-hbase/issues/3575)) ([87d36b3](https://togithub.com/googleapis/java-bigtable-hbase/commit/87d36b3d04c2adc65a835779a91fba2b7814e6c3)) ##### Dependencies - update dependency com.google.cloud:google-cloud-bigtable-emulator to v0.143.2 ([#​3564](https://togithub.com/googleapis/java-bigtable-hbase/issues/3564)) ([10e2128](https://togithub.com/googleapis/java-bigtable-hbase/commit/10e21285800f9d3ee7078a8bfa89f644b250d3b1)) - update dependency com.google.errorprone:error_prone_annotations to v2.12.1 ([#​3576](https://togithub.com/googleapis/java-bigtable-hbase/issues/3576)) ([705741d](https://togithub.com/googleapis/java-bigtable-hbase/commit/705741d1f9b6b06e341dade14c72ba42fe0adf89)) - update dependency com.google.errorprone:error_prone_annotations to v2.13.1 ([#​3580](https://togithub.com/googleapis/java-bigtable-hbase/issues/3580)) ([a34a82a](https://togithub.com/googleapis/java-bigtable-hbase/commit/a34a82a99301d27e221fe472358e6efcccd24bb5)) - update dependency net.bytebuddy:byte-buddy to v1.12.9 ([#​3578](https://togithub.com/googleapis/java-bigtable-hbase/issues/3578)) ([31c2268](https://togithub.com/googleapis/java-bigtable-hbase/commit/31c226814af840edb2974eeec40c3e7203330981)) - upgrade guava to 31.1-jre and Bigtable to 2.6.2 ([#​3582](https://togithub.com/googleapis/java-bigtable-hbase/issues/3582)) ([f9e988d](https://togithub.com/googleapis/java-bigtable-hbase/commit/f9e988d40925559ac40bdc09f5a0f468e24d7748))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- bigtable/hbase/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigtable/hbase/snippets/pom.xml b/bigtable/hbase/snippets/pom.xml index ad17bb2c1d8..fa82e01c881 100644 --- a/bigtable/hbase/snippets/pom.xml +++ b/bigtable/hbase/snippets/pom.xml @@ -51,7 +51,7 @@ com.google.cloud.bigtable bigtable-hbase-1.x - 2.1.1 + 2.2.0 From 3d50d0e6e756d6c18d36137c0d027aec4968578d Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 5 May 2022 18:22:22 +0200 Subject: [PATCH 091/136] fix(deps): update dependency com.google.cloud.sql:cloud-sql-connector-r2dbc-postgres to v1.6.0 (#7114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.sql:cloud-sql-connector-r2dbc-postgres](https://togithub.com/GoogleCloudPlatform/cloud-sql-mysql-socket-factory) | `1.5.0` -> `1.6.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-postgres/1.6.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-postgres/1.6.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-postgres/1.6.0/compatibility-slim/1.5.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-postgres/1.6.0/confidence-slim/1.5.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
GoogleCloudPlatform/cloud-sql-mysql-socket-factory ### [`v1.6.0`](https://togithub.com/GoogleCloudPlatform/cloud-sql-mysql-socket-factory/blob/HEAD/CHANGELOG.md#​160-httpsgithubcomGoogleCloudPlatformcloud-sql-jdbc-socket-factorycomparev150v160-2022-05-03) [Compare Source](https://togithub.com/GoogleCloudPlatform/cloud-sql-mysql-socket-factory/compare/v1.5.0...v1.6.0) ##### Features - **jdbc/postgres:** add compatibility for GraalVM native image ([#​805](https://togithub.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/issues/805)) ([c00c255](https://togithub.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/commit/c00c25533e31caadf0db8c50077cc1c310fd106c))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- cloud-sql/r2dbc/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-sql/r2dbc/pom.xml b/cloud-sql/r2dbc/pom.xml index c3190eb5fc5..6759c57b232 100644 --- a/cloud-sql/r2dbc/pom.xml +++ b/cloud-sql/r2dbc/pom.xml @@ -60,7 +60,7 @@ com.google.cloud.sql cloud-sql-connector-r2dbc-postgres - 1.5.0 + 1.6.0 From 215b55f88efdfe48a9c00eb10b7bc0f11dc70418 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 5 May 2022 18:24:16 +0200 Subject: [PATCH 092/136] fix(deps): update dependency com.google.cloud.sql:cloud-sql-connector-r2dbc-mysql to v1.6.0 (#7113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.sql:cloud-sql-connector-r2dbc-mysql](https://togithub.com/GoogleCloudPlatform/cloud-sql-mysql-socket-factory) | `1.5.0` -> `1.6.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-mysql/1.6.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-mysql/1.6.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-mysql/1.6.0/compatibility-slim/1.5.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.sql:cloud-sql-connector-r2dbc-mysql/1.6.0/confidence-slim/1.5.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
GoogleCloudPlatform/cloud-sql-mysql-socket-factory ### [`v1.6.0`](https://togithub.com/GoogleCloudPlatform/cloud-sql-mysql-socket-factory/blob/HEAD/CHANGELOG.md#​160-httpsgithubcomGoogleCloudPlatformcloud-sql-jdbc-socket-factorycomparev150v160-2022-05-03) [Compare Source](https://togithub.com/GoogleCloudPlatform/cloud-sql-mysql-socket-factory/compare/v1.5.0...v1.6.0) ##### Features - **jdbc/postgres:** add compatibility for GraalVM native image ([#​805](https://togithub.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/issues/805)) ([c00c255](https://togithub.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/commit/c00c25533e31caadf0db8c50077cc1c310fd106c))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- cloud-sql/r2dbc/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-sql/r2dbc/pom.xml b/cloud-sql/r2dbc/pom.xml index 6759c57b232..5cedae050d2 100644 --- a/cloud-sql/r2dbc/pom.xml +++ b/cloud-sql/r2dbc/pom.xml @@ -48,7 +48,7 @@ com.google.cloud.sql cloud-sql-connector-r2dbc-mysql - 1.5.0 + 1.6.0 From 4039e1e19a67f1724067292cc6824e5440ac7c1a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 5 May 2022 18:26:15 +0200 Subject: [PATCH 093/136] fix(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-beam to v2.2.0 (#7110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud.bigtable:bigtable-hbase-beam](https://cloud.google.com/bigtable/) ([source](https://togithub.com/googleapis/java-bigtable-hbase)) | `2.1.1` -> `2.2.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.2.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.2.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.2.0/compatibility-slim/2.1.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud.bigtable:bigtable-hbase-beam/2.2.0/confidence-slim/2.1.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-bigtable-hbase ### [`v2.2.0`](https://togithub.com/googleapis/java-bigtable-hbase/blob/HEAD/CHANGELOG.md#​220-httpsgithubcomgoogleapisjava-bigtable-hbasecomparev211v220-2022-05-03) [Compare Source](https://togithub.com/googleapis/java-bigtable-hbase/compare/v2.1.1...v2.2.0) ##### Features - log version and settings on startup ([#​3601](https://togithub.com/googleapis/java-bigtable-hbase/issues/3601)) ([109023a](https://togithub.com/googleapis/java-bigtable-hbase/commit/109023aa980aaf26229544f271ca348466eac5fe)) - next release from main branch is 2.2.0 ([#​3593](https://togithub.com/googleapis/java-bigtable-hbase/issues/3593)) ([58a6ce4](https://togithub.com/googleapis/java-bigtable-hbase/commit/58a6ce47f0990260a097b9d2f641f74745a9f163)) ##### Bug Fixes - disabling incompatible mutation metrics for HBase 1.3 or lower ([#​3599](https://togithub.com/googleapis/java-bigtable-hbase/issues/3599)) ([9a693e8](https://togithub.com/googleapis/java-bigtable-hbase/commit/9a693e823a683542acef9932d042778a32495769)) - published dependencies of bigtable-beam-import ([#​3600](https://togithub.com/googleapis/java-bigtable-hbase/issues/3600)) ([0dfb130](https://togithub.com/googleapis/java-bigtable-hbase/commit/0dfb13089c6afa56dc1f8f7eddfb63c1d33e483a)) ##### Dependencies - update dependency net.bytebuddy:byte-buddy to v1.12.10 ([#​3597](https://togithub.com/googleapis/java-bigtable-hbase/issues/3597)) ([283cef8](https://togithub.com/googleapis/java-bigtable-hbase/commit/283cef872a6c08771cd5e5b9f760d386b07e97c8)) ##### [2.1.1](https://togithub.com/googleapis/java-bigtable-hbase/compare/v2.1.0...v2.1.1) (2022-04-20) ##### Bug Fixes - \[hbase-cbt-replication] use instance/project URI in log ([#​3575](https://togithub.com/googleapis/java-bigtable-hbase/issues/3575)) ([87d36b3](https://togithub.com/googleapis/java-bigtable-hbase/commit/87d36b3d04c2adc65a835779a91fba2b7814e6c3)) ##### Dependencies - update dependency com.google.cloud:google-cloud-bigtable-emulator to v0.143.2 ([#​3564](https://togithub.com/googleapis/java-bigtable-hbase/issues/3564)) ([10e2128](https://togithub.com/googleapis/java-bigtable-hbase/commit/10e21285800f9d3ee7078a8bfa89f644b250d3b1)) - update dependency com.google.errorprone:error_prone_annotations to v2.12.1 ([#​3576](https://togithub.com/googleapis/java-bigtable-hbase/issues/3576)) ([705741d](https://togithub.com/googleapis/java-bigtable-hbase/commit/705741d1f9b6b06e341dade14c72ba42fe0adf89)) - update dependency com.google.errorprone:error_prone_annotations to v2.13.1 ([#​3580](https://togithub.com/googleapis/java-bigtable-hbase/issues/3580)) ([a34a82a](https://togithub.com/googleapis/java-bigtable-hbase/commit/a34a82a99301d27e221fe472358e6efcccd24bb5)) - update dependency net.bytebuddy:byte-buddy to v1.12.9 ([#​3578](https://togithub.com/googleapis/java-bigtable-hbase/issues/3578)) ([31c2268](https://togithub.com/googleapis/java-bigtable-hbase/commit/31c226814af840edb2974eeec40c3e7203330981)) - upgrade guava to 31.1-jre and Bigtable to 2.6.2 ([#​3582](https://togithub.com/googleapis/java-bigtable-hbase/issues/3582)) ([f9e988d](https://togithub.com/googleapis/java-bigtable-hbase/commit/f9e988d40925559ac40bdc09f5a0f468e24d7748))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- bigtable/beam/bulk-data-generator/pom.xml | 2 +- bigtable/beam/helloworld/pom.xml | 2 +- bigtable/beam/keyviz-art/pom.xml | 2 +- bigtable/beam/workload-generator/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bigtable/beam/bulk-data-generator/pom.xml b/bigtable/beam/bulk-data-generator/pom.xml index 3b7e8fe5ce0..717d6cf05f8 100644 --- a/bigtable/beam/bulk-data-generator/pom.xml +++ b/bigtable/beam/bulk-data-generator/pom.xml @@ -65,7 +65,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.1 + 2.2.0 diff --git a/bigtable/beam/helloworld/pom.xml b/bigtable/beam/helloworld/pom.xml index f58fd38216d..872101a4aa7 100644 --- a/bigtable/beam/helloworld/pom.xml +++ b/bigtable/beam/helloworld/pom.xml @@ -63,7 +63,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.1 + 2.2.0 diff --git a/bigtable/beam/keyviz-art/pom.xml b/bigtable/beam/keyviz-art/pom.xml index da05665f1c4..e87239edd2a 100644 --- a/bigtable/beam/keyviz-art/pom.xml +++ b/bigtable/beam/keyviz-art/pom.xml @@ -61,7 +61,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.1 + 2.2.0 diff --git a/bigtable/beam/workload-generator/pom.xml b/bigtable/beam/workload-generator/pom.xml index 1914d089e9a..bc0ffc3037d 100644 --- a/bigtable/beam/workload-generator/pom.xml +++ b/bigtable/beam/workload-generator/pom.xml @@ -104,7 +104,7 @@ com.google.cloud.bigtable bigtable-hbase-beam - 2.1.1 + 2.2.0 From 44926097ebbc0c08ce2c51d8e9eac24d1489a64d Mon Sep 17 00:00:00 2001 From: Shubha Rajan Date: Thu, 5 May 2022 10:50:52 -0700 Subject: [PATCH 094/136] feat: Update Postgres samples to include more connection methods (#7080) --- cloud-sql/postgres/servlet/.env.yaml | 8 + cloud-sql/postgres/servlet/README.md | 63 +++++++- cloud-sql/postgres/servlet/pom.xml | 34 ++++- .../ConnectionPoolContextListener.java | 107 +------------ .../cloudsql/ConnectionPoolFactory.java | 57 +++++++ .../ConnectorConnectionPoolFactory.java | 107 +++++++++++++ .../com/example/cloudsql/IndexServlet.java | 61 +------- .../cloudsql/TcpConnectionPoolFactory.java | 87 +++++++++++ .../com/example/cloudsql/TemplateData.java | 88 +++++++++++ .../main/java/com/example/cloudsql/Utils.java | 54 +++++++ .../com/example/cloudsql/functions/Main.java | 142 ++++++++++++++++++ .../java/com/TestIndexServletPostgres.java | 1 - 12 files changed, 645 insertions(+), 164 deletions(-) create mode 100644 cloud-sql/postgres/servlet/.env.yaml create mode 100644 cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java create mode 100644 cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java create mode 100644 cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java create mode 100644 cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TemplateData.java create mode 100644 cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/Utils.java create mode 100644 cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/functions/Main.java diff --git a/cloud-sql/postgres/servlet/.env.yaml b/cloud-sql/postgres/servlet/.env.yaml new file mode 100644 index 00000000000..73e93097662 --- /dev/null +++ b/cloud-sql/postgres/servlet/.env.yaml @@ -0,0 +1,8 @@ +INSTANCE_CONNECTION_NAME: ::INSTANCE-NAME> +INSTANCE_UNIX_SOCKET: /cloudsql/::INSTANCE-NAME> +INSTANCE_HOST: '127.0.0.1' +DB_PORT: 5432 +DB_USER: +DB_IAM_USER: +DB_PASS: +DB_NAME: diff --git a/cloud-sql/postgres/servlet/README.md b/cloud-sql/postgres/servlet/README.md index 3c021a79125..7b9d6627d03 100644 --- a/cloud-sql/postgres/servlet/README.md +++ b/cloud-sql/postgres/servlet/README.md @@ -27,10 +27,50 @@ export DB_PASS='my-db-pass' export DB_NAME='my_db' ``` Note: Saving credentials in environment variables is convenient, but not secure - consider a more -secure solution such as [Cloud KMS](https://cloud.google.com/kms/) to help keep secrets safe. +secure solution such as [Secret Manager](https://cloud.google.com/secret-manager/) to help keep secrets safe. + +## Configure SSL Certificates +For deployments that connect directly to a Cloud SQL instance with TCP, +without using the Cloud SQL Proxy, +configuring SSL certificates will ensure the connection is encrypted. +1. Use the gcloud CLI to [download the server certificate](https://cloud.google.com/sql/docs/mysql/configure-ssl-instance#server-certs) for your Cloud SQL instance. + - Get information about the service certificate: + ``` + gcloud beta sql ssl server-ca-certs list --instance=INSTANCE_NAME + ``` + - Create a server certificate: + ``` + gcloud beta sql ssl server-ca-certs create --instance=INSTANCE_NAME + ``` + - Download the certificate information to a local PEM file + ``` + gcloud beta sql ssl server-ca-certs list \ + --format="value(cert)" \ + --instance=INSTANCE_NAME > \ + server-ca.pem + ``` + +2. Use the gcloud CLI to [create and download a client public key certificate and client private key](https://cloud.google.com/sql/docs/postgres/configure-ssl-instance#client-certs) + - Create a client certificate using the ssl client-certs create command: + ``` + gcloud sql ssl client-certs create CERT_NAME client-key.pem --instance=INSTANCE_NAME + ``` + - Retrieve the public key for the certificate you just created and copy it into the client-cert.pem file with the ssl client-certs describe command: + ``` + gcloud sql ssl client-certs describe CERT_NAME \ + --instance=INSTANCE_NAME \ + --format="value(cert)" > client-cert.pem + ``` +3. Convert the downloaded PEM certificate and key to a PKCS12 archive using `openssl`: + ``` + openssl pkcs12 -export -in client-cert.pem -inkey client-key.pem \ + -name "mysqlclient" -passout pass: -out client-keystore.p12 + ``` +4. Set the `SSL_CLIENT_KEY_PATH` and `SSL_CLIENT_KEY_PASSWD` environment variables to the values from the previous step. +The client key path should point to the PKCS12 archive file. +6. Set the `SSL_SERVER_CA_PATH` environment variables to point to the `server-ca.pem` file downloaded earlier ## Deploying locally - To run this application locally, run the following command inside the project folder: ```bash @@ -48,13 +88,19 @@ and verify that has been added in your build section as a plugin. -### Development Server +### App Engine Development Server The following command will run the application locally in the the GAE-development server: ```bash mvn appengine:run ``` +### Cloud Functions Development Server +To run the application locally as a Cloud Function, run the following command: +``` +mvn function:run -Drun.functionTarget=com.example.cloudsql.functions.Main +``` + ### Deploy to Google App Engine First, update `src/main/webapp/WEB-INF/appengine-web.xml` with the correct values to pass the @@ -120,3 +166,14 @@ mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \ For more details about using Cloud Run see http://cloud.run. Review other [Java on Cloud Run samples](../../../run/). + +### Deploy to Google Cloud Functions + +To deploy the application to Cloud Functions, first fill in the values for required environment variables in `.env.yaml`. Then run the following command +``` +gcloud functions deploy mysql-sample \ + --trigger-http \ + --entry-point com.example.cloudsql.functions.Main \ + --runtime java11 \ + --env-vars-file .env.yaml +``` diff --git a/cloud-sql/postgres/servlet/pom.xml b/cloud-sql/postgres/servlet/pom.xml index 348a6c4dad6..ec0ee9efe26 100644 --- a/cloud-sql/postgres/servlet/pom.xml +++ b/cloud-sql/postgres/servlet/pom.xml @@ -82,10 +82,27 @@ 1.1.3 test + + + com.google.cloud.functions.invoker + java-function-invoker + 1.0.1 + + + com.google.cloud.functions + functions-framework-api + 1.0.4 + provided + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.eclipse.jetty jetty-maven-plugin @@ -103,7 +120,22 @@ GCLOUD_CONFIG GCLOUD_CONFIG
-
+
+ + + com.google.cloud.functions + function-maven-plugin + 0.10.0 + + com.example.cloudsql.functions.Main + + diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java index f299927fab9..db3373071a0 100644 --- a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java @@ -16,11 +16,8 @@ package com.example.cloudsql; -import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.sql.Connection; -import java.sql.PreparedStatement; import java.sql.SQLException; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; @@ -34,102 +31,6 @@ @WebListener("Creates a connection pool that is stored in the Servlet's context for later use.") public class ConnectionPoolContextListener implements ServletContextListener { - // Saving credentials in environment variables is convenient, but not secure - consider a more - // secure solution such as https://cloud.google.com/kms/ to help keep secrets safe. - private static final String INSTANCE_CONNECTION_NAME = - System.getenv("INSTANCE_CONNECTION_NAME"); - private static final String DB_USER = System.getenv("DB_USER"); - private static final String DB_PASS = System.getenv("DB_PASS"); - private static final String DB_NAME = System.getenv("DB_NAME"); - - @SuppressFBWarnings( - value = "USBR_UNNECESSARY_STORE_BEFORE_RETURN", - justification = "Necessary for sample region tag.") - private DataSource createConnectionPool() { - // [START cloud_sql_postgres_servlet_create] - // Note: For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections - // which is preferred to using the Cloud SQL Auth Proxy with Unix sockets. - // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details. - - // The configuration object specifies behaviors for the connection pool. - HikariConfig config = new HikariConfig(); - - // The following URL is equivalent to setting the config options below: - // jdbc:postgresql:///?cloudSqlInstance=& - // socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=&password= - // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory - // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url - - // Configure which instance and what database user to connect with. - config.setJdbcUrl(String.format("jdbc:postgresql:///%s", DB_NAME)); - config.setUsername(DB_USER); // e.g. "root", "postgres" - config.setPassword(DB_PASS); // e.g. "my-password" - - config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.postgres.SocketFactory"); - config.addDataSourceProperty("cloudSqlInstance", INSTANCE_CONNECTION_NAME); - - - // The ipTypes argument can be used to specify a comma delimited list of preferred IP types - // for connecting to a Cloud SQL instance. The argument ipTypes=PRIVATE will force the - // SocketFactory to connect with an instance's associated private IP. - config.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE"); - - // ... Specify additional connection properties here. - // [START_EXCLUDE] - - // [START cloud_sql_postgres_servlet_limit] - // maximumPoolSize limits the total number of concurrent connections this pool will keep. Ideal - // values for this setting are highly variable on app design, infrastructure, and database. - config.setMaximumPoolSize(5); - // minimumIdle is the minimum number of idle connections Hikari maintains in the pool. - // Additional connections will be established to meet this value unless the pool is full. - config.setMinimumIdle(5); - // [END cloud_sql_postgres_servlet_limit] - - // [START cloud_sql_postgres_servlet_timeout] - // setConnectionTimeout is the maximum number of milliseconds to wait for a connection checkout. - // Any attempt to retrieve a connection from this pool that exceeds the set limit will throw an - // SQLException. - config.setConnectionTimeout(10000); // 10 seconds - // idleTimeout is the maximum amount of time a connection can sit in the pool. Connections that - // sit idle for this many milliseconds are retried if minimumIdle is exceeded. - config.setIdleTimeout(600000); // 10 minutes - // [END cloud_sql_postgres_servlet_timeout] - - // [START cloud_sql_postgres_servlet_backoff] - // Hikari automatically delays between failed connection attempts, eventually reaching a - // maximum delay of `connectionTimeout / 2` between attempts. - // [END cloud_sql_postgres_servlet_backoff] - - // [START cloud_sql_postgres_servlet_lifetime] - // maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that - // live longer than this many milliseconds will be closed and reestablished between uses. This - // value should be several minutes shorter than the database's timeout value to avoid unexpected - // terminations. - config.setMaxLifetime(1800000); // 30 minutes - // [END cloud_sql_postgres_servlet_lifetime] - - // [END_EXCLUDE] - - // Initialize the connection pool using the configuration object. - DataSource pool = new HikariDataSource(config); - // [END cloud_sql_postgres_servlet_create] - return pool; - } - - private void createTable(DataSource pool) throws SQLException { - // Safely attempt to create the table schema. - try (Connection conn = pool.getConnection()) { - String stmt = - "CREATE TABLE IF NOT EXISTS votes ( " - + "vote_id SERIAL NOT NULL, time_cast timestamp NOT NULL, candidate CHAR(6) NOT NULL," - + " PRIMARY KEY (vote_id) );"; - try (PreparedStatement createTableStatement = conn.prepareStatement(stmt);) { - createTableStatement.execute(); - } - } - } - @Override public void contextDestroyed(ServletContextEvent event) { // This function is called when the Servlet is destroyed. @@ -146,11 +47,15 @@ public void contextInitialized(ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); DataSource pool = (DataSource) servletContext.getAttribute("my-pool"); if (pool == null) { - pool = createConnectionPool(); + if (System.getenv("INSTANCE_HOST") != null) { + pool = TcpConnectionPoolFactory.createConnectionPool(); + } else { + pool = ConnectorConnectionPoolFactory.createConnectionPool(); + } servletContext.setAttribute("my-pool", pool); } try { - createTable(pool); + Utils.createTable(pool); } catch (SQLException ex) { throw new RuntimeException( "Unable to verify table schema. Please double check the steps" diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java new file mode 100644 index 00000000000..62c45366891 --- /dev/null +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import com.zaxxer.hikari.HikariConfig; + +public class ConnectionPoolFactory { + + public static HikariConfig configureConnectionPool(HikariConfig config) { + // [START cloud_sql_postgres_servlet_limit] + // maximumPoolSize limits the total number of concurrent connections this pool will keep. Ideal + // values for this setting are highly variable on app design, infrastructure, and database. + config.setMaximumPoolSize(5); + // minimumIdle is the minimum number of idle connections Hikari maintains in the pool. + // Additional connections will be established to meet this value unless the pool is full. + config.setMinimumIdle(5); + // [END cloud_sql_postgres_servlet_limit] + + // [START cloud_sql_postgres_servlet_timeout] + // setConnectionTimeout is the maximum number of milliseconds to wait for a connection checkout. + // Any attempt to retrieve a connection from this pool that exceeds the set limit will throw an + // SQLException. + config.setConnectionTimeout(10000); // 10 seconds + // idleTimeout is the maximum amount of time a connection can sit in the pool. Connections that + // sit idle for this many milliseconds are retried if minimumIdle is exceeded. + config.setIdleTimeout(600000); // 10 minutes + // [END cloud_sql_postgres_servlet_timeout] + + // [START cloud_sql_postgres_servlet_backoff] + // Hikari automatically delays between failed connection attempts, eventually reaching a + // maximum delay of `connectionTimeout / 2` between attempts. + // [END cloud_sql_postgres_servlet_backoff] + + // [START cloud_sql_postgres_servlet_lifetime] + // maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that + // live longer than this many milliseconds will be closed and reestablished between uses. This + // value should be several minutes shorter than the database's timeout value to avoid unexpected + // terminations. + config.setMaxLifetime(1800000); // 30 minutes + // [END cloud_sql_postgres_servlet_lifetime] + return config; + } +} diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java new file mode 100644 index 00000000000..ca2dc179c15 --- /dev/null +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java @@ -0,0 +1,107 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +// [START cloud_sql_postgres_servlet_connect_connector] +// [START cloud_sql_postgres_servlet_connect_unix] +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; + +public class ConnectorConnectionPoolFactory extends ConnectionPoolFactory { + + // Note: Saving credentials in environment variables is convenient, but not + // secure - consider a more secure solution such as + // Cloud Secret Manager (https://cloud.google.com/secret-manager) to help + // keep secrets safe. + private static final String INSTANCE_CONNECTION_NAME = + System.getenv("INSTANCE_CONNECTION_NAME"); + private static final String INSTANCE_UNIX_SOCKET = System.getenv("INSTANCE_UNIX_SOCKET"); + private static final String DB_USER = System.getenv("DB_USER"); + private static final String DB_PASS = System.getenv("DB_PASS"); + private static final String DB_NAME = System.getenv("DB_NAME"); + + public static DataSource createConnectionPool() { + // The configuration object specifies behaviors for the connection pool. + HikariConfig config = new HikariConfig(); + + // The following URL is equivalent to setting the config options below: + // jdbc:postgresql:///?cloudSqlInstance=& + // socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=&password= + // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory + // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url + + // Configure which instance and what database user to connect with. + config.setJdbcUrl(String.format("jdbc:postgresql:///%s", DB_NAME)); + config.setUsername(DB_USER); // e.g. "root", _postgres" + config.setPassword(DB_PASS); // e.g. "my-password" + + config.addDataSourceProperty("socketFactory", "com.google.cloud.sql_postgres.SocketFactory"); + config.addDataSourceProperty("cloudSqlInstance", INSTANCE_CONNECTION_NAME); + + // [END cloud_sql_postgres_servlet_connect_connector] + // Unix sockets are not natively supported in Java, so it is necessary to use the Cloud SQL + // Java Connector to connect. When setting INSTANCE_UNIX_SOCKET, the connector will + // call an external package that will enable Unix socket connections. + // Note: For Java users, the Cloud SQL Java Connector can provide authenticated connections + // which is usually preferable to using the Cloud SQL Proxy with Unix sockets. + // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details. + if (INSTANCE_UNIX_SOCKET != null) { + config.addDataSourceProperty("unixSocketPath", INSTANCE_UNIX_SOCKET); + } + // [START cloud_sql_postgres_servlet_connect_connector] + + // [END cloud_sql_postgres_servlet_connect_unix] + // The ipTypes argument can be used to specify a comma delimited list of preferred IP types + // for connecting to a Cloud SQL instance. The argument ipTypes=PRIVATE will force the + // SocketFactory to connect with an instance's associated private IP. + config.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE"); + // [START cloud_sql_postgres_servlet_connect_unix] + + // [END cloud_sql_postgres_servlet_connect_connector] + // [END cloud_sql_postgres_servlet_connect_unix] + // [START cloud_sql_postgres_servlet_auto_iam_authn] + // If connecting using automatic database authentication, follow the instructions for + // connecting using the connector, but set the DB_IAM_USER value to an IAM user or + // service account that has been given access to the database. + // See https://cloud.google.com/sql/docs/postgres/iam-logins for more details. + String dbIamUser = System.getenv("DB_IAM_USER"); + if (dbIamUser != null) { + config.addDataSourceProperty("enableIamAuth", "true"); + config.addDataSourceProperty("user", dbIamUser); + // Password must be set to a nonempty value to bypass driver validation errors. + config.addDataSourceProperty("password", "password"); + // Explicitly set sslmode to disable to prevent driver from hanging. + // The Java Connector will handle SSL so it is unneccesary to enable it at the driver level. + config.addDataSourceProperty("sslmode", "disable"); + } + // [END cloud_sql_postgres_servlet_auto_iam_authn] + // [START cloud_sql_postgres_servlet_connect_connector] + // [START cloud_sql_postgres_servlet_connect_unix] + + + // ... Specify additional connection properties here. + // [START_EXCLUDE] + configureConnectionPool(config); + // [END_EXCLUDE] + + // Initialize the connection pool using the configuration object. + return new HikariDataSource(config); + } +} +// [END cloud_sql_postgres_servlet_connect_connector] +// [END cloud_sql_postgres_servlet_connect_unix] diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/IndexServlet.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/IndexServlet.java index 32b1eeb92dc..10e73fd094c 100644 --- a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/IndexServlet.java +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/IndexServlet.java @@ -43,69 +43,14 @@ @WebServlet(name = "Index", value = "") public class IndexServlet extends HttpServlet { - class TemplateData { - - public int tabCount; - public int spaceCount; - public List recentVotes; - - public TemplateData(int tabCount, int spaceCount, List recentVotes) { - this.tabCount = tabCount; - this.spaceCount = spaceCount; - this.recentVotes = recentVotes; - } - } - private static final Logger LOGGER = Logger.getLogger(IndexServlet.class.getName()); public TemplateData getTemplateData(DataSource pool) throws ServletException { - - int tabCount = 0; - int spaceCount = 0; - List recentVotes = new ArrayList<>(); - try (Connection conn = pool.getConnection()) { - // PreparedStatements are compiled by the database immediately and executed at a later date. - // Most databases cache previously compiled queries, which improves efficiency. - String stmt1 = "SELECT candidate, time_cast FROM votes ORDER BY time_cast DESC LIMIT 5"; - try (PreparedStatement voteStmt = conn.prepareStatement(stmt1);) { - // Execute the statement - ResultSet voteResults = voteStmt.executeQuery(); - // Convert a ResultSet into Vote objects - while (voteResults.next()) { - String candidate = voteResults.getString(1); - Timestamp timeCast = voteResults.getTimestamp(2); - recentVotes.add(new Vote(candidate.trim(), timeCast)); - } - } - - // PreparedStatements can also be executed multiple times with different arguments. This can - // improve efficiency, and project a query from being vulnerable to an SQL injection. - String stmt2 = "SELECT COUNT(vote_id) FROM votes WHERE candidate=?"; - try (PreparedStatement voteCountStmt = conn.prepareStatement(stmt2);) { - voteCountStmt.setString(1, "TABS"); - ResultSet tabResult = voteCountStmt.executeQuery(); - if (tabResult.next()) { // Move to the first result - tabCount = tabResult.getInt(1); - } - - voteCountStmt.setString(1, "SPACES"); - ResultSet spaceResult = voteCountStmt.executeQuery(); - if (spaceResult.next()) { // Move to the first result - spaceCount = spaceResult.getInt(1); - } - } + try { + return TemplateData.getTemplateData(pool); } catch (SQLException ex) { - // If something goes wrong, the application needs to react appropriately. This might mean - // getting a new connection and executing the query again, or it might mean redirecting the - // user to a different page to let them know something went wrong. - throw new ServletException( - "Unable to successfully connect to the database. Please check the " - + "steps in the README and try again.", - ex); + throw new ServletException(ex); } - TemplateData templateData = new TemplateData(tabCount, spaceCount, recentVotes); - - return templateData; } @Override diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java new file mode 100644 index 00000000000..7908f2029ff --- /dev/null +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java @@ -0,0 +1,87 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +// [START cloud_sql_postgres_servlet_connect_tcp] +// [START cloud_sql_postgres_servlet_connect_tcp_sslcerts] + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; + +public class TcpConnectionPoolFactory extends ConnectionPoolFactory { + + // Note: Saving credentials in environment variables is convenient, but not + // secure - consider a more secure solution such as + // Cloud Secret Manager (https://cloud.google.com/secret-manager) to help + // keep secrets safe. + private static final String DB_USER = System.getenv("DB_USER"); + private static final String DB_PASS = System.getenv("DB_PASS"); + private static final String DB_NAME = System.getenv("DB_NAME"); + + private static final String INSTANCE_HOST = System.getenv("INSTANCE_HOST"); + private static final String DB_PORT = System.getenv("DB_PORT"); + + // [END cloud_sql_postgres_servlet_connect_tcp] + private static final String SSL_CLIENT_KEY_PATH = System.getenv("SSL_CLIENT_KEY_PATH"); + private static final String SSL_CLIENT_KEY_PASSWD = System.getenv("SSL_CLIENT_KEY_PASSWD"); + private static final String SSL_SERVER_CA_PATH = System.getenv("SSL_SERVER_CA_PATH"); + // [START cloud_sql_postgres_servlet_connect_tcp] + + public static DataSource createConnectionPool() { + // The configuration object specifies behaviors for the connection pool. + HikariConfig config = new HikariConfig(); + + // The following URL is equivalent to setting the config options below: + // jdbc:postgresql://:/?user=&password= + // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory + // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url + + // Configure which instance and what database user to connect with. + config.setJdbcUrl(String.format("jdbc:postgresql://%s:%s/%s", INSTANCE_HOST, DB_PORT, DB_NAME)); + config.setUsername(DB_USER); // e.g. "root", "postgres" + config.setPassword(DB_PASS); // e.g. "my-password" + + // [END cloud_sql_postgres_servlet_connect_tcp] + // (OPTIONAL) Configure SSL certificates + // For deployments that connect directly to a Cloud SQL instance without + // using the Cloud SQL Proxy, configuring SSL certificates will ensure the + // connection is encrypted. + // See the link below for more information on how to configure SSL Certificates for use with + // the Postgres JDBC driver + // https://jdbc.postgresql.org/documentation/head/ssl-client.html + if (SSL_CLIENT_KEY_PATH != null && SSL_SERVER_CA_PATH != null) { + config.addDataSourceProperty("ssl", "true"); + config.addDataSourceProperty("sslmode", "verify-full"); + + config.addDataSourceProperty("sslkey", SSL_CLIENT_KEY_PATH); + config.addDataSourceProperty("sslpassword", SSL_CLIENT_KEY_PASSWD); + config.addDataSourceProperty("sslrootcert", SSL_SERVER_CA_PATH); + } + // [START cloud_sql_postgres_servlet_connect_tcp] + + // ... Specify additional connection properties here. + // [START_EXCLUDE] + configureConnectionPool(config); + // [END_EXCLUDE] + + // Initialize the connection pool using the configuration object. + return new HikariDataSource(config); + } +} +// [END cloud_sql_postgres_servlet_connect_tcp] +// [END cloud_sql_postgres_servlet_connect_tcp_sslcerts] diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TemplateData.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TemplateData.java new file mode 100644 index 00000000000..10a7f00de27 --- /dev/null +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/TemplateData.java @@ -0,0 +1,88 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import javax.sql.DataSource; + +public class TemplateData { + + public int tabCount; + public int spaceCount; + public List recentVotes; + + public TemplateData(int tabCount, int spaceCount, List recentVotes) { + this.tabCount = tabCount; + this.spaceCount = spaceCount; + this.recentVotes = recentVotes; + } + + public static TemplateData getTemplateData(DataSource pool) throws SQLException { + int tabCount = 0; + int spaceCount = 0; + List recentVotes = new ArrayList<>(); + try (Connection conn = pool.getConnection()) { + // PreparedStatements are compiled by the database immediately and executed at a later date. + // Most databases cache previously compiled queries, which improves efficiency. + String stmt1 = "SELECT candidate, time_cast FROM votes ORDER BY time_cast DESC LIMIT 5"; + try (PreparedStatement voteStmt = conn.prepareStatement(stmt1);) { + // Execute the statement + ResultSet voteResults = voteStmt.executeQuery(); + // Convert a ResultSet into Vote objects + while (voteResults.next()) { + String candidate = voteResults.getString(1); + Timestamp timeCast = voteResults.getTimestamp(2); + recentVotes.add(new Vote(candidate.trim(), timeCast)); + } + } + + // PreparedStatements can also be executed multiple times with different arguments. This can + // improve efficiency, and project a query from being vulnerable to an SQL injection. + String stmt2 = "SELECT COUNT(vote_id) FROM votes WHERE candidate=?"; + try (PreparedStatement voteCountStmt = conn.prepareStatement(stmt2);) { + voteCountStmt.setString(1, "TABS"); + ResultSet tabResult = voteCountStmt.executeQuery(); + if (tabResult.next()) { // Move to the first result + tabCount = tabResult.getInt(1); + } + + voteCountStmt.setString(1, "SPACES"); + ResultSet spaceResult = voteCountStmt.executeQuery(); + if (spaceResult.next()) { // Move to the first result + spaceCount = spaceResult.getInt(1); + } + } + } catch (SQLException ex) { + // If something goes wrong, the application needs to react appropriately. This might mean + // getting a new connection and executing the query again, or it might mean redirecting the + // user to a different page to let them know something went wrong. + throw new SQLException( + "Unable to successfully connect to the database. Please check the " + + "steps in the README and try again.", + ex); + } + TemplateData templateData = new TemplateData(tabCount, spaceCount, recentVotes); + + return templateData; + } +} diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/Utils.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/Utils.java new file mode 100644 index 00000000000..0c1dcaceb41 --- /dev/null +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/Utils.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Locale; +import javax.annotation.Nullable; +import javax.sql.DataSource; + +public class Utils { + + // Used to validate user input. All user provided data should be validated and sanitized before + // being used something like a SQL query. Returns null if invalid. + @Nullable + public static String validateTeam(String input) { + if (input != null) { + input = input.toUpperCase(Locale.ENGLISH); + // Must be either "TABS" or "SPACES" + if (!"TABS".equals(input) && !"SPACES".equals(input)) { + return null; + } + } + return input; + } + + public static void createTable(DataSource pool) throws SQLException { + // Safely attempt to create the table schema. + try (Connection conn = pool.getConnection()) { + String stmt = + "CREATE TABLE IF NOT EXISTS votes ( " + + "vote_id SERIAL NOT NULL, time_cast timestamp NOT NULL, candidate CHAR(6) NOT NULL," + + " PRIMARY KEY (vote_id) );"; + try (PreparedStatement createTableStatement = conn.prepareStatement(stmt);) { + createTableStatement.execute(); + } + } + } +} diff --git a/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/functions/Main.java b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/functions/Main.java new file mode 100644 index 00000000000..e42f4ce7128 --- /dev/null +++ b/cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/functions/Main.java @@ -0,0 +1,142 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql.functions; + +import com.example.cloudsql.ConnectorConnectionPoolFactory; +import com.example.cloudsql.TcpConnectionPoolFactory; +import com.example.cloudsql.TemplateData; +import com.example.cloudsql.Utils; +import com.google.cloud.functions.HttpFunction; +import com.google.cloud.functions.HttpRequest; +import com.google.cloud.functions.HttpResponse; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.Date; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.sql.DataSource; + +public class Main implements HttpFunction { + + private Logger logger = Logger.getLogger(Main.class.getName()); + private static final Gson gson = new Gson(); + + // Declared at cold-start, but only initialized if/when the function executes + // Uses the "initialization-on-demand holder" idiom + // More information: https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom + private static class PoolHolder { + + // Making the default constructor private prohibits instantiation of this class + private PoolHolder() { + } + + // This value is initialized only if (and when) the getInstance() function below is called + private static final DataSource INSTANCE = setupPool(); + + private static DataSource setupPool() { + DataSource pool; + if (System.getenv("INSTANCE_HOST") != null) { + pool = TcpConnectionPoolFactory.createConnectionPool(); + } else { + pool = ConnectorConnectionPoolFactory.createConnectionPool(); + } + try { + Utils.createTable(pool); + } catch (SQLException ex) { + throw new RuntimeException( + "Unable to verify table schema. Please double check the steps" + + "in the README and try again.", + ex); + } + return pool; + } + + private static DataSource getInstance() { + return PoolHolder.INSTANCE; + } + } + + private void returnVoteCounts(HttpRequest req, HttpResponse resp) + throws SQLException, IOException { + DataSource pool = PoolHolder.getInstance(); + TemplateData templateData = TemplateData.getTemplateData(pool); + JsonObject respContent = new JsonObject(); + + // Return JSON Data + respContent.addProperty("tabCount", templateData.tabCount); + respContent.addProperty("spaceCount", templateData.spaceCount); + respContent.addProperty("recentVotes", gson.toJson(templateData.recentVotes)); + resp.getWriter().write(respContent.toString()); + resp.setStatusCode(HttpURLConnection.HTTP_OK); + } + + private void submitVote(HttpRequest req, HttpResponse resp) throws IOException { + DataSource pool = PoolHolder.getInstance(); + Timestamp now = new Timestamp(new Date().getTime()); + JsonObject body = gson.fromJson(req.getReader(), JsonObject.class); + String team = Utils.validateTeam(body.get("team").getAsString()); + if (team == null) { + resp.setStatusCode(400); + resp.getWriter().append("Invalid team specified."); + return; + } + try (Connection conn = pool.getConnection()) { + // PreparedStatements can be more efficient and project against injections. + String stmt = "INSERT INTO votes (time_cast, candidate) VALUES (?, ?);"; + try (PreparedStatement voteStmt = conn.prepareStatement(stmt);) { + voteStmt.setTimestamp(1, now); + voteStmt.setString(2, team); + + // Finally, execute the statement. If it fails, an error will be thrown. + voteStmt.execute(); + } + } catch (SQLException ex) { + // If something goes wrong, handle the error in this section. This might involve retrying or + // adjusting parameters depending on the situation. + logger.log(Level.WARNING, "Error while attempting to submit vote.", ex); + resp.setStatusCode(500); + resp.getWriter() + .write( + "Unable to successfully cast vote! Please check the application " + + "logs for more details."); + } + } + + @Override + public void service(HttpRequest req, HttpResponse resp) throws IOException, SQLException { + + String method = req.getMethod(); + switch (method) { + case "GET": + returnVoteCounts(req, resp); + break; + case "POST": + submitVote(req, resp); + break; + default: + resp.setStatusCode(HttpURLConnection.HTTP_BAD_METHOD); + resp.getWriter().write(String.format("HTTP Method %s is not supported", method)); + break; + } + } +} diff --git a/cloud-sql/postgres/servlet/src/test/java/com/TestIndexServletPostgres.java b/cloud-sql/postgres/servlet/src/test/java/com/TestIndexServletPostgres.java index d0d6c4e62c6..4cfde1336f4 100644 --- a/cloud-sql/postgres/servlet/src/test/java/com/TestIndexServletPostgres.java +++ b/cloud-sql/postgres/servlet/src/test/java/com/TestIndexServletPostgres.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.example.cloudsql.IndexServlet.TemplateData; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import java.io.PrintWriter; From 3bfe22a63e6ada0af8b0b9a1e4750df9bc6ebd68 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 5 May 2022 23:51:41 +0200 Subject: [PATCH 095/136] fix(deps): update dependency com.slack.api:slack-app-backend to v1.22.0 (#7116) --- functions/slack/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/slack/pom.xml b/functions/slack/pom.xml index e94d08f85d9..3a6f3b41053 100644 --- a/functions/slack/pom.xml +++ b/functions/slack/pom.xml @@ -77,7 +77,7 @@ com.slack.api slack-app-backend - 1.21.2 + 1.22.0 From 4ff47620eb6b3cb2e8b326815188b56ed1a90cb7 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:22:19 +0200 Subject: [PATCH 096/136] fix(deps): update dependency com.google.cloud.sql:cloud-sql-connector-jdbc-sqlserver to v1.6.0 (#7112) * fix(deps): update dependency com.google.cloud.sql:cloud-sql-connector-jdbc-sqlserver to v1.6.0 * Update pom.xml Co-authored-by: Shubha Rajan --- cloud-sql/sqlserver/client-side-encryption/pom.xml | 2 +- cloud-sql/sqlserver/servlet/pom.xml | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cloud-sql/sqlserver/client-side-encryption/pom.xml b/cloud-sql/sqlserver/client-side-encryption/pom.xml index 2086d392ede..94d69542ee4 100644 --- a/cloud-sql/sqlserver/client-side-encryption/pom.xml +++ b/cloud-sql/sqlserver/client-side-encryption/pom.xml @@ -62,7 +62,7 @@ com.google.cloud.sql cloud-sql-connector-jdbc-sqlserver - 1.5.0 + 1.6.0 com.microsoft.sqlserver diff --git a/cloud-sql/sqlserver/servlet/pom.xml b/cloud-sql/sqlserver/servlet/pom.xml index 2d6a7fe46f4..a1b4853883d 100644 --- a/cloud-sql/sqlserver/servlet/pom.xml +++ b/cloud-sql/sqlserver/servlet/pom.xml @@ -57,7 +57,7 @@ com.google.cloud.sql cloud-sql-connector-jdbc-sqlserver - 1.5.0 + 1.6.0 com.zaxxer @@ -86,6 +86,11 @@ + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.eclipse.jetty jetty-maven-plugin From 9db61af3cc772c671f06691e287bd1154f41737c Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:23:19 +0200 Subject: [PATCH 097/136] fix(deps): update dependency com.google.cloud.sql:mysql-socket-factory-connector-j-8 to v1.6.0 (#7115) * fix(deps): update dependency com.google.cloud.sql:mysql-socket-factory-connector-j-8 to v1.6.0 * Update pom.xml Co-authored-by: Shubha Rajan --- appengine-java11/cloudsql/pom.xml | 2 +- cloud-sql/mysql/client-side-encryption/pom.xml | 2 +- cloud-sql/mysql/servlet/pom.xml | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/appengine-java11/cloudsql/pom.xml b/appengine-java11/cloudsql/pom.xml index dbb0d5ad878..40a7f88b63d 100644 --- a/appengine-java11/cloudsql/pom.xml +++ b/appengine-java11/cloudsql/pom.xml @@ -79,7 +79,7 @@ com.google.cloud.sql mysql-socket-factory-connector-j-8 - 1.5.0 + 1.6.0 provided diff --git a/cloud-sql/mysql/client-side-encryption/pom.xml b/cloud-sql/mysql/client-side-encryption/pom.xml index a04568f3ead..bf6e8e5ad39 100644 --- a/cloud-sql/mysql/client-side-encryption/pom.xml +++ b/cloud-sql/mysql/client-side-encryption/pom.xml @@ -62,7 +62,7 @@ com.google.cloud.sql mysql-socket-factory-connector-j-8 - 1.5.0 + 1.6.0 mysql diff --git a/cloud-sql/mysql/servlet/pom.xml b/cloud-sql/mysql/servlet/pom.xml index 13616c0b3a4..8cddb071e9a 100644 --- a/cloud-sql/mysql/servlet/pom.xml +++ b/cloud-sql/mysql/servlet/pom.xml @@ -57,7 +57,7 @@ com.google.cloud.sql mysql-socket-factory-connector-j-8 - 1.5.0 + 1.6.0 com.zaxxer @@ -107,6 +107,11 @@ + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.eclipse.jetty jetty-maven-plugin From b0240d6e98a57b21e3629c6d1e6a031f355eb05b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:24:12 +0200 Subject: [PATCH 098/136] fix(deps): update dependency com.google.cloud.functions.invoker:java-function-invoker to v1.1.0 (#7111) * fix(deps): update dependency com.google.cloud.functions.invoker:java-function-invoker to v1.1.0 Co-authored-by: Shubha Rajan --- cloud-sql/mysql/servlet/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-sql/mysql/servlet/pom.xml b/cloud-sql/mysql/servlet/pom.xml index 8cddb071e9a..c496f85ffef 100644 --- a/cloud-sql/mysql/servlet/pom.xml +++ b/cloud-sql/mysql/servlet/pom.xml @@ -95,7 +95,7 @@ com.google.cloud.functions.invoker java-function-invoker - 1.0.1 + 1.1.0 com.google.cloud.functions From 5aaf0d617c824050d9818ac7956ed5101fd28bef Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:25:28 +0200 Subject: [PATCH 099/136] chore(deps): update dependency com.github.spotbugs:spotbugs-annotations to v4.7.0 (#7105) --- pubsub/spring/build.gradle | 2 +- pubsub/streaming-analytics/build.gradle | 2 +- pubsublite/streaming-analytics/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubsub/spring/build.gradle b/pubsub/spring/build.gradle index af88a7bfbc5..6771f659495 100644 --- a/pubsub/spring/build.gradle +++ b/pubsub/spring/build.gradle @@ -34,7 +34,7 @@ description = 'Spring Cloud GCP Pub/Sub Code Sample' java.sourceCompatibility = JavaVersion.VERSION_1_8 dependencies { - implementation 'com.github.spotbugs:spotbugs-annotations:4.6.0' + implementation 'com.github.spotbugs:spotbugs-annotations:4.7.0' implementation 'org.springframework.boot:spring-boot-starter-web:2.5.7' implementation 'com.google.cloud:spring-cloud-gcp-starter-pubsub:3.2.1' implementation 'org.springframework.integration:spring-integration-core:5.5.11' diff --git a/pubsub/streaming-analytics/build.gradle b/pubsub/streaming-analytics/build.gradle index d7f07f0eff0..6da227e5235 100644 --- a/pubsub/streaming-analytics/build.gradle +++ b/pubsub/streaming-analytics/build.gradle @@ -36,7 +36,7 @@ repositories { def beamVersion = '2.38.0' def slf4jVersion = '1.7.36' dependencies { - implementation 'com.github.spotbugs:spotbugs-annotations:4.6.0' + implementation 'com.github.spotbugs:spotbugs-annotations:4.7.0' implementation "org.apache.beam:beam-sdks-java-core:${beamVersion}" implementation "org.apache.beam:beam-sdks-java-io-google-cloud-platform:${beamVersion}" implementation "org.apache.beam:beam-examples-java:${beamVersion}" diff --git a/pubsublite/streaming-analytics/build.gradle b/pubsublite/streaming-analytics/build.gradle index 771babcda6b..4baab23fe1d 100644 --- a/pubsublite/streaming-analytics/build.gradle +++ b/pubsublite/streaming-analytics/build.gradle @@ -36,7 +36,7 @@ repositories { def beamVersion = '2.38.0' def slf4jVersion = '1.7.36' dependencies { - implementation 'com.github.spotbugs:spotbugs-annotations:4.6.0' + implementation 'com.github.spotbugs:spotbugs-annotations:4.7.0' implementation "org.slf4j:slf4j-api:${slf4jVersion}" implementation "org.slf4j:slf4j-jdk14:${slf4jVersion}" implementation "org.apache.beam:beam-sdks-java-core:${beamVersion}" From 96f33acfc5715e2fc7e16354a6bdbae5dfd014c7 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:25:46 +0200 Subject: [PATCH 100/136] fix(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-1.x-hadoop to v2.2.0 (#7109) --- appengine-java8/bigtable/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java8/bigtable/pom.xml b/appengine-java8/bigtable/pom.xml index f360c44e112..2ede3685309 100644 --- a/appengine-java8/bigtable/pom.xml +++ b/appengine-java8/bigtable/pom.xml @@ -47,7 +47,7 @@ limitations under the License. com.google.cloud.bigtable bigtable-hbase-1.x-hadoop - 2.1.1 + 2.2.0 From 45593f8864af231e5614f2a2cb3f9541a99b36c1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:26:07 +0200 Subject: [PATCH 101/136] chore(deps): update quarkus.version to v2.9.0.final (#7107) --- appengine-java11/quarkus-helloworld/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/quarkus-helloworld/pom.xml b/appengine-java11/quarkus-helloworld/pom.xml index 1660212f092..66cbce5ff2c 100644 --- a/appengine-java11/quarkus-helloworld/pom.xml +++ b/appengine-java11/quarkus-helloworld/pom.xml @@ -32,7 +32,7 @@ limitations under the License. 2.22.2 11 11 - 2.8.2.Final + 2.9.0.Final UTF-8 From f8909105ab8003dca9460adf106ca80628e9e4b6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:26:24 +0200 Subject: [PATCH 102/136] chore(deps): update dependency com.google.cloud.bigtable:bigtable-hbase-2.x-hadoop to v2.2.0 (#7106) --- bigtable/spark/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigtable/spark/build.sbt b/bigtable/spark/build.sbt index 016f5e59190..10a9f936ddd 100644 --- a/bigtable/spark/build.sbt +++ b/bigtable/spark/build.sbt @@ -22,7 +22,7 @@ version := "0.1" // https://cloud.google.com/dataproc/docs/concepts/versioning/dataproc-release-1.4 scalaVersion := "2.11.12" val sparkVersion = "2.4.8" -val bigtableVersion = "2.1.1" +val bigtableVersion = "2.2.0" val hbaseVersion = "2.4.9" libraryDependencies ++= Seq( From 48bd06cc29154bc0163c4a43ea37c6151868de55 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:26:44 +0200 Subject: [PATCH 103/136] fix(deps): update dependency com.google.http-client:google-http-client-jackson2 to v1.41.8 (#7103) --- storage/xml-api/cmdline-sample/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xml-api/cmdline-sample/pom.xml b/storage/xml-api/cmdline-sample/pom.xml index ea9ce0b895b..df7f4c9aecc 100644 --- a/storage/xml-api/cmdline-sample/pom.xml +++ b/storage/xml-api/cmdline-sample/pom.xml @@ -30,7 +30,7 @@ - 1.41.7 + 1.41.8 UTF-8 1.6.0 1.8 From 5f7a5061d7e0659761739e54cca2d9f968c3bba5 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:27:10 +0200 Subject: [PATCH 104/136] fix(deps): update dependency com.google.apis:google-api-services-iam to v1-rev20220428-1.32.1 (#7101) --- iam/api-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iam/api-client/pom.xml b/iam/api-client/pom.xml index 224b4f82b3d..0d8472b4ac7 100644 --- a/iam/api-client/pom.xml +++ b/iam/api-client/pom.xml @@ -56,7 +56,7 @@ com.google.apis google-api-services-iam - v1-rev20220421-1.32.1 + v1-rev20220428-1.32.1 From 7f07254b65670e2d83c50d8ce1583b3e549bb295 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:27:29 +0200 Subject: [PATCH 105/136] chore(deps): update ktor_version to v2.0.2-eap-389 (#7100) --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index 6fb90800432..5f01e4ea9d5 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -33,7 +33,7 @@ limitations under the License. 11 11 - 2.0.2-eap-386 + 2.0.2-eap-389 official 1.6.21 1.2.11 From eec6f6bf00807e3bf85905145d19f67a2fca7a72 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 6 May 2022 21:42:48 +0200 Subject: [PATCH 106/136] fix(deps): update dependency org.postgresql:postgresql to v42.3.5 (#7104) * fix(deps): update dependency org.postgresql:postgresql to v42.3.5 * Update pom.xml Co-authored-by: Shubha Rajan --- cloud-sql/postgres/client-side-encryption/pom.xml | 2 +- cloud-sql/postgres/servlet/pom.xml | 2 +- flexible/postgres/pom.xml | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cloud-sql/postgres/client-side-encryption/pom.xml b/cloud-sql/postgres/client-side-encryption/pom.xml index 24eaf38e7d2..a0667ee00a7 100644 --- a/cloud-sql/postgres/client-side-encryption/pom.xml +++ b/cloud-sql/postgres/client-side-encryption/pom.xml @@ -67,7 +67,7 @@ org.postgresql postgresql - 42.3.4 + 42.3.5 com.google.crypto.tink diff --git a/cloud-sql/postgres/servlet/pom.xml b/cloud-sql/postgres/servlet/pom.xml index ec0ee9efe26..b900ee22881 100644 --- a/cloud-sql/postgres/servlet/pom.xml +++ b/cloud-sql/postgres/servlet/pom.xml @@ -52,7 +52,7 @@ org.postgresql postgresql - 42.3.4 + 42.3.5 com.google.cloud.sql diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index ec8d5245b44..ec6ebd76778 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -79,7 +79,7 @@ org.postgresql postgresql - 42.3.4 + 42.3.5 @@ -102,6 +102,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin From d944990f78809db639d16e455aa635603c8e0eba Mon Sep 17 00:00:00 2001 From: Shubha Rajan Date: Fri, 6 May 2022 15:45:19 -0700 Subject: [PATCH 107/136] chore: add maven-war-plugin to fix java17 periodic failures (#7117) --- appengine-java11-bundled-services/datastore/pom.xml | 5 +++++ appengine-java11/guestbook-cloud-firestore/pom.xml | 5 +++++ appengine-java11/helloworld-servlet/pom.xml | 5 +++++ appengine-java11/oauth2/pom.xml | 5 +++++ appengine-java8/analytics/pom.xml | 5 +++++ appengine-java8/appidentity/pom.xml | 5 +++++ appengine-java8/datastore-indexes-exploding/pom.xml | 5 +++++ appengine-java8/datastore-indexes-perfect/pom.xml | 5 +++++ appengine-java8/datastore-indexes/pom.xml | 5 +++++ appengine-java8/datastore-schedule-export/pom.xml | 5 +++++ appengine-java8/datastore/pom.xml | 5 +++++ appengine-java8/endpoints-v2-migration/pom.xml | 5 +++++ appengine-java8/firebase-event-proxy/pom.xml | 5 +++++ appengine-java8/firebase-tictactoe/pom.xml | 5 +++++ appengine-java8/guestbook-cloud-datastore/pom.xml | 5 +++++ appengine-java8/helloworld/pom.xml | 5 +++++ appengine-java8/iap/pom.xml | 5 +++++ appengine-java8/mail/pom.xml | 5 +++++ appengine-java8/mailgun/pom.xml | 5 +++++ appengine-java8/mailjet/pom.xml | 5 +++++ appengine-java8/multitenancy/pom.xml | 5 +++++ appengine-java8/pubsub/pom.xml | 5 +++++ appengine-java8/remote-server/pom.xml | 6 +++++- appengine-java8/sendgrid/pom.xml | 5 +++++ appengine-java8/spanner/pom.xml | 6 +++++- appengine-java8/static-files/pom.xml | 5 +++++ appengine-java8/tasks/quickstart/pom.xml | 5 +++++ appengine-java8/tasks/snippets/pom.xml | 1 - appengine-java8/twilio/pom.xml | 5 +++++ appengine-java8/urlfetch/pom.xml | 5 +++++ appengine-java8/users/pom.xml | 5 +++++ endpoints/multiple-versions/pom.xml | 5 +++++ flexible/analytics/pom.xml | 5 +++++ flexible/async-rest/pom.xml | 5 +++++ flexible/cloudsql/pom.xml | 5 +++++ flexible/cloudstorage/pom.xml | 5 +++++ flexible/cron/pom.xml | 5 +++++ flexible/datastore/pom.xml | 5 +++++ flexible/disk/pom.xml | 5 +++++ flexible/errorreporting/pom.xml | 5 +++++ flexible/extending-runtime/pom.xml | 5 +++++ flexible/helloworld/pom.xml | 6 ++++++ flexible/memcache/pom.xml | 6 ++++++ flexible/pubsub/pom.xml | 5 +++++ flexible/static-files/pom.xml | 10 ++++++++++ flexible/twilio/pom.xml | 5 +++++ flexible/websocket-jetty/pom.xml | 5 +++++ flexible/websocket-jsr356/pom.xml | 5 +++++ memorystore/redis/pom.xml | 5 +++++ session-handling/pom.xml | 5 +++++ 50 files changed, 252 insertions(+), 3 deletions(-) diff --git a/appengine-java11-bundled-services/datastore/pom.xml b/appengine-java11-bundled-services/datastore/pom.xml index 1c9d5ec64be..47624da98de 100644 --- a/appengine-java11-bundled-services/datastore/pom.xml +++ b/appengine-java11-bundled-services/datastore/pom.xml @@ -126,6 +126,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java11/guestbook-cloud-firestore/pom.xml b/appengine-java11/guestbook-cloud-firestore/pom.xml index 493914abf5b..12cc6bdab0c 100644 --- a/appengine-java11/guestbook-cloud-firestore/pom.xml +++ b/appengine-java11/guestbook-cloud-firestore/pom.xml @@ -91,6 +91,11 @@ guestbook + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java11/helloworld-servlet/pom.xml b/appengine-java11/helloworld-servlet/pom.xml index a944824994f..b2050c08b25 100644 --- a/appengine-java11/helloworld-servlet/pom.xml +++ b/appengine-java11/helloworld-servlet/pom.xml @@ -67,6 +67,11 @@ limitations under the License. helloworld + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java11/oauth2/pom.xml b/appengine-java11/oauth2/pom.xml index 0b3d5956b7a..5abbac38ebc 100644 --- a/appengine-java11/oauth2/pom.xml +++ b/appengine-java11/oauth2/pom.xml @@ -101,6 +101,11 @@ oauth2 + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/analytics/pom.xml b/appengine-java8/analytics/pom.xml index 34b087b0986..c7f58045cad 100644 --- a/appengine-java8/analytics/pom.xml +++ b/appengine-java8/analytics/pom.xml @@ -107,6 +107,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/appidentity/pom.xml b/appengine-java8/appidentity/pom.xml index 71c9c0bf20f..e6a15292f82 100644 --- a/appengine-java8/appidentity/pom.xml +++ b/appengine-java8/appidentity/pom.xml @@ -105,6 +105,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/datastore-indexes-exploding/pom.xml b/appengine-java8/datastore-indexes-exploding/pom.xml index 327c6a61c83..aea3f4099ec 100644 --- a/appengine-java8/datastore-indexes-exploding/pom.xml +++ b/appengine-java8/datastore-indexes-exploding/pom.xml @@ -92,6 +92,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/datastore-indexes-perfect/pom.xml b/appengine-java8/datastore-indexes-perfect/pom.xml index 52c09210a1c..cf5bfdc4200 100644 --- a/appengine-java8/datastore-indexes-perfect/pom.xml +++ b/appengine-java8/datastore-indexes-perfect/pom.xml @@ -92,6 +92,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/datastore-indexes/pom.xml b/appengine-java8/datastore-indexes/pom.xml index 9855620a8c8..54ded644380 100644 --- a/appengine-java8/datastore-indexes/pom.xml +++ b/appengine-java8/datastore-indexes/pom.xml @@ -93,6 +93,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/datastore-schedule-export/pom.xml b/appengine-java8/datastore-schedule-export/pom.xml index 91f6131da78..eec7b45a92d 100644 --- a/appengine-java8/datastore-schedule-export/pom.xml +++ b/appengine-java8/datastore-schedule-export/pom.xml @@ -82,6 +82,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/datastore/pom.xml b/appengine-java8/datastore/pom.xml index f1cccb033f0..a26012c2bf7 100644 --- a/appengine-java8/datastore/pom.xml +++ b/appengine-java8/datastore/pom.xml @@ -125,6 +125,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/endpoints-v2-migration/pom.xml b/appengine-java8/endpoints-v2-migration/pom.xml index 11aa141c06c..4fdf1b61c36 100644 --- a/appengine-java8/endpoints-v2-migration/pom.xml +++ b/appengine-java8/endpoints-v2-migration/pom.xml @@ -68,6 +68,11 @@ limitations under the License. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/firebase-event-proxy/pom.xml b/appengine-java8/firebase-event-proxy/pom.xml index d8f67e9c1fe..e0383e893ff 100644 --- a/appengine-java8/firebase-event-proxy/pom.xml +++ b/appengine-java8/firebase-event-proxy/pom.xml @@ -95,6 +95,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/firebase-tictactoe/pom.xml b/appengine-java8/firebase-tictactoe/pom.xml index 7ce4e3c8207..a526a5bb72b 100644 --- a/appengine-java8/firebase-tictactoe/pom.xml +++ b/appengine-java8/firebase-tictactoe/pom.xml @@ -118,6 +118,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/guestbook-cloud-datastore/pom.xml b/appengine-java8/guestbook-cloud-datastore/pom.xml index 55fd8ab29e7..48ea294c768 100644 --- a/appengine-java8/guestbook-cloud-datastore/pom.xml +++ b/appengine-java8/guestbook-cloud-datastore/pom.xml @@ -109,6 +109,11 @@ + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/helloworld/pom.xml b/appengine-java8/helloworld/pom.xml index cab223542d5..59bfe6b0490 100644 --- a/appengine-java8/helloworld/pom.xml +++ b/appengine-java8/helloworld/pom.xml @@ -96,6 +96,11 @@ limitations under the License. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/iap/pom.xml b/appengine-java8/iap/pom.xml index 875731117e6..0389b36bfd1 100644 --- a/appengine-java8/iap/pom.xml +++ b/appengine-java8/iap/pom.xml @@ -48,6 +48,11 @@ Copyright 2017 Google Inc. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.apache.maven.plugins maven-compiler-plugin diff --git a/appengine-java8/mail/pom.xml b/appengine-java8/mail/pom.xml index f81a458d171..37fdb5db769 100644 --- a/appengine-java8/mail/pom.xml +++ b/appengine-java8/mail/pom.xml @@ -59,6 +59,11 @@ Copyright 2016 Google Inc. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/mailgun/pom.xml b/appengine-java8/mailgun/pom.xml index e7d76db1d72..f73552b6afb 100644 --- a/appengine-java8/mailgun/pom.xml +++ b/appengine-java8/mailgun/pom.xml @@ -65,6 +65,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/mailjet/pom.xml b/appengine-java8/mailjet/pom.xml index 7d1de1b5f50..f6f201a8c86 100644 --- a/appengine-java8/mailjet/pom.xml +++ b/appengine-java8/mailjet/pom.xml @@ -71,6 +71,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/multitenancy/pom.xml b/appengine-java8/multitenancy/pom.xml index 5d5c4dc60c0..c4ce2ae33f5 100644 --- a/appengine-java8/multitenancy/pom.xml +++ b/appengine-java8/multitenancy/pom.xml @@ -116,6 +116,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/pubsub/pom.xml b/appengine-java8/pubsub/pom.xml index f4bd15fd5f2..31c230b1322 100644 --- a/appengine-java8/pubsub/pom.xml +++ b/appengine-java8/pubsub/pom.xml @@ -81,6 +81,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/remote-server/pom.xml b/appengine-java8/remote-server/pom.xml index 19f4711f7ce..c0ae14d5462 100644 --- a/appengine-java8/remote-server/pom.xml +++ b/appengine-java8/remote-server/pom.xml @@ -60,7 +60,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes - + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/sendgrid/pom.xml b/appengine-java8/sendgrid/pom.xml index ef71be0d232..e083eb17f24 100644 --- a/appengine-java8/sendgrid/pom.xml +++ b/appengine-java8/sendgrid/pom.xml @@ -56,6 +56,11 @@ Copyright 2018 Google LLC ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/spanner/pom.xml b/appengine-java8/spanner/pom.xml index c3831740be2..a0077228ea9 100644 --- a/appengine-java8/spanner/pom.xml +++ b/appengine-java8/spanner/pom.xml @@ -86,7 +86,11 @@ 9.4.44.v20210927 - + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.apache.maven.plugins 3.8.1 diff --git a/appengine-java8/static-files/pom.xml b/appengine-java8/static-files/pom.xml index 3b649199fdc..c422d09b34b 100644 --- a/appengine-java8/static-files/pom.xml +++ b/appengine-java8/static-files/pom.xml @@ -48,6 +48,11 @@ Copyright 2015 Google Inc. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/tasks/quickstart/pom.xml b/appengine-java8/tasks/quickstart/pom.xml index 9da543949dc..b240e6d893d 100644 --- a/appengine-java8/tasks/quickstart/pom.xml +++ b/appengine-java8/tasks/quickstart/pom.xml @@ -80,6 +80,11 @@ Copyright 2018 Google LLC ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/tasks/snippets/pom.xml b/appengine-java8/tasks/snippets/pom.xml index f1cad895322..62fdef30d4f 100644 --- a/appengine-java8/tasks/snippets/pom.xml +++ b/appengine-java8/tasks/snippets/pom.xml @@ -18,7 +18,6 @@ Copyright 2019 Google LLC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - war 1.0-SNAPSHOT com.example.task cloud-tasks-snippets diff --git a/appengine-java8/twilio/pom.xml b/appengine-java8/twilio/pom.xml index 99477e3d820..a6e686d7c9f 100644 --- a/appengine-java8/twilio/pom.xml +++ b/appengine-java8/twilio/pom.xml @@ -56,6 +56,11 @@ Copyright 2015 Google Inc. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/urlfetch/pom.xml b/appengine-java8/urlfetch/pom.xml index 393c2fa40f1..cd0f2c26df6 100644 --- a/appengine-java8/urlfetch/pom.xml +++ b/appengine-java8/urlfetch/pom.xml @@ -55,6 +55,11 @@ Copyright 2015 Google Inc. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/appengine-java8/users/pom.xml b/appengine-java8/users/pom.xml index ca423da13ab..fdf1789b75d 100644 --- a/appengine-java8/users/pom.xml +++ b/appengine-java8/users/pom.xml @@ -105,6 +105,11 @@ Copyright 2015 Google Inc. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/endpoints/multiple-versions/pom.xml b/endpoints/multiple-versions/pom.xml index 4c9ef0d3bb5..270fc3f20cc 100644 --- a/endpoints/multiple-versions/pom.xml +++ b/endpoints/multiple-versions/pom.xml @@ -70,6 +70,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/analytics/pom.xml b/flexible/analytics/pom.xml index 3716a167766..5f057167f82 100644 --- a/flexible/analytics/pom.xml +++ b/flexible/analytics/pom.xml @@ -57,6 +57,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/async-rest/pom.xml b/flexible/async-rest/pom.xml index e3601dcee01..b4e1f5d4a9d 100644 --- a/flexible/async-rest/pom.xml +++ b/flexible/async-rest/pom.xml @@ -44,6 +44,11 @@ + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.eclipse.jetty jetty-maven-plugin diff --git a/flexible/cloudsql/pom.xml b/flexible/cloudsql/pom.xml index 082d881b242..413a20024e1 100644 --- a/flexible/cloudsql/pom.xml +++ b/flexible/cloudsql/pom.xml @@ -100,6 +100,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/cloudstorage/pom.xml b/flexible/cloudstorage/pom.xml index 7309b52e8da..3c1ca6ec892 100644 --- a/flexible/cloudstorage/pom.xml +++ b/flexible/cloudstorage/pom.xml @@ -75,6 +75,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/cron/pom.xml b/flexible/cron/pom.xml index f0c9467d44a..85ee4aca8fd 100644 --- a/flexible/cron/pom.xml +++ b/flexible/cron/pom.xml @@ -54,6 +54,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/datastore/pom.xml b/flexible/datastore/pom.xml index 192b2e362d6..e4d384332d7 100644 --- a/flexible/datastore/pom.xml +++ b/flexible/datastore/pom.xml @@ -75,6 +75,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/disk/pom.xml b/flexible/disk/pom.xml index 1972caa1c3a..b936a875454 100644 --- a/flexible/disk/pom.xml +++ b/flexible/disk/pom.xml @@ -53,6 +53,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/errorreporting/pom.xml b/flexible/errorreporting/pom.xml index a191342fe11..ff487cee57c 100644 --- a/flexible/errorreporting/pom.xml +++ b/flexible/errorreporting/pom.xml @@ -57,6 +57,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/extending-runtime/pom.xml b/flexible/extending-runtime/pom.xml index 3b4b9044b7f..a666a3a7c98 100644 --- a/flexible/extending-runtime/pom.xml +++ b/flexible/extending-runtime/pom.xml @@ -53,6 +53,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/helloworld/pom.xml b/flexible/helloworld/pom.xml index 267a03862b0..0f9f039dd03 100644 --- a/flexible/helloworld/pom.xml +++ b/flexible/helloworld/pom.xml @@ -59,6 +59,12 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/memcache/pom.xml b/flexible/memcache/pom.xml index 8988c82fcc3..c53ec74a8cc 100644 --- a/flexible/memcache/pom.xml +++ b/flexible/memcache/pom.xml @@ -62,6 +62,12 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/pubsub/pom.xml b/flexible/pubsub/pom.xml index d484f2d649b..c84f5900107 100644 --- a/flexible/pubsub/pom.xml +++ b/flexible/pubsub/pom.xml @@ -103,6 +103,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/static-files/pom.xml b/flexible/static-files/pom.xml index a7782a0cbb6..bfcada7cf6a 100644 --- a/flexible/static-files/pom.xml +++ b/flexible/static-files/pom.xml @@ -53,6 +53,16 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/twilio/pom.xml b/flexible/twilio/pom.xml index cc136211ae8..85075f89d69 100644 --- a/flexible/twilio/pom.xml +++ b/flexible/twilio/pom.xml @@ -60,6 +60,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools appengine-maven-plugin diff --git a/flexible/websocket-jetty/pom.xml b/flexible/websocket-jetty/pom.xml index 9bf42d13c07..40c7ef68372 100644 --- a/flexible/websocket-jetty/pom.xml +++ b/flexible/websocket-jetty/pom.xml @@ -72,6 +72,11 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools diff --git a/flexible/websocket-jsr356/pom.xml b/flexible/websocket-jsr356/pom.xml index ddadb45b464..26913fbab68 100644 --- a/flexible/websocket-jsr356/pom.xml +++ b/flexible/websocket-jsr356/pom.xml @@ -69,6 +69,11 @@ limitations under the License. ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + com.google.cloud.tools diff --git a/memorystore/redis/pom.xml b/memorystore/redis/pom.xml index 87b5af307c1..ce8fb765b69 100644 --- a/memorystore/redis/pom.xml +++ b/memorystore/redis/pom.xml @@ -58,6 +58,11 @@ servlet/target/visitcounter-1.0-SNAPSHOT/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.eclipse.jetty diff --git a/session-handling/pom.xml b/session-handling/pom.xml index d14286e2516..bc5270bfd7b 100644 --- a/session-handling/pom.xml +++ b/session-handling/pom.xml @@ -96,6 +96,11 @@ Copyright 2019 Google LLC ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + org.eclipse.jetty jetty-maven-plugin From 956a962fc15d168f8d72714634b20aed4d27e3bf Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 7 May 2022 01:12:10 +0200 Subject: [PATCH 108/136] chore(deps): update dependency com.google.cloud.tools:appengine-gradle-plugin to v2.4.3 (#7099) --- appengine-java8/bigtable/build.gradle | 2 +- appengine-java8/endpoints-v2-backend/build.gradle | 2 +- appengine-java8/endpoints-v2-guice/build.gradle | 2 +- appengine-java8/endpoints-v2-migration/build.gradle | 2 +- appengine-java8/endpoints-v2-skeleton/build.gradle | 2 +- appengine-java8/helloworld/build.gradle | 2 +- flexible/helloworld/build.gradle | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/appengine-java8/bigtable/build.gradle b/appengine-java8/bigtable/build.gradle index 4cfaf44aba1..cb9d98ec979 100644 --- a/appengine-java8/bigtable/build.gradle +++ b/appengine-java8/bigtable/build.gradle @@ -18,7 +18,7 @@ buildscript { // Configuration for building mavenCentral() } dependencies { - classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.2' + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.3' classpath 'org.akhikhl.gretty:gretty:+' } } diff --git a/appengine-java8/endpoints-v2-backend/build.gradle b/appengine-java8/endpoints-v2-backend/build.gradle index 8777ff8038c..434d39f0c31 100644 --- a/appengine-java8/endpoints-v2-backend/build.gradle +++ b/appengine-java8/endpoints-v2-backend/build.gradle @@ -21,7 +21,7 @@ buildscript { // [START endpoints_plugin] classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0' // [END endpoints_plugin] - classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.2' + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.3' } } diff --git a/appengine-java8/endpoints-v2-guice/build.gradle b/appengine-java8/endpoints-v2-guice/build.gradle index bdf9f22b74e..bbb641df97c 100644 --- a/appengine-java8/endpoints-v2-guice/build.gradle +++ b/appengine-java8/endpoints-v2-guice/build.gradle @@ -19,7 +19,7 @@ buildscript { dependencies { classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0' - classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.2' + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.3' } } diff --git a/appengine-java8/endpoints-v2-migration/build.gradle b/appengine-java8/endpoints-v2-migration/build.gradle index 3ff42eddd6e..0058eef6cdb 100644 --- a/appengine-java8/endpoints-v2-migration/build.gradle +++ b/appengine-java8/endpoints-v2-migration/build.gradle @@ -20,7 +20,7 @@ buildscript { // Configuration for building } dependencies { // App Engine Gradle plugin - classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.2' + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.3' // Endpoints Frameworks Gradle plugin classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0' diff --git a/appengine-java8/endpoints-v2-skeleton/build.gradle b/appengine-java8/endpoints-v2-skeleton/build.gradle index 5620dfb4a52..a85dcc35a8b 100644 --- a/appengine-java8/endpoints-v2-skeleton/build.gradle +++ b/appengine-java8/endpoints-v2-skeleton/build.gradle @@ -20,7 +20,7 @@ buildscript { dependencies { classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0' - classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.2' + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.3' } } // [END build_script] diff --git a/appengine-java8/helloworld/build.gradle b/appengine-java8/helloworld/build.gradle index 724d1c98767..2e11c316436 100644 --- a/appengine-java8/helloworld/build.gradle +++ b/appengine-java8/helloworld/build.gradle @@ -18,7 +18,7 @@ buildscript { // Configuration for building mavenCentral() } dependencies { - classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.2' // If a newer version is available, use it + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.3' // If a newer version is available, use it } } diff --git a/flexible/helloworld/build.gradle b/flexible/helloworld/build.gradle index 37d52f83091..1974cdf7415 100644 --- a/flexible/helloworld/build.gradle +++ b/flexible/helloworld/build.gradle @@ -18,7 +18,7 @@ buildscript { // Configuration for building mavenCentral() } dependencies { - classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.2' + classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.4.3' classpath 'org.akhikhl.gretty:gretty:+' } } From 02f3e2a30ba84befced1dc89d46744c0140e61ec Mon Sep 17 00:00:00 2001 From: Shubha Rajan Date: Mon, 9 May 2022 09:42:17 -0700 Subject: [PATCH 109/136] fix: java.lang.reflect.InaccessibleObjectException in functions.StackdriverLogging sample (#7118) * fix: java.lang.reflect.InaccessibleObjectException in functions.StackdriverLogging sample --- functions/logging/stackdriver-logging/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/logging/stackdriver-logging/pom.xml b/functions/logging/stackdriver-logging/pom.xml index 6117a9b4ab5..46e9835b679 100644 --- a/functions/logging/stackdriver-logging/pom.xml +++ b/functions/logging/stackdriver-logging/pom.xml @@ -105,6 +105,8 @@ 3.0.0-M5 + + --add-opens java.base/java.time=ALL-UNNAMED **/*Test.java From e96d917eb65fdc32c6f0734ae31adb5b9175f4cc Mon Sep 17 00:00:00 2001 From: Shubha Rajan Date: Mon, 9 May 2022 09:54:59 -0700 Subject: [PATCH 110/136] feat: update SQL Server samples to include more connection methods (#7098) * feat: update SQL Server samples to include more connection methods --- cloud-sql/mysql/servlet/README.md | 2 +- cloud-sql/mysql/servlet/pom.xml | 1 + cloud-sql/postgres/servlet/README.md | 2 +- cloud-sql/sqlserver/servlet/.env.yaml | 6 + cloud-sql/sqlserver/servlet/README.md | 47 +++++- cloud-sql/sqlserver/servlet/pom.xml | 14 +- .../ConnectionPoolContextListener.java | 100 +----------- .../cloudsql/ConnectionPoolFactory.java | 57 +++++++ .../ConnectorConnectionPoolFactory.java | 74 +++++++++ .../com/example/cloudsql/IndexServlet.java | 70 +-------- .../cloudsql/TcpConnectionPoolFactory.java | 81 ++++++++++ .../com/example/cloudsql/TemplateData.java | 84 +++++++++++ .../main/java/com/example/cloudsql/Utils.java | 59 ++++++++ .../com/example/cloudsql/functions/Main.java | 142 ++++++++++++++++++ .../java/com/TestIndexServletSqlServer.java | 4 +- 15 files changed, 579 insertions(+), 164 deletions(-) create mode 100644 cloud-sql/sqlserver/servlet/.env.yaml create mode 100644 cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java create mode 100644 cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java create mode 100644 cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java create mode 100644 cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TemplateData.java create mode 100644 cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/Utils.java create mode 100644 cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/functions/Main.java diff --git a/cloud-sql/mysql/servlet/README.md b/cloud-sql/mysql/servlet/README.md index 915f0e13fdf..533cf1075cb 100644 --- a/cloud-sql/mysql/servlet/README.md +++ b/cloud-sql/mysql/servlet/README.md @@ -181,7 +181,7 @@ mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \ To deploy the application to Cloud Functions, first fill in the values for required environment variables in `.env.yaml`. Then run the following command ``` -gcloud functions deploy mysql-sample \ +gcloud functions deploy sql-sample \ --trigger-http \ --entry-point com.example.cloudsql.functions.Main \ --runtime java11 \ diff --git a/cloud-sql/mysql/servlet/pom.xml b/cloud-sql/mysql/servlet/pom.xml index c496f85ffef..b92ed13b1cb 100644 --- a/cloud-sql/mysql/servlet/pom.xml +++ b/cloud-sql/mysql/servlet/pom.xml @@ -92,6 +92,7 @@ 1.1.3 test + com.google.cloud.functions.invoker java-function-invoker diff --git a/cloud-sql/postgres/servlet/README.md b/cloud-sql/postgres/servlet/README.md index 7b9d6627d03..499e0495fb4 100644 --- a/cloud-sql/postgres/servlet/README.md +++ b/cloud-sql/postgres/servlet/README.md @@ -171,7 +171,7 @@ mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \ To deploy the application to Cloud Functions, first fill in the values for required environment variables in `.env.yaml`. Then run the following command ``` -gcloud functions deploy mysql-sample \ +gcloud functions deploy sql-sample \ --trigger-http \ --entry-point com.example.cloudsql.functions.Main \ --runtime java11 \ diff --git a/cloud-sql/sqlserver/servlet/.env.yaml b/cloud-sql/sqlserver/servlet/.env.yaml new file mode 100644 index 00000000000..807c8b3988f --- /dev/null +++ b/cloud-sql/sqlserver/servlet/.env.yaml @@ -0,0 +1,6 @@ +INSTANCE_CONNECTION_NAME: ::INSTANCE-NAME> +INSTANCE_HOST: '127.0.0.1' +DB_PORT: 1433 +DB_USER: +DB_PASS: +DB_NAME: diff --git a/cloud-sql/sqlserver/servlet/README.md b/cloud-sql/sqlserver/servlet/README.md index cde50bd12b4..b895b145123 100644 --- a/cloud-sql/sqlserver/servlet/README.md +++ b/cloud-sql/sqlserver/servlet/README.md @@ -31,6 +31,34 @@ export DB_NAME='my_db' Note: Saving credentials in environment variables is convenient, but not secure - consider a more secure solution such as [Cloud KMS](https://cloud.google.com/kms/) or [Secret Manager](https://cloud.google.com/secret-manager/) to help keep secrets safe. +## Configure SSL Certificates +For deployments that connect directly to a Cloud SQL instance with TCP, +without using the Cloud SQL Proxy, +configuring SSL certificates will ensure the connection is encrypted. +1. Use the gcloud CLI to [download the server certificate](https://cloud.google.com/sql/docs/mysql/configure-ssl-instance#server-certs) for your Cloud SQL instance. + - Get information about the service certificate: + ``` + gcloud beta sql ssl server-ca-certs list --instance=INSTANCE_NAME + ``` + - Create a server certificate: + ``` + gcloud beta sql ssl server-ca-certs create --instance=INSTANCE_NAME + ``` + - Download the certificate information to a local PEM file + ``` + gcloud beta sql ssl server-ca-certs list \ + --format="value(cert)" \ + --instance=INSTANCE_NAME > \ + server-ca.pem + ``` + +1. [Import the server certificate into a custom Java truststore](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html) using `keytool`: + ``` + keytool -importcert -alias MySQLCACert -file server-ca.pem \ + -keystore -storepass + ``` +1. Set the `TRUST_CERT_KEYSTORE_PATH` and `TRUST_CERT_KEYSTORE_PASSWD` environment variables to the values used in the previous step. + ## Deploying locally To run this application locally, run the following command inside the project folder: @@ -50,7 +78,7 @@ and verify that has been added in your build section as a plugin. -### Development Server +### App Engine Development Server The following command will run the application locally in the the GAE-development server: ```bash @@ -59,6 +87,12 @@ mvn clean package appengine:run Note: if the GAE development server fails to start, check that you are using a supported version of Java. Supported versions are Java 8 and Java 11. +### Cloud Functions Development Server +To run the application locally as a Cloud Function, run the following command: +``` +mvn function:run -Drun.functionTarget=com.example.cloudsql.functions.Main +``` + ### Deploy to Google Cloud First, update `src/main/webapp/WEB-INF/appengine-web.xml` with the correct values to pass the @@ -125,5 +159,16 @@ mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \ For more details about using Cloud Run see http://cloud.run. Review other [Java on Cloud Run samples](../../../run/). +### Deploy to Google Cloud Functions + +To deploy the application to Cloud Functions, first fill in the values for required environment variables in `.env.yaml`. Then run the following command +``` +gcloud functions deploy sql-sample \ + --trigger-http \ + --entry-point com.example.cloudsql.functions.Main \ + --runtime java11 \ + --env-vars-file .env.yaml +``` + ### Cleanup To avoid incurring any charges, navigate to your project's [App Engine settings](https://console.cloud.google.com/appengine/settings) and click `Disable Application`. Also [delete your Cloud SQL Instance](https://cloud.google.com/sql/docs/mysql/delete-instance) if you no longer need it. diff --git a/cloud-sql/sqlserver/servlet/pom.xml b/cloud-sql/sqlserver/servlet/pom.xml index a1b4853883d..0dcb41a1304 100644 --- a/cloud-sql/sqlserver/servlet/pom.xml +++ b/cloud-sql/sqlserver/servlet/pom.xml @@ -52,7 +52,7 @@ com.microsoft.sqlserver mssql-jdbc - 9.4.1.jre8 + 10.2.0.jre8 com.google.cloud.sql @@ -82,6 +82,18 @@ 1.1.3 test + + + com.google.cloud.functions.invoker + java-function-invoker + 1.0.1 + + + com.google.cloud.functions + functions-framework-api + 1.0.4 + provided + diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java index cd25eb98bb2..b7f534bb2fc 100644 --- a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java @@ -16,10 +16,7 @@ package com.example.cloudsql; -import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; -import java.sql.Connection; -import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.logging.Logger; import javax.servlet.ServletContextEvent; @@ -40,94 +37,6 @@ public class ConnectionPoolContextListener implements ServletContextListener { private static final String DB_PASS = System.getenv("DB_PASS"); private static final String DB_NAME = System.getenv("DB_NAME"); - private DataSource createConnectionPool() { - // [START cloud_sql_sqlserver_servlet_create] - // Note: For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections - // which is preferred to using the Cloud SQL Proxy with Unix sockets. - // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details. - - // The configuration object specifies behaviors for the connection pool. - HikariConfig config = new HikariConfig(); - - // The following is equivalent to setting the config options below: - // jdbc:sqlserver://;user=;password=;databaseName=; - // socketFactoryClass=com.google.cloud.sql.sqlserver.SocketFactory; - // socketFactoryConstructorArg= - - // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory - // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url - - // Configure which instance and what database user to connect with. - config - .setDataSourceClassName("com.microsoft.sqlserver.jdbc.SQLServerDataSource"); - config.setUsername(DB_USER); // e.g. "root", "sqlserver" - config.setPassword(DB_PASS); // e.g. "my-password" - config.addDataSourceProperty("databaseName", DB_NAME); - - config.addDataSourceProperty("socketFactoryClass", - "com.google.cloud.sql.sqlserver.SocketFactory"); - config.addDataSourceProperty("socketFactoryConstructorArg", INSTANCE_CONNECTION_NAME); - - // ... Specify additional connection properties here. - - // [START_EXCLUDE] - - // [START cloud_sql_sqlserver_servlet_limit] - // maximumPoolSize limits the total number of concurrent connections this pool will keep. Ideal - // values for this setting are highly variable on app design, infrastructure, and database. - config.setMaximumPoolSize(5); - // minimumIdle is the minimum number of idle connections Hikari maintains in the pool. - // Additional connections will be established to meet this value unless the pool is full. - config.setMinimumIdle(5); - // [END cloud_sql_sqlserver_servlet_limit] - - // [START cloud_sql_sqlserver_servlet_timeout] - // setConnectionTimeout is the maximum number of milliseconds to wait for a connection checkout. - // Any attempt to retrieve a connection from this pool that exceeds the set limit will throw an - // SQLException. - config.setConnectionTimeout(10000); // 10 seconds - // idleTimeout is the maximum amount of time a connection can sit in the pool. Connections that - // sit idle for this many milliseconds are retried if minimumIdle is exceeded. - config.setIdleTimeout(600000); // 10 minutes - // [END cloud_sql_sqlserver_servlet_timeout] - - // [START cloud_sql_sqlserver_servlet_backoff] - // Hikari automatically delays between failed connection attempts, eventually reaching a - // maximum delay of `connectionTimeout / 2` between attempts. - // [END cloud_sql_sqlserver_servlet_backoff] - - // [START cloud_sql_sqlserver_servlet_lifetime] - // maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that - // live longer than this many milliseconds will be closed and reestablished between uses. This - // value should be several minutes shorter than the database's timeout value to avoid unexpected - // terminations. - config.setMaxLifetime(1800000); // 30 minutes - // [END cloud_sql_sqlserver_servlet_lifetime] - - // [END_EXCLUDE] - - // Initialize the connection pool using the configuration object. - DataSource pool = new HikariDataSource(config); - // [END cloud_sql_sqlserver_servlet_create] - return pool; - } - - private void createTable(DataSource pool) throws SQLException { - // Safely attempt to create the table schema. - try (Connection conn = pool.getConnection()) { - PreparedStatement createTableStatement = conn.prepareStatement( - "IF NOT EXISTS (" - + "SELECT * FROM sysobjects WHERE name='votes' and xtype='U')" - + "CREATE TABLE votes (" - + "vote_id INT NOT NULL IDENTITY," - + "time_cast DATETIME NOT NULL," - + "candidate VARCHAR(6) NOT NULL," - + "PRIMARY KEY (vote_id));" - ); - createTableStatement.execute(); - } - } - @Override public void contextDestroyed(ServletContextEvent event) { // This function is called when the Servlet is destroyed. @@ -143,11 +52,16 @@ public void contextInitialized(ServletContextEvent event) { // that can be used to connect to. DataSource pool = (DataSource) event.getServletContext().getAttribute("my-pool"); if (pool == null) { - pool = createConnectionPool(); + if (System.getenv("INSTANCE_HOST") != null) { + pool = TcpConnectionPoolFactory.createConnectionPool(); + } else { + pool = ConnectorConnectionPoolFactory.createConnectionPool(); + } event.getServletContext().setAttribute("my-pool", pool); } try { - createTable(pool); + // from src/main/java/com/example/cloudsql/Utils.java + Utils.createTable(pool); } catch (SQLException ex) { throw new RuntimeException("Unable to verify table schema. Please double check the steps" + "in the README and try again.", ex); diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java new file mode 100644 index 00000000000..e35b731771d --- /dev/null +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectionPoolFactory.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import com.zaxxer.hikari.HikariConfig; + +public class ConnectionPoolFactory { + + public static HikariConfig configureConnectionPool(HikariConfig config) { + // [START cloud_sql_sqlserver_servlet_limit] + // maximumPoolSize limits the total number of concurrent connections this pool will keep. Ideal + // values for this setting are highly variable on app design, infrastructure, and database. + config.setMaximumPoolSize(5); + // minimumIdle is the minimum number of idle connections Hikari maintains in the pool. + // Additional connections will be established to meet this value unless the pool is full. + config.setMinimumIdle(5); + // [END cloud_sql_sqlserver_servlet_limit] + + // [START cloud_sql_sqlserver_servlet_timeout] + // setConnectionTimeout is the maximum number of milliseconds to wait for a connection checkout. + // Any attempt to retrieve a connection from this pool that exceeds the set limit will throw an + // SQLException. + config.setConnectionTimeout(10000); // 10 seconds + // idleTimeout is the maximum amount of time a connection can sit in the pool. Connections that + // sit idle for this many milliseconds are retried if minimumIdle is exceeded. + config.setIdleTimeout(600000); // 10 minutes + // [END cloud_sql_sqlserver_servlet_timeout] + + // [START cloud_sql_sqlserver_servlet_backoff] + // Hikari automatically delays between failed connection attempts, eventually reaching a + // maximum delay of `connectionTimeout / 2` between attempts. + // [END cloud_sql_sqlserver_servlet_backoff] + + // [START cloud_sql_sqlserver_servlet_lifetime] + // maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that + // live longer than this many milliseconds will be closed and reestablished between uses. This + // value should be several minutes shorter than the database's timeout value to avoid unexpected + // terminations. + config.setMaxLifetime(1800000); // 30 minutes + // [END cloud_sql_sqlserver_servlet_lifetime] + return config; + } +} diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java new file mode 100644 index 00000000000..b4d738cd846 --- /dev/null +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/ConnectorConnectionPoolFactory.java @@ -0,0 +1,74 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +// [START cloud_sql_sqlserver_servlet_connect_connector] + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; + +public class ConnectorConnectionPoolFactory extends ConnectionPoolFactory { + + // Note: Saving credentials in environment variables is convenient, but not + // secure - consider a more secure solution such as + // Cloud Secret Manager (https://cloud.google.com/secret-manager) to help + // keep secrets safe. + private static final String INSTANCE_CONNECTION_NAME = + System.getenv("INSTANCE_CONNECTION_NAME"); + private static final String DB_USER = System.getenv("DB_USER"); + private static final String DB_PASS = System.getenv("DB_PASS"); + private static final String DB_NAME = System.getenv("DB_NAME"); + + public static DataSource createConnectionPool() { + // The configuration object specifies behaviors for the connection pool. + HikariConfig config = new HikariConfig(); + + // The following is equivalent to setting the config options below: + // jdbc:sqlserver://;user=;password=;databaseName=; + // socketFactoryClass=com.google.cloud.sql.sqlserver.SocketFactory; + // socketFactoryConstructorArg= + + // See the link below for more info on building a JDBC URL for the Cloud SQL JDBC Socket Factory + // https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#creating-the-jdbc-url + + // Configure which instance and what database user to connect with. + config + .setDataSourceClassName("com.microsoft.sqlserver.jdbc.SQLServerDataSource"); + config.setUsername(DB_USER); // e.g. "root", "sqlserver" + config.setPassword(DB_PASS); // e.g. "my-password" + config.addDataSourceProperty("databaseName", DB_NAME); + + config.addDataSourceProperty("socketFactoryClass", + "com.google.cloud.sql.sqlserver.SocketFactory"); + config.addDataSourceProperty("socketFactoryConstructorArg", INSTANCE_CONNECTION_NAME); + + // The Java Connector provides SSL encryption, so it should be disabled + // at the driver level. + config.addDataSourceProperty("encrypt", "false"); + + // ... Specify additional connection properties here. + // [START_EXCLUDE] + configureConnectionPool(config); + // [END_EXCLUDE] + + // Initialize the connection pool using the configuration object. + return new HikariDataSource(config); + } +} +// [END cloud_sql_sqlserver_servlet_connect_connector] + diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/IndexServlet.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/IndexServlet.java index 425d358f132..60aa1ba8621 100644 --- a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/IndexServlet.java +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/IndexServlet.java @@ -19,12 +19,9 @@ import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.Date; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletException; @@ -35,71 +32,17 @@ import javax.sql.DataSource; - @WebServlet(name = "Index", value = "") public class IndexServlet extends HttpServlet { private static final Logger LOGGER = Logger.getLogger(IndexServlet.class.getName()); - class TemplateData { - - public int tabCount; - public int spaceCount; - public List recentVotes; - - public TemplateData(int tabCount, int spaceCount, List recentVotes) { - this.tabCount = tabCount; - this.spaceCount = spaceCount; - this.recentVotes = recentVotes; - } - } - public TemplateData getTemplateData(DataSource pool) throws ServletException { - - int tabCount; - int spaceCount; - List recentVotes = new ArrayList<>(); - try (Connection conn = pool.getConnection()) { - // PreparedStatements are compiled by the database immediately and executed at a later date. - // Most databases cache previously compiled queries, which improves efficiency. - PreparedStatement voteStmt = conn.prepareStatement( - "SELECT TOP(5) candidate, time_cast FROM votes ORDER BY time_cast DESC"); - // Execute the statement - ResultSet voteResults = voteStmt.executeQuery(); - // Convert a ResultSet into Vote objects - while (voteResults.next()) { - String candidate = voteResults.getString(1); - Timestamp timeCast = voteResults.getTimestamp(2); - Vote vote = new Vote(candidate.trim(), timeCast); - recentVotes.add(vote); - } - - // PreparedStatements can also be executed multiple times with different arguments. This can - // improve efficiency, and project a query from being vulnerable to an SQL injection. - PreparedStatement voteCountStmt = conn.prepareStatement( - "SELECT COUNT(vote_id) FROM votes WHERE candidate=?"); - - voteCountStmt.setString(1, "TABS"); - ResultSet tabResult = voteCountStmt.executeQuery(); - tabResult.next(); // Move to the first result - tabCount = tabResult.getInt(1); - - voteCountStmt.setString(1, "SPACES"); - ResultSet spaceResult = voteCountStmt.executeQuery(); - spaceResult.next(); // Move to the first result - spaceCount = spaceResult.getInt(1); - + try { + return TemplateData.getTemplateData(pool); } catch (SQLException ex) { - // If something goes wrong, the application needs to react appropriately. This might mean - // getting a new connection and executing the query again, or it might mean redirecting the - // user to a different page to let them know something went wrong. - throw new ServletException("Unable to successfully connect to the database. Please check the " - + "steps in the README and try again.", ex); + throw new ServletException(ex); } - - TemplateData templateData = new TemplateData(tabCount, spaceCount, recentVotes); - - return templateData; } @Override @@ -122,12 +65,9 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { // Get the team from the request and record the time of the vote. - String team = req.getParameter("team"); - if (team != null) { - team = team.toUpperCase(); - } + String team = Utils.validateTeam(req.getParameter("team")); Timestamp now = new Timestamp(new Date().getTime()); - if (team == null || (!team.equals("TABS") && !team.equals("SPACES"))) { + if (team == null) { resp.setStatus(400); resp.getWriter().append("Invalid team specified."); return; diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java new file mode 100644 index 00000000000..97f64d02286 --- /dev/null +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TcpConnectionPoolFactory.java @@ -0,0 +1,81 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +// [START cloud_sql_sqlserver_servlet_connect_tcp] +// [START cloud_sql_sqlserver_servlet_connect_tcp_sslcerts] + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; + +public class TcpConnectionPoolFactory extends ConnectionPoolFactory { + + // Note: Saving credentials in environment variables is convenient, but not + // secure - consider a more secure solution such as + // Cloud Secret Manager (https://cloud.google.com/secret-manager) to help + // keep secrets safe. + private static final String DB_USER = System.getenv("DB_USER"); + private static final String DB_PASS = System.getenv("DB_PASS"); + private static final String DB_NAME = System.getenv("DB_NAME"); + + private static final String INSTANCE_HOST = System.getenv("INSTANCE_HOST"); + private static final String DB_PORT = System.getenv("DB_PORT"); + + // [END cloud_sql_sqlserver_servlet_connect_tcp] + private static final String TRUST_CERT_KEYSTORE_PATH = System.getenv( + "TRUST_CERT_KEYSTORE_NAME"); + private static final String TRUST_CERT_KEYSTORE_PASSWD = System.getenv( + "TRUST_CERT_KEYSTORE_PASSWD"); + // [START cloud_sql_sqlserver_servlet_connect_tcp] + + public static DataSource createConnectionPool() { + // The configuration object specifies behaviors for the connection pool. + HikariConfig config = new HikariConfig(); + + // Configure which instance and what database user to connect with. + config.setJdbcUrl( + String.format("jdbc:sqlserver://%s:%s;databaseName=%s", INSTANCE_HOST, DB_PORT, DB_NAME)); + config.setUsername(DB_USER); // e.g. "root", "sqlserver" + config.setPassword(DB_PASS); // e.g. "my-password" + + // [END cloud_sql_sqlserver_servlet_connect_tcp] + // (OPTIONAL) Configure SSL certificates + // For deployments that connect directly to a Cloud SQL instance without + // using the Cloud SQL Proxy, configuring SSL certificates will ensure the + // connection is encrypted. + // For details about how the SQL Server JDBC driver handles SSL encryption, see the link below + // https://docs.microsoft.com/en-us/sql/connect/jdbc/understanding-ssl-support?view=sql-server-ver15 + + if (TRUST_CERT_KEYSTORE_PATH != null) { + config.addDataSourceProperty("encrypt", "true"); + config.addDataSourceProperty("trustStore", TRUST_CERT_KEYSTORE_PATH); + config.addDataSourceProperty("trustStorePassword", TRUST_CERT_KEYSTORE_PASSWD); + } + // [START cloud_sql_sqlserver_servlet_connect_tcp] + + // ... Specify additional connection properties here. + // [START_EXCLUDE] + configureConnectionPool(config); + // [END_EXCLUDE] + + // Initialize the connection pool using the configuration object. + return new HikariDataSource(config); + } +} +// [END cloud_sql_sqlserver_servlet_connect_tcp] +// [END cloud_sql_sqlserver_servlet_connect_tcp_sslcerts] diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TemplateData.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TemplateData.java new file mode 100644 index 00000000000..c2cb79e0a3d --- /dev/null +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/TemplateData.java @@ -0,0 +1,84 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import javax.sql.DataSource; + +public class TemplateData { + + public int tabCount; + public int spaceCount; + public List recentVotes; + + public TemplateData(int tabCount, int spaceCount, List recentVotes) { + this.tabCount = tabCount; + this.spaceCount = spaceCount; + this.recentVotes = recentVotes; + } + + public static TemplateData getTemplateData(DataSource pool) throws SQLException { + int tabCount; + int spaceCount; + List recentVotes = new ArrayList<>(); + try (Connection conn = pool.getConnection()) { + // PreparedStatements are compiled by the database immediately and executed at a later date. + // Most databases cache previously compiled queries, which improves efficiency. + PreparedStatement voteStmt = conn.prepareStatement( + "SELECT TOP(5) candidate, time_cast FROM votes ORDER BY time_cast DESC"); + // Execute the statement + ResultSet voteResults = voteStmt.executeQuery(); + // Convert a ResultSet into Vote objects + while (voteResults.next()) { + String candidate = voteResults.getString(1); + Timestamp timeCast = voteResults.getTimestamp(2); + Vote vote = new Vote(candidate.trim(), timeCast); + recentVotes.add(vote); + } + + // PreparedStatements can also be executed multiple times with different arguments. This can + // improve efficiency, and project a query from being vulnerable to an SQL injection. + PreparedStatement voteCountStmt = conn.prepareStatement( + "SELECT COUNT(vote_id) FROM votes WHERE candidate=?"); + + voteCountStmt.setString(1, "TABS"); + ResultSet tabResult = voteCountStmt.executeQuery(); + tabResult.next(); // Move to the first result + tabCount = tabResult.getInt(1); + + voteCountStmt.setString(1, "SPACES"); + ResultSet spaceResult = voteCountStmt.executeQuery(); + spaceResult.next(); // Move to the first result + spaceCount = spaceResult.getInt(1); + + } catch (SQLException ex) { + // If something goes wrong, the application needs to react appropriately. This might mean + // getting a new connection and executing the query again, or it might mean redirecting the + // user to a different page to let them know something went wrong. + throw new SQLException("Unable to successfully connect to the database. Please check the " + + "steps in the README and try again.", ex); + } + + return new TemplateData(tabCount, spaceCount, recentVotes); + } +} diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/Utils.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/Utils.java new file mode 100644 index 00000000000..08b6425982e --- /dev/null +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/Utils.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Locale; +import javax.annotation.Nullable; +import javax.sql.DataSource; + +public class Utils { + + // Used to validate user input. All user provided data should be validated and sanitized before + // being used something like a SQL query. Returns null if invalid. + @Nullable + public static String validateTeam(String input) { + if (input != null) { + input = input.toUpperCase(Locale.ENGLISH); + // Must be either "TABS" or "SPACES" + if (!"TABS".equals(input) && !"SPACES".equals(input)) { + return null; + } + } + return input; + } + + public static void createTable(DataSource pool) throws SQLException { + // Safely attempt to create the table schema. + try (Connection conn = pool.getConnection()) { + PreparedStatement createTableStatement = conn.prepareStatement( + "IF NOT EXISTS (" + + "SELECT * FROM sysobjects WHERE name='votes' and xtype='U')" + + "CREATE TABLE votes (" + + "vote_id INT NOT NULL IDENTITY," + + "time_cast DATETIME NOT NULL," + + "candidate VARCHAR(6) NOT NULL," + + "PRIMARY KEY (vote_id));" + ); + createTableStatement.execute(); + } + } + + +} diff --git a/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/functions/Main.java b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/functions/Main.java new file mode 100644 index 00000000000..e42f4ce7128 --- /dev/null +++ b/cloud-sql/sqlserver/servlet/src/main/java/com/example/cloudsql/functions/Main.java @@ -0,0 +1,142 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.cloudsql.functions; + +import com.example.cloudsql.ConnectorConnectionPoolFactory; +import com.example.cloudsql.TcpConnectionPoolFactory; +import com.example.cloudsql.TemplateData; +import com.example.cloudsql.Utils; +import com.google.cloud.functions.HttpFunction; +import com.google.cloud.functions.HttpRequest; +import com.google.cloud.functions.HttpResponse; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.util.Date; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.sql.DataSource; + +public class Main implements HttpFunction { + + private Logger logger = Logger.getLogger(Main.class.getName()); + private static final Gson gson = new Gson(); + + // Declared at cold-start, but only initialized if/when the function executes + // Uses the "initialization-on-demand holder" idiom + // More information: https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom + private static class PoolHolder { + + // Making the default constructor private prohibits instantiation of this class + private PoolHolder() { + } + + // This value is initialized only if (and when) the getInstance() function below is called + private static final DataSource INSTANCE = setupPool(); + + private static DataSource setupPool() { + DataSource pool; + if (System.getenv("INSTANCE_HOST") != null) { + pool = TcpConnectionPoolFactory.createConnectionPool(); + } else { + pool = ConnectorConnectionPoolFactory.createConnectionPool(); + } + try { + Utils.createTable(pool); + } catch (SQLException ex) { + throw new RuntimeException( + "Unable to verify table schema. Please double check the steps" + + "in the README and try again.", + ex); + } + return pool; + } + + private static DataSource getInstance() { + return PoolHolder.INSTANCE; + } + } + + private void returnVoteCounts(HttpRequest req, HttpResponse resp) + throws SQLException, IOException { + DataSource pool = PoolHolder.getInstance(); + TemplateData templateData = TemplateData.getTemplateData(pool); + JsonObject respContent = new JsonObject(); + + // Return JSON Data + respContent.addProperty("tabCount", templateData.tabCount); + respContent.addProperty("spaceCount", templateData.spaceCount); + respContent.addProperty("recentVotes", gson.toJson(templateData.recentVotes)); + resp.getWriter().write(respContent.toString()); + resp.setStatusCode(HttpURLConnection.HTTP_OK); + } + + private void submitVote(HttpRequest req, HttpResponse resp) throws IOException { + DataSource pool = PoolHolder.getInstance(); + Timestamp now = new Timestamp(new Date().getTime()); + JsonObject body = gson.fromJson(req.getReader(), JsonObject.class); + String team = Utils.validateTeam(body.get("team").getAsString()); + if (team == null) { + resp.setStatusCode(400); + resp.getWriter().append("Invalid team specified."); + return; + } + try (Connection conn = pool.getConnection()) { + // PreparedStatements can be more efficient and project against injections. + String stmt = "INSERT INTO votes (time_cast, candidate) VALUES (?, ?);"; + try (PreparedStatement voteStmt = conn.prepareStatement(stmt);) { + voteStmt.setTimestamp(1, now); + voteStmt.setString(2, team); + + // Finally, execute the statement. If it fails, an error will be thrown. + voteStmt.execute(); + } + } catch (SQLException ex) { + // If something goes wrong, handle the error in this section. This might involve retrying or + // adjusting parameters depending on the situation. + logger.log(Level.WARNING, "Error while attempting to submit vote.", ex); + resp.setStatusCode(500); + resp.getWriter() + .write( + "Unable to successfully cast vote! Please check the application " + + "logs for more details."); + } + } + + @Override + public void service(HttpRequest req, HttpResponse resp) throws IOException, SQLException { + + String method = req.getMethod(); + switch (method) { + case "GET": + returnVoteCounts(req, resp); + break; + case "POST": + submitVote(req, resp); + break; + default: + resp.setStatusCode(HttpURLConnection.HTTP_BAD_METHOD); + resp.getWriter().write(String.format("HTTP Method %s is not supported", method)); + break; + } + } +} diff --git a/cloud-sql/sqlserver/servlet/src/test/java/com/TestIndexServletSqlServer.java b/cloud-sql/sqlserver/servlet/src/test/java/com/TestIndexServletSqlServer.java index b6c930d71bf..c73d91ba42a 100644 --- a/cloud-sql/sqlserver/servlet/src/test/java/com/TestIndexServletSqlServer.java +++ b/cloud-sql/sqlserver/servlet/src/test/java/com/TestIndexServletSqlServer.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.example.cloudsql.IndexServlet.TemplateData; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import java.io.PrintWriter; @@ -94,6 +93,7 @@ public static void createPool() throws SQLException { "com.google.cloud.sql.sqlserver.SocketFactory"); config.addDataSourceProperty("socketFactoryConstructorArg", System.getenv("SQLSERVER_CONNECTION_NAME")); + config.addDataSourceProperty("encrypt", "false"); pool = new HikariDataSource(config); createTable(pool); @@ -138,4 +138,4 @@ public void testServletPost() throws Exception { writer.flush(); assertTrue(stringWriter.toString().contains("Vote successfully cast for")); } -} \ No newline at end of file +} From a4a2e507e7d1122808cf14b1f6f4994b6f5c79f5 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:12:12 +0200 Subject: [PATCH 111/136] fix(deps): update dependency com.google.api-client:google-api-client-gson to v1.34.1 (#7127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api-client:google-api-client-gson](https://togithub.com/googleapis/google-api-java-client) | `1.34.0` -> `1.34.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.1/compatibility-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-gson/1.34.1/confidence-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-api-java-client ### [`v1.34.1`](https://togithub.com/googleapis/google-api-java-client/releases/v1.34.1) [Compare Source](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) ##### [1.34.1](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) (2022-05-06) ##### Dependencies - downgrade appengine to 1.9.X ([#​2053](https://togithub.com/googleapis/google-api-java-client/issues/2053)) ([8d9a863](https://togithub.com/googleapis/google-api-java-client/commit/8d9a863033672bb2a0b2d826e0ba6025f437cf96)) - google-http-client 1.41.8 ([#​2056](https://togithub.com/googleapis/google-api-java-client/issues/2056)) ([d1e84ac](https://togithub.com/googleapis/google-api-java-client/commit/d1e84acf81141159283d7d33a1cd8221b3aac4fd))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- compute/cmdline/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/cmdline/pom.xml b/compute/cmdline/pom.xml index b35aec203f6..54541005105 100644 --- a/compute/cmdline/pom.xml +++ b/compute/cmdline/pom.xml @@ -50,7 +50,7 @@ limitations under the License. com.google.api-client google-api-client-gson - 1.34.0 + 1.34.1 From 270311f19c490d5296076524af289a344b850944 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:40:13 +0200 Subject: [PATCH 112/136] fix(deps): update dependency com.google.api-client:google-api-client-jackson2 to v1.34.1 (#7128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api-client:google-api-client-jackson2](https://togithub.com/googleapis/google-api-java-client) | `1.34.0` -> `1.34.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.1/compatibility-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-jackson2/1.34.1/confidence-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-api-java-client ### [`v1.34.1`](https://togithub.com/googleapis/google-api-java-client/releases/v1.34.1) [Compare Source](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) ##### [1.34.1](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) (2022-05-06) ##### Dependencies - downgrade appengine to 1.9.X ([#​2053](https://togithub.com/googleapis/google-api-java-client/issues/2053)) ([8d9a863](https://togithub.com/googleapis/google-api-java-client/commit/8d9a863033672bb2a0b2d826e0ba6025f437cf96)) - google-http-client 1.41.8 ([#​2056](https://togithub.com/googleapis/google-api-java-client/issues/2056)) ([d1e84ac](https://togithub.com/googleapis/google-api-java-client/commit/d1e84acf81141159283d7d33a1cd8221b3aac4fd))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index 1ece8f1ccfd..ee4c723d2a6 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -88,7 +88,7 @@ com.google.api-client google-api-client-jackson2 - 1.34.0 + 1.34.1 com.google.http-client diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index abc1525861a..4db138ad520 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -97,7 +97,7 @@ com.google.api-client google-api-client-jackson2 - 1.34.0 + 1.34.1 com.google.http-client From 27ca40a4ac70d741ff53d7b7fa3f425801dcc6f2 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:48:11 +0200 Subject: [PATCH 113/136] fix(deps): update dependency com.google.api-client:google-api-client-appengine to v1.34.1 (#7126) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api-client:google-api-client-appengine](https://togithub.com/googleapis/google-api-java-client) | `1.34.0` -> `1.34.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.1/compatibility-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client-appengine/1.34.1/confidence-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-api-java-client ### [`v1.34.1`](https://togithub.com/googleapis/google-api-java-client/releases/v1.34.1) [Compare Source](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) ##### [1.34.1](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) (2022-05-06) ##### Dependencies - downgrade appengine to 1.9.X ([#​2053](https://togithub.com/googleapis/google-api-java-client/issues/2053)) ([8d9a863](https://togithub.com/googleapis/google-api-java-client/commit/8d9a863033672bb2a0b2d826e0ba6025f437cf96)) - google-http-client 1.41.8 ([#​2056](https://togithub.com/googleapis/google-api-java-client/issues/2056)) ([d1e84ac](https://togithub.com/googleapis/google-api-java-client/commit/d1e84acf81141159283d7d33a1cd8221b3aac4fd))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- storage/xml-api/serviceaccount-appengine-sample/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/xml-api/serviceaccount-appengine-sample/pom.xml b/storage/xml-api/serviceaccount-appengine-sample/pom.xml index 4c748d48656..130abe465cf 100644 --- a/storage/xml-api/serviceaccount-appengine-sample/pom.xml +++ b/storage/xml-api/serviceaccount-appengine-sample/pom.xml @@ -35,7 +35,7 @@ 1.8 1.8 - 1.34.0 + 1.34.1 ${project.build.directory}/${project.build.finalName} UTF-8 From 4b111eff80af6bd2268d020d1b2427e105094a34 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:50:12 +0200 Subject: [PATCH 114/136] chore(deps): update dependency org.apache.hbase:hbase-client to v2.4.12 (#7122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.apache.hbase:hbase-client](https://hbase.apache.org) ([source](https://gitbox.apache.org/repos/asf?p=hbase)) | `2.4.11` -> `2.4.12` | [![age](https://badges.renovateapi.com/packages/maven/org.apache.hbase:hbase-client/2.4.12/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.apache.hbase:hbase-client/2.4.12/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.apache.hbase:hbase-client/2.4.12/compatibility-slim/2.4.11)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.apache.hbase:hbase-client/2.4.12/confidence-slim/2.4.11)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java8/bigtable/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java8/bigtable/build.gradle b/appengine-java8/bigtable/build.gradle index cb9d98ec979..63332506c3e 100644 --- a/appengine-java8/bigtable/build.gradle +++ b/appengine-java8/bigtable/build.gradle @@ -46,7 +46,7 @@ repositories { dependencies { compile group: 'com.google.cloud.bigtable', name: 'bigtable-hbase-1.2', version:'1.0.0-pre3' - compile group: 'org.apache.hbase', name: 'hbase-client', version:'2.4.11' + compile group: 'org.apache.hbase', name: 'hbase-client', version:'2.4.12' compile group: 'io.netty', name: 'netty-tcnative-boringssl-static', version:'2.0.50.Final' compile group: 'jstl', name: 'jstl', version:'1.2' From e2a9b4d2f3ee808060d452a5be7414d27841aa3b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:50:17 +0200 Subject: [PATCH 115/136] chore(deps): update dependency org.codehaus.mojo:exec-maven-plugin to v3 (#7132) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.codehaus.mojo:exec-maven-plugin](http://www.mojohaus.org/exec-maven-plugin) ([source](https://togithub.com/mojohaus/exec-maven-plugin)) | `1.2.1` -> `3.0.0` | [![age](https://badges.renovateapi.com/packages/maven/org.codehaus.mojo:exec-maven-plugin/3.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.codehaus.mojo:exec-maven-plugin/3.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.codehaus.mojo:exec-maven-plugin/3.0.0/compatibility-slim/1.2.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.codehaus.mojo:exec-maven-plugin/3.0.0/confidence-slim/1.2.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java11/kotlin-ktor/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java11/kotlin-ktor/pom.xml b/appengine-java11/kotlin-ktor/pom.xml index 5f01e4ea9d5..e480653d73d 100644 --- a/appengine-java11/kotlin-ktor/pom.xml +++ b/appengine-java11/kotlin-ktor/pom.xml @@ -121,7 +121,7 @@ limitations under the License. org.codehaus.mojo exec-maven-plugin - 1.2.1 + 3.0.0 From 86124440cccf21149a4e1375022613598316809b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:52:10 +0200 Subject: [PATCH 116/136] fix(deps): update dependency com.slack.api:slack-app-backend to v1.22.1 (#7130) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.slack.api:slack-app-backend](https://togithub.com/slackapi/java-slack-sdk) | `1.22.0` -> `1.22.1` | [![age](https://badges.renovateapi.com/packages/maven/com.slack.api:slack-app-backend/1.22.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.slack.api:slack-app-backend/1.22.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.slack.api:slack-app-backend/1.22.1/compatibility-slim/1.22.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.slack.api:slack-app-backend/1.22.1/confidence-slim/1.22.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
slackapi/java-slack-sdk ### [`v1.22.1`](https://togithub.com/slackapi/java-slack-sdk/releases/v1.22.1) [Compare Source](https://togithub.com/slackapi/java-slack-sdk/compare/v1.22.0...v1.22.1) #### Changes - \[bolt] [#​984](https://togithub.com/slackapi/java-slack-sdk/issues/984) Add granular user change events - Thanks [@​seratch](https://togithub.com/seratch) - \[slack-api-client] [#​983](https://togithub.com/slackapi/java-slack-sdk/issues/983) Tweaking warnings related to missing accessibility fields text and fallback when posting messages - Thanks [@​filmaj](https://togithub.com/filmaj) - \[slack-api-client] Add new properties to Audit Logs API response classes - Thanks [@​seratch](https://togithub.com/seratch) *** - All issues/pull requests: https://github.com/slackapi/java-slack-sdk/milestone/57?closed=1 - All changes: https://github.com/slackapi/java-slack-sdk/compare/v1.22.0...v1.22.1
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- functions/slack/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/slack/pom.xml b/functions/slack/pom.xml index 3a6f3b41053..7e5650d6a92 100644 --- a/functions/slack/pom.xml +++ b/functions/slack/pom.xml @@ -77,7 +77,7 @@ com.slack.api slack-app-backend - 1.22.0 + 1.22.1 From cf73d28aaac95de469ec7af5aa02990d29c44aea Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:52:13 +0200 Subject: [PATCH 117/136] fix(deps): update dependency redis.clients:jedis to v4.2.3 (#7131) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [redis.clients:jedis](https://togithub.com/redis/jedis) | `4.2.2` -> `4.2.3` | [![age](https://badges.renovateapi.com/packages/maven/redis.clients:jedis/4.2.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/redis.clients:jedis/4.2.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/redis.clients:jedis/4.2.3/compatibility-slim/4.2.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/redis.clients:jedis/4.2.3/confidence-slim/4.2.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
redis/jedis ### [`v4.2.3`](https://togithub.com/redis/jedis/releases/v4.2.3) [Compare Source](https://togithub.com/redis/jedis/compare/v4.2.2...v4.2.3) #### 🐛 Bug Fixes - Fix: return of CLUSTER REPLICAS is Array reply ([#​2990](https://togithub.com/redis/jedis/issues/2990)) - Fix PENDING entries of xinfoStreamFull method ([#​2988](https://togithub.com/redis/jedis/issues/2988)) #### Contributors We'd like to thank all the contributors who worked on this release! [@​sazzad16](https://togithub.com/sazzad16), [@​martin-nagy](https://togithub.com/martin-nagy) and [@​buession](https://togithub.com/buession)
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- memorystore/redis/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memorystore/redis/pom.xml b/memorystore/redis/pom.xml index ce8fb765b69..1067021c90c 100644 --- a/memorystore/redis/pom.xml +++ b/memorystore/redis/pom.xml @@ -49,7 +49,7 @@ redis.clients jedis - 4.2.2 + 4.2.3 From 6fc0d857931d5de96909cb2ec83a4236f786bb02 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 20:54:12 +0200 Subject: [PATCH 118/136] fix(deps): update dependency com.auth0:java-jwt to v3.19.2 (#7123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.auth0:java-jwt](https://togithub.com/auth0/java-jwt) | `3.19.1` -> `3.19.2` | [![age](https://badges.renovateapi.com/packages/maven/com.auth0:java-jwt/3.19.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.auth0:java-jwt/3.19.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.auth0:java-jwt/3.19.2/compatibility-slim/3.19.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.auth0:java-jwt/3.19.2/confidence-slim/3.19.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
auth0/java-jwt ### [`v3.19.2`](https://togithub.com/auth0/java-jwt/blob/HEAD/CHANGELOG.md#​3192-httpsgithubcomauth0java-jwttree3192-2022-05-05) [Compare Source](https://togithub.com/auth0/java-jwt/compare/3.19.1...3.19.2) [Full Changelog](https://togithub.com/auth0/java-jwt/compare/3.19.1...3.19.2) **Security** - \[SDK-3311] Added protection against CVE-2022-21449 [#​579](https://togithub.com/auth0/java-jwt/pull/579) ([poovamraj](https://togithub.com/poovamraj))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- compute/signed-metadata/pom.xml | 2 +- endpoints/getting-started/clients/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compute/signed-metadata/pom.xml b/compute/signed-metadata/pom.xml index 05aca3e9311..7c7d4871c48 100644 --- a/compute/signed-metadata/pom.xml +++ b/compute/signed-metadata/pom.xml @@ -40,7 +40,7 @@ com.auth0 java-jwt - 3.19.1 + 3.19.2 com.google.code.gson diff --git a/endpoints/getting-started/clients/pom.xml b/endpoints/getting-started/clients/pom.xml index c77433153fd..086c14202c7 100644 --- a/endpoints/getting-started/clients/pom.xml +++ b/endpoints/getting-started/clients/pom.xml @@ -33,7 +33,7 @@ com.auth0 java-jwt - 3.19.1 + 3.19.2 From 3ffbef2193b1c99bdbf1b254abaf8d500ac83715 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 21:02:55 +0200 Subject: [PATCH 119/136] fix(deps): update dependency com.google.cloud:google-cloud-video-transcoder to v1.0.4 (#7029) --- media/transcoder/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/transcoder/pom.xml b/media/transcoder/pom.xml index 80c808fa033..9cfdc44f36e 100644 --- a/media/transcoder/pom.xml +++ b/media/transcoder/pom.xml @@ -53,7 +53,7 @@ com.google.cloud google-cloud-video-transcoder - 1.0.3 + 1.0.4 com.google.cloud From e7a0deaeecf8796b97e53a81bfd588a9877edd45 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 21:03:19 +0200 Subject: [PATCH 120/136] fix(deps): update dependency com.google.apis:google-api-services-cloudiot to v1-rev20220425-1.32.1 (#7129) --- iot/api-client/codelab/manager/pom.xml | 2 +- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iot/api-client/codelab/manager/pom.xml b/iot/api-client/codelab/manager/pom.xml index 5ca3aae1e17..99166dd5fb5 100644 --- a/iot/api-client/codelab/manager/pom.xml +++ b/iot/api-client/codelab/manager/pom.xml @@ -67,7 +67,7 @@ com.google.apis google-api-services-cloudiot - v1-rev20220330-1.32.1 + v1-rev20220425-1.32.1 com.google.cloud diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index ee4c723d2a6..0dfb00f8539 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -58,7 +58,7 @@ com.google.apis google-api-services-cloudiot - v1-rev20220330-1.32.1 + v1-rev20220425-1.32.1 com.google.cloud diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index 4db138ad520..d9454776f2b 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -62,7 +62,7 @@ com.google.apis google-api-services-cloudiot - v1-rev20220330-1.32.1 + v1-rev20220425-1.32.1 com.google.cloud From 9a08106e55a91e1d31c5b02d843444d1cddae204 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 21:16:12 +0200 Subject: [PATCH 121/136] fix(deps): update dependency com.google.http-client:google-http-client-jackson2 to v1.41.8 (#7102) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.http-client:google-http-client-jackson2](https://togithub.com/googleapis/google-http-java-client) | `1.41.7` -> `1.41.8` | [![age](https://badges.renovateapi.com/packages/maven/com.google.http-client:google-http-client-jackson2/1.41.8/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.http-client:google-http-client-jackson2/1.41.8/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.http-client:google-http-client-jackson2/1.41.8/compatibility-slim/1.41.7)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.http-client:google-http-client-jackson2/1.41.8/confidence-slim/1.41.7)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-http-java-client ### [`v1.41.8`](https://togithub.com/googleapis/google-http-java-client/releases/v1.41.8) ##### [1.41.8](https://togithub.com/googleapis/google-http-java-client/compare/v1.41.7...v1.41.8) (2022-04-29) ##### Dependencies - downgrade appengine to 1.9.X ([#​1645](https://togithub.com/googleapis/google-http-java-client/issues/1645)) ([da9dd8b](https://togithub.com/googleapis/google-http-java-client/commit/da9dd8bca97cc10712ce24054d2edd3d5ac2e571))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- appengine-java11/oauth2/pom.xml | 2 +- cloud-sql/mysql/client-side-encryption/pom.xml | 2 +- cloud-sql/postgres/client-side-encryption/pom.xml | 2 +- cloud-sql/sqlserver/client-side-encryption/pom.xml | 2 +- functions/slack/pom.xml | 2 +- healthcare/v1/pom.xml | 2 +- iam/api-client/pom.xml | 2 +- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- jobs/v3/pom.xml | 2 +- jobs/v4/pom.xml | 2 +- mlengine/online-prediction/pom.xml | 2 +- trace/pom.xml | 2 +- vision/face-detection/pom.xml | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/appengine-java11/oauth2/pom.xml b/appengine-java11/oauth2/pom.xml index 5abbac38ebc..a4688d78266 100644 --- a/appengine-java11/oauth2/pom.xml +++ b/appengine-java11/oauth2/pom.xml @@ -77,7 +77,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/cloud-sql/mysql/client-side-encryption/pom.xml b/cloud-sql/mysql/client-side-encryption/pom.xml index bf6e8e5ad39..65a462d67ea 100644 --- a/cloud-sql/mysql/client-side-encryption/pom.xml +++ b/cloud-sql/mysql/client-side-encryption/pom.xml @@ -57,7 +57,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 com.google.cloud.sql diff --git a/cloud-sql/postgres/client-side-encryption/pom.xml b/cloud-sql/postgres/client-side-encryption/pom.xml index a0667ee00a7..68d8f39064a 100644 --- a/cloud-sql/postgres/client-side-encryption/pom.xml +++ b/cloud-sql/postgres/client-side-encryption/pom.xml @@ -57,7 +57,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 com.google.cloud.sql diff --git a/cloud-sql/sqlserver/client-side-encryption/pom.xml b/cloud-sql/sqlserver/client-side-encryption/pom.xml index 94d69542ee4..d4e8c755d3d 100644 --- a/cloud-sql/sqlserver/client-side-encryption/pom.xml +++ b/cloud-sql/sqlserver/client-side-encryption/pom.xml @@ -57,7 +57,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 com.google.cloud.sql diff --git a/functions/slack/pom.xml b/functions/slack/pom.xml index 7e5650d6a92..1d36495df43 100644 --- a/functions/slack/pom.xml +++ b/functions/slack/pom.xml @@ -66,7 +66,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/healthcare/v1/pom.xml b/healthcare/v1/pom.xml index 405b73e4066..92dda4ddc71 100644 --- a/healthcare/v1/pom.xml +++ b/healthcare/v1/pom.xml @@ -75,7 +75,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 com.google.apis diff --git a/iam/api-client/pom.xml b/iam/api-client/pom.xml index 0d8472b4ac7..3343322171d 100644 --- a/iam/api-client/pom.xml +++ b/iam/api-client/pom.xml @@ -50,7 +50,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index 0dfb00f8539..537683d9ab2 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -93,7 +93,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index d9454776f2b..c2e4677090a 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -102,7 +102,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/jobs/v3/pom.xml b/jobs/v3/pom.xml index cdcf3762f37..94b702904db 100644 --- a/jobs/v3/pom.xml +++ b/jobs/v3/pom.xml @@ -42,7 +42,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/jobs/v4/pom.xml b/jobs/v4/pom.xml index 49108e5b209..a7e20928860 100644 --- a/jobs/v4/pom.xml +++ b/jobs/v4/pom.xml @@ -55,7 +55,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/mlengine/online-prediction/pom.xml b/mlengine/online-prediction/pom.xml index ff6191fd93f..0d0e103d4e8 100644 --- a/mlengine/online-prediction/pom.xml +++ b/mlengine/online-prediction/pom.xml @@ -76,7 +76,7 @@ limitations under the License. com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 diff --git a/trace/pom.xml b/trace/pom.xml index 14ad99a6bb4..8935ac1b029 100644 --- a/trace/pom.xml +++ b/trace/pom.xml @@ -95,7 +95,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 test diff --git a/vision/face-detection/pom.xml b/vision/face-detection/pom.xml index c97da1378c6..910f65e060a 100644 --- a/vision/face-detection/pom.xml +++ b/vision/face-detection/pom.xml @@ -56,7 +56,7 @@ com.google.http-client google-http-client-jackson2 - 1.41.7 + 1.41.8 From 24eff5a695b8e861b0e89a41a36cd7f0ef6863b4 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 21:18:13 +0200 Subject: [PATCH 122/136] fix(deps): update dependency com.google.api-client:google-api-client to v1.34.1 (#7124) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api-client:google-api-client](https://togithub.com/googleapis/google-api-java-client) | `1.34.0` -> `1.34.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client/1.34.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client/1.34.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client/1.34.1/compatibility-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api-client:google-api-client/1.34.1/confidence-slim/1.34.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/google-api-java-client ### [`v1.34.1`](https://togithub.com/googleapis/google-api-java-client/releases/v1.34.1) [Compare Source](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) ##### [1.34.1](https://togithub.com/googleapis/google-api-java-client/compare/v1.34.0...v1.34.1) (2022-05-06) ##### Dependencies - downgrade appengine to 1.9.X ([#​2053](https://togithub.com/googleapis/google-api-java-client/issues/2053)) ([8d9a863](https://togithub.com/googleapis/google-api-java-client/commit/8d9a863033672bb2a0b2d826e0ba6025f437cf96)) - google-http-client 1.41.8 ([#​2056](https://togithub.com/googleapis/google-api-java-client/issues/2056)) ([d1e84ac](https://togithub.com/googleapis/google-api-java-client/commit/d1e84acf81141159283d7d33a1cd8221b3aac4fd))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- cloud-sql/mysql/client-side-encryption/pom.xml | 2 +- cloud-sql/postgres/client-side-encryption/pom.xml | 2 +- cloud-sql/sqlserver/client-side-encryption/pom.xml | 2 +- flexible/cloudsql/pom.xml | 2 +- flexible/postgres/pom.xml | 2 +- healthcare/v1/pom.xml | 2 +- iot/api-client/codelab/manager/pom.xml | 2 +- iot/api-client/end-to-end-example/pom.xml | 2 +- iot/api-client/manager/pom.xml | 2 +- pubsublite/streaming-analytics/build.gradle | 2 +- pubsublite/streaming-analytics/pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cloud-sql/mysql/client-side-encryption/pom.xml b/cloud-sql/mysql/client-side-encryption/pom.xml index 65a462d67ea..56bcd128fb4 100644 --- a/cloud-sql/mysql/client-side-encryption/pom.xml +++ b/cloud-sql/mysql/client-side-encryption/pom.xml @@ -48,7 +48,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 diff --git a/cloud-sql/postgres/client-side-encryption/pom.xml b/cloud-sql/postgres/client-side-encryption/pom.xml index 68d8f39064a..54e4eab9f3a 100644 --- a/cloud-sql/postgres/client-side-encryption/pom.xml +++ b/cloud-sql/postgres/client-side-encryption/pom.xml @@ -48,7 +48,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 diff --git a/cloud-sql/sqlserver/client-side-encryption/pom.xml b/cloud-sql/sqlserver/client-side-encryption/pom.xml index d4e8c755d3d..36b34820877 100644 --- a/cloud-sql/sqlserver/client-side-encryption/pom.xml +++ b/cloud-sql/sqlserver/client-side-encryption/pom.xml @@ -48,7 +48,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 diff --git a/flexible/cloudsql/pom.xml b/flexible/cloudsql/pom.xml index 413a20024e1..07e0e744f44 100644 --- a/flexible/cloudsql/pom.xml +++ b/flexible/cloudsql/pom.xml @@ -56,7 +56,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 com.google.api-client diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index ec6ebd76778..0d9f7ca3a2c 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -56,7 +56,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 com.google.api-client diff --git a/healthcare/v1/pom.xml b/healthcare/v1/pom.xml index 92dda4ddc71..5375492d8d7 100644 --- a/healthcare/v1/pom.xml +++ b/healthcare/v1/pom.xml @@ -85,7 +85,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 com.google.auth diff --git a/iot/api-client/codelab/manager/pom.xml b/iot/api-client/codelab/manager/pom.xml index 99166dd5fb5..a481c1d34c5 100644 --- a/iot/api-client/codelab/manager/pom.xml +++ b/iot/api-client/codelab/manager/pom.xml @@ -87,7 +87,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 commons-cli diff --git a/iot/api-client/end-to-end-example/pom.xml b/iot/api-client/end-to-end-example/pom.xml index 537683d9ab2..ec2a74c338e 100644 --- a/iot/api-client/end-to-end-example/pom.xml +++ b/iot/api-client/end-to-end-example/pom.xml @@ -78,7 +78,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 commons-cli diff --git a/iot/api-client/manager/pom.xml b/iot/api-client/manager/pom.xml index c2e4677090a..cac5a6f1c72 100644 --- a/iot/api-client/manager/pom.xml +++ b/iot/api-client/manager/pom.xml @@ -87,7 +87,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 commons-cli diff --git a/pubsublite/streaming-analytics/build.gradle b/pubsublite/streaming-analytics/build.gradle index 4baab23fe1d..ccf71d36cf0 100644 --- a/pubsublite/streaming-analytics/build.gradle +++ b/pubsublite/streaming-analytics/build.gradle @@ -44,7 +44,7 @@ dependencies { implementation "org.apache.beam:beam-examples-java:${beamVersion}" runtimeOnly "org.apache.beam:beam-runners-direct-java:${beamVersion}" runtimeOnly "org.apache.beam:beam-runners-google-cloud-dataflow-java:${beamVersion}" - testImplementation 'com.google.api-client:google-api-client:1.34.0' + testImplementation 'com.google.api-client:google-api-client:1.34.1' testImplementation 'com.google.apis:google-api-services-dataflow:v1b3-rev20210825-1.32.1' testImplementation 'com.google.cloud:google-cloud-core:2.3.2' testImplementation 'com.google.cloud:google-cloud-storage:2.6.1' diff --git a/pubsublite/streaming-analytics/pom.xml b/pubsublite/streaming-analytics/pom.xml index 68bb87302cc..f56b2b6cb9e 100644 --- a/pubsublite/streaming-analytics/pom.xml +++ b/pubsublite/streaming-analytics/pom.xml @@ -131,7 +131,7 @@ com.google.api-client google-api-client - 1.34.0 + 1.34.1 From 0919c59d7f6ab561f9cdaa3c6d854d1d8e7a8310 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 10 May 2022 22:00:15 +0200 Subject: [PATCH 123/136] fix(deps): update dependency com.microsoft.sqlserver:mssql-jdbc to v10 (#7133) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.microsoft.sqlserver:mssql-jdbc](https://togithub.com/Microsoft/mssql-jdbc) | `9.4.1.jre8` -> `10.2.0.jre8` | [![age](https://badges.renovateapi.com/packages/maven/com.microsoft.sqlserver:mssql-jdbc/10.2.0.jre8/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.microsoft.sqlserver:mssql-jdbc/10.2.0.jre8/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.microsoft.sqlserver:mssql-jdbc/10.2.0.jre8/compatibility-slim/9.4.1.jre8)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.microsoft.sqlserver:mssql-jdbc/10.2.0.jre8/confidence-slim/9.4.1.jre8)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Never, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/GoogleCloudPlatform/java-docs-samples). --- cloud-sql/sqlserver/client-side-encryption/pom.xml | 2 +- .../src/main/java/cloudsql/tink/CloudSqlConnectionPool.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cloud-sql/sqlserver/client-side-encryption/pom.xml b/cloud-sql/sqlserver/client-side-encryption/pom.xml index 36b34820877..a810a155482 100644 --- a/cloud-sql/sqlserver/client-side-encryption/pom.xml +++ b/cloud-sql/sqlserver/client-side-encryption/pom.xml @@ -67,7 +67,7 @@ com.microsoft.sqlserver mssql-jdbc - 9.4.1.jre8 + 10.2.0.jre8 com.google.crypto.tink diff --git a/cloud-sql/sqlserver/client-side-encryption/src/main/java/cloudsql/tink/CloudSqlConnectionPool.java b/cloud-sql/sqlserver/client-side-encryption/src/main/java/cloudsql/tink/CloudSqlConnectionPool.java index 23eaa7c6866..a0a9438f943 100644 --- a/cloud-sql/sqlserver/client-side-encryption/src/main/java/cloudsql/tink/CloudSqlConnectionPool.java +++ b/cloud-sql/sqlserver/client-side-encryption/src/main/java/cloudsql/tink/CloudSqlConnectionPool.java @@ -35,6 +35,10 @@ public static DataSource createConnectionPool(String dbUser, String dbPass, Stri config.setPassword(dbPass); // e.g. "my-password" config.addDataSourceProperty("databaseName", dbName); + // The Cloud SQL Java Connector provides SSL encryption so + // it should be disabled at the driver level + config.addDataSourceProperty("encrypt", "false"); + config.addDataSourceProperty("socketFactoryClass", "com.google.cloud.sql.sqlserver.SocketFactory"); config.addDataSourceProperty("socketFactoryConstructorArg", instanceConnectionName); @@ -60,4 +64,4 @@ public static void createTable(DataSource pool, String tableName) throws SQLExce } } } -// [END cloud_sql_sqlserver_cse_db] \ No newline at end of file +// [END cloud_sql_sqlserver_cse_db] From 5560581eca5fce8f64016903a50b408702f80b88 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 12 May 2022 18:11:27 +0200 Subject: [PATCH 124/136] fix(deps): update dependency com.google.protobuf:protobuf-java-util to v3.20.1 (#7065) --- kms/pom.xml | 2 +- secretmanager/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kms/pom.xml b/kms/pom.xml index 07582115704..40f91c506a6 100644 --- a/kms/pom.xml +++ b/kms/pom.xml @@ -31,7 +31,7 @@ com.google.protobuf protobuf-java-util - 3.20.0 + 3.20.1 diff --git a/secretmanager/pom.xml b/secretmanager/pom.xml index 21001137c9e..341da9e1d2a 100644 --- a/secretmanager/pom.xml +++ b/secretmanager/pom.xml @@ -47,7 +47,7 @@ com.google.protobuf protobuf-java-util - 3.20.0 + 3.20.1 From cad8e98d45da69a74a14486707a071c816eab5bc Mon Sep 17 00:00:00 2001 From: Sampath Kumar Date: Thu, 12 May 2022 18:11:52 +0200 Subject: [PATCH 125/136] docs: add Google Cloud Samples browser link to readme template (#7137) Adding a generic Google Code Sample link to the readme template. This is for the benefit of the users, in navigating available Google Cloud code samples. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9f8c938af38..e8a06cd1398 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ This repository holds sample code written in Java that demonstrates the Some samples have accompanying guides on . See respective README files for details. +## Google Cloud Samples + +To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples?l=java). + ## Set Up 1. [Set up your Java Development Environment](https://cloud.google.com/java/docs/setup) From 6f8408fd115b3f6527db4233120555ba3444f47a Mon Sep 17 00:00:00 2001 From: Aaron Wanjala Date: Thu, 12 May 2022 17:15:43 -0400 Subject: [PATCH 126/136] docs(bundled services): Include instructions to add bundled services JAR (#7135) Since most users looking to access bundled services will want to use the App Engine APIs directly, I think it makes sense to include steps to add the required dependency. --- appengine-java11-bundled-services/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/appengine-java11-bundled-services/README.md b/appengine-java11-bundled-services/README.md index dfd651aced4..700f8fb1de2 100644 --- a/appengine-java11-bundled-services/README.md +++ b/appengine-java11-bundled-services/README.md @@ -39,9 +39,10 @@ access control, billing, and services. ## Development differences between App Engine Java8 and Java11 Bundled Services -The only difference between a Java8 application and a Java11 application is in the `appengine-web.xml` file +The only differences between a Java8 application and a Java11 application are the addition of the bundled services JAR, and an added line in the `appengine-web.xml` file where you need to define the Java11 runtime and declare you need the App Engine APIs: +In `appengine-web.xml`: ```XML java11 @@ -49,6 +50,16 @@ where you need to define the Java11 runtime and declare you need the App Engine ``` +In your `pom.xml`'s ``: +```XML + + com.google.appengine + appengine-api-1.0-sdk + 2.0.4 + +``` + + ```shell mvn appengine:deploy ``` From e9dec4f85b394aa09889b1513580413f77cb06c8 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Fri, 13 May 2022 11:46:07 +0530 Subject: [PATCH 127/136] docs(compute-samples): added parallel testing support (#7071) * docs(compute-samples): added parallel testing support * chore: try Timeout Rule * chore: Make it a ClassRule * chore(debug): change to 1 s timeout * modified cleanup function to include filter * reverted back to jupiter class timeout rule * split huge test file to smaller ones * lint fix and refactored acc to review comments * force adding junit4 to be used in surefire plugin * revert junit dependency and adding skiptest * added skiptest for failsafe plugin Co-authored-by: kurtisvg <31518063+kurtisvg@users.noreply.github.com> --- compute/cloud-client/pom.xml | 52 ++- .../java/compute/CreateEncryptedInstance.java | 8 +- .../main/java/compute/CreateFirewallRule.java | 8 +- .../src/main/java/compute/CreateInstance.java | 8 +- .../compute/CreateInstanceFromTemplate.java | 9 +- ...eateInstanceFromTemplateWithOverrides.java | 9 +- .../java/compute/CreateInstanceTemplate.java | 14 +- .../java/compute/CreateInstancesAdvanced.java | 18 +- .../compute/CreateTemplateFromInstance.java | 8 +- .../compute/CreateTemplateWithSubnet.java | 8 +- .../main/java/compute/DeleteFirewallRule.java | 8 +- .../src/main/java/compute/DeleteInstance.java | 8 +- .../java/compute/DeleteInstanceTemplate.java | 9 +- .../main/java/compute/PatchFirewallRule.java | 8 +- .../src/main/java/compute/ResetInstance.java | 8 +- .../java/compute/SetUsageExportBucket.java | 14 +- .../java/compute/StartEncryptedInstance.java | 8 +- .../src/main/java/compute/StartInstance.java | 8 +- .../src/main/java/compute/StopInstance.java | 8 +- .../CreateInstanceWithCustomHostname.java | 9 +- .../CreateInstanceDeleteProtection.java | 10 +- .../deleteprotection/SetDeleteProtection.java | 9 +- .../CreatePreemptibleInstance.java | 10 +- .../src/test/java/compute/FirewallIT.java | 164 ++++++++ .../java/compute/InstanceOperationsIT.java | 176 ++++++++ .../java/compute/InstanceTemplatesIT.java | 34 +- .../java/compute/InstancesAdvancedIT.java | 276 +++++++++++++ .../src/test/java/compute/SnippetsIT.java | 384 ++---------------- .../src/test/java/compute/Util.java | 76 +++- .../CustomHostnameInstanceIT.java | 29 +- .../deleteprotection/DeleteProtectionIT.java | 31 +- .../compute/preemptible/PreemptibleIT.java | 28 +- 32 files changed, 964 insertions(+), 493 deletions(-) create mode 100644 compute/cloud-client/src/test/java/compute/FirewallIT.java create mode 100644 compute/cloud-client/src/test/java/compute/InstanceOperationsIT.java create mode 100644 compute/cloud-client/src/test/java/compute/InstancesAdvancedIT.java diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 46f262fc7ab..e07ac0200df 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -37,7 +37,7 @@ com.google.api gax-httpjson - 0.100.0 + 0.99.0 @@ -54,6 +54,25 @@ test 4.13.2 + + + + org.junit.jupiter + junit-jupiter-api + 5.8.2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test + @@ -63,7 +82,7 @@ com.google.cloud import pom - 25.1.0 + 25.0.0 @@ -88,4 +107,33 @@ 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M6 + + + all + true + 10C + true + + **/*IT.java + + false + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M6 + + true + + + + + diff --git a/compute/cloud-client/src/main/java/compute/CreateEncryptedInstance.java b/compute/cloud-client/src/main/java/compute/CreateEncryptedInstance.java index c1a36efa86b..8829834adbc 100644 --- a/compute/cloud-client/src/main/java/compute/CreateEncryptedInstance.java +++ b/compute/cloud-client/src/main/java/compute/CreateEncryptedInstance.java @@ -30,11 +30,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateEncryptedInstance { public static void main(String[] args) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // TODO(developer): Replace these variables before running the sample. String project = "your-project-id"; String zone = "zone-name"; @@ -48,7 +50,7 @@ public static void main(String[] args) // in the specified project and zone. public static void createEncryptedInstance(String project, String zone, String instanceName, String diskEncryptionKey) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { /* Below are sample values that can be replaced. machineType: machine type of the VM being created. (This value uses the format zones/{zone}/machineTypes/{type_name}. @@ -111,7 +113,7 @@ public static void createEncryptedInstance(String project, String zone, String i instancesClient.insertAsync(insertInstanceRequest); // Wait for the operation to complete. - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance creation failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/CreateFirewallRule.java b/compute/cloud-client/src/main/java/compute/CreateFirewallRule.java index dff25241c83..61a72e8ad10 100644 --- a/compute/cloud-client/src/main/java/compute/CreateFirewallRule.java +++ b/compute/cloud-client/src/main/java/compute/CreateFirewallRule.java @@ -26,11 +26,13 @@ import java.io.IOException; import java.util.UUID; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateFirewallRule { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample /* project: project ID or project number of the Cloud project you want to use. firewallRuleName: name of the rule that is created. @@ -49,7 +51,7 @@ public static void main(String[] args) // Creates a simple firewall rule allowing for incoming HTTP and // HTTPS access from the entire Internet. public static void createFirewall(String project, String firewallRuleName, String network) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call the `firewallsClient.close()` method on the client to safely @@ -78,7 +80,7 @@ public static void createFirewall(String project, String firewallRuleName, Strin .setFirewallResource(firewallRule) .setProject(project).build(); - firewallsClient.insertAsync(insertFirewallRequest).get(); + firewallsClient.insertAsync(insertFirewallRequest).get(3, TimeUnit.MINUTES); System.out.println("Firewall rule created successfully -> " + firewallRuleName); } diff --git a/compute/cloud-client/src/main/java/compute/CreateInstance.java b/compute/cloud-client/src/main/java/compute/CreateInstance.java index bc45d1ac6d4..6c012330f1f 100644 --- a/compute/cloud-client/src/main/java/compute/CreateInstance.java +++ b/compute/cloud-client/src/main/java/compute/CreateInstance.java @@ -29,11 +29,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateInstance { public static void main(String[] args) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // TODO(developer): Replace these variables before running the sample. String project = "your-project-id"; String zone = "zone-name"; @@ -44,7 +46,7 @@ public static void main(String[] args) // Create a new instance with the provided "instanceName" value in the specified project and zone. public static void createInstance(String project, String zone, String instanceName) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // Below are sample values that can be replaced. // machineType: machine type of the VM being created. // * This value uses the format zones/{zone}/machineTypes/{type_name}. @@ -105,7 +107,7 @@ public static void createInstance(String project, String zone, String instanceNa insertInstanceRequest); // Wait for the operation to complete. - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance creation failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplate.java b/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplate.java index 6bb7e5a216d..3d8e2bea792 100644 --- a/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplate.java +++ b/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplate.java @@ -25,11 +25,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateInstanceFromTemplate { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* TODO(developer): Replace these variables before running the sample. projectId - ID or number of the project you want to use. zone - Name of the zone you want to check, for example: us-west3-b @@ -51,7 +53,7 @@ public static void main(String[] args) // Create a new instance from template in the specified project and zone. public static void createInstanceFromTemplate(String projectId, String zone, String instanceName, String instanceTemplateUrl) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstancesClient instancesClient = InstancesClient.create()) { @@ -61,7 +63,8 @@ public static void createInstanceFromTemplate(String projectId, String zone, Str .setInstanceResource(Instance.newBuilder().setName(instanceName).build()) .setSourceInstanceTemplate(instanceTemplateUrl).build(); - Operation response = instancesClient.insertAsync(insertInstanceRequest).get(); + Operation response = instancesClient.insertAsync(insertInstanceRequest) + .get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance creation from template failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplateWithOverrides.java b/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplateWithOverrides.java index 27bc0f92df4..3ff0e4530cb 100644 --- a/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplateWithOverrides.java +++ b/compute/cloud-client/src/main/java/compute/CreateInstanceFromTemplateWithOverrides.java @@ -28,11 +28,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateInstanceFromTemplateWithOverrides { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* TODO(developer): Replace these variables before running the sample. * projectId - ID or number of the project you want to use. * zone - Name of the zone you want to check, for example: us-west3-b @@ -62,7 +64,7 @@ public static void main(String[] args) // but overrides the disk and machine type options in the template. public static void createInstanceFromTemplateWithOverrides(String projectId, String zone, String instanceName, String instanceTemplateName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstancesClient instancesClient = InstancesClient.create(); InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) { @@ -100,7 +102,8 @@ public static void createInstanceFromTemplateWithOverrides(String projectId, Str .setInstanceResource(instance) .setSourceInstanceTemplate(instanceTemplate.getSelfLink()).build(); - Operation response = instancesClient.insertAsync(insertInstanceRequest).get(); + Operation response = instancesClient.insertAsync(insertInstanceRequest) + .get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance creation from template with overrides failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java b/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java index b9bca07fcad..f0394d13bc3 100644 --- a/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java +++ b/compute/cloud-client/src/main/java/compute/CreateInstanceTemplate.java @@ -30,11 +30,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateInstanceTemplate { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId: project ID or project number of the Cloud project you use. // templateName: name of the new template to create. @@ -48,7 +50,7 @@ public static void main(String[] args) instance configuration. */ public static void createInstanceTemplate(String projectId, String templateName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) { String machineType = "e2-standard-4"; @@ -86,7 +88,8 @@ public static void createInstanceTemplate(String projectId, String templateName) .setProperties(instanceProperties).build()).build(); // Create the Instance Template. - Operation response = instanceTemplatesClient.insertAsync(insertInstanceTemplateRequest).get(); + Operation response = instanceTemplatesClient.insertAsync(insertInstanceTemplateRequest) + .get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance Template creation failed ! ! " + response); @@ -98,7 +101,7 @@ public static void createInstanceTemplate(String projectId, String templateName) } public static void createInstanceTemplateWithDiskType(String projectId, String templateName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create(); GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) { @@ -123,7 +126,8 @@ public static void createInstanceTemplateWithDiskType(String projectId, String t .setProject(projectId) .setInstanceTemplateResource(instanceTemplate).build(); - Operation response = instanceTemplatesClient.insertAsync(insertInstanceTemplateRequest).get(); + Operation response = instanceTemplatesClient.insertAsync(insertInstanceTemplateRequest) + .get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance Template creation failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/CreateInstancesAdvanced.java b/compute/cloud-client/src/main/java/compute/CreateInstancesAdvanced.java index 1c6c2217ded..dad7c6f6372 100644 --- a/compute/cloud-client/src/main/java/compute/CreateInstancesAdvanced.java +++ b/compute/cloud-client/src/main/java/compute/CreateInstancesAdvanced.java @@ -37,6 +37,8 @@ import java.io.IOException; import java.util.Vector; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateInstancesAdvanced { // [END compute_instances_create_from_image] @@ -195,7 +197,7 @@ private static AttachedDisk diskFromSnapshot(String diskType, int diskSizeGb, bo */ private static Instance createWithDisks(String project, String zone, String instanceName, Vector disks, String machineType, String network, String subnetwork) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { try (InstancesClient instancesClient = InstancesClient.create()) { // Use the network interface provided in the networkName argument. NetworkInterface networkInterface; @@ -231,7 +233,7 @@ private static Instance createWithDisks(String project, String zone, String inst insertInstanceRequest); // Wait for the operation to complete. - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance creation failed ! ! " + response); @@ -260,7 +262,7 @@ private static Instance createWithDisks(String project, String zone, String inst * @return Instance object. */ public static Instance createFromPublicImage(String project, String zone, String instanceName) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { try (ImagesClient imagesClient = ImagesClient.create()) { // List of public operating system (OS) images: https://cloud.google.com/compute/docs/images/os-details Image image = imagesClient.getFromFamily("debian-cloud", "debian-10"); @@ -287,7 +289,7 @@ public static Instance createFromPublicImage(String project, String zone, String */ public static Instance createFromCustomImage(String project, String zone, String instanceName, String customImage) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { String diskType = String.format("zones/%s/diskTypes/pd-standard", zone); Vector disks = new Vector<>(); disks.add(diskFromImage(diskType, 10, true, customImage)); @@ -307,7 +309,7 @@ public static Instance createFromCustomImage(String project, String zone, String * @return Instance object. */ public static Instance createWithAdditionalDisk(String project, String zone, String instanceName) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { try (ImagesClient imagesClient = ImagesClient.create()) { // List of public operating system (OS) images: https://cloud.google.com/compute/docs/images/os-details Image image = imagesClient.getFromFamily("debian-cloud", "debian-10"); @@ -335,7 +337,7 @@ public static Instance createWithAdditionalDisk(String project, String zone, Str */ public static Instance createFromSnapshot(String project, String zone, String instanceName, String snapshotName) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { String diskType = String.format("zones/%s/diskTypes/pd-standard", zone); Vector disks = new Vector<>(); disks.add(diskFromSnapshot(diskType, 11, true, snapshotName)); @@ -358,7 +360,7 @@ public static Instance createFromSnapshot(String project, String zone, String in */ public static Instance createWithSnapshottedDataDisk(String project, String zone, String instanceName, String snapshotName) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { try (ImagesClient imagesClient = ImagesClient.create()) { // List of public operating system (OS) images: https://cloud.google.com/compute/docs/images/os-details Image image = imagesClient.getFromFamily("debian-cloud", "debian-10"); @@ -389,7 +391,7 @@ public static Instance createWithSnapshottedDataDisk(String project, String zone */ public static Instance createWithSubnetwork(String project, String zone, String instanceName, String networkLink, String subnetworkLink) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { try (ImagesClient imagesClient = ImagesClient.create()) { // List of public operating system (OS) images: https://cloud.google.com/compute/docs/images/os-details Image image = imagesClient.getFromFamily("debian-cloud", "debian-10"); diff --git a/compute/cloud-client/src/main/java/compute/CreateTemplateFromInstance.java b/compute/cloud-client/src/main/java/compute/CreateTemplateFromInstance.java index 1e766647931..1d9595972d4 100644 --- a/compute/cloud-client/src/main/java/compute/CreateTemplateFromInstance.java +++ b/compute/cloud-client/src/main/java/compute/CreateTemplateFromInstance.java @@ -28,11 +28,13 @@ import com.google.cloud.compute.v1.SourceInstanceParams; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateTemplateFromInstance { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId: project ID or project number of the Cloud project you use. // instance: the instance to base the new template on. This value uses the following format: @@ -49,7 +51,7 @@ public static void main(String[] args) // This new template specifies a different boot disk. public static void createTemplateFromInstance(String projectId, String templateName, String instance) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create(); GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) { @@ -81,7 +83,7 @@ public static void createTemplateFromInstance(String projectId, String templateN .build(); Operation operation = instanceTemplatesClient.insertCallable() - .futureCall(insertInstanceTemplateRequest).get(); + .futureCall(insertInstanceTemplateRequest).get(3, TimeUnit.MINUTES); Operation response = globalOperationsClient.wait(projectId, operation.getName()); diff --git a/compute/cloud-client/src/main/java/compute/CreateTemplateWithSubnet.java b/compute/cloud-client/src/main/java/compute/CreateTemplateWithSubnet.java index f92ae6f65cd..602db9d2d57 100644 --- a/compute/cloud-client/src/main/java/compute/CreateTemplateWithSubnet.java +++ b/compute/cloud-client/src/main/java/compute/CreateTemplateWithSubnet.java @@ -29,11 +29,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateTemplateWithSubnet { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* TODO(developer): Replace these variables before running the sample. projectId: project ID or project number of the Cloud project you use. @@ -54,7 +56,7 @@ public static void main(String[] args) // Create an instance template that uses a provided subnet. public static void createTemplateWithSubnet(String projectId, String network, String subnetwork, String templateName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create(); GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.create()) { @@ -87,7 +89,7 @@ public static void createTemplateWithSubnet(String projectId, String network, St .build(); Operation operation = instanceTemplatesClient.insertCallable() - .futureCall(insertInstanceTemplateRequest).get(); + .futureCall(insertInstanceTemplateRequest).get(3, TimeUnit.MINUTES); Operation response = globalOperationsClient.wait(projectId, operation.getName()); diff --git a/compute/cloud-client/src/main/java/compute/DeleteFirewallRule.java b/compute/cloud-client/src/main/java/compute/DeleteFirewallRule.java index aa755db0883..0985adc6c3a 100644 --- a/compute/cloud-client/src/main/java/compute/DeleteFirewallRule.java +++ b/compute/cloud-client/src/main/java/compute/DeleteFirewallRule.java @@ -24,11 +24,13 @@ import java.io.IOException; import java.util.UUID; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class DeleteFirewallRule { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample // project: project ID or project number of the Cloud project you want to use. // firewallRuleName: name of the firewall rule you want to delete. @@ -40,7 +42,7 @@ public static void main(String[] args) // Deletes a firewall rule from the project. public static void deleteFirewallRule(String project, String firewallRuleName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call the `firewallsClient.close()` method on the client to safely @@ -49,7 +51,7 @@ public static void deleteFirewallRule(String project, String firewallRuleName) OperationFuture operation = firewallsClient.deleteAsync(project, firewallRuleName); - operation.get(); + operation.get(3, TimeUnit.MINUTES); System.out.println("Deleted firewall rule -> " + firewallRuleName); } diff --git a/compute/cloud-client/src/main/java/compute/DeleteInstance.java b/compute/cloud-client/src/main/java/compute/DeleteInstance.java index f5279aa485b..f3533778ec7 100644 --- a/compute/cloud-client/src/main/java/compute/DeleteInstance.java +++ b/compute/cloud-client/src/main/java/compute/DeleteInstance.java @@ -24,11 +24,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class DeleteInstance { public static void main(String[] args) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // TODO(developer): Replace these variables before running the sample. String project = "your-project-id"; String zone = "zone-name"; @@ -39,7 +41,7 @@ public static void main(String[] args) // Delete the instance specified by `instanceName` // if it's present in the given project and zone. public static void deleteInstance(String project, String zone, String instanceName) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call // the `instancesClient.close()` method on the client to safely @@ -57,7 +59,7 @@ public static void deleteInstance(String project, String zone, String instanceNa OperationFuture operation = instancesClient.deleteAsync( deleteInstanceRequest); // Wait for the operation to complete. - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance deletion failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java b/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java index 2ade4bf7612..3c3fa07c024 100644 --- a/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java +++ b/compute/cloud-client/src/main/java/compute/DeleteInstanceTemplate.java @@ -23,11 +23,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class DeleteInstanceTemplate { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId: project ID or project number of the Cloud project you use. // templateName: name of the new template to create. @@ -38,7 +40,7 @@ public static void main(String[] args) // Delete an instance template. public static void deleteInstanceTemplate(String projectId, String templateName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) { DeleteInstanceTemplateRequest deleteInstanceTemplateRequest = DeleteInstanceTemplateRequest @@ -46,7 +48,8 @@ public static void deleteInstanceTemplate(String projectId, String templateName) .setProject(projectId) .setInstanceTemplate(templateName).build(); - Operation response = instanceTemplatesClient.deleteAsync(deleteInstanceTemplateRequest).get(); + Operation response = instanceTemplatesClient.deleteAsync(deleteInstanceTemplateRequest) + .get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Instance template deletion failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/PatchFirewallRule.java b/compute/cloud-client/src/main/java/compute/PatchFirewallRule.java index d7e7f91f87a..5cbda7d58e4 100644 --- a/compute/cloud-client/src/main/java/compute/PatchFirewallRule.java +++ b/compute/cloud-client/src/main/java/compute/PatchFirewallRule.java @@ -26,11 +26,13 @@ import java.io.IOException; import java.util.UUID; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class PatchFirewallRule { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample // project: project ID or project number of the Cloud project you want to use. // firewallRuleName: name of the rule you want to modify. @@ -44,7 +46,7 @@ public static void main(String[] args) // Modifies the priority of a given firewall rule. public static void patchFirewallPriority(String project, String firewallRuleName, int priority) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call the `firewallsClient.close()` method on the client to safely @@ -63,7 +65,7 @@ public static void patchFirewallPriority(String project, String firewallRuleName OperationFuture operation = firewallsClient.patchAsync( patchFirewallRequest); - operation.get(); + operation.get(3, TimeUnit.MINUTES); System.out.println("Firewall Patch applied successfully ! "); } } diff --git a/compute/cloud-client/src/main/java/compute/ResetInstance.java b/compute/cloud-client/src/main/java/compute/ResetInstance.java index 480f412f699..ed6381e5759 100644 --- a/compute/cloud-client/src/main/java/compute/ResetInstance.java +++ b/compute/cloud-client/src/main/java/compute/ResetInstance.java @@ -25,11 +25,13 @@ import com.google.cloud.compute.v1.ResetInstanceRequest; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class ResetInstance { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. /* project: project ID or project number of the Cloud project your instance belongs to. zone: name of the zone your instance belongs to. @@ -44,7 +46,7 @@ public static void main(String[] args) // Resets a running Google Compute Engine instance (with unencrypted disks). public static void resetInstance(String project, String zone, String instanceName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call the `instancesClient.close()` method on the client to safely @@ -59,7 +61,7 @@ public static void resetInstance(String project, String zone, String instanceNam OperationFuture operation = instancesClient.resetAsync( resetInstanceRequest); - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.getStatus() == Status.DONE) { System.out.println("Instance reset successfully ! "); diff --git a/compute/cloud-client/src/main/java/compute/SetUsageExportBucket.java b/compute/cloud-client/src/main/java/compute/SetUsageExportBucket.java index faf7a3bf9b7..4ffc676aac2 100644 --- a/compute/cloud-client/src/main/java/compute/SetUsageExportBucket.java +++ b/compute/cloud-client/src/main/java/compute/SetUsageExportBucket.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; // [END compute_usage_report_disable] // [END compute_usage_report_get] @@ -40,7 +41,7 @@ public class SetUsageExportBucket { public static void main(String[] args) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // TODO(developer): Create a Google Cloud Storage bucket. // bucketName: Cloud Storage Bucket used to store Compute Engine usage reports. @@ -59,7 +60,7 @@ public static void main(String[] args) // This sample presents how to interpret the default value for the report name prefix parameter. public static void setUsageExportBucket(String project, String bucketName, String reportNamePrefix) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // bucketName: Cloud Storage Bucket used to store Compute Engine usage reports. // An existing Google Cloud Storage bucket is required. @@ -89,7 +90,7 @@ public static void setUsageExportBucket(String project, String bucketName, .build()); // Wait for the operation to complete. - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.hasError()) { System.out.println("Setting usage export bucket failed ! ! " + response); @@ -143,7 +144,7 @@ public static UsageExportLocation getUsageExportBucket(String project) throws IO // Disable Compute Engine usage export bucket for the Cloud project. public static boolean disableUsageExportBucket(String project) - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { try (ProjectsClient projectsClient = ProjectsClient.create()) { @@ -158,7 +159,8 @@ public static boolean disableUsageExportBucket(String project) .build()); // Wait for the operation to complete. - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); + ; if (response.hasError()) { System.out.println("Disable usage export bucket failed ! ! " + response); @@ -166,7 +168,7 @@ public static boolean disableUsageExportBucket(String project) } // Wait for the settings to be effected. - TimeUnit.SECONDS.sleep(5); + TimeUnit.SECONDS.sleep(15); // Return false if the usage reports is disabled. return projectsClient.get(project).getUsageExportLocation().hasBucketName(); } diff --git a/compute/cloud-client/src/main/java/compute/StartEncryptedInstance.java b/compute/cloud-client/src/main/java/compute/StartEncryptedInstance.java index 7dc0eb70102..9e5b2b62704 100644 --- a/compute/cloud-client/src/main/java/compute/StartEncryptedInstance.java +++ b/compute/cloud-client/src/main/java/compute/StartEncryptedInstance.java @@ -30,11 +30,13 @@ import com.google.cloud.compute.v1.StartWithEncryptionKeyInstanceRequest; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class StartEncryptedInstance { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. /* project: project ID or project number of the Cloud project your instance belongs to. zone: name of the zone your instance belongs to. @@ -54,7 +56,7 @@ public static void main(String[] args) // Starts a stopped Google Compute Engine instance (with encrypted disks). public static void startEncryptedInstance(String project, String zone, String instanceName, String key) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call the `instancesClient.close()` method on the client to safely @@ -94,7 +96,7 @@ public static void startEncryptedInstance(String project, String zone, String in OperationFuture operation = instancesClient.startWithEncryptionKeyAsync( encryptionKeyInstanceRequest); - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.getStatus() == Status.DONE) { System.out.println("Encrypted instance started successfully ! "); diff --git a/compute/cloud-client/src/main/java/compute/StartInstance.java b/compute/cloud-client/src/main/java/compute/StartInstance.java index 4bcf20de89e..3c8ab90bb7e 100644 --- a/compute/cloud-client/src/main/java/compute/StartInstance.java +++ b/compute/cloud-client/src/main/java/compute/StartInstance.java @@ -25,11 +25,13 @@ import com.google.cloud.compute.v1.StartInstanceRequest; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class StartInstance { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. /* project: project ID or project number of the Cloud project your instance belongs to. zone: name of the zone your instance belongs to. @@ -43,7 +45,7 @@ public static void main(String[] args) // Starts a stopped Google Compute Engine instance (with unencrypted disks). public static void startInstance(String project, String zone, String instanceName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call the `instancesClient.close()` method on the client to safely @@ -61,7 +63,7 @@ public static void startInstance(String project, String zone, String instanceNam startInstanceRequest); // Wait for the operation to complete. - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.getStatus() == Status.DONE) { System.out.println("Instance started successfully ! "); diff --git a/compute/cloud-client/src/main/java/compute/StopInstance.java b/compute/cloud-client/src/main/java/compute/StopInstance.java index 7fd341b5ee5..ce22aa11458 100644 --- a/compute/cloud-client/src/main/java/compute/StopInstance.java +++ b/compute/cloud-client/src/main/java/compute/StopInstance.java @@ -25,11 +25,13 @@ import com.google.cloud.compute.v1.StopInstanceRequest; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class StopInstance { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. /* project: project ID or project number of the Cloud project your instance belongs to. zone: name of the zone your instance belongs to. @@ -44,7 +46,7 @@ public static void main(String[] args) // Stops a started Google Compute Engine instance. public static void stopInstance(String project, String zone, String instanceName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call the `instancesClient.close()` method on the client to safely @@ -59,7 +61,7 @@ public static void stopInstance(String project, String zone, String instanceName OperationFuture operation = instancesClient.stopAsync( stopInstanceRequest); - Operation response = operation.get(); + Operation response = operation.get(3, TimeUnit.MINUTES); if (response.getStatus() == Status.DONE) { System.out.println("Instance stopped successfully ! "); diff --git a/compute/cloud-client/src/main/java/compute/customhostname/CreateInstanceWithCustomHostname.java b/compute/cloud-client/src/main/java/compute/customhostname/CreateInstanceWithCustomHostname.java index 03238336edc..03f07491a37 100644 --- a/compute/cloud-client/src/main/java/compute/customhostname/CreateInstanceWithCustomHostname.java +++ b/compute/cloud-client/src/main/java/compute/customhostname/CreateInstanceWithCustomHostname.java @@ -27,11 +27,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateInstanceWithCustomHostname { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // hostName: Custom hostname of the new VM instance. // * Custom hostnames must conform to RFC 1035 requirements for valid hostnames. @@ -45,7 +47,7 @@ public static void main(String[] args) // Creates an instance with custom hostname. public static void createInstanceWithCustomHostname(String projectId, String zone, String instanceName, String hostName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // machineType - Machine type for the VM instance specified in the following format: // * "zones/{zone}/machineTypes/{type_name}". For example: // * "zones/europe-west3-c/machineTypes/f1-micro" @@ -101,7 +103,8 @@ public static void createInstanceWithCustomHostname(String projectId, String zon .setInstanceResource(instanceResource).build(); // Wait for the create operation to complete. - Operation response = instancesClient.insertAsync(request).get(); + Operation response = instancesClient.insertAsync(request).get(3, TimeUnit.MINUTES); + ; if (response.hasError()) { System.out.printf("Instance creation failed for instance: %s ; Response: %s ! ! ", diff --git a/compute/cloud-client/src/main/java/compute/deleteprotection/CreateInstanceDeleteProtection.java b/compute/cloud-client/src/main/java/compute/deleteprotection/CreateInstanceDeleteProtection.java index c8fafb7e5f1..71b880e2301 100644 --- a/compute/cloud-client/src/main/java/compute/deleteprotection/CreateInstanceDeleteProtection.java +++ b/compute/cloud-client/src/main/java/compute/deleteprotection/CreateInstanceDeleteProtection.java @@ -27,11 +27,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateInstanceDeleteProtection { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // project: project ID or project number of the Cloud project you want to use. // zone: name of the zone you want to use. For example: “us-west3-b” @@ -48,7 +50,7 @@ public static void main(String[] args) // Send an instance creation request to the Compute Engine API and wait for it to complete. public static void createInstanceDeleteProtection(String projectId, String zone, String instanceName, boolean deleteProtection) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { String machineType = String.format("zones/%s/machineTypes/e2-small", zone); String sourceImage = String @@ -98,7 +100,9 @@ public static void createInstanceDeleteProtection(String projectId, String zone, .build(); // Wait for the create operation to complete. - Operation response = instancesClient.insertAsync(insertInstanceRequest).get(); + Operation response = instancesClient.insertAsync(insertInstanceRequest) + .get(3, TimeUnit.MINUTES); + ; if (response.hasError()) { System.out.println("Instance creation failed ! ! " + response); diff --git a/compute/cloud-client/src/main/java/compute/deleteprotection/SetDeleteProtection.java b/compute/cloud-client/src/main/java/compute/deleteprotection/SetDeleteProtection.java index 13df47926a0..3720261d3a4 100644 --- a/compute/cloud-client/src/main/java/compute/deleteprotection/SetDeleteProtection.java +++ b/compute/cloud-client/src/main/java/compute/deleteprotection/SetDeleteProtection.java @@ -22,11 +22,13 @@ import com.google.cloud.compute.v1.SetDeletionProtectionInstanceRequest; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class SetDeleteProtection { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // project: project ID or project number of the Cloud project you want to use. // zone: name of the zone you want to use. For example: “us-west3-b” @@ -43,7 +45,7 @@ public static void main(String[] args) // Updates the "Delete Protection" setting of given instance. public static void setDeleteProtection(String projectId, String zone, String instanceName, boolean deleteProtection) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (InstancesClient instancesClient = InstancesClient.create()) { @@ -55,7 +57,8 @@ public static void setDeleteProtection(String projectId, String zone, .setDeletionProtection(deleteProtection) .build(); - instancesClient.setDeletionProtectionAsync(request).get(); + instancesClient.setDeletionProtectionAsync(request).get(3, TimeUnit.MINUTES); + ; // Retrieve the updated setting from the instance. System.out.printf("Updated Delete Protection setting: %s", instancesClient.get(projectId, zone, instanceName).getDeletionProtection()); diff --git a/compute/cloud-client/src/main/java/compute/preemptible/CreatePreemptibleInstance.java b/compute/cloud-client/src/main/java/compute/preemptible/CreatePreemptibleInstance.java index 05c2ce0c6c0..2965512eb4a 100644 --- a/compute/cloud-client/src/main/java/compute/preemptible/CreatePreemptibleInstance.java +++ b/compute/cloud-client/src/main/java/compute/preemptible/CreatePreemptibleInstance.java @@ -28,11 +28,13 @@ import com.google.cloud.compute.v1.Scheduling; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreatePreemptibleInstance { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId: project ID or project number of the Cloud project you want to use. // zone: name of the zone you want to use. For example: “us-west3-b” @@ -47,7 +49,7 @@ public static void main(String[] args) // Send an instance creation request with preemptible settings to the Compute Engine API // and wait for it to complete. public static void createPremptibleInstance(String projectId, String zone, String instanceName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { String machineType = String.format("zones/%s/machineTypes/e2-small", zone); String sourceImage = "projects/debian-cloud/global/images/family/debian-11"; @@ -97,7 +99,9 @@ public static void createPremptibleInstance(String projectId, String zone, Strin .build(); // Wait for the create operation to complete. - Operation response = instancesClient.insertAsync(insertInstanceRequest).get(); + Operation response = instancesClient.insertAsync(insertInstanceRequest) + .get(3, TimeUnit.MINUTES); + ; if (response.hasError()) { System.out.println("Instance creation failed ! ! " + response); diff --git a/compute/cloud-client/src/test/java/compute/FirewallIT.java b/compute/cloud-client/src/test/java/compute/FirewallIT.java new file mode 100644 index 00000000000..6a64961274d --- /dev/null +++ b/compute/cloud-client/src/test/java/compute/FirewallIT.java @@ -0,0 +1,164 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package compute; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.NotFoundException; +import com.google.cloud.compute.v1.FirewallsClient; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.Assert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) +public class FirewallIT { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static String FIREWALL_RULE_CREATE; + private static String NETWORK_NAME; + + private ByteArrayOutputStream stdOut; + + // Check if the required environment variables are set. + public static void requireEnvVar(String envVarName) { + assertWithMessage(String.format("Missing environment variable '%s' ", envVarName)) + .that(System.getenv(envVarName)).isNotEmpty(); + } + + @BeforeAll + public static void setUp() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + + FIREWALL_RULE_CREATE = "firewall-rule-" + UUID.randomUUID(); + NETWORK_NAME = "global/networks/default"; + + compute.CreateFirewallRule.createFirewall(PROJECT_ID, FIREWALL_RULE_CREATE, NETWORK_NAME); + TimeUnit.SECONDS.sleep(10); + + stdOut.close(); + System.setOut(out); + } + + + @AfterAll + public static void cleanup() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + // Delete all instances created for testing. + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + + if (!isFirewallRuleDeletedByGceEnforcer(PROJECT_ID, FIREWALL_RULE_CREATE)) { + DeleteFirewallRule.deleteFirewallRule(PROJECT_ID, FIREWALL_RULE_CREATE); + } + + stdOut.close(); + System.setOut(out); + } + + public static boolean isFirewallRuleDeletedByGceEnforcer( + String projectId, String firewallRule) + throws IOException { + /* (**INTERNAL method**) + This method will prevent test failure if the firewall rule was auto-deleted by GCE Enforcer. + (Feel free to remove this method if not running on a Google-owned project.) + */ + try { + GetFirewallRule.getFirewallRule(projectId, firewallRule); + } catch (NotFoundException e) { + System.out.println("Rule already deleted! "); + return true; + } catch (InvalidArgumentException | NullPointerException e) { + System.out.println("Rule is not ready (probably being deleted)."); + return true; + } + return false; + } + + @BeforeEach + public void beforeEach() { + stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + } + + @AfterEach + public void afterEach() { + stdOut = null; + System.setOut(null); + } + + @Test + public void testListFirewallRules() + throws IOException, ExecutionException, InterruptedException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + if (!isFirewallRuleDeletedByGceEnforcer(PROJECT_ID, FIREWALL_RULE_CREATE)) { + compute.ListFirewallRules.listFirewallRules(PROJECT_ID); + assertThat(stdOut.toString()).contains(FIREWALL_RULE_CREATE); + } + // Clear system output to not affect other tests. + // Refrain from setting out to null. + stdOut.close(); + System.setOut(out); + } + + @Test + public void testPatchFirewallRule() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + // Firewall rule is auto-deleted by GCE Enforcer within a few minutes. + if (!isFirewallRuleDeletedByGceEnforcer(PROJECT_ID, FIREWALL_RULE_CREATE)) { + try (FirewallsClient client = FirewallsClient.create()) { + Assert.assertEquals(1000, client.get(PROJECT_ID, FIREWALL_RULE_CREATE).getPriority()); + compute.PatchFirewallRule.patchFirewallPriority(PROJECT_ID, FIREWALL_RULE_CREATE, 500); + TimeUnit.SECONDS.sleep(5); + Assert.assertEquals(500, client.get(PROJECT_ID, FIREWALL_RULE_CREATE).getPriority()); + } + } + // Clear system output to not affect other tests. + // Refrain from setting out to null as it will throw NullPointer in the subsequent tests. + stdOut.close(); + System.setOut(out); + } + +} diff --git a/compute/cloud-client/src/test/java/compute/InstanceOperationsIT.java b/compute/cloud-client/src/test/java/compute/InstanceOperationsIT.java new file mode 100644 index 00000000000..eae0ac8c2ec --- /dev/null +++ b/compute/cloud-client/src/test/java/compute/InstanceOperationsIT.java @@ -0,0 +1,176 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package compute; + +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.cloud.compute.v1.Instance.Status; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.time.LocalDateTime; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.Assert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) +public class InstanceOperationsIT { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static String ZONE; + private static String MACHINE_NAME; + private static String MACHINE_NAME_ENCRYPTED; + private static String RAW_KEY; + + private ByteArrayOutputStream stdOut; + + // Check if the required environment variables are set. + public static void requireEnvVar(String envVarName) { + assertWithMessage(String.format("Missing environment variable '%s' ", envVarName)) + .that(System.getenv(envVarName)).isNotEmpty(); + } + + @BeforeAll + public static void setUp() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + + ZONE = "us-central1-a"; + MACHINE_NAME = "my-new-test-instance" + UUID.randomUUID(); + MACHINE_NAME_ENCRYPTED = "encrypted-test-instance" + UUID.randomUUID(); + RAW_KEY = Util.getBase64EncodedKey(); + + // Cleanup existing stale resources. + Util.cleanUpExistingInstances("my-new-test-instance", PROJECT_ID, ZONE); + Util.cleanUpExistingInstances("encrypted-test-instance", PROJECT_ID, ZONE); + + compute.CreateInstance.createInstance(PROJECT_ID, ZONE, MACHINE_NAME); + compute.CreateEncryptedInstance + .createEncryptedInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED, RAW_KEY); + + TimeUnit.SECONDS.sleep(10); + + stdOut.close(); + System.setOut(out); + } + + + @AfterAll + public static void cleanup() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + + // Delete all instances created for testing. + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED); + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME); + + stdOut.close(); + System.setOut(out); + } + + @BeforeEach + public void beforeEach() { + stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + } + + @AfterEach + public void afterEach() { + stdOut = null; + System.setOut(null); + } + + @Test + public void testInstanceOperations() + throws IOException, ExecutionException, InterruptedException, TimeoutException { + Assert.assertEquals(Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME), + Status.RUNNING.toString()); + + // Stopping the instance. + StopInstance.stopInstance(PROJECT_ID, ZONE, MACHINE_NAME); + // Wait for the operation to complete. Setting timeout to 3 mins. + LocalDateTime endTime = LocalDateTime.now().plusMinutes(3); + while (!Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME) + .equalsIgnoreCase(Status.STOPPED.toString()) + && LocalDateTime.now().isBefore(endTime)) { + TimeUnit.SECONDS.sleep(5); + } + Assert.assertEquals(Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME), + Status.TERMINATED.toString()); + + // Starting the instance. + StartInstance.startInstance(PROJECT_ID, ZONE, MACHINE_NAME); + // Wait for the operation to complete. Setting timeout to 3 mins. + endTime = LocalDateTime.now().plusMinutes(3); + while (!Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME) + .equalsIgnoreCase(Status.RUNNING.toString()) + && LocalDateTime.now().isBefore(endTime)) { + TimeUnit.SECONDS.sleep(5); + } + Assert.assertEquals(Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME), + Status.RUNNING.toString()); + } + + @Test + public void testEncryptedInstanceOperations() + throws IOException, ExecutionException, InterruptedException, TimeoutException { + Assert.assertEquals(Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED), + Status.RUNNING.toString()); + + // Stopping the encrypted instance. + StopInstance.stopInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED); + // Wait for the operation to complete. Setting timeout to 3 mins. + LocalDateTime endTime = LocalDateTime.now().plusMinutes(3); + while (!Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED) + .equalsIgnoreCase(Status.STOPPED.toString()) + && LocalDateTime.now().isBefore(endTime)) { + TimeUnit.SECONDS.sleep(5); + } + Assert.assertEquals(Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED), + Status.TERMINATED.toString()); + + // Starting the encrypted instance. + StartEncryptedInstance + .startEncryptedInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED, RAW_KEY); + // Wait for the operation to complete. Setting timeout to 3 mins. + endTime = LocalDateTime.now().plusMinutes(3); + while (!Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED) + .equalsIgnoreCase(Status.RUNNING.toString()) + && LocalDateTime.now().isBefore(endTime)) { + TimeUnit.SECONDS.sleep(5); + } + Assert.assertEquals(Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED), + Status.RUNNING.toString()); + } +} diff --git a/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java b/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java index 0fb8b4bef49..6bef26c0c06 100644 --- a/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java +++ b/compute/cloud-client/src/test/java/compute/InstanceTemplatesIT.java @@ -27,19 +27,21 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.AfterClass; +import java.util.concurrent.TimeoutException; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) public class InstanceTemplatesIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); private static final String DEFAULT_REGION = "us-central1"; private static final String DEFAULT_ZONE = DEFAULT_REGION + "-a"; @@ -59,8 +61,10 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass - public static void setup() throws IOException, ExecutionException, InterruptedException { + @BeforeAll + public static void setup() + throws IOException, ExecutionException, InterruptedException, TimeoutException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); @@ -113,11 +117,13 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx Assert.assertEquals( getInstance(DEFAULT_ZONE, MACHINE_NAME_CR_TEMPLATE_OR).getDisksCount(), 2); stdOut.close(); - System.setOut(null); + System.setOut(out); } - @AfterClass - public static void cleanup() throws IOException, ExecutionException, InterruptedException { + @AfterAll + public static void cleanup() + throws IOException, ExecutionException, InterruptedException, TimeoutException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); // Delete instances. @@ -135,7 +141,7 @@ public static void cleanup() throws IOException, ExecutionException, Interrupted assertThat(stdOut.toString()) .contains("Instance template deletion operation status for " + TEMPLATE_NAME_WITH_SUBNET); stdOut.close(); - System.setOut(null); + System.setOut(out); } public static Instance getInstance(String zone, String instanceName) throws IOException { @@ -144,13 +150,13 @@ public static Instance getInstance(String zone, String instanceName) throws IOEx } } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); diff --git a/compute/cloud-client/src/test/java/compute/InstancesAdvancedIT.java b/compute/cloud-client/src/test/java/compute/InstancesAdvancedIT.java new file mode 100644 index 00000000000..cd0552603f7 --- /dev/null +++ b/compute/cloud-client/src/test/java/compute/InstancesAdvancedIT.java @@ -0,0 +1,276 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package compute; + +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.compute.v1.Disk; +import com.google.cloud.compute.v1.DisksClient; +import com.google.cloud.compute.v1.Image; +import com.google.cloud.compute.v1.ImagesClient; +import com.google.cloud.compute.v1.Instance.Status; +import com.google.cloud.compute.v1.Operation; +import com.google.cloud.compute.v1.Snapshot; +import com.google.cloud.compute.v1.SnapshotsClient; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.Assert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) +public class InstancesAdvancedIT { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static String ZONE; + private static String MACHINE_NAME_PUBLIC_IMAGE; + private static String MACHINE_NAME_CUSTOM_IMAGE; + private static String MACHINE_NAME_ADDITIONAL_DISK; + private static String MACHINE_NAME_SNAPSHOT; + private static String MACHINE_NAME_SNAPSHOT_ADDITIONAL; + private static String MACHINE_NAME_SUBNETWORK; + private static Disk TEST_DISK; + private static Image TEST_IMAGE; + private static Snapshot TEST_SNAPSHOT; + private static String NETWORK_NAME; + private static String SUBNETWORK_NAME; + + private ByteArrayOutputStream stdOut; + + // Check if the required environment variables are set. + public static void requireEnvVar(String envVarName) { + assertWithMessage(String.format("Missing environment variable '%s' ", envVarName)) + .that(System.getenv(envVarName)).isNotEmpty(); + } + + @BeforeAll + public static void setup() + throws IOException, ExecutionException, InterruptedException, TimeoutException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + + ZONE = "us-central1-a"; + MACHINE_NAME_PUBLIC_IMAGE = "test-instance-pub-" + UUID.randomUUID(); + MACHINE_NAME_CUSTOM_IMAGE = "test-instance-cust-" + UUID.randomUUID(); + MACHINE_NAME_ADDITIONAL_DISK = "test-instance-add-" + UUID.randomUUID(); + MACHINE_NAME_SNAPSHOT = "test-instance-snap-" + UUID.randomUUID(); + MACHINE_NAME_SNAPSHOT_ADDITIONAL = "test-instance-snapa-" + UUID.randomUUID(); + MACHINE_NAME_SUBNETWORK = "test-instance-subnet-" + UUID.randomUUID(); + NETWORK_NAME = "global/networks/default"; + SUBNETWORK_NAME = "regions/us-central1/subnetworks/default"; + + TEST_DISK = createSourceDisk(); + TEST_SNAPSHOT = createSnapshot(TEST_DISK); + TEST_IMAGE = createImage(TEST_DISK); + + Util.cleanUpExistingInstances("test-instance", PROJECT_ID, ZONE); + + compute.CreateInstancesAdvanced.createFromPublicImage(PROJECT_ID, ZONE, + MACHINE_NAME_PUBLIC_IMAGE); + compute.CreateInstancesAdvanced.createFromCustomImage(PROJECT_ID, ZONE, + MACHINE_NAME_CUSTOM_IMAGE, TEST_IMAGE.getSelfLink()); + compute.CreateInstancesAdvanced.createWithAdditionalDisk(PROJECT_ID, ZONE, + MACHINE_NAME_ADDITIONAL_DISK); + compute.CreateInstancesAdvanced.createFromSnapshot(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT, + TEST_SNAPSHOT.getSelfLink()); + compute.CreateInstancesAdvanced.createWithSnapshottedDataDisk(PROJECT_ID, ZONE, + MACHINE_NAME_SNAPSHOT_ADDITIONAL, TEST_SNAPSHOT.getSelfLink()); + compute.CreateInstancesAdvanced.createWithSubnetwork(PROJECT_ID, ZONE, MACHINE_NAME_SUBNETWORK, + NETWORK_NAME, SUBNETWORK_NAME); + + TimeUnit.SECONDS.sleep(10); + stdOut.close(); + System.setOut(out); + } + + @AfterAll + public static void cleanup() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + // Delete all instances created for testing. + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_PUBLIC_IMAGE); + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_CUSTOM_IMAGE); + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_ADDITIONAL_DISK); + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT); + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT_ADDITIONAL); + compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_SUBNETWORK); + + deleteImage(TEST_IMAGE); + deleteSnapshot(TEST_SNAPSHOT); + deleteDisk(TEST_DISK); + + stdOut.close(); + System.setOut(out); + } + + private static Image getActiveDebian() + throws IOException { + try (ImagesClient imagesClient = ImagesClient.create()) { + return imagesClient.getFromFamily("debian-cloud", "debian-11"); + } + } + + private static Disk createSourceDisk() + throws IOException, ExecutionException, InterruptedException, TimeoutException { + try (DisksClient disksClient = DisksClient.create()) { + + Disk disk = Disk.newBuilder() + .setSourceImage(getActiveDebian().getSelfLink()) + .setName("test-disk-" + UUID.randomUUID()) + .build(); + + OperationFuture operation = disksClient.insertAsync(PROJECT_ID, ZONE, + disk); + // Wait for the operation to complete. + operation.get(3, TimeUnit.MINUTES); + return disksClient.get(PROJECT_ID, ZONE, disk.getName()); + } + } + + private static void deleteDisk(Disk disk) + throws IOException, InterruptedException, ExecutionException, TimeoutException { + try (DisksClient disksClient = DisksClient.create()) { + OperationFuture operation = disksClient.deleteAsync(PROJECT_ID, ZONE, + disk.getName()); + operation.get(3, TimeUnit.MINUTES); + } + } + + private static Snapshot createSnapshot(Disk srcDisk) + throws IOException, InterruptedException, ExecutionException, TimeoutException { + try (SnapshotsClient snapshotsClient = SnapshotsClient.create(); + DisksClient disksClient = DisksClient.create()) { + + Snapshot snapshot = Snapshot.newBuilder() + .setName("test-snap-" + UUID.randomUUID()) + .build(); + + OperationFuture operation = disksClient.createSnapshotAsync(PROJECT_ID, + ZONE, srcDisk.getName(), + snapshot); + operation.get(3, TimeUnit.MINUTES); + return snapshotsClient.get(PROJECT_ID, snapshot.getName()); + } + } + + private static void deleteSnapshot(Snapshot snapshot) + throws IOException, InterruptedException, ExecutionException, TimeoutException { + try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) { + OperationFuture operation = snapshotsClient.deleteAsync(PROJECT_ID, + snapshot.getName()); + operation.get(3, TimeUnit.MINUTES); + } + } + + private static Image createImage(Disk srcDisk) + throws IOException, InterruptedException, ExecutionException, TimeoutException { + try (ImagesClient imagesClient = ImagesClient.create()) { + + Image image = Image.newBuilder() + .setName("test-img-" + UUID.randomUUID()) + .setSourceDisk(srcDisk.getSelfLink()) + .build(); + + OperationFuture operation = imagesClient.insertAsync(PROJECT_ID, image); + operation.get(3, TimeUnit.MINUTES); + return imagesClient.get(PROJECT_ID, image.getName()); + } + } + + private static void deleteImage(Image image) + throws IOException, InterruptedException, ExecutionException, TimeoutException { + try (ImagesClient imagesClient = ImagesClient.create()) { + OperationFuture operation = imagesClient.deleteAsync(PROJECT_ID, + image.getName()); + operation.get(3, TimeUnit.MINUTES); + } + } + + + @BeforeEach + public void beforeEach() { + stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + } + + @AfterEach + public void afterEach() { + stdOut = null; + System.setOut(null); + } + + @Test + public void testCreatePublicImage() throws IOException { + // Check if the instance was successfully created during the setup. + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_PUBLIC_IMAGE); + Assert.assertEquals(response, Status.RUNNING.toString()); + } + + @Test + public void testCreateCustomImage() throws IOException { + // Check if the instance was successfully created during the setup. + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_CUSTOM_IMAGE); + Assert.assertEquals(response, Status.RUNNING.toString()); + } + + @Test + public void testCreateAdditionalDisk() throws IOException { + // Check if the instance was successfully created during the setup. + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_ADDITIONAL_DISK); + Assert.assertEquals(response, Status.RUNNING.toString()); + } + + @Test + public void testCreateFromSnapshot() throws IOException { + // Check if the instance was successfully created during the setup. + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT); + Assert.assertEquals(response, Status.RUNNING.toString()); + } + + @Test + public void testCreateFromSnapshotAdditional() throws IOException { + // Check if the instance was successfully created during the setup. + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT_ADDITIONAL); + Assert.assertEquals(response, Status.RUNNING.toString()); + } + + @Test + public void testCreateInSubnetwork() throws IOException { + // Check if the instance was successfully created during the setup. + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_SUBNETWORK); + Assert.assertEquals(response, Status.RUNNING.toString()); + } + +} diff --git a/compute/cloud-client/src/test/java/compute/SnippetsIT.java b/compute/cloud-client/src/test/java/compute/SnippetsIT.java index 673f9fc446d..9c0a0f1dd2b 100644 --- a/compute/cloud-client/src/test/java/compute/SnippetsIT.java +++ b/compute/cloud-client/src/test/java/compute/SnippetsIT.java @@ -20,19 +20,9 @@ import static com.google.common.truth.Truth.assertWithMessage; import com.google.api.gax.longrunning.OperationFuture; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.api.gax.rpc.NotFoundException; -import com.google.cloud.compute.v1.Disk; -import com.google.cloud.compute.v1.DisksClient; -import com.google.cloud.compute.v1.FirewallsClient; -import com.google.cloud.compute.v1.Image; -import com.google.cloud.compute.v1.ImagesClient; -import com.google.cloud.compute.v1.Instance; import com.google.cloud.compute.v1.Instance.Status; import com.google.cloud.compute.v1.InstancesClient; import com.google.cloud.compute.v1.Operation; -import com.google.cloud.compute.v1.Snapshot; -import com.google.cloud.compute.v1.SnapshotsClient; import com.google.cloud.compute.v1.UsageExportLocation; import com.google.cloud.storage.Bucket; import com.google.cloud.storage.BucketInfo; @@ -41,49 +31,33 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.nio.charset.StandardCharsets; -import java.security.SecureRandom; -import java.time.LocalDateTime; -import java.util.Base64; import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.stream.IntStream; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) public class SnippetsIT { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); private static String ZONE; private static String MACHINE_NAME; - private static String MACHINE_NAME_DELETE; private static String MACHINE_NAME_LIST_INSTANCE; private static String MACHINE_NAME_WAIT_FOR_OP; private static String MACHINE_NAME_ENCRYPTED; - private static String MACHINE_NAME_PUBLIC_IMAGE; - private static String MACHINE_NAME_CUSTOM_IMAGE; - private static String MACHINE_NAME_ADDITIONAL_DISK; - private static String MACHINE_NAME_SNAPSHOT; - private static String MACHINE_NAME_SNAPSHOT_ADDITIONAL; - private static String MACHINE_NAME_SUBNETWORK; private static String BUCKET_NAME; private static String IMAGE_PROJECT_NAME; - private static String FIREWALL_RULE_CREATE; - private static String NETWORK_NAME; - private static String SUBNETWORK_NAME; private static String RAW_KEY; - private static Disk TEST_DISK; - private static Image TEST_IMAGE; - private static Snapshot TEST_SNAPSHOT; private ByteArrayOutputStream stdOut; @@ -93,8 +67,10 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass - public static void setUp() throws IOException, InterruptedException, ExecutionException { + @BeforeAll + public static void setUp() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); @@ -102,22 +78,12 @@ public static void setUp() throws IOException, InterruptedException, ExecutionEx ZONE = "us-central1-a"; MACHINE_NAME = "my-new-test-instance" + UUID.randomUUID(); - MACHINE_NAME_DELETE = "my-new-test-instance" + UUID.randomUUID(); MACHINE_NAME_LIST_INSTANCE = "my-new-test-instance" + UUID.randomUUID(); MACHINE_NAME_WAIT_FOR_OP = "my-new-test-instance" + UUID.randomUUID(); MACHINE_NAME_ENCRYPTED = "encrypted-test-instance" + UUID.randomUUID(); - MACHINE_NAME_PUBLIC_IMAGE = "test-instance-pub-" + UUID.randomUUID(); - MACHINE_NAME_CUSTOM_IMAGE = "test-instance-cust-" + UUID.randomUUID(); - MACHINE_NAME_ADDITIONAL_DISK = "test-instance-add-" + UUID.randomUUID(); - MACHINE_NAME_SNAPSHOT = "test-instance-snap-" + UUID.randomUUID(); - MACHINE_NAME_SNAPSHOT_ADDITIONAL = "test-instance-snapa-" + UUID.randomUUID(); - MACHINE_NAME_SUBNETWORK = "test-instance-subnet-" + UUID.randomUUID(); BUCKET_NAME = "my-new-test-bucket" + UUID.randomUUID(); IMAGE_PROJECT_NAME = "windows-sql-cloud"; - FIREWALL_RULE_CREATE = "firewall-rule-" + UUID.randomUUID(); - NETWORK_NAME = "global/networks/default"; - SUBNETWORK_NAME = "regions/us-central1/subnetworks/default"; - RAW_KEY = getBase64EncodedKey(); + RAW_KEY = Util.getBase64EncodedKey(); // Cleanup existing stale resources. Util.cleanUpExistingInstances("my-new-test-instance", PROJECT_ID, ZONE); @@ -125,242 +91,53 @@ public static void setUp() throws IOException, InterruptedException, ExecutionEx Util.cleanUpExistingInstances("test-instance-", PROJECT_ID, ZONE); compute.CreateInstance.createInstance(PROJECT_ID, ZONE, MACHINE_NAME); - compute.CreateInstance.createInstance(PROJECT_ID, ZONE, MACHINE_NAME_DELETE); compute.CreateInstance.createInstance(PROJECT_ID, ZONE, MACHINE_NAME_LIST_INSTANCE); compute.CreateInstance.createInstance(PROJECT_ID, ZONE, MACHINE_NAME_WAIT_FOR_OP); compute.CreateEncryptedInstance .createEncryptedInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED, RAW_KEY); - TEST_DISK = createSourceDisk(); - TEST_SNAPSHOT = createSnapshot(TEST_DISK); - TEST_IMAGE = createImage(TEST_DISK); - - compute.CreateInstancesAdvanced.createFromPublicImage(PROJECT_ID, ZONE, - MACHINE_NAME_PUBLIC_IMAGE); - compute.CreateInstancesAdvanced.createFromCustomImage(PROJECT_ID, ZONE, - MACHINE_NAME_CUSTOM_IMAGE, TEST_IMAGE.getSelfLink()); - compute.CreateInstancesAdvanced.createWithAdditionalDisk(PROJECT_ID, ZONE, - MACHINE_NAME_ADDITIONAL_DISK); - compute.CreateInstancesAdvanced.createFromSnapshot(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT, - TEST_SNAPSHOT.getSelfLink()); - compute.CreateInstancesAdvanced.createWithSnapshottedDataDisk(PROJECT_ID, ZONE, - MACHINE_NAME_SNAPSHOT_ADDITIONAL, TEST_SNAPSHOT.getSelfLink()); - compute.CreateInstancesAdvanced.createWithSubnetwork(PROJECT_ID, ZONE, MACHINE_NAME_SUBNETWORK, - NETWORK_NAME, SUBNETWORK_NAME); - - TimeUnit.SECONDS.sleep(10); - compute.CreateFirewallRule.createFirewall(PROJECT_ID, FIREWALL_RULE_CREATE, NETWORK_NAME); TimeUnit.SECONDS.sleep(10); - // Moving the following tests to setup section as the created firewall rule is auto-deleted - // by GCE Enforcer within a few minutes. - testListFirewallRules(); - testPatchFirewallRule(); // Create a Google Cloud Storage bucket for UsageReports Storage storage = StorageOptions.newBuilder().setProjectId(PROJECT_ID).build().getService(); storage.create(BucketInfo.of(BUCKET_NAME)); stdOut.close(); - System.setOut(null); + System.setOut(out); } - @AfterClass - public static void cleanup() throws IOException, InterruptedException, ExecutionException { + @AfterAll + public static void cleanup() + throws IOException, InterruptedException, ExecutionException, TimeoutException { + final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); // Delete all instances created for testing. requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); requireEnvVar("GOOGLE_CLOUD_PROJECT"); - if (!isFirewallRuleDeletedByGceEnforcer(PROJECT_ID, FIREWALL_RULE_CREATE)) { - DeleteFirewallRule.deleteFirewallRule(PROJECT_ID, FIREWALL_RULE_CREATE); - } compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED); compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME); compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_LIST_INSTANCE); - compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_PUBLIC_IMAGE); - compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_CUSTOM_IMAGE); - compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_ADDITIONAL_DISK); - compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT); - compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_SNAPSHOT_ADDITIONAL); - compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_SUBNETWORK); - - deleteImage(TEST_IMAGE); - deleteSnapshot(TEST_SNAPSHOT); - deleteDisk(TEST_DISK); - // Delete the Google Cloud Storage bucket created for usage reports. Storage storage = StorageOptions.newBuilder().setProjectId(PROJECT_ID).build().getService(); Bucket bucket = storage.get(BUCKET_NAME); bucket.delete(); - stdOut.close(); - System.setOut(null); - } - - private static Image getActiveDebian() - throws IOException { - try (ImagesClient imagesClient = ImagesClient.create()) { - return imagesClient.getFromFamily("debian-cloud", "debian-11"); - } - } - - private static Disk createSourceDisk() - throws IOException, ExecutionException, InterruptedException { - try (DisksClient disksClient = DisksClient.create()) { - - Disk disk = Disk.newBuilder() - .setSourceImage(getActiveDebian().getSelfLink()) - .setName("test-disk-" + UUID.randomUUID()) - .build(); - - OperationFuture operation = disksClient.insertAsync(PROJECT_ID, ZONE, - disk); - // Wait for the operation to complete. - operation.get(); - return disksClient.get(PROJECT_ID, ZONE, disk.getName()); - } - } - - private static void deleteDisk(Disk disk) - throws IOException, InterruptedException, ExecutionException { - try (DisksClient disksClient = DisksClient.create()) { - OperationFuture operation = disksClient.deleteAsync(PROJECT_ID, ZONE, - disk.getName()); - operation.get(); - } - } - - private static Snapshot createSnapshot(Disk srcDisk) - throws IOException, InterruptedException, ExecutionException { - try (SnapshotsClient snapshotsClient = SnapshotsClient.create(); - DisksClient disksClient = DisksClient.create()) { - - Snapshot snapshot = Snapshot.newBuilder() - .setName("test-snap-" + UUID.randomUUID()) - .build(); - - OperationFuture operation = disksClient.createSnapshotAsync(PROJECT_ID, - ZONE, srcDisk.getName(), - snapshot); - operation.get(); - return snapshotsClient.get(PROJECT_ID, snapshot.getName()); - } - } - - private static void deleteSnapshot(Snapshot snapshot) - throws IOException, InterruptedException, ExecutionException { - try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) { - OperationFuture operation = snapshotsClient.deleteAsync(PROJECT_ID, - snapshot.getName()); - operation.get(); - } - } - - private static Image createImage(Disk srcDisk) - throws IOException, InterruptedException, ExecutionException { - try (ImagesClient imagesClient = ImagesClient.create()) { - - Image image = Image.newBuilder() - .setName("test-img-" + UUID.randomUUID()) - .setSourceDisk(srcDisk.getSelfLink()) - .build(); - - OperationFuture operation = imagesClient.insertAsync(PROJECT_ID, image); - operation.get(); - return imagesClient.get(PROJECT_ID, image.getName()); - } - } - - private static void deleteImage(Image image) - throws IOException, InterruptedException, ExecutionException { - try (ImagesClient imagesClient = ImagesClient.create()) { - OperationFuture operation = imagesClient.deleteAsync(PROJECT_ID, - image.getName()); - operation.get(); - } - } - - public static String getBase64EncodedKey() { - String sampleSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - StringBuilder stringBuilder = new StringBuilder(); - SecureRandom random = new SecureRandom(); - IntStream.range(0, 32) - .forEach( - x -> stringBuilder.append(sampleSpace.charAt(random.nextInt(sampleSpace.length())))); - - return Base64.getEncoder() - .encodeToString(stringBuilder.toString().getBytes(StandardCharsets.US_ASCII)); - } - - public static void testListFirewallRules() - throws IOException, ExecutionException, InterruptedException { - final PrintStream out = System.out; - ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); - System.setOut(new PrintStream(stdOut)); - if (!isFirewallRuleDeletedByGceEnforcer(PROJECT_ID, FIREWALL_RULE_CREATE)) { - compute.ListFirewallRules.listFirewallRules(PROJECT_ID); - assertThat(stdOut.toString()).contains(FIREWALL_RULE_CREATE); - } - // Clear system output to not affect other tests. - // Refrain from setting out to null. - stdOut.close(); - System.setOut(out); - } - - public static void testPatchFirewallRule() - throws IOException, InterruptedException, ExecutionException { - final PrintStream out = System.out; - ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); - System.setOut(new PrintStream(stdOut)); - if (!isFirewallRuleDeletedByGceEnforcer(PROJECT_ID, FIREWALL_RULE_CREATE)) { - try (FirewallsClient client = FirewallsClient.create()) { - Assert.assertEquals(1000, client.get(PROJECT_ID, FIREWALL_RULE_CREATE).getPriority()); - compute.PatchFirewallRule.patchFirewallPriority(PROJECT_ID, FIREWALL_RULE_CREATE, 500); - TimeUnit.SECONDS.sleep(5); - Assert.assertEquals(500, client.get(PROJECT_ID, FIREWALL_RULE_CREATE).getPriority()); - } - } - // Clear system output to not affect other tests. - // Refrain from setting out to null as it will throw NullPointer in the subsequent tests. stdOut.close(); System.setOut(out); } - public static boolean isFirewallRuleDeletedByGceEnforcer(String projectId, - String firewallRule) throws IOException, ExecutionException, InterruptedException { - /* (**INTERNAL method**) - This method will prevent test failure if the firewall rule was auto-deleted by GCE Enforcer. - (Feel free to remove this method if not running on a Google-owned project.) - */ - try { - GetFirewallRule.getFirewallRule(projectId, firewallRule); - } catch (NotFoundException e) { - System.out.println("Rule already deleted ! "); - return true; - } catch (InvalidArgumentException | NullPointerException e) { - System.out.println("Rule is not ready (probably being deleted)."); - return true; - } - return false; - } - public static String getInstanceStatus(String instanceName) throws IOException { - try (InstancesClient instancesClient = InstancesClient.create()) { - Instance response = instancesClient.get(PROJECT_ID, ZONE, instanceName); - return response.getStatus(); - } - } - - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); @@ -369,58 +146,17 @@ public void afterEach() { @Test public void testCreateInstance() throws IOException { // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME); + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME); Assert.assertEquals(response, Status.RUNNING.toString()); } @Test public void testCreateEncryptedInstance() throws IOException { // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME_ENCRYPTED); + String response = Util.getInstanceStatus(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED); Assert.assertEquals(response, Status.RUNNING.toString()); } - @Test - public void testCreatePublicImage() throws IOException { - // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME_PUBLIC_IMAGE); - Assert.assertEquals(response, Status.RUNNING.toString()); - } - - @Test - public void testCreateCustomImage() throws IOException { - // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME_CUSTOM_IMAGE); - Assert.assertEquals(response, Status.RUNNING.toString()); - } - - @Test - public void testCreateAdditionalDisk() throws IOException { - // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME_ADDITIONAL_DISK); - Assert.assertEquals(response, Status.RUNNING.toString()); - } - - @Test - public void testCreateFromSnapshot() throws IOException { - // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME_SNAPSHOT); - Assert.assertEquals(response, Status.RUNNING.toString()); - } - - @Test - public void testCreateFromSnapshotAdditional() throws IOException { - // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME_SNAPSHOT_ADDITIONAL); - Assert.assertEquals(response, Status.RUNNING.toString()); - } - - @Test - public void testCreateInSubnetwork() throws IOException { - // Check if the instance was successfully created during the setup. - String response = getInstanceStatus(MACHINE_NAME_SUBNETWORK); - Assert.assertEquals(response, Status.RUNNING.toString()); - } @Test public void testListInstance() throws IOException { @@ -435,25 +171,20 @@ public void testListAllInstances() throws IOException { } @Test - public void testDeleteInstance() throws IOException, InterruptedException, ExecutionException { - compute.DeleteInstance.deleteInstance(PROJECT_ID, ZONE, MACHINE_NAME_DELETE); - assertThat(stdOut.toString()).contains("Operation Status: DONE"); - } - - @Test - public void testWaitForOperation() throws IOException, InterruptedException, ExecutionException { + public void testWaitForOperation() + throws IOException, InterruptedException, ExecutionException, TimeoutException { // Construct a delete request and get the operation instance. InstancesClient instancesClient = InstancesClient.create(); OperationFuture operation = instancesClient.deleteAsync(PROJECT_ID, ZONE, MACHINE_NAME_WAIT_FOR_OP); // Wait for the operation to complete. - operation.get(); + operation.get(3, TimeUnit.MINUTES); assertThat(stdOut.toString().contains("Operation Status: DONE")); } @Test public void testSetUsageBucketExportCustomPrefix() - throws IOException, InterruptedException, ExecutionException { + throws IOException, InterruptedException, ExecutionException, TimeoutException { // Set custom Report Name Prefix. String customPrefix = "my-custom-prefix"; compute.SetUsageExportBucket.setUsageExportBucket(PROJECT_ID, BUCKET_NAME, customPrefix); @@ -489,69 +220,4 @@ public void testListImagesByPage() throws IOException { Assert.assertTrue(stdOut.toString().contains("Page Number: 1")); } - @Test - public void testInstanceOperations() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.RUNNING.toString()); - - // Suspending the instance. - // Once the machine is running, give it some time to fully start all processes - // before trying to suspend it. - TimeUnit.SECONDS.sleep(45); - SuspendInstance.suspendInstance(PROJECT_ID, ZONE, MACHINE_NAME); - TimeUnit.SECONDS.sleep(10); - Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.SUSPENDED.toString()); - - // Resuming the instance. - ResumeInstance.resumeInstance(PROJECT_ID, ZONE, MACHINE_NAME); - Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.RUNNING.toString()); - - // Stopping the instance. - StopInstance.stopInstance(PROJECT_ID, ZONE, MACHINE_NAME); - // Wait for the operation to complete. Setting timeout to 3 mins. - LocalDateTime endTime = LocalDateTime.now().plusMinutes(3); - while (getInstanceStatus(MACHINE_NAME).equalsIgnoreCase(Status.STOPPING.toString()) - && LocalDateTime.now().isBefore(endTime)) { - TimeUnit.SECONDS.sleep(5); - } - Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.TERMINATED.toString()); - - // Starting the instance. - StartInstance.startInstance(PROJECT_ID, ZONE, MACHINE_NAME); - // Wait for the operation to complete. Setting timeout to 3 mins. - endTime = LocalDateTime.now().plusMinutes(3); - while (getInstanceStatus(MACHINE_NAME).equalsIgnoreCase(Status.RUNNING.toString()) - && LocalDateTime.now().isBefore(endTime)) { - TimeUnit.SECONDS.sleep(5); - } - Assert.assertEquals(getInstanceStatus(MACHINE_NAME), Status.RUNNING.toString()); - } - - @Test - public void testEncryptedInstanceOperations() - throws IOException, ExecutionException, InterruptedException { - Assert.assertEquals(getInstanceStatus(MACHINE_NAME_ENCRYPTED), Status.RUNNING.toString()); - - // Stopping the encrypted instance. - StopInstance.stopInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED); - // Wait for the operation to complete. Setting timeout to 3 mins. - LocalDateTime endTime = LocalDateTime.now().plusMinutes(3); - while (getInstanceStatus(MACHINE_NAME_ENCRYPTED).equalsIgnoreCase(Status.STOPPING.toString()) - && LocalDateTime.now().isBefore(endTime)) { - TimeUnit.SECONDS.sleep(5); - } - Assert.assertEquals(getInstanceStatus(MACHINE_NAME_ENCRYPTED), Status.TERMINATED.toString()); - - // Starting the encrypted instance. - StartEncryptedInstance - .startEncryptedInstance(PROJECT_ID, ZONE, MACHINE_NAME_ENCRYPTED, RAW_KEY); - // Wait for the operation to complete. Setting timeout to 3 mins. - endTime = LocalDateTime.now().plusMinutes(3); - while (getInstanceStatus(MACHINE_NAME_ENCRYPTED).equalsIgnoreCase(Status.RUNNING.toString()) - && LocalDateTime.now().isBefore(endTime)) { - TimeUnit.SECONDS.sleep(5); - } - Assert.assertEquals(getInstanceStatus(MACHINE_NAME_ENCRYPTED), Status.RUNNING.toString()); - } - } diff --git a/compute/cloud-client/src/test/java/compute/Util.java b/compute/cloud-client/src/test/java/compute/Util.java index f68cca0f0ce..cf0adb0de7e 100644 --- a/compute/cloud-client/src/test/java/compute/Util.java +++ b/compute/cloud-client/src/test/java/compute/Util.java @@ -16,15 +16,27 @@ package compute; +import com.google.cloud.compute.v1.AggregatedListInstancesRequest; import com.google.cloud.compute.v1.Instance; +import com.google.cloud.compute.v1.Instance.Status; import com.google.cloud.compute.v1.InstanceTemplate; +import com.google.cloud.compute.v1.InstanceTemplatesClient; +import com.google.cloud.compute.v1.InstanceTemplatesClient.ListPagedResponse; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.InstancesClient.AggregatedListPagedResponse; import com.google.cloud.compute.v1.InstancesScopedList; +import com.google.cloud.compute.v1.ListInstanceTemplatesRequest; import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.SecureRandom; import java.time.Instant; import java.time.OffsetDateTime; import java.time.temporal.ChronoUnit; +import java.util.Base64; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import java.util.stream.IntStream; public class Util { // Cleans existing test resources if any. @@ -36,14 +48,15 @@ public class Util { // Delete templates which starts with the given prefixToDelete and // has creation timestamp >24 hours. public static void cleanUpExistingInstanceTemplates(String prefixToDelete, String projectId) - throws IOException, ExecutionException, InterruptedException { - for (InstanceTemplate template : ListInstanceTemplates.listInstanceTemplates(projectId) + throws IOException, ExecutionException, InterruptedException, TimeoutException { + for (InstanceTemplate template : listFilteredInstanceTemplates(projectId, prefixToDelete) .iterateAll()) { if (!template.hasCreationTimestamp()) { continue; } if (template.getName().contains(prefixToDelete) - && isCreatedBeforeThresholdTime(template.getCreationTimestamp())) { + && isCreatedBeforeThresholdTime(template.getCreationTimestamp()) + && template.isInitialized()) { DeleteInstanceTemplate.deleteInstanceTemplate(projectId, template.getName()); } } @@ -54,15 +67,16 @@ && isCreatedBeforeThresholdTime(template.getCreationTimestamp())) { // has creation timestamp >24 hours. public static void cleanUpExistingInstances(String prefixToDelete, String projectId, String instanceZone) - throws IOException, ExecutionException, InterruptedException { - for (Entry instanceGroup : ListAllInstances.listAllInstances( - projectId).iterateAll()) { + throws IOException, ExecutionException, InterruptedException, TimeoutException { + for (Entry instanceGroup : listFilteredInstances( + projectId, prefixToDelete).iterateAll()) { for (Instance instance : instanceGroup.getValue().getInstancesList()) { if (!instance.hasCreationTimestamp()) { continue; } if (instance.getName().contains(prefixToDelete) - && isCreatedBeforeThresholdTime(instance.getCreationTimestamp())) { + && isCreatedBeforeThresholdTime(instance.getCreationTimestamp()) + && instance.getStatus().equalsIgnoreCase(Status.RUNNING.toString())) { DeleteInstance.deleteInstance(projectId, instanceZone, instance.getName()); } } @@ -74,4 +88,52 @@ public static boolean isCreatedBeforeThresholdTime(String timestamp) { .isBefore(Instant.now().minus(DELETION_THRESHOLD_TIME_HOURS, ChronoUnit.HOURS)); } + public static AggregatedListPagedResponse listFilteredInstances(String project, + String instanceNamePrefix) throws IOException { + try (InstancesClient instancesClient = InstancesClient.create()) { + + AggregatedListInstancesRequest aggregatedListInstancesRequest = AggregatedListInstancesRequest + .newBuilder() + .setProject(project) + .setFilter(String.format("name:%s", instanceNamePrefix)) + .build(); + + return instancesClient + .aggregatedList(aggregatedListInstancesRequest); + } + } + + public static ListPagedResponse listFilteredInstanceTemplates(String projectId, + String instanceTemplatePrefix) throws IOException { + try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) { + ListInstanceTemplatesRequest listInstanceTemplatesRequest = + ListInstanceTemplatesRequest.newBuilder() + .setProject(projectId) + .setFilter(String.format("name:%s", instanceTemplatePrefix)) + .build(); + + return instanceTemplatesClient.list(listInstanceTemplatesRequest); + } + } + + public static String getBase64EncodedKey() { + String sampleSpace = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + StringBuilder stringBuilder = new StringBuilder(); + SecureRandom random = new SecureRandom(); + IntStream.range(0, 32) + .forEach( + x -> stringBuilder.append(sampleSpace.charAt(random.nextInt(sampleSpace.length())))); + + return Base64.getEncoder() + .encodeToString(stringBuilder.toString().getBytes(StandardCharsets.US_ASCII)); + } + + public static String getInstanceStatus(String project, String zone, String instanceName) + throws IOException { + try (InstancesClient instancesClient = InstancesClient.create()) { + Instance response = instancesClient.get(project, zone, instanceName); + return response.getStatus(); + } + } + } \ No newline at end of file diff --git a/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java b/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java index 770b4e2aca6..4766568c834 100644 --- a/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java +++ b/compute/cloud-client/src/test/java/compute/customhostname/CustomHostnameInstanceIT.java @@ -25,17 +25,20 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) public class CustomHostnameInstanceIT { - private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); private static String INSTANCE_NAME; private static String ZONE; @@ -49,8 +52,9 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass - public static void setup() throws IOException, ExecutionException, InterruptedException { + @BeforeAll + public static void setup() + throws IOException, ExecutionException, InterruptedException, TimeoutException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); @@ -70,8 +74,9 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - @AfterClass - public static void cleanUp() throws IOException, ExecutionException, InterruptedException { + @AfterAll + public static void cleanUp() + throws IOException, ExecutionException, InterruptedException, TimeoutException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); @@ -80,13 +85,13 @@ public static void cleanUp() throws IOException, ExecutionException, Interrupted System.setOut(out); } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); diff --git a/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java b/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java index 7ccda634cb1..9409b1128a7 100644 --- a/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java +++ b/compute/cloud-client/src/test/java/compute/deleteprotection/DeleteProtectionIT.java @@ -26,16 +26,20 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.AfterClass; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) public class DeleteProtectionIT { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); @@ -50,8 +54,9 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass - public static void setup() throws IOException, ExecutionException, InterruptedException { + @BeforeAll + public static void setup() + throws IOException, ExecutionException, InterruptedException, TimeoutException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); @@ -72,8 +77,9 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - @AfterClass - public static void cleanUp() throws IOException, ExecutionException, InterruptedException { + @AfterAll + public static void cleanUp() + throws IOException, ExecutionException, InterruptedException, TimeoutException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); @@ -88,20 +94,21 @@ public static void cleanUp() throws IOException, ExecutionException, Interrupted System.setOut(out); } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); } @Test - public void testDeleteProtection() throws IOException, ExecutionException, InterruptedException { + public void testDeleteProtection() + throws IOException, ExecutionException, InterruptedException, TimeoutException { Assert.assertTrue(GetDeleteProtection.getDeleteProtection(PROJECT_ID, ZONE, INSTANCE_NAME)); SetDeleteProtection.setDeleteProtection(PROJECT_ID, ZONE, INSTANCE_NAME, false); Assert.assertFalse(GetDeleteProtection.getDeleteProtection(PROJECT_ID, ZONE, INSTANCE_NAME)); diff --git a/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java b/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java index 5e33c314b99..98673bc14a9 100644 --- a/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java +++ b/compute/cloud-client/src/test/java/compute/preemptible/PreemptibleIT.java @@ -28,15 +28,19 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) public class PreemptibleIT { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); @@ -51,8 +55,9 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass - public static void setup() throws IOException, ExecutionException, InterruptedException { + @BeforeAll + public static void setup() + throws IOException, ExecutionException, InterruptedException, TimeoutException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); @@ -73,8 +78,9 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - @AfterClass - public static void cleanUp() throws IOException, ExecutionException, InterruptedException { + @AfterAll + public static void cleanUp() + throws IOException, ExecutionException, InterruptedException, TimeoutException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); @@ -85,13 +91,13 @@ public static void cleanUp() throws IOException, ExecutionException, Interrupted System.setOut(out); } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); From 8ae047c641a4f6fc58c25008b4736c2ce9095466 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Mon, 11 Apr 2022 14:23:36 +0530 Subject: [PATCH 128/136] docs(compute-samples): add snippets and tests for windows instance management --- ...eFirewallRuleForWindowsActivationHost.java | 82 +++++++++++ .../CreateRouteToWindowsActivationHost.java | 80 +++++++++++ ...CreateWindowsServerInstanceExternalIp.java | 116 +++++++++++++++ ...CreateWindowsServerInstanceInternalIp.java | 127 +++++++++++++++++ .../GetInstanceSerialPort.java | 51 +++++++ .../CreatingManagingWindowsInstancesIT.java | 132 ++++++++++++++++++ 6 files changed, 588 insertions(+) create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java create mode 100644 compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java create mode 100644 compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java new file mode 100644 index 00000000000..fad6b990b5c --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java @@ -0,0 +1,82 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; + +// [START compute_create_egress_rule_windows_activation] + +import com.google.cloud.compute.v1.Allowed; +import com.google.cloud.compute.v1.Firewall; +import com.google.cloud.compute.v1.FirewallsClient; +import com.google.cloud.compute.v1.InsertFirewallRequest; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateFirewallRuleForWindowsActivationHost { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // firewallRuleName - Name of the firewall rule you want to create. + String firewallRuleName = "firewall-rule-name"; + + // networkName - Name of the network you want the new instance to use. + // * For example: "global/networks/default" represents the network + // * named "default", which is created automatically for each project. + String networkName = "global/networks/default"; + + createFirewallRuleForWindowsActivationHost(projectId, firewallRuleName, networkName); + } + + // Creates a new allow egress firewall rule with the highest priority for host + // kms.windows.googlecloud.com (35.190.247.13) for Windows activation. + public static void createFirewallRuleForWindowsActivationHost(String projectId, + String firewallRuleName, String networkName) + throws IOException, ExecutionException, InterruptedException { + + try (FirewallsClient firewallsClient = FirewallsClient.create()) { + + Firewall firewall = Firewall.newBuilder() + .setName(firewallRuleName) + .addAllowed(Allowed.newBuilder() + .setIPProtocol("tcp") + .addPorts("1688") + .build()) + .setDirection("EGRESS") + .setNetwork(networkName) + .addDestinationRanges("35.190.247.13/32") + .setPriority(0) + .build(); + + InsertFirewallRequest request = InsertFirewallRequest.newBuilder() + .setProject(projectId) + .setFirewallResource(firewall) + .build(); + + Operation operation = firewallsClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.println("Firewall rule creation failed ! ! " + operation.getError()); + return; + } + + System.out.printf("Firewall rule created %s", firewallRuleName); + } + } +} +// [END compute_create_egress_rule_windows_activation] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java new file mode 100644 index 00000000000..259030a0b4e --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_create_route_windows_activation] + +import com.google.cloud.compute.v1.InsertRouteRequest; +import com.google.cloud.compute.v1.Operation; +import com.google.cloud.compute.v1.Route; +import com.google.cloud.compute.v1.RoutesClient; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateRouteToWindowsActivationHost { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // routeName - Name of the route you want to create. + String routeName = "route-name"; + + // networkName - Name of the network you want the new instance to use. + // * For example: "global/networks/default" represents the network + // * named "default", which is created automatically for each project. + String networkName = "global/networks/default"; + + createRouteToWindowsActivationHost(projectId, routeName, networkName); + } + + // Creates a new route to kms.windows.googlecloud.com (35.190.247.13) for Windows activation. + public static void createRouteToWindowsActivationHost(String projectId, String routeName, + String networkName) + throws IOException, ExecutionException, InterruptedException { + + try (RoutesClient routesClient = RoutesClient.create()) { + + // If you have Windows instances without external IP addresses, + // you must also enable Private Google Access so that instances + // with only internal IP addresses can send traffic to the external + // IP address for kms.windows.googlecloud.com. + // More infromation: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling + Route route = Route.newBuilder() + .setName(routeName) + .setDestRange("35.190.247.13/32") + .setNetwork(networkName) + .setNextHopGateway( + String.format("project/%s/global/gateways/default-internet-gateway", projectId)) + .build(); + + InsertRouteRequest request = InsertRouteRequest.newBuilder() + .setProject(projectId) + .setRouteResource(route) + .build(); + + Operation operation = routesClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.printf("Error in creating route %s", operation.getError()); + return; + } + + System.out.printf("Route created %s", routeName); + } + } +} +// [END compute_create_route_windows_activation] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java new file mode 100644 index 00000000000..f9742ccd050 --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java @@ -0,0 +1,116 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_create_windows_instance_external_ip] + +import com.google.cloud.compute.v1.AccessConfig; +import com.google.cloud.compute.v1.AttachedDisk; +import com.google.cloud.compute.v1.AttachedDiskInitializeParams; +import com.google.cloud.compute.v1.InsertInstanceRequest; +import com.google.cloud.compute.v1.Instance; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.NetworkInterface; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateWindowsServerInstanceExternalIp { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // zone - Name of the zone you want to use, for example: us-west3-b + String zone = "europe-central2-b"; + + // instanceName - Name of the new machine. + String instanceName = "instance-name"; + + createWindowsServerInstanceExternalIp(projectId, zone, instanceName); + } + + // Creates a new Windows Server instance that has an external IP address. + public static void createWindowsServerInstanceExternalIp(String projectId, String zone, + String instanceName) + throws IOException, ExecutionException, InterruptedException { + + // machineType - Machine type you want to create in following format: + // * "zones/{zone}/machineTypes/{type_name}". For example: + // * "zones/europe-west3-c/machineTypes/f1-micro" + // * You can find the list of available machine types using: + // * https://cloud.google.com/sdk/gcloud/reference/compute/machine-types/list + String machineType = "n1-standard-1"; + // sourceImageFamily - Name of the public image family for Windows Server or SQL Server images. + // * https://cloud.google.com/compute/docs/images#os-compute-support + String sourceImageFamily = "windows-2012-r2"; + + try (InstancesClient instancesClient = InstancesClient.create()) { + + AttachedDisk attachedDisk = AttachedDisk.newBuilder() + // Describe the size and source image of the boot disk to attach to the instance. + .setInitializeParams(AttachedDiskInitializeParams.newBuilder() + .setDiskSizeGb(64) + .setSourceImage( + String.format("projects/windows-cloud/global/images/family/%s", + sourceImageFamily)) + .build()) + .setAutoDelete(true) + .setBoot(true) + .setType(AttachedDisk.Type.PERSISTENT.toString()) + .build(); + + Instance instance = Instance.newBuilder() + .setName(instanceName) + .setMachineType(String.format("zones/%s/machineTypes/%s", zone, machineType)) + .addDisks(attachedDisk) + .addNetworkInterfaces(NetworkInterface.newBuilder() + .addAccessConfigs(AccessConfig.newBuilder() + .setType("ONE_TO_ONE_NAT") + .setName("External NAT") + .build()) + // If you going you use custom VPC network, it must be configured + // to allow access to kms.windows.googlecloud.com. + // https://cloud.google.com/compute/docs/instances/windows/creating-managing-windows-instances#kms-server. + .setName("global/networks/default") + .build()) + // If you chose an image that supports Shielded VM, you can optionally change the + // instance's Shielded VM settings. + // .setShieldedInstanceConfig(ShieldedInstanceConfig.newBuilder() + // .setEnableSecureBoot(true) + // .setEnableVtpm(true) + // .setEnableIntegrityMonitoring(true) + // .build()) + .build(); + + InsertInstanceRequest request = InsertInstanceRequest.newBuilder() + .setProject(projectId) + .setZone(zone) + .setInstanceResource(instance) + .build(); + + Operation operation = instancesClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.printf("Error in creating instance %s", operation.getError()); + return; + } + + System.out.printf("Instance created %s", instanceName); + } + } +} +// [END compute_create_windows_instance_external_ip] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java new file mode 100644 index 00000000000..0142322eec1 --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java @@ -0,0 +1,127 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_create_windows_instance_internal_ip] + +import com.google.cloud.compute.v1.AttachedDisk; +import com.google.cloud.compute.v1.AttachedDiskInitializeParams; +import com.google.cloud.compute.v1.InsertInstanceRequest; +import com.google.cloud.compute.v1.Instance; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.NetworkInterface; +import com.google.cloud.compute.v1.Operation; +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +public class CreateWindowsServerInstanceInternalIp { + + public static void main(String[] args) + throws IOException, ExecutionException, InterruptedException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // zone - Name of the zone you want to use, for example: us-west3-b + String zone = "europe-central2-b"; + + // instanceName - Name of the new machine. + String instanceName = "instance-name"; + + // networkLink - Name of the network you want the new instance to use. + // * For example: "global/networks/default" represents the network + // * named "default", which is created automatically for each project. + String networkLink = "global/networks/default"; + + // subnetworkLink - Name of the subnetwork you want the new instance to use. + // * This value uses the following format: + // * "regions/{region}/subnetworks/{subnetwork_name}" + String subnetworkLink = "regions/europe-central2/subnetworks/default"; + + createWindowsServerInstanceInternalIp(projectId, zone, instanceName, networkLink, + subnetworkLink); + } + + // Creates a new Windows Server instance that has only an internal IP address. + public static void createWindowsServerInstanceInternalIp(String projectId, String zone, + String instanceName, String networkLink, String subnetworkLink) + throws IOException, ExecutionException, InterruptedException { + + // machineType - Machine type you want to create in following format: + // * "zones/{zone}/machineTypes/{type_name}". For example: + // * "zones/europe-west3-c/machineTypes/f1-micro" + // * You can find the list of available machine types using: + // * https://cloud.google.com/sdk/gcloud/reference/compute/machine-types/list + String machineType = "n1-standard-1"; + // sourceImageFamily - Name of the public image family for Windows Server or SQL Server images. + // * https://cloud.google.com/compute/docs/images#os-compute-support + String sourceImageFamily = "windows-2012-r2"; + + try (InstancesClient instancesClient = InstancesClient.create()) { + + AttachedDisk attachedDisk = AttachedDisk.newBuilder() + // Describe the size and source image of the boot disk to attach to the instance. + .setInitializeParams(AttachedDiskInitializeParams.newBuilder() + .setDiskSizeGb(64) + .setSourceImage( + String.format("projects/windows-cloud/global/images/family/%s", + sourceImageFamily)) + .build()) + .setAutoDelete(true) + .setBoot(true) + .setType(AttachedDisk.Type.PERSISTENT.toString()) + .build(); + + Instance instance = Instance.newBuilder() + .setName(instanceName) + .setMachineType(String.format("zones/%s/machineTypes/%s", zone, machineType)) + .addDisks(attachedDisk) + .addNetworkInterfaces(NetworkInterface.newBuilder() + // You must verify or configure routes and firewall rules in your VPC network + // to allow access to kms.windows.googlecloud.com. + // More information about access to kms.windows.googlecloud.com: https://cloud.google.com/compute/docs/instances/windows/creating-managing-windows-instances#kms-server + + // Additionally, you must enable Private Google Access for subnets in your VPC network + // that contain Windows instances with only internal IP addresses. + // More information about Private Google Access: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling + .setName(networkLink) + .setSubnetwork(subnetworkLink) + .build()) + // If you chose an image that supports Shielded VM, you can optionally change the + // instance's Shielded VM settings. + // .setShieldedInstanceConfig(ShieldedInstanceConfig.newBuilder() + // .setEnableSecureBoot(true) + // .setEnableVtpm(true) + // .setEnableIntegrityMonitoring(true) + // .build()) + .build(); + + InsertInstanceRequest request = InsertInstanceRequest.newBuilder() + .setProject(projectId) + .setZone(zone) + .setInstanceResource(instance) + .build(); + + Operation operation = instancesClient.insertAsync(request).get(); + + if (operation.hasError()) { + System.out.printf("Error in creating instance %s", operation.getError()); + return; + } + + System.out.printf("Instance created %s", instanceName); + } + } +} +// [END compute_create_windows_instance_internal_ip] \ No newline at end of file diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java new file mode 100644 index 00000000000..d60076f4282 --- /dev/null +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java @@ -0,0 +1,51 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; +// [START compute_get_instance_serial_port] + +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.SerialPortOutput; +import java.io.IOException; + +public class GetInstanceSerialPort { + + public static void main(String[] args) throws IOException { + // TODO(developer): Replace these variables before running the sample. + // projectId - ID or number of the project you want to use. + String projectId = "your-google-cloud-project-id"; + + // zone - Name of the zone you want to check, for example: us-west3-b + String zone = "europe-central2-b"; + + // instanceName - Name of the instance you want to check. + String instanceName = "instance-name"; + + getInstanceSerialPort(projectId, zone, instanceName); + } + + // Prints an instance serial port output. + public static void getInstanceSerialPort(String projectId, String zone, String instanceName) + throws IOException { + + try (InstancesClient instancesClient = InstancesClient.create()) { + + SerialPortOutput serialPortOutput = instancesClient.getSerialPortOutput(projectId, zone, + instanceName); + + System.out.printf("Output from instance serial port %s", serialPortOutput.getContents()); + } + } +} +// [END compute_get_instance_serial_port] \ No newline at end of file diff --git a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java new file mode 100644 index 00000000000..090780f29d9 --- /dev/null +++ b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java @@ -0,0 +1,132 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package compute.windows.windowsinstances; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.cloud.compute.v1.RoutesClient; +import compute.DeleteFirewallRule; +import compute.DeleteInstance; +import compute.Util; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class CreatingManagingWindowsInstancesIT { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String ZONE = "europe-central2-b"; + private static String INSTANCE_NAME_EXTERNAL; + private static String INSTANCE_NAME_INTERNAL; + private static String FIREWALL_RULE_NAME; + private static String NETWORK_NAME; + private static String SUBNETWORK_NAME; + private static String ROUTE_NAME; + + private ByteArrayOutputStream stdOut; + + // Check if the required environment variables are set. + public static void requireEnvVar(String envVarName) { + assertWithMessage(String.format("Missing environment variable '%s' ", envVarName)) + .that(System.getenv(envVarName)).isNotEmpty(); + } + + @BeforeClass + public static void setup() throws IOException, ExecutionException, InterruptedException { + final PrintStream out = System.out; + ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + + // Cleanup existing test instances. + Util.cleanUpExistingInstances("windows-test-instance", PROJECT_ID, ZONE); + + String uuid = UUID.randomUUID().toString().split("-")[0]; + INSTANCE_NAME_EXTERNAL = "windows-test-instance-external-" + uuid; + INSTANCE_NAME_INTERNAL = "windows-test-instance-internal-" + uuid; + FIREWALL_RULE_NAME = "windows-test-firewall-" + uuid; + NETWORK_NAME = "global/networks/default-compute"; + SUBNETWORK_NAME = "regions/europe-central2/subnetworks/default-compute"; + ROUTE_NAME = "windows-test-route-" + uuid; + + stdOut.close(); + System.setOut(out); + } + + public static void deleteRoute() throws IOException, ExecutionException, InterruptedException { + try (RoutesClient routesClient = RoutesClient.create()) { + routesClient.deleteAsync(PROJECT_ID, ROUTE_NAME).get(); + } + } + + @Before + public void beforeEach() { + stdOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(stdOut)); + } + + @After + public void afterEach() { + stdOut = null; + System.setOut(null); + } + + @Test + public void testCreateWindowsServerInstanceExternalIp() + throws IOException, ExecutionException, InterruptedException { + // Create Windows server instance with external IP. + CreateWindowsServerInstanceExternalIp.createWindowsServerInstanceExternalIp(PROJECT_ID, ZONE, + INSTANCE_NAME_EXTERNAL); + assertThat(stdOut.toString()).contains("Instance created " + INSTANCE_NAME_EXTERNAL); + + // Delete instance. + DeleteInstance.deleteInstance(PROJECT_ID, ZONE, INSTANCE_NAME_EXTERNAL); + } + + @Test + public void testCreateWindowsServerInstanceInternalIp() + throws IOException, ExecutionException, InterruptedException { + // Create Windows server instance with internal IP and firewall rule. + CreateWindowsServerInstanceInternalIp.createWindowsServerInstanceInternalIp(PROJECT_ID, ZONE, + INSTANCE_NAME_INTERNAL, NETWORK_NAME, SUBNETWORK_NAME); + assertThat(stdOut.toString()).contains("Instance created " + INSTANCE_NAME_INTERNAL); + CreateFirewallRuleForWindowsActivationHost.createFirewallRuleForWindowsActivationHost( + PROJECT_ID, ZONE, NETWORK_NAME); + assertThat(stdOut.toString()).contains( + String.format("Firewall rule created %s", FIREWALL_RULE_NAME)); + CreateRouteToWindowsActivationHost.createRouteToWindowsActivationHost(PROJECT_ID, ROUTE_NAME, + NETWORK_NAME); + assertThat(stdOut.toString()).contains(String.format("Route created %s", ROUTE_NAME)); + + // Delete Route. + deleteRoute(); + // Delete Firewall. + DeleteFirewallRule.deleteFirewallRule(PROJECT_ID, FIREWALL_RULE_NAME); + // Delete Instance. + DeleteInstance.deleteInstance(PROJECT_ID, ZONE, INSTANCE_NAME_INTERNAL); + } +} From 5cc313414854bbe78b09dcc175ac32a8e92d9512 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Mon, 11 Apr 2022 14:53:53 +0530 Subject: [PATCH 129/136] lint fix --- .../windowsinstances/CreateRouteToWindowsActivationHost.java | 1 + .../windowsinstances/CreateWindowsServerInstanceExternalIp.java | 1 + .../windowsinstances/CreateWindowsServerInstanceInternalIp.java | 1 + .../compute/windows/windowsinstances/GetInstanceSerialPort.java | 1 + 4 files changed, 4 insertions(+) diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java index 259030a0b4e..1d58512626e 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_create_route_windows_activation] import com.google.cloud.compute.v1.InsertRouteRequest; diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java index f9742ccd050..3ba17fa5d87 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_create_windows_instance_external_ip] import com.google.cloud.compute.v1.AccessConfig; diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java index 0142322eec1..eca8eefec29 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_create_windows_instance_internal_ip] import com.google.cloud.compute.v1.AttachedDisk; diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java index d60076f4282..689dabfd207 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java @@ -13,6 +13,7 @@ // limitations under the License. package compute.windows.windowsinstances; + // [START compute_get_instance_serial_port] import com.google.cloud.compute.v1.InstancesClient; From 4faedba4c587d67f0b5a69739a4e81ca65beb2f0 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Tue, 19 Apr 2022 22:11:17 +0530 Subject: [PATCH 130/136] added mvn surefire plugin --- compute/cloud-client/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index e07ac0200df..c277bb15ca7 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -84,6 +84,13 @@ pom 25.0.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M6 + maven-plugin + From fa17e122ad7b9bfb35590c5fea081ff46cf79d71 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Mon, 25 Apr 2022 22:16:45 +0530 Subject: [PATCH 131/136] updated mvn surefire config --- compute/cloud-client/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index c277bb15ca7..1eba4572e52 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -90,6 +90,11 @@ maven-surefire-plugin 3.0.0-M6 maven-plugin + + + *IT.java + + From 5101298e6ea598155d9ec51b2c0797430fea6d58 Mon Sep 17 00:00:00 2001 From: Sita Lakshmi Sangameswaran Date: Mon, 25 Apr 2022 22:18:42 +0530 Subject: [PATCH 132/136] updated mvn surefire config --- compute/cloud-client/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/cloud-client/pom.xml b/compute/cloud-client/pom.xml index 1eba4572e52..511e6201519 100644 --- a/compute/cloud-client/pom.xml +++ b/compute/cloud-client/pom.xml @@ -92,7 +92,7 @@ maven-plugin - *IT.java + **/*IT.java From e21e626c0c6da33718475713d9201fccc0beda88 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Tue, 26 Apr 2022 00:38:14 +0530 Subject: [PATCH 133/136] updated comments --- .../CreateFirewallRuleForWindowsActivationHost.java | 5 ++++- .../CreateRouteToWindowsActivationHost.java | 7 ++++--- .../CreateWindowsServerInstanceExternalIp.java | 2 ++ .../CreateWindowsServerInstanceInternalIp.java | 2 ++ .../windows/windowsinstances/GetInstanceSerialPort.java | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java index fad6b990b5c..1c5f0b6d748 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java @@ -48,11 +48,13 @@ public static void main(String[] args) public static void createFirewallRuleForWindowsActivationHost(String projectId, String firewallRuleName, String networkName) throws IOException, ExecutionException, InterruptedException { - + // Instantiates a client. try (FirewallsClient firewallsClient = FirewallsClient.create()) { Firewall firewall = Firewall.newBuilder() .setName(firewallRuleName) + // These are the default values for kms.windows.googlecloud.com + // See, https://cloud.google.com/compute/docs/instances/windows/creating-managing-windows-instances#firewall_rule_requirements .addAllowed(Allowed.newBuilder() .setIPProtocol("tcp") .addPorts("1688") @@ -68,6 +70,7 @@ public static void createFirewallRuleForWindowsActivationHost(String projectId, .setFirewallResource(firewall) .build(); + // Wait for the operation to complete. Operation operation = firewallsClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java index 1d58512626e..cd2169bce03 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java @@ -46,20 +46,20 @@ public static void main(String[] args) public static void createRouteToWindowsActivationHost(String projectId, String routeName, String networkName) throws IOException, ExecutionException, InterruptedException { - + // Instantiates a client. try (RoutesClient routesClient = RoutesClient.create()) { // If you have Windows instances without external IP addresses, // you must also enable Private Google Access so that instances // with only internal IP addresses can send traffic to the external // IP address for kms.windows.googlecloud.com. - // More infromation: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling + // More information: https://cloud.google.com/vpc/docs/configure-private-google-access#enabling Route route = Route.newBuilder() .setName(routeName) .setDestRange("35.190.247.13/32") .setNetwork(networkName) .setNextHopGateway( - String.format("project/%s/global/gateways/default-internet-gateway", projectId)) + String.format("projects/%s/global/gateways/default-internet-gateway", projectId)) .build(); InsertRouteRequest request = InsertRouteRequest.newBuilder() @@ -67,6 +67,7 @@ public static void createRouteToWindowsActivationHost(String projectId, String r .setRouteResource(route) .build(); + // Wait for the operation to complete. Operation operation = routesClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java index 3ba17fa5d87..237b741abdd 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java @@ -59,6 +59,7 @@ public static void createWindowsServerInstanceExternalIp(String projectId, Strin // * https://cloud.google.com/compute/docs/images#os-compute-support String sourceImageFamily = "windows-2012-r2"; + // Instantiates a client. try (InstancesClient instancesClient = InstancesClient.create()) { AttachedDisk attachedDisk = AttachedDisk.newBuilder() @@ -103,6 +104,7 @@ public static void createWindowsServerInstanceExternalIp(String projectId, Strin .setInstanceResource(instance) .build(); + // Wait for the operation to complete. Operation operation = instancesClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java index eca8eefec29..8338f7bd72d 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java @@ -69,6 +69,7 @@ public static void createWindowsServerInstanceInternalIp(String projectId, Strin // * https://cloud.google.com/compute/docs/images#os-compute-support String sourceImageFamily = "windows-2012-r2"; + // Instantiates a client. try (InstancesClient instancesClient = InstancesClient.create()) { AttachedDisk attachedDisk = AttachedDisk.newBuilder() @@ -114,6 +115,7 @@ public static void createWindowsServerInstanceInternalIp(String projectId, Strin .setInstanceResource(instance) .build(); + // Wait for the operation to complete. Operation operation = instancesClient.insertAsync(request).get(); if (operation.hasError()) { diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java index 689dabfd207..6a60d644003 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/GetInstanceSerialPort.java @@ -39,7 +39,7 @@ public static void main(String[] args) throws IOException { // Prints an instance serial port output. public static void getInstanceSerialPort(String projectId, String zone, String instanceName) throws IOException { - + // Instantiates a client. try (InstancesClient instancesClient = InstancesClient.create()) { SerialPortOutput serialPortOutput = instancesClient.getSerialPortOutput(projectId, zone, From 190e4f57c9bd6e7a81dc0c7a91833982c1335433 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Tue, 26 Apr 2022 00:38:39 +0530 Subject: [PATCH 134/136] modified param value --- .../CreatingManagingWindowsInstancesIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java index 090780f29d9..566b293b5cb 100644 --- a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java +++ b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java @@ -69,8 +69,8 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx INSTANCE_NAME_EXTERNAL = "windows-test-instance-external-" + uuid; INSTANCE_NAME_INTERNAL = "windows-test-instance-internal-" + uuid; FIREWALL_RULE_NAME = "windows-test-firewall-" + uuid; - NETWORK_NAME = "global/networks/default-compute"; - SUBNETWORK_NAME = "regions/europe-central2/subnetworks/default-compute"; + NETWORK_NAME = "global/networks/default"; + SUBNETWORK_NAME = "regions/europe-central2/subnetworks/default"; ROUTE_NAME = "windows-test-route-" + uuid; stdOut.close(); @@ -115,7 +115,7 @@ public void testCreateWindowsServerInstanceInternalIp() INSTANCE_NAME_INTERNAL, NETWORK_NAME, SUBNETWORK_NAME); assertThat(stdOut.toString()).contains("Instance created " + INSTANCE_NAME_INTERNAL); CreateFirewallRuleForWindowsActivationHost.createFirewallRuleForWindowsActivationHost( - PROJECT_ID, ZONE, NETWORK_NAME); + PROJECT_ID, FIREWALL_RULE_NAME, NETWORK_NAME); assertThat(stdOut.toString()).contains( String.format("Firewall rule created %s", FIREWALL_RULE_NAME)); CreateRouteToWindowsActivationHost.createRouteToWindowsActivationHost(PROJECT_ID, ROUTE_NAME, From aec0f29e771fe5553fccf039b7965a115f01ec90 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Wed, 27 Apr 2022 17:12:31 +0530 Subject: [PATCH 135/136] added junit jupiter engine to run beforeeach and aftereach methods in parallel with mvn surefire tests --- .../CreatingManagingWindowsInstancesIT.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java index 566b293b5cb..68938cddb14 100644 --- a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java +++ b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java @@ -26,10 +26,10 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -53,7 +53,7 @@ public static void requireEnvVar(String envVarName) { .that(System.getenv(envVarName)).isNotEmpty(); } - @BeforeClass + @BeforeAll public static void setup() throws IOException, ExecutionException, InterruptedException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); @@ -83,13 +83,13 @@ public static void deleteRoute() throws IOException, ExecutionException, Interru } } - @Before + @BeforeEach public void beforeEach() { stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); } - @After + @AfterEach public void afterEach() { stdOut = null; System.setOut(null); From 483901053823389ddf2cc47ac9a40b6eac468d13 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Fri, 13 May 2022 12:14:18 +0530 Subject: [PATCH 136/136] added timeout for get methods and jupiter dependency --- ...eateFirewallRuleForWindowsActivationHost.java | 9 ++++++--- .../CreateRouteToWindowsActivationHost.java | 9 ++++++--- .../CreateWindowsServerInstanceExternalIp.java | 9 ++++++--- .../CreateWindowsServerInstanceInternalIp.java | 9 ++++++--- .../CreatingManagingWindowsInstancesIT.java | 16 +++++++++++----- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java index 1c5f0b6d748..b741c47fa0b 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateFirewallRuleForWindowsActivationHost.java @@ -23,11 +23,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateFirewallRuleForWindowsActivationHost { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId - ID or number of the project you want to use. String projectId = "your-google-cloud-project-id"; @@ -47,7 +49,7 @@ public static void main(String[] args) // kms.windows.googlecloud.com (35.190.247.13) for Windows activation. public static void createFirewallRuleForWindowsActivationHost(String projectId, String firewallRuleName, String networkName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // Instantiates a client. try (FirewallsClient firewallsClient = FirewallsClient.create()) { @@ -71,7 +73,8 @@ public static void createFirewallRuleForWindowsActivationHost(String projectId, .build(); // Wait for the operation to complete. - Operation operation = firewallsClient.insertAsync(request).get(); + Operation operation = firewallsClient.insertAsync(request).get(3, TimeUnit.MINUTES); + ; if (operation.hasError()) { System.out.println("Firewall rule creation failed ! ! " + operation.getError()); diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java index cd2169bce03..8c9cd06a57b 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateRouteToWindowsActivationHost.java @@ -22,11 +22,13 @@ import com.google.cloud.compute.v1.RoutesClient; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateRouteToWindowsActivationHost { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId - ID or number of the project you want to use. String projectId = "your-google-cloud-project-id"; @@ -45,7 +47,7 @@ public static void main(String[] args) // Creates a new route to kms.windows.googlecloud.com (35.190.247.13) for Windows activation. public static void createRouteToWindowsActivationHost(String projectId, String routeName, String networkName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // Instantiates a client. try (RoutesClient routesClient = RoutesClient.create()) { @@ -68,7 +70,8 @@ public static void createRouteToWindowsActivationHost(String projectId, String r .build(); // Wait for the operation to complete. - Operation operation = routesClient.insertAsync(request).get(); + Operation operation = routesClient.insertAsync(request).get(3, TimeUnit.MINUTES); + ; if (operation.hasError()) { System.out.printf("Error in creating route %s", operation.getError()); diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java index 237b741abdd..84367a26b57 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceExternalIp.java @@ -26,11 +26,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateWindowsServerInstanceExternalIp { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId - ID or number of the project you want to use. String projectId = "your-google-cloud-project-id"; @@ -47,7 +49,7 @@ public static void main(String[] args) // Creates a new Windows Server instance that has an external IP address. public static void createWindowsServerInstanceExternalIp(String projectId, String zone, String instanceName) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // machineType - Machine type you want to create in following format: // * "zones/{zone}/machineTypes/{type_name}". For example: @@ -105,7 +107,8 @@ public static void createWindowsServerInstanceExternalIp(String projectId, Strin .build(); // Wait for the operation to complete. - Operation operation = instancesClient.insertAsync(request).get(); + Operation operation = instancesClient.insertAsync(request).get(3, TimeUnit.MINUTES); + ; if (operation.hasError()) { System.out.printf("Error in creating instance %s", operation.getError()); diff --git a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java index 8338f7bd72d..f54e0a2aa1b 100644 --- a/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java +++ b/compute/cloud-client/src/main/java/compute/windows/windowsinstances/CreateWindowsServerInstanceInternalIp.java @@ -25,11 +25,13 @@ import com.google.cloud.compute.v1.Operation; import java.io.IOException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; public class CreateWindowsServerInstanceInternalIp { public static void main(String[] args) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // projectId - ID or number of the project you want to use. String projectId = "your-google-cloud-project-id"; @@ -57,7 +59,7 @@ public static void main(String[] args) // Creates a new Windows Server instance that has only an internal IP address. public static void createWindowsServerInstanceInternalIp(String projectId, String zone, String instanceName, String networkLink, String subnetworkLink) - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // machineType - Machine type you want to create in following format: // * "zones/{zone}/machineTypes/{type_name}". For example: @@ -116,7 +118,8 @@ public static void createWindowsServerInstanceInternalIp(String projectId, Strin .build(); // Wait for the operation to complete. - Operation operation = instancesClient.insertAsync(request).get(); + Operation operation = instancesClient.insertAsync(request).get(3, TimeUnit.MINUTES); + ; if (operation.hasError()) { System.out.printf("Error in creating instance %s", operation.getError()); diff --git a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java index 68938cddb14..7a0d33aa094 100644 --- a/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java +++ b/compute/cloud-client/src/test/java/compute/windows/windowsinstances/CreatingManagingWindowsInstancesIT.java @@ -26,14 +26,18 @@ import java.io.PrintStream; import java.util.UUID; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) +@Timeout(value = 10, unit = TimeUnit.MINUTES) public class CreatingManagingWindowsInstancesIT { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); @@ -54,7 +58,8 @@ public static void requireEnvVar(String envVarName) { } @BeforeAll - public static void setup() throws IOException, ExecutionException, InterruptedException { + public static void setup() + throws IOException, ExecutionException, InterruptedException, TimeoutException { final PrintStream out = System.out; ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdOut)); @@ -77,9 +82,10 @@ public static void setup() throws IOException, ExecutionException, InterruptedEx System.setOut(out); } - public static void deleteRoute() throws IOException, ExecutionException, InterruptedException { + public static void deleteRoute() + throws IOException, ExecutionException, InterruptedException, TimeoutException { try (RoutesClient routesClient = RoutesClient.create()) { - routesClient.deleteAsync(PROJECT_ID, ROUTE_NAME).get(); + routesClient.deleteAsync(PROJECT_ID, ROUTE_NAME).get(3, TimeUnit.MINUTES); } } @@ -97,7 +103,7 @@ public void afterEach() { @Test public void testCreateWindowsServerInstanceExternalIp() - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // Create Windows server instance with external IP. CreateWindowsServerInstanceExternalIp.createWindowsServerInstanceExternalIp(PROJECT_ID, ZONE, INSTANCE_NAME_EXTERNAL); @@ -109,7 +115,7 @@ public void testCreateWindowsServerInstanceExternalIp() @Test public void testCreateWindowsServerInstanceInternalIp() - throws IOException, ExecutionException, InterruptedException { + throws IOException, ExecutionException, InterruptedException, TimeoutException { // Create Windows server instance with internal IP and firewall rule. CreateWindowsServerInstanceInternalIp.createWindowsServerInstanceInternalIp(PROJECT_ID, ZONE, INSTANCE_NAME_INTERNAL, NETWORK_NAME, SUBNETWORK_NAME);