Skip to content

Commit

Permalink
try maxDownloadTime for connection timed out test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking committed Sep 30, 2023
1 parent b53a953 commit 21bc3cf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/it/tests/basic-it/windows/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<property name="bootProp" value="${basedir}/src/test/resources/bootstrap.properties" />

<target name="installServer">
<wlp:install-liberty licenseCode="${wlp.license}" version="${wlp.version}" basedir="${target.dir}" maxDownloadTime="120" />
<wlp:install-liberty licenseCode="${wlp.license}" version="${wlp.version}" basedir="${target.dir}" maxDownloadTime="120" skipDownloadIfExisting="true" />
</target>

<target name="createServer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public class InstallLibertyTask extends AbstractTask {
private String runtimeUrl;
private String username;
private String password;
private long maxDownloadTime;
private String maxDownloadTime;
private boolean offline;
private boolean useOpenLiberty;
private boolean skipDownloadIfExisting;

private boolean skipAlreadyInstalledCheck = false;

Expand Down Expand Up @@ -98,10 +99,14 @@ private void doExecute() throws Exception {
}

protected void downloadFile(URL source, File dest) throws IOException {
downloadFile(source, dest, false);
}

protected void downloadFile(URL source, File dest, boolean skipExisting) throws IOException {
if (offline) {
offlineDownload(source, dest);
} else {
onlineDownload(source, dest);
onlineDownload(source, dest, skipExisting);
}
}

Expand All @@ -113,7 +118,11 @@ private void offlineDownload(URL source, File dest) throws IOException {
}
}

private void onlineDownload(URL source, File dest) throws IOException {
private void onlineDownload(URL source, File dest, boolean skipExisting) throws IOException {
if (skipExisting && dest.exists()) {
return;
}

Get get = (Get) getProject().createTask("get");
DownloadProgress progress = null;
if (verbose) {
Expand All @@ -122,7 +131,7 @@ private void onlineDownload(URL source, File dest) throws IOException {
get.setUseTimestamp(true);
get.setUsername(username);
get.setPassword(password);
get.setMaxTime(maxDownloadTime);
get.setMaxTime(getMaxDownloadTime());
get.setRetries(5);
get.doGet(source, dest, Project.MSG_INFO, progress);
}
Expand Down Expand Up @@ -232,10 +241,18 @@ public void setPassword(String password) {
}

public long getMaxDownloadTime() {
return maxDownloadTime;
if (maxDownloadTime == null) {
return 0;
} else {
return Long.parseLong(maxDownloadTime);
}
}

public void setMaxDownloadTime(long maxDownloadTime) {
this.maxDownloadTime = Long.toString(maxDownloadTime);
}

public void setMaxDownloadTime(String maxDownloadTime) {
this.maxDownloadTime = maxDownloadTime;
}

Expand All @@ -262,4 +279,12 @@ public void setSkipAlreadyInstalledCheck(boolean skipAlreadyInstalledCheck) {
public boolean getSkipAlreadyInstalledCheck() {
return skipAlreadyInstalledCheck;
}

public boolean getSkipDownloadIfExisting() {
return skipDownloadIfExisting;
}

public void setSkipDownloadIfExisting(boolean skipDownloadIfExisting) {
this.skipDownloadIfExisting = skipDownloadIfExisting;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void install(InstallLibertyTask task) throws Exception {

// Download version json file
File versionInfoFile = new File(cacheDir, "openliberty-versions.json");
task.downloadFile(versionInfoUrl, versionInfoFile);
task.downloadFile(versionInfoUrl, versionInfoFile, task.getSkipDownloadIfExisting());

// Parse JSON
InputStream versionInfoIs = new FileInputStream(versionInfoFile);
Expand All @@ -53,7 +53,7 @@ public void install(InstallLibertyTask task) throws Exception {
String versionUrl = baseUrl + version + "/";
URL runtimeInfoUrl = new URL(versionUrl + "info.json");
File runtimeInfoFile = new File(cacheDir, version + ".json");
task.downloadFile(runtimeInfoUrl, runtimeInfoFile);
task.downloadFile(runtimeInfoUrl, runtimeInfoFile, task.getSkipDownloadIfExisting());

// Parse JSON
InputStream runtimeInfoIs = new FileInputStream(runtimeInfoFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void install(InstallLibertyTask task) throws Exception {
// download yml file
URL ymlURL = new URL(url);
File ymlFile = new File(cacheDir, InstallUtils.getFile(ymlURL));
task.downloadFile(ymlURL, ymlFile);
task.downloadFile(ymlURL, ymlFile, task.getSkipDownloadIfExisting());

// parse yml
List<LibertyInfo> versions = LibertyYaml.parse(ymlFile);
Expand Down

0 comments on commit 21bc3cf

Please sign in to comment.