aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@verizonmedia.com>2021-06-21 21:53:06 +0200
committerGitHub <noreply@github.com>2021-06-21 21:53:06 +0200
commit8588e7ccf1f2b747bf3b5ac12a786dba3c330dde (patch)
tree121c7e4ce5b68faca6d1fe4a096327ae93325faa
parentb11d4b8247201ccad1bf151ae80ee761a6d6ce99 (diff)
parent0a24b7e4a9346b65b62fd8cc7121e1bb3e196910 (diff)
Merge pull request #18353 from vespa-engine/hmusum/debug-failing-unit-test
Debug unstable unit test
-rw-r--r--filedistribution/src/main/java/com/yahoo/vespa/filedistribution/Downloads.java5
-rw-r--r--filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java23
2 files changed, 17 insertions, 11 deletions
diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/Downloads.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/Downloads.java
index eb0976edc40..d364e9ec48d 100644
--- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/Downloads.java
+++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/Downloads.java
@@ -104,6 +104,11 @@ public class Downloads {
return Map.copyOf(downloadStatus);
}
+ @Override
+ public String toString() {
+ return downloadStatus.entrySet().stream().map(entry -> entry.getKey().value() + "=>" + entry.getValue().progress).collect(Collectors.joining(", "));
+ }
+
}
static class DownloadStatus {
diff --git a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java
index c4848140b2d..287cc7a74f3 100644
--- a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java
+++ b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java
@@ -112,7 +112,7 @@ public class FileDownloaderTest {
// Receives fileReference, should return and make it available to caller
String filename = "abc.jar";
- receiveFile(fileDownloader, fileReference, filename, FileReferenceData.Type.file, "some other content");
+ receiveFile(fileReference, filename, FileReferenceData.Type.file, "some other content");
Optional<File> downloadedFile = fileDownloader.getFile(fileReference);
assertTrue(downloadedFile.isPresent());
@@ -121,6 +121,8 @@ public class FileDownloaderTest {
assertEquals("some other content", IOUtils.readFile(downloadedFile.get()));
// Verify download status when downloaded
+ System.out.println(downloads.downloadStatuses());
+ double downloadStatus = downloads.downloadStatus(fileReference);
assertDownloadStatus(fileReference, 1.0);
}
@@ -146,7 +148,7 @@ public class FileDownloaderTest {
File tarFile = CompressedFileReference.compress(tempPath.toFile(), Arrays.asList(fooFile, barFile), new File(tempPath.toFile(), filename));
byte[] tarredContent = IOUtils.readFileBytes(tarFile);
- receiveFile(fileDownloader, fileReference, filename, FileReferenceData.Type.compressed, tarredContent);
+ receiveFile(fileReference, filename, FileReferenceData.Type.compressed, tarredContent);
Optional<File> downloadedFile = fileDownloader.getFile(fileReference);
assertTrue(downloadedFile.isPresent());
@@ -179,7 +181,7 @@ public class FileDownloaderTest {
// Receives fileReference, should return and make it available to caller
String filename = "abc.jar";
- receiveFile(fileDownloader, fileReference, filename, FileReferenceData.Type.file, "some other content");
+ receiveFile(fileReference, filename, FileReferenceData.Type.file, "some other content");
Optional<File> downloadedFile = fileDownloader.getFile(fileReference);
assertTrue(downloadedFile.isPresent());
File downloadedFileFullPath = new File(fileReferenceFullPath, filename);
@@ -216,7 +218,7 @@ public class FileDownloaderTest {
Future<Future<Optional<File>>> future2 = executor.submit(() -> fileDownloader.getFutureFile(fileReferenceDownload));
// Receive file, will complete downloading and futures
- receiveFile(fileDownloader, fileReference, filename, FileReferenceData.Type.file, "some other content");
+ receiveFile(fileReference, filename, FileReferenceData.Type.file, "some other content");
// Check that we got file correctly with first request
Optional<File> downloadedFile = future1.get().get();
@@ -232,7 +234,7 @@ public class FileDownloaderTest {
}
@Test
- public void setFilesToDownload() throws IOException {
+ public void setFilesToDownload() {
Duration timeout = Duration.ofMillis(200);
MockConnection connectionPool = new MockConnection();
connectionPool.setResponseHandler(new MockConnection.WaitResponseHandler(timeout.plus(Duration.ofMillis(1000))));
@@ -243,7 +245,7 @@ public class FileDownloaderTest {
assertTrue(fileDownloader.isDownloading(xyzzy));
assertFalse(fileDownloader.getFile(xyzzy).isPresent());
// Receive files to simulate download
- receiveFile(fileDownloader, xyzzy, "xyzzy.jar", FileReferenceData.Type.file, "content");
+ receiveFile(xyzzy, "xyzzy.jar", FileReferenceData.Type.file, "content");
// Should not download, since file has already been downloaded
fileDownloader.downloadIfNeeded(new FileReferenceDownload(xyzzy));
// and file should be available
@@ -254,7 +256,7 @@ public class FileDownloaderTest {
public void receiveFile() throws IOException {
FileReference foobar = new FileReference("foobar");
String filename = "foo.jar";
- receiveFile(fileDownloader, foobar, filename, FileReferenceData.Type.file, "content");
+ receiveFile(foobar, filename, FileReferenceData.Type.file, "content");
File downloadedFile = new File(fileReferenceFullPath(downloadDir, foobar), filename);
assertEquals("content", IOUtils.readFile(downloadedFile));
}
@@ -275,12 +277,11 @@ public class FileDownloaderTest {
assertEquals(expectedDownloadStatus, downloadStatus, 0.0001);
}
- private void receiveFile(FileDownloader fileDownloader, FileReference fileReference, String filename,
- FileReferenceData.Type type, String content) {
- receiveFile(fileDownloader, fileReference, filename, type, Utf8.toBytes(content));
+ private void receiveFile(FileReference fileReference, String filename, FileReferenceData.Type type, String content) {
+ receiveFile(fileReference, filename, type, Utf8.toBytes(content));
}
- private void receiveFile(FileDownloader fileDownloader, FileReference fileReference, String filename,
+ private void receiveFile(FileReference fileReference, String filename,
FileReferenceData.Type type, byte[] content) {
XXHash64 hasher = XXHashFactory.fastestInstance().hash64();
FileReceiver.Session session =