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 659e08b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 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
2 changes: 1 addition & 1 deletion src/it/tests/install-server-it/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<property name="servername" value="wlp.ant.test" />

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

<delete dir="${wlp.usr.dir}" />
<delete dir="${wlp.output.dir}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void install(InstallLibertyTask task, File cacheDir, String url) throws
task.checkLicenseSet();

// download Liberty jar
task.downloadFile(downloadURL, cachedFile);
task.downloadFile(downloadURL, cachedFile, task.getSkipDownloadIfExisting());

// do license check
task.checkLicense(getLicenseCode(cachedFile));
Expand All @@ -91,7 +91,7 @@ private void install(InstallLibertyTask task, File cacheDir, String url) throws
task.installLiberty(cachedFile);
} else {
// download zip file
task.downloadFile(downloadURL, cachedFile);
task.downloadFile(downloadURL, cachedFile, task.getSkipDownloadIfExisting());

// unzip
task.unzipLiberty(cachedFile);
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 Expand Up @@ -93,7 +93,7 @@ public void install(InstallLibertyTask task) throws Exception {

URL runtimeUrl = new URL(runtimeUrlString);
File runtimeFile = new File(versionCacheDir, InstallUtils.getFile(runtimeUrl));
task.downloadFile(runtimeUrl, runtimeFile);
task.downloadFile(runtimeUrl, runtimeFile, task.getSkipDownloadIfExisting());

if(runtimeUrlString.endsWith(".jar")) {
task.installLiberty(runtimeFile);
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 Expand Up @@ -103,23 +103,23 @@ public void install(InstallLibertyTask task) throws Exception {
// download license
URL licenseURL = new URL(selectedVersion.getLicenseUri());
File licenseFile = new File(versionCacheDir, InstallUtils.getFile(licenseURL));
task.downloadFile(licenseURL, licenseFile);
task.downloadFile(licenseURL, licenseFile, task.getSkipDownloadIfExisting());

// do license check
task.checkLicense(InstallUtils.getLicenseCode(licenseFile, LICENSE_REGEX));

// download Liberty jar
URL libertyURL = new URL(uri);
File libertyFile = new File(versionCacheDir, InstallUtils.getFile(libertyURL));
task.downloadFile(libertyURL, libertyFile);
task.downloadFile(libertyURL, libertyFile, task.getSkipDownloadIfExisting());

// install Liberty jar
task.installLiberty(libertyFile);
} else if(uri.endsWith(".zip")) {
// download zip file
URL libertyURL = new URL(uri);
File libertyFile = new File(versionCacheDir, InstallUtils.getFile(libertyURL));
task.downloadFile(libertyURL, libertyFile);
task.downloadFile(libertyURL, libertyFile, task.getSkipDownloadIfExisting());

// unzip
task.unzipLiberty(libertyFile);
Expand Down

0 comments on commit 659e08b

Please sign in to comment.