From 47d57ead5ee61e9b9cfb0dbee83b3a9c645f8b85 Mon Sep 17 00:00:00 2001 From: Eric Pugh Date: Wed, 13 Nov 2024 17:33:39 -0500 Subject: [PATCH] Integration test of simple UBI setup. --- .../solr/handler/component/LoggingStream.java | 23 +----------- .../solr/handler/component/UBIComponent.java | 6 ++-- solr/packaging/test/test_ubi.bats | 36 +++++-------------- 3 files changed, 13 insertions(+), 52 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/component/LoggingStream.java b/solr/core/src/java/org/apache/solr/handler/component/LoggingStream.java index 34209e6deb3..fdeb3dd9d03 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/LoggingStream.java +++ b/solr/core/src/java/org/apache/solr/handler/component/LoggingStream.java @@ -65,7 +65,6 @@ public class LoggingStream extends TupleStream implements Expressible { // field name in summary tuple for #docs updated in batch public static String BATCH_LOGGED_FIELD_NAME = "batchLogged"; - private StreamContext context; private Path chroot; /** @@ -139,12 +138,6 @@ public void open() throws IOException { SolrException.ErrorCode.BAD_REQUEST, "file to log to must be under " + chroot); } - // if (!Files.exists(filePath)) { - // - // throw new SolrException( - // SolrException.ErrorCode.BAD_REQUEST, - // "file/directory to stream doesn't exist: " + crawlRootStr); - // } fos = new FileOutputStream(filePath.toFile()); writer = new OutputStreamWriter(fos, StandardCharsets.UTF_8); @@ -204,9 +197,6 @@ private StreamExpression toExpression(StreamFactory factory, boolean includeStre throws IOException { StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass())); expression.addParameter(filepath); - // expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost)); - // expression.addParameter( - // new StreamExpressionNamedParameter("batchSize", Integer.toString(updateBatchSize))); if (includeStreams) { if (tupleSource != null) { @@ -247,7 +237,6 @@ public Explanation toExplanation(StreamFactory factory) throws IOException { @Override public void setStreamContext(StreamContext context) { - this.context = context; Object solrCoreObj = context.get("solr-core"); if (solrCoreObj == null || !(solrCoreObj instanceof SolrCore)) { throw new SolrException( @@ -271,16 +260,6 @@ public void setStreamContext(StreamContext context) { this.tupleSource.setStreamContext(context); } - private void verifyCollectionName(String collectionName, StreamExpression expression) - throws IOException { - if (null == collectionName) { - throw new IOException( - String.format( - Locale.ROOT, - "invalid expression %s - collectionName expected as first operand", - expression)); - } - } // private SolrInputDocument convertTupleTJson(Tuple tuple) { // SolrInputDocument doc = new SolrInputDocument(); @@ -307,7 +286,7 @@ private void addMultivaluedField(SolrInputDocument doc, String fieldName, List tuples = getTuples(stream); log.error("Here are the tuples (" + tuples.size() + "):" + tuples); } + else { + log.error("UBI Query Stream is null, can't log query information."); + } } protected List getTuples(TupleStream tupleStream) throws IOException { diff --git a/solr/packaging/test/test_ubi.bats b/solr/packaging/test/test_ubi.bats index bc52b8e51fe..392d09b5615 100644 --- a/solr/packaging/test/test_ubi.bats +++ b/solr/packaging/test/test_ubi.bats @@ -26,7 +26,7 @@ teardown() { save_home_on_failure delete_all_collections - SOLR_STOP_WAIT=1 solr stop -all >/dev/null 2>&1 + SOLR_STOP_WAIT=1 solr stop --all >/dev/null 2>&1 } @test "Run set up process" { @@ -48,7 +48,7 @@ teardown() { assert_output --partial '"status":0' - curl -X POST -H 'Content-type:application/json' -d '{ + run curl -X POST -H 'Content-type:application/json' -d '{ "update-requesthandler": { "name": "/select", "class": "solr.SearchHandler", @@ -58,7 +58,7 @@ teardown() { assert_output --partial '"status":0' - curl -X POST -H 'Content-type:application/json' -d '{ + run curl -X POST -H 'Content-type:application/json' -d '{ "update-requesthandler": { "name": "/query", "class": "solr.SearchHandler", @@ -72,31 +72,11 @@ teardown() { run curl "http://localhost:${SOLR_PORT}/solr/techproducts/select?q=*:*&rows=3&ubi=true" assert_output --partial '"status":0' assert_output --partial '"query_id":"1234' - - - # Rich UBI user query tracking enabled query - run curl -X POST -H 'Content-type:application/json' -d '{ - "query" : "ram OR memory", - "filter": [ - "inStock:true" - ], - "limit":2, - "params": { - "ubi": "true", - "query_id": "xyz890", - "user_query": { - "query": "RAM memory", - "experiment": "supersecret", - "page": 1, - "filter": "productStatus:available" - } - } - }' "http://localhost:${SOLR_PORT}/solr/techproducts/query" - assert_output --partial '"query_id":"xyz890"' + # No luck on getting the logs to read. - #run cat "${SOLR_LOGS_DIR}/solr.log" - #run tail -n 1 "${SOLR_LOGS_DIR}/ubi_queries.jsonl" - #assert_output --partial "inStock:false" - #assert_file_contains "${SOLR_LOGS_DIR}/ubi_queries.jsonl" 'eric' + assert_file_exist ${SOLR_TIP}/example/techproducts/solr/userfiles/ubi_queries.jsonl + run tail -n 1 "${SOLR_TIP}/example/techproducts/solr/userfiles/ubi_queries.jsonl" + assert_output --partial '{"id":"49","a_i":"1","b_i":"5"}' + assert_file_contains "${SOLR_TIP}/example/techproducts/solr/userfiles/ubi_queries.jsonl" '{"id":"49","a_i":"1","b_i":"5"}' }