You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2022/08/12 13:43:24 UTC

[GitHub] [jackrabbit-oak] thomasmueller commented on a diff in pull request #644: OAK-9874 (unit test only) - Add a (failing and @Ignored) unit test to check that queries return same result with and without index.

thomasmueller commented on code in PR #644:
URL: https://github.com/apache/jackrabbit-oak/pull/644#discussion_r944478419


##########
oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexAndTraversalQueriesSimilarResultsCommonTest.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index;
+
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.index.search.util.IndexDefinitionBuilder;
+import org.apache.jackrabbit.oak.query.AbstractQueryTest;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public abstract class IndexAndTraversalQueriesSimilarResultsCommonTest extends AbstractQueryTest {
+
+    protected IndexOptions indexOptions;
+    protected TestRepository repositoryOptionsUtil;
+
+    protected void assertEventually(Runnable r) {
+        TestUtils.assertEventually(r, ((repositoryOptionsUtil.isAsync() ? repositoryOptionsUtil.defaultAsyncIndexingTimeInSeconds : 0) + 3000) * 5);
+    }
+
+    @Override
+    protected void createTestIndexNode() throws Exception {
+        // This is necessary so that queries without indexes will return results
+        setTraversalEnabled(true);
+    }
+
+    protected Tree setIndex(IndexDefinitionBuilder builder, String idxName) {
+        return builder.build(root.getTree("/").addChild(INDEX_DEFINITIONS_NAME).addChild(idxName));
+    }
+
+    protected List<String> passingQueries;
+
+    protected List<String> failingQueries;

Review Comment:
   Nitpicking here a bit... for me the term "queriesFailed" means that there was an exception when running the query... What about "sameResultQueries" / "differentResultQueries" or "queriesWithSameResult" / "queriesWithDifferentResult"?



##########
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAndTraversalQueriesSimilarResultsCommonTest.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.elastic;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.jackrabbit.oak.InitialContentHelper;
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.plugins.index.IndexAndTraversalQueriesSimilarResultsCommonTest;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
+import org.junit.ClassRule;
+
+public class ElasticIndexAndTraversalQueriesSimilarResultsCommonTest extends IndexAndTraversalQueriesSimilarResultsCommonTest {
+
+    @ClassRule
+    public static final ElasticConnectionRule elasticRule =
+            new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING);
+
+    public ElasticIndexAndTraversalQueriesSimilarResultsCommonTest() {
+        indexOptions = new ElasticIndexOptions();
+        super.passingQueries = ImmutableList.of(

Review Comment:
   This and LuceneIndexAndTraversalQueriesSimilarResultsCommonTest seem to have the same values for passingQueries and failingQueries... so could we move this to IndexAndTraversalQueriesSimilarResultsCommonTest ? Maybe I'm missing some aspect that wouldn't allow this... or do you think this will change in the future?
   



-- 
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: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org