Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cadc-inventory-db update to support node size metadata and workflow #557

Merged
merged 17 commits into from
Mar 13, 2024
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
4 changes: 2 additions & 2 deletions cadc-inventory-db/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def git_url = 'https://github.com/opencadc/storage-inventory'
mainClassName = 'org.opencadc.inventory.db.version.Main'

dependencies {
compile 'org.opencadc:cadc-util:[1.10.3,2.0)'
compile 'org.opencadc:cadc-util:[1.11.0,2.0)'
compile 'org.opencadc:cadc-gms:[1.0.0,)'
compile 'org.opencadc:cadc-inventory:[0.9.4,)'
compile 'org.opencadc:cadc-vos:[2.0,3.0)'
compile 'org.opencadc:cadc-vos:[2.0.5,3.0)'

testCompile 'junit:junit:[4.0,)'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import org.junit.Test;
import org.opencadc.inventory.Artifact;
import org.opencadc.inventory.InventoryUtil;
import org.opencadc.inventory.Namespace;
import org.opencadc.inventory.SiteLocation;
import org.opencadc.inventory.StorageLocation;
import org.opencadc.inventory.StoredArtifactComparator;
Expand Down Expand Up @@ -955,6 +956,9 @@ public void testIteratorClose() {
public void testArtifactIterator() {
int num = 10;
try {
final Date startDate = new Date();
Thread.sleep(10L);

int numArtifacts = 0;
int numStuffExpected = 0;
// artifacts with storageLocation
Expand All @@ -977,6 +981,7 @@ public void testArtifactIterator() {
numStuffExpected++;
}
}

// some artifacts with no storageLocation
collection = "STUFF";
for (int i = num; i < 2 * num; i++) {
Expand All @@ -996,6 +1001,12 @@ public void testArtifactIterator() {
numStuffExpected++;
}
}

Thread.sleep(10L);
final Date midDate = new Date();
Thread.sleep(10L);
final int midNumStuff = numStuffExpected;

// some artifacts with siteLocations
UUID siteID = UUID.randomUUID();
int numSiteExpected = 0;
Expand All @@ -1018,6 +1029,8 @@ public void testArtifactIterator() {
numStuffExpected++;
}
}
Thread.sleep(10L);
final Date endDate = new Date();
log.info("added: " + numArtifacts);

log.info("count all...");
Expand All @@ -1032,13 +1045,14 @@ public void testArtifactIterator() {
Assert.assertEquals("count", numArtifacts, count);

log.info("count with criteria...");
final Namespace ns = new Namespace("cadc:STUFF/");
count = 0;
try (ResourceIterator<Artifact> iter = originDAO.iterator("uri like 'cadc:STUFF/%'", null, false)) {
try (ResourceIterator<Artifact> iter = originDAO.iterator(ns, null, false)) {
while (iter.hasNext()) {
Artifact actual = iter.next();
count++;
log.info("found: " + actual.getURI());
Assert.assertTrue("STUFF", actual.getURI().toASCIIString().startsWith("cadc:STUFF/"));
Assert.assertTrue("STUFF", actual.getURI().toASCIIString().startsWith(ns.getNamespace()));
}
}
Assert.assertEquals("count", numStuffExpected, count);
Expand All @@ -1065,7 +1079,8 @@ public void testArtifactIterator() {
while (iter.hasNext()) {
Artifact actual = iter.next();
count++;
log.info("found: " + actual.getURI());
log.info("found: " + actual.getBucket() + " " + actual.getURI());
Assert.assertTrue(actual.getBucket().startsWith(bpre));
}
}
}
Expand All @@ -1075,18 +1090,56 @@ public void testArtifactIterator() {
count = 0;
for (byte b = 0; b < 16; b++) {
String bpre = HexUtil.toHex(b).substring(1);
log.debug("bucket prefix: " + bpre);
try (ResourceIterator<Artifact> iter = originDAO.iterator("uri like 'cadc:STUFF/%'", bpre, false)) {
log.info("bucket prefix: " + bpre);
try (ResourceIterator<Artifact> iter = originDAO.iterator(ns, bpre, false)) {
while (iter.hasNext()) {
Artifact actual = iter.next();
count++;
log.info("found: " + actual.getURI());
Assert.assertTrue("STUFF", actual.getURI().toASCIIString().startsWith("cadc:STUFF/"));
log.info("found: " + actual.getBucket() + " " + actual.getURI());
Assert.assertTrue(actual.getBucket().startsWith(bpre));
Assert.assertTrue("STUFF", actual.getURI().toASCIIString().startsWith(ns.getNamespace()));
}
}
}
Assert.assertEquals("count", numStuffExpected, count);

log.info("count vs Namespace incremental from start...");
DateFormat df = DateUtil.getDateFormat(DateUtil.IVOA_DATE_FORMAT, DateUtil.UTC);
count = 0;
try (ResourceIterator<Artifact> iter = originDAO.iterator(ns, null, startDate, true)) {
while (iter.hasNext()) {
Artifact actual = iter.next();
count++;
log.info("found: " + actual.getBucket() + " " + actual.getURI() + " " + df.format(actual.getContentLastModified()));
Assert.assertTrue("STUFF", actual.getURI().toASCIIString().startsWith(ns.getNamespace()));
}
}
Assert.assertEquals("count", numStuffExpected, count);

log.info("count vs Namespace incremental from mid...");
count = 0;
try (ResourceIterator<Artifact> iter = originDAO.iterator(ns, null, midDate, true)) {
while (iter.hasNext()) {
Artifact actual = iter.next();
count++;
log.info("found: " + actual.getBucket() + " " + actual.getURI() + " " + df.format(actual.getContentLastModified()));
Assert.assertTrue("STUFF", actual.getURI().toASCIIString().startsWith(ns.getNamespace()));
}
}
Assert.assertEquals("count", midNumStuff, count);

log.info("count vs Namespace incremental from end...");
count = 0;
try (ResourceIterator<Artifact> iter = originDAO.iterator(ns, null, endDate, true)) {
while (iter.hasNext()) {
Artifact actual = iter.next();
count++;
log.info("found: " + actual.getBucket() + " " + actual.getURI() + " " + df.format(actual.getContentLastModified()));
Assert.assertTrue("STUFF", actual.getURI().toASCIIString().startsWith(ns.getNamespace()));
}
}
Assert.assertEquals("count", 0, count);

} catch (Exception unexpected) {
log.error("unexpected exception", unexpected);
Assert.fail("unexpected exception: " + unexpected);
Expand Down
Loading
Loading