Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cadc-test-vos/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sourceCompatibility = 11

group = 'org.opencadc'

version = '2.1.13'
version = '2.1.14'

description = 'OpenCADC VOSpace test library'
def git_url = 'https://github.com/opencadc/vos'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@
import ca.nrc.cadc.net.HttpGet;
import ca.nrc.cadc.net.HttpPost;
import ca.nrc.cadc.net.HttpUpload;
import ca.nrc.cadc.net.PreconditionFailedException;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.RegistryClient;
import ca.nrc.cadc.util.HexUtil;
import ca.nrc.cadc.uws.ExecutionPhase;
import ca.nrc.cadc.uws.Job;
import ca.nrc.cadc.uws.JobReader;
Expand All @@ -90,6 +92,8 @@
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.security.MessageDigest;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -182,7 +186,6 @@ private void verifyPushPull(URI testURI) throws Exception {
URL putURL = null;
for (Protocol p : details.getProtocols()) {
String endpoint = p.getEndpoint();
log.info("PUT endpoint: " + endpoint);
try {

URL u = new URL(endpoint);
Expand All @@ -198,13 +201,35 @@ private void verifyPushPull(URI testURI) throws Exception {
// put the bytes
Random rnd = new Random();
byte[] data = new byte[1024];
long datalen = (long) data.length;
rnd.nextBytes(data);
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(data);
URI digestURI = URI.create("md5:" + HexUtil.toHex(md5.digest()));

// attempt to put with checksum mismatches
rnd.nextBytes(data);
log.info("PUT: " + putURL + " " + digestURI);
FileContent content = new FileContent(data, "application/octet-stream");
HttpUpload put = new HttpUpload(content, putURL);
put.setDigest(digestURI);
put.run();
log.info("put reject: " + put.getResponseCode() + " " + put.getThrowable() + " " + put.getDigest());
Assert.assertEquals(412, put.getResponseCode());
Assert.assertEquals(PreconditionFailedException.class, put.getThrowable().getClass());

// now put data with correct checksum
md5.reset();
md5.update(data);
digestURI = URI.create("md5:" + HexUtil.toHex(md5.digest()));
content = new FileContent(data, "application/octet-stream");
put = new HttpUpload(content, putURL);
put.setDigest(digestURI);
put.run();
log.info("put: " + put.getResponseCode() + " " + put.getThrowable());
log.info("put accept: " + put.getResponseCode() + " " + put.getThrowable() + " " + put.getDigest());
Assert.assertEquals(201, put.getResponseCode());
Assert.assertNull(put.getThrowable());
Assert.assertEquals(digestURI, put.getDigest());

// Create a pull-from-vospace Transfer for the node
Transfer pullTransfer = new Transfer(testURI, Direction.pullFromVoSpace);
Expand Down
2 changes: 1 addition & 1 deletion cavern/VERSION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## deployable containers have a semantic and build tag
# semantic version tag: major.minor
# build version tag: timestamp
VER=0.9.1
VER=0.9.2
TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")"
unset VER
8 changes: 2 additions & 6 deletions cavern/src/main/java/org/opencadc/cavern/files/PutAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import ca.nrc.cadc.io.ByteLimitExceededException;
import ca.nrc.cadc.io.MultiBufferIO;
import ca.nrc.cadc.io.WriteException;
import ca.nrc.cadc.net.PreconditionFailedException;
import ca.nrc.cadc.net.ResourceNotFoundException;
import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.rest.InlineContentException;
Expand Down Expand Up @@ -244,7 +245,7 @@ public void doAction() throws Exception {
log.debug("upload corrupt: " + expectedMD5 + " != " + propValue);
OutputStream trunc = Files.newOutputStream(target, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
trunc.close();
actualMD5 = null;
throw new PreconditionFailedException("checksum mismatch: " + expectedMD5 + " != " + actualMD5);
}

// re-read node from filesystem
Expand Down Expand Up @@ -315,11 +316,6 @@ public void doAction() throws Exception {
if (bytesWritten > 0L) {
logInfo.setBytes(bytesWritten);
}
if (successful) {
log.debug("put: done " + nodeURI.getURI().toASCIIString());
} else if (putStarted) {
cleanupOnFailure(target, node);
}
}
}

Expand Down