HyemIin commented on code in PR #1700:
URL: https://github.com/apache/stormcrawler/pull/1700#discussion_r2447970954
##########
external/opensearch/src/test/java/org/apache/stormcrawler/opensearch/bolt/StatusBoltTest.java:
##########
@@ -128,23 +124,27 @@ private Future<Integer> store(String url, Status status,
Metadata metadata) {
}
@Test
- @Timeout(value = 2, unit = TimeUnit.MINUTES)
- // see https://github.com/apache/stormcrawler/issues/885
- void checkListKeyFromOpensearch()
- throws IOException, ExecutionException, InterruptedException,
TimeoutException {
- String url = "https://www.url.net/something";
- Metadata md = new Metadata();
- md.addValue("someKey", "someValue");
- store(url, Status.DISCOVERED, md).get(10, TimeUnit.SECONDS);
- assertEquals(1, output.getAckedTuples().size());
- // check output in Opensearch?
- String id = org.apache.commons.codec.digest.DigestUtils.sha256Hex(url);
- GetResponse result = client.get(new GetRequest("status", id),
RequestOptions.DEFAULT);
- Map<String, Object> sourceAsMap = result.getSourceAsMap();
- final String pfield = "metadata.someKey";
- sourceAsMap = (Map<String, Object>) sourceAsMap.get("metadata");
- final var pfieldNew = pfield.substring(9);
- Object key = sourceAsMap.get(pfieldNew);
- assertTrue(key instanceof java.util.ArrayList);
+ public void testWaitAckCacheSpecAppliedFromConfig() throws Exception {
+ Map<String, Object> conf = new HashMap<>();
+ conf.put("opensearch.status.waitack.cache.spec",
"maximumSize=10,expireAfterWrite=1s");
+ conf.put("opensearch.status.routing.fieldname", "metadata.key");
+ conf.put("scheduler.class",
"org.apache.stormcrawler.persistence.DefaultScheduler");
+
+ TopologyContext mockContext = Mockito.mock(TopologyContext.class);
+ OutputCollector mockCollector = Mockito.mock(OutputCollector.class);
+
+ StatusUpdaterBolt bolt = new StatusUpdaterBolt();
+ try {
+ bolt.prepare(conf, mockContext, mockCollector);
+ } catch (RuntimeException e) {
+ // 연결 실패 시 예외 분기 발생 → Jacoco branch coverage 확보
+ assertTrue(e.getMessage().contains("Can't connect"));
+ }
+
+ Field field = StatusUpdaterBolt.class.getDeclaredField("waitAck");
Review Comment:
This test was only intended to verify that the value defined in the YAML
config was correctly applied.
It was temporarily added while debugging a Jacoco coverage issue, so I’ll
remove it and include the fix in this commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]