Skip to content

Commit

Permalink
[FLINK-19158][e2e] Fix wget timeout mechanism and cache config
Browse files Browse the repository at this point in the history
This closes apache#14694
  • Loading branch information
rmetzger committed Jan 20, 2021
1 parent c6b3799 commit c96c395
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.flink.tests.util;

import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -35,6 +36,7 @@ public static final class WGetBuilder {

private final String url;
private Path targetDir;
private long timeoutSecs;

WGetBuilder(String url) {
this.url = url;
Expand All @@ -45,6 +47,11 @@ public WGetBuilder targetDir(Path dir) {
return this;
}

public WGetBuilder timeoutSecs(Duration timeout) {
this.timeoutSecs = timeout.getSeconds();
return this;
}

public String[] build() {
final List<String> commandsList = new ArrayList<>(5);
commandsList.add("wget");
Expand All @@ -54,6 +61,10 @@ public String[] build() {
commandsList.add("-P");
commandsList.add(targetDir.toAbsolutePath().toString());
}
if (timeoutSecs > 0) {
commandsList.add("--timeout");
commandsList.add(Long.toString(timeoutSecs));
}
commandsList.add(url);
return commandsList.toArray(new String[commandsList.size()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ public Path getOrDownload(final String url, final Path targetDir) throws IOExcep
Files.createDirectories(scopedDownloadDir);
log.info("Downloading {}.", url);
AutoClosableProcess.create(
CommandLineWrapper.wget(url).targetDir(scopedDownloadDir).build())
CommandLineWrapper.wget(url)
.targetDir(scopedDownloadDir)
.timeoutSecs(downloadAttemptTimeout)
.build())
.runBlockingWithRetry(
downloadMaxRetries, downloadAttemptTimeout, downloadGlobalTimeout);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public final class PersistingDownloadCache extends AbstractDownloadCache {
public PersistingDownloadCache(final Path path, final Period ttl) {
super(path);
this.ttl = ttl;
log.info("Using PersistingDownloadCache with path {} and ttl {}", path, ttl);
}

@Override
Expand Down

0 comments on commit c96c395

Please sign in to comment.