Skip to content

Commit

Permalink
Use a dynamitc method to wait for indexing.
Browse files Browse the repository at this point in the history
  • Loading branch information
taojing2002 committed Oct 29, 2019
1 parent daf263d commit c24b557
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/edu/ucsb/nceas/metacat/annotation/OrcidServiceTest.java
Expand Up @@ -27,6 +27,7 @@
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.io.IOUtils;
import org.dataone.service.types.v1.Identifier;
import org.dataone.service.types.v1.ObjectFormatIdentifier;
import org.dataone.service.types.v1.Session;
Expand Down Expand Up @@ -92,7 +93,17 @@ public void findMatches() throws Exception {
object = new FileInputStream(new File(path));
Identifier pid = MNodeService.getInstance(request).create(session, guid, object, sysmeta);
object.close();
Thread.sleep(2000);
String query = "q=id:"+guid.getValue();
InputStream stream = MNodeService.getInstance(request).query(session, "solr", query);
String resultStr = IOUtils.toString(stream, "UTF-8");
int times = 0;
int tryAcccounts = 20;
while ( (resultStr == null || !resultStr.contains("checksum")) && times <= tryAcccounts) {
Thread.sleep(1000);
times++;
stream = MNodeService.getInstance(request).query(session, "solr", query);
resultStr = IOUtils.toString(stream, "UTF-8");
}


int count = 0;
Expand Down

0 comments on commit c24b557

Please sign in to comment.