From 5238be8779238518d1a2190e42c9b0c36e8785d3 Mon Sep 17 00:00:00 2001
From: jiangmichaellll <40044148+jiangmichaellll@users.noreply.github.com>
Date: Mon, 12 Apr 2021 17:24:21 -0400
Subject: [PATCH] chore(deps): update dependency
com.google.cloud.samples:shared-configuration to v1.0.22 (#144)
---
.kokoro/build.sh | 3 -
samples/pom.xml | 2 +-
samples/snapshot/pom.xml | 2 +-
samples/snippets/pom.xml | 2 +-
.../java/pubsublite/spark/SampleTestBase.java | 72 ++++++++++++-------
.../spark/SamplesIntegrationTest.java | 1 +
versions.txt | 1 -
7 files changed, 52 insertions(+), 31 deletions(-)
diff --git a/.kokoro/build.sh b/.kokoro/build.sh
index 0deb86dc..00089722 100755
--- a/.kokoro/build.sh
+++ b/.kokoro/build.sh
@@ -78,9 +78,6 @@ samples)
if [[ -f ${SAMPLES_DIR}/pom.xml ]]
then
- # get versions for constructing the full names of the packaged JARs
- export CONNECTOR_VERSION=$(grep pubsublite-spark-sql-streaming ${scriptDir}/../versions.txt | cut -d: -f3)
- export SAMPLE_VERSION=$(grep com.google.cloud.samples.shared-configuration: ${scriptDir}/../versions.txt | cut -d: -f3)
if [ -f "${KOKORO_GFILE_DIR}/secret_manager/java-pubsublite-spark-samples-secrets" ]
then
source "${KOKORO_GFILE_DIR}/secret_manager/java-pubsublite-spark-samples-secrets"
diff --git a/samples/pom.xml b/samples/pom.xml
index 9beedc36..239a13c7 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -17,7 +17,7 @@
com.google.cloud.samples
shared-configuration
- 1.0.21
+ 1.0.22
diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml
index dac341b7..41f7156f 100644
--- a/samples/snapshot/pom.xml
+++ b/samples/snapshot/pom.xml
@@ -14,7 +14,7 @@
com.google.cloud.samples
shared-configuration
- 1.0.21
+ 1.0.22
diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml
index 6e60540f..e8e620ae 100644
--- a/samples/snippets/pom.xml
+++ b/samples/snippets/pom.xml
@@ -14,7 +14,7 @@
com.google.cloud.samples
shared-configuration
- 1.0.21
+ 1.0.22
diff --git a/samples/snippets/src/test/java/pubsublite/spark/SampleTestBase.java b/samples/snippets/src/test/java/pubsublite/spark/SampleTestBase.java
index 6086b2cc..9c83b3cb 100644
--- a/samples/snippets/src/test/java/pubsublite/spark/SampleTestBase.java
+++ b/samples/snippets/src/test/java/pubsublite/spark/SampleTestBase.java
@@ -33,17 +33,20 @@
import com.google.cloud.storage.BlobId;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Storage;
-import com.google.common.collect.ImmutableList;
+import com.google.common.flogger.GoogleLogger;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.Arrays;
import java.util.Map;
+import java.util.Optional;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.shared.invoker.DefaultInvocationRequest;
import org.apache.maven.shared.invoker.DefaultInvoker;
+import org.apache.maven.shared.invoker.InvocationOutputHandler;
import org.apache.maven.shared.invoker.InvocationRequest;
import org.apache.maven.shared.invoker.InvocationResult;
import org.apache.maven.shared.invoker.Invoker;
@@ -52,6 +55,8 @@
public abstract class SampleTestBase {
+ private static final GoogleLogger log = GoogleLogger.forEnclosingClass();
+
private static final String CLOUD_REGION = "CLOUD_REGION";
private static final String CLOUD_ZONE = "CLOUD_ZONE";
private static final String PROJECT_NUMBER = "GOOGLE_CLOUD_PROJECT_NUMBER";
@@ -59,8 +64,6 @@ public abstract class SampleTestBase {
private static final String TOPIC_ID = "TOPIC_ID";
private static final String CLUSTER_NAME = "CLUSTER_NAME";
private static final String BUCKET_NAME = "BUCKET_NAME";
- private static final String SAMPLE_VERSION = "SAMPLE_VERSION";
- private static final String CONNECTOR_VERSION = "CONNECTOR_VERSION";
protected final String runId = UUID.randomUUID().toString();
protected CloudRegion cloudRegion;
@@ -91,32 +94,14 @@ protected void setupEnvVars() {
PROJECT_NUMBER,
TOPIC_ID,
CLUSTER_NAME,
- BUCKET_NAME,
- SAMPLE_VERSION,
- CONNECTOR_VERSION);
+ BUCKET_NAME);
cloudRegion = CloudRegion.of(env.get(CLOUD_REGION));
cloudZone = CloudZone.of(cloudRegion, env.get(CLOUD_ZONE).charAt(0));
projectId = ProjectId.of(env.get(PROJECT_ID));
projectNumber = ProjectNumber.of(Long.parseLong(env.get(PROJECT_NUMBER)));
sourceTopicId = TopicName.of(env.get(TOPIC_ID));
-
clusterName = env.get(CLUSTER_NAME);
bucketName = env.get(BUCKET_NAME);
- workingDir =
- System.getProperty("user.dir")
- .replace("/samples/snapshot", "")
- .replace("/samples/snippets", "");
- sampleVersion = env.get(SAMPLE_VERSION);
- connectorVersion = env.get(CONNECTOR_VERSION);
- sampleJarName = String.format("pubsublite-spark-snippets-%s.jar", sampleVersion);
- connectorJarName =
- String.format("pubsublite-spark-sql-streaming-%s-with-dependencies.jar", connectorVersion);
- sampleJarNameInGCS = String.format("pubsublite-spark-snippets-%s-%s.jar", sampleVersion, runId);
- connectorJarNameInGCS =
- String.format(
- "pubsublite-spark-sql-streaming-%s-with-dependencies-%s.jar", connectorVersion, runId);
- sampleJarLoc = String.format("%s/samples/snippets/target/%s", workingDir, sampleJarName);
- connectorJarLoc = String.format("%s/target/%s", workingDir, connectorJarName);
}
protected void findMavenHome() throws Exception {
@@ -131,12 +116,14 @@ protected void findMavenHome() throws Exception {
}
}
- protected void mavenPackage(String workingDir)
+ private void runMavenCommand(
+ String workingDir, Optional outputHandler, String... goals)
throws MavenInvocationException, CommandLineException {
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(new File(workingDir + "/pom.xml"));
- request.setGoals(ImmutableList.of("clean", "package", "-Dmaven.test.skip=true"));
+ request.setGoals(Arrays.asList(goals.clone()));
Invoker invoker = new DefaultInvoker();
+ outputHandler.ifPresent(invoker::setOutputHandler);
invoker.setMavenHome(new File(mavenHome));
InvocationResult result = invoker.execute(request);
if (result.getExecutionException() != null) {
@@ -145,6 +132,43 @@ protected void mavenPackage(String workingDir)
assertThat(result.getExitCode()).isEqualTo(0);
}
+ protected void mavenPackage(String workingDir)
+ throws MavenInvocationException, CommandLineException {
+ runMavenCommand(workingDir, Optional.empty(), "clean", "package", "-Dmaven.test.skip=true");
+ }
+
+ private void getVersion(String workingDir, InvocationOutputHandler outputHandler)
+ throws MavenInvocationException, CommandLineException {
+ runMavenCommand(
+ workingDir,
+ Optional.of(outputHandler),
+ "-q",
+ "-Dexec.executable=echo",
+ "-Dexec.args='${project.version}'",
+ "--non-recursive",
+ "exec:exec");
+ }
+
+ protected void setupVersions() throws MavenInvocationException, CommandLineException {
+ workingDir =
+ System.getProperty("user.dir")
+ .replace("/samples/snapshot", "")
+ .replace("/samples/snippets", "");
+ getVersion(workingDir, (l) -> connectorVersion = l);
+ log.atInfo().log("Connector version is: %s", connectorVersion);
+ getVersion(workingDir + "/samples", (l) -> sampleVersion = l);
+ log.atInfo().log("Sample version is: %s", sampleVersion);
+ sampleJarName = String.format("pubsublite-spark-snippets-%s.jar", sampleVersion);
+ connectorJarName =
+ String.format("pubsublite-spark-sql-streaming-%s-with-dependencies.jar", connectorVersion);
+ sampleJarNameInGCS = String.format("pubsublite-spark-snippets-%s-%s.jar", sampleVersion, runId);
+ connectorJarNameInGCS =
+ String.format(
+ "pubsublite-spark-sql-streaming-%s-with-dependencies-%s.jar", connectorVersion, runId);
+ sampleJarLoc = String.format("%s/samples/snippets/target/%s", workingDir, sampleJarName);
+ connectorJarLoc = String.format("%s/target/%s", workingDir, connectorJarName);
+ }
+
protected void uploadGCS(Storage storage, String fileNameInGCS, String fileLoc) throws Exception {
BlobId blobId = BlobId.of(bucketName, fileNameInGCS);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).build();
diff --git a/samples/snippets/src/test/java/pubsublite/spark/SamplesIntegrationTest.java b/samples/snippets/src/test/java/pubsublite/spark/SamplesIntegrationTest.java
index 7be0f801..50ff198c 100644
--- a/samples/snippets/src/test/java/pubsublite/spark/SamplesIntegrationTest.java
+++ b/samples/snippets/src/test/java/pubsublite/spark/SamplesIntegrationTest.java
@@ -63,6 +63,7 @@ public void beforeClass() throws Exception {
log.atInfo().log("RunId is: %s", runId);
setupEnvVars();
findMavenHome();
+ setupVersions();
// Maven package into jars
mavenPackage(workingDir);
diff --git a/versions.txt b/versions.txt
index b62cf13b..01dcba34 100644
--- a/versions.txt
+++ b/versions.txt
@@ -2,4 +2,3 @@
# module:released-version:current-version
pubsublite-spark-sql-streaming:0.1.0:0.1.1-SNAPSHOT
-com.google.cloud.samples.shared-configuration:1.0.21:1.0.21