Skip to content

Commit 4e6edcb

Browse files
authored
chore: remove the archive jar file & download it (#226)
1 parent 075ea17 commit 4e6edcb

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

computer-test/conf/images/test.jar

-1.54 KB
Binary file not shown.

computer-test/src/main/java/org/apache/hugegraph/computer/k8s/KubernetesDriverTest.java

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.FileNotFoundException;
2323
import java.io.IOException;
2424
import java.io.InputStream;
25+
import java.net.URL;
2526
import java.util.HashMap;
2627
import java.util.Map;
2728
import java.util.UUID;
@@ -147,13 +148,14 @@ public void testConstruct() {
147148

148149
@Test
149150
public void testUploadAlgorithmJar() throws FileNotFoundException {
150-
Whitebox.setInternalState(this.driver, "bashPath",
151-
"conf/images/docker_push_test.sh");
152-
Whitebox.setInternalState(this.driver, "registry",
153-
"registry.hub.docker.com");
154-
155-
InputStream inputStream = new FileInputStream(
156-
"conf/images/test.jar");
151+
Whitebox.setInternalState(this.driver, "bashPath", "conf/images/docker_push_test.sh");
152+
Whitebox.setInternalState(this.driver, "registry", "registry.hub.docker.com");
153+
String url = "https://github.com/apache/hugegraph-doc/raw/" +
154+
"binary-1.0/dist/computer/test.jar";
155+
String path = "conf/images/test.jar";
156+
downloadFileByUrl(url, path);
157+
158+
InputStream inputStream = new FileInputStream(path);
157159
this.driver.uploadAlgorithmJar("PageRank", inputStream);
158160

159161
File file = new File("/tmp/upload.txt");
@@ -166,12 +168,13 @@ public void testUploadAlgorithmJar() throws FileNotFoundException {
166168

167169
@Test
168170
public void testUploadAlgorithmJarWithError() throws FileNotFoundException {
169-
Whitebox.setInternalState(this.driver, "bashPath",
170-
"conf/images/upload_test-x.sh");
171-
172-
InputStream inputStream = new FileInputStream(
173-
"conf/images/test.jar");
171+
Whitebox.setInternalState(this.driver, "bashPath", "conf/images/upload_test-x.sh");
172+
String url = "https://github.com/apache/hugegraph-doc/raw/" +
173+
"binary-1.0/dist/computer/test.jar";
174+
String path = "conf/images/test.jar";
175+
downloadFileByUrl(url, path);
174176

177+
InputStream inputStream = new FileInputStream(path);
175178
Assert.assertThrows(ComputerDriverException.class, () -> {
176179
this.driver.uploadAlgorithmJar("PageRank", inputStream);
177180
}, e -> {
@@ -315,4 +318,14 @@ public void testCheckComputerConf() {
315318
);
316319
});
317320
}
321+
322+
public static void downloadFileByUrl(String url, String destPath) {
323+
int connectTimeout = 5000;
324+
int readTimeout = 10000;
325+
try {
326+
FileUtils.copyURLToFile(new URL(url), new File(destPath), connectTimeout, readTimeout);
327+
} catch (IOException e) {
328+
throw new RuntimeException(e);
329+
}
330+
}
318331
}

0 commit comments

Comments
 (0)