You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by ji...@apache.org on 2023/01/17 02:25:36 UTC
[incubator-hugegraph-computer] branch master updated: chore: remove the archive jar file & download it (#226)
This is an automated email from the ASF dual-hosted git repository.
jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-computer.git
The following commit(s) were added to refs/heads/master by this push:
new 4e6edcb9 chore: remove the archive jar file & download it (#226)
4e6edcb9 is described below
commit 4e6edcb9df9f80997799344a5351564f7695b621
Author: imbajin <ji...@apache.org>
AuthorDate: Tue Jan 17 10:25:30 2023 +0800
chore: remove the archive jar file & download it (#226)
---
computer-test/conf/images/test.jar | Bin 1576 -> 0 bytes
.../computer/k8s/KubernetesDriverTest.java | 37 ++++++++++++++-------
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/computer-test/conf/images/test.jar b/computer-test/conf/images/test.jar
deleted file mode 100644
index 3b0502e8..00000000
Binary files a/computer-test/conf/images/test.jar and /dev/null differ
diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/KubernetesDriverTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/KubernetesDriverTest.java
index 1f6a3469..7ac3e6cb 100644
--- a/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/KubernetesDriverTest.java
+++ b/computer-test/src/main/java/org/apache/hugegraph/computer/k8s/KubernetesDriverTest.java
@@ -22,6 +22,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -147,13 +148,14 @@ public class KubernetesDriverTest extends AbstractK8sTest {
@Test
public void testUploadAlgorithmJar() throws FileNotFoundException {
- Whitebox.setInternalState(this.driver, "bashPath",
- "conf/images/docker_push_test.sh");
- Whitebox.setInternalState(this.driver, "registry",
- "registry.hub.docker.com");
-
- InputStream inputStream = new FileInputStream(
- "conf/images/test.jar");
+ Whitebox.setInternalState(this.driver, "bashPath", "conf/images/docker_push_test.sh");
+ Whitebox.setInternalState(this.driver, "registry", "registry.hub.docker.com");
+ String url = "https://github.com/apache/hugegraph-doc/raw/" +
+ "binary-1.0/dist/computer/test.jar";
+ String path = "conf/images/test.jar";
+ downloadFileByUrl(url, path);
+
+ InputStream inputStream = new FileInputStream(path);
this.driver.uploadAlgorithmJar("PageRank", inputStream);
File file = new File("/tmp/upload.txt");
@@ -166,12 +168,13 @@ public class KubernetesDriverTest extends AbstractK8sTest {
@Test
public void testUploadAlgorithmJarWithError() throws FileNotFoundException {
- Whitebox.setInternalState(this.driver, "bashPath",
- "conf/images/upload_test-x.sh");
-
- InputStream inputStream = new FileInputStream(
- "conf/images/test.jar");
+ Whitebox.setInternalState(this.driver, "bashPath", "conf/images/upload_test-x.sh");
+ String url = "https://github.com/apache/hugegraph-doc/raw/" +
+ "binary-1.0/dist/computer/test.jar";
+ String path = "conf/images/test.jar";
+ downloadFileByUrl(url, path);
+ InputStream inputStream = new FileInputStream(path);
Assert.assertThrows(ComputerDriverException.class, () -> {
this.driver.uploadAlgorithmJar("PageRank", inputStream);
}, e -> {
@@ -315,4 +318,14 @@ public class KubernetesDriverTest extends AbstractK8sTest {
);
});
}
+
+ public static void downloadFileByUrl(String url, String destPath) {
+ int connectTimeout = 5000;
+ int readTimeout = 10000;
+ try {
+ FileUtils.copyURLToFile(new URL(url), new File(destPath), connectTimeout, readTimeout);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
}