aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
diff options
context:
space:
mode:
authorGravatar olaola <olaola@google.com>2017-06-19 16:55:24 -0400
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-06-20 14:35:24 -0400
commitbfd1d3384b41ac9e563afe5c95afa010d8c19f4a (patch)
tree275fb466b04a28b668685655f7473d4b32f863da /src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
parent44dd226a540ace2ef1c348f778512616de82ce31 (diff)
Adding support for SHA256 for remote execution. Switch remote execution to use
the currently defined hash function for blobs. Some refactoring. Adding an option to set the hash function in the remote worker, defaulting to the current behavior (unfortunately it is a build option, have not found a clean way to specify it at runtime). BUG=62622420 TESTED=remote worker RELNOTES: none PiperOrigin-RevId: 159473116
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java b/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
index 20ef2cfd05..71d5edf88e 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
@@ -57,31 +57,17 @@ public class DigestUtilsTest {
FileSystem myfs = new InMemoryFileSystem(BlazeClock.instance()) {
@Override
- protected byte[] getMD5Digest(Path path) throws IOException {
+ protected byte[] getDigest(Path path, HashFunction hashFunction) throws IOException {
try {
barrierLatch.countDown();
readyLatch.countDown();
- // Either both threads will be inside getMD5Digest at the same time or they
+ // Either both threads will be inside getDigest at the same time or they
// both will be blocked.
barrierLatch.await();
} catch (Exception e) {
throw new IOException(e);
}
- return super.getMD5Digest(path);
- }
-
- @Override
- protected byte[] getSHA1Digest(Path path) throws IOException {
- try {
- barrierLatch.countDown();
- readyLatch.countDown();
- // Either both threads will be inside getSHA1Digest at the same time or they
- // both will be blocked.
- barrierLatch.await();
- } catch (Exception e) {
- throw new IOException(e);
- }
- return super.getSHA1Digest(path);
+ return super.getDigest(path, hashFunction);
}
@Override
@@ -111,9 +97,9 @@ public class DigestUtilsTest {
thread1.start();
thread2.start();
if (!expectConcurrent) { // Synchronized case.
- // Wait until at least one thread reached getMD5Digest().
+ // Wait until at least one thread reached getDigest().
assertThat(readyLatch.await(TestUtils.WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS)).isTrue();
- // Only 1 thread should be inside getMD5Digest().
+ // Only 1 thread should be inside getDigest().
assertThat(barrierLatch.getCount()).isEqualTo(1);
barrierLatch.countDown(); // Release barrier latch, allowing both threads to proceed.
}
@@ -123,8 +109,8 @@ public class DigestUtilsTest {
}
/**
- * Ensures that MD5 calculation is synchronized for files
- * greater than 4096 bytes if MD5 is not available cheaply,
+ * Ensures that digest calculation is synchronized for files
+ * greater than 4096 bytes if the digest is not available cheaply,
* so machines with rotating drives don't become unusable.
*/
@Test
@@ -240,9 +226,9 @@ public class DigestUtilsTest {
}
@Override
- protected byte[] getDigest(Path path) throws IOException {
+ protected byte[] getDigest(Path path, HashFunction hashFunction) throws IOException {
getDigestCounter.incrementAndGet();
- return super.getDigest(path);
+ return super.getDigest(path, hashFunction);
}
};