From 64ffc728027adcf9259d0cd5f756f85baf4f6826 Mon Sep 17 00:00:00 2001 From: imbajin Date: Mon, 16 Jan 2023 23:31:52 +0800 Subject: [PATCH] chore: remove the archive jar file & download it --- computer-test/conf/images/test.jar | Bin 1576 -> 0 bytes .../computer/k8s/KubernetesDriverTest.java | 37 ++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) delete mode 100644 computer-test/conf/images/test.jar diff --git a/computer-test/conf/images/test.jar b/computer-test/conf/images/test.jar deleted file mode 100644 index 3b0502e8c8614be6c30e6f46a5554ccff098d3b0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1576 zcmWIWW@h1H00HYM_kzF-D8UJ&eO*Hwbv^yu^aG&EI2f#e%Jy_Ptjz*SHvq8+vNB&s zKTkK;;1E4ux6i(3PWyQ4>RsgZ*3~+9=KSU$gDb`lo)+nNojal9t?R_W{$xqm6fx}s zDiu5Dco`RamCV&zE3#@*<<2?XLBifa!3S!NHywG>6T*7`$fhectjV^k(Q?O5BMm_0EJFt=fPfgjmzxrt?|d2o+lDptl+oSdJlmz0>9QmU6xnx2|o zlvt2~#{e_p3;-HhP+F2&q??$No?nz%l93BHlY`+y_3EI|Wf#_qGBPk2GBGgNl5J)I z(CrnuIjs|Yy^k0Ow7vf;s`_0m_N#*G+j}gD;;i-`q$Y3dHIY|&SysPK@orhP`(dmCuoUP_0A*53XeR_<+?NFX6P?C#nns2&ERQXiNf3@F?uoS}qPW1QpJG2)A!?_BG zT__6gf};F_)S{Bi)MC|>8@Ub{2ryjuyYJD0V&_W=9t$ToYgmL9>@!Oj+Tdw1xv75r zgC7-lX9{zNmhGtd;AXAYQ~;FaT^HA zp%4IajUh0Pp}7W|fmrh^%ns~17G}$m##XZJfaYIB;9^g#2&=vViwp9+1F{N{bOXFu R*+8bU1EB}d%u~!D9snBw@fQF9 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 8dd505352..ccaefc3fa 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 @@ -23,6 +23,7 @@ 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; @@ -148,13 +149,14 @@ public void testConstruct() { @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"); @@ -167,12 +169,13 @@ public void testUploadAlgorithmJar() throws FileNotFoundException { @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 -> { @@ -316,4 +319,14 @@ public void testCheckComputerConf() { ); }); } + + 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); + } + } }