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/09 13:57:55 UTC

[GitHub] [jackrabbit-oak] tihom88 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.

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


##########
oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/SameQueryResultsWithAndWithoutIndexTest.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 com.google.common.collect.ImmutableList;
+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.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.fail;
+
+public abstract class SameQueryResultsWithAndWithoutIndexTest 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));
+    }
+
+    final private static List<String> testQueries = ImmutableList.of(

Review Comment:
   I think most of the queries should have correct results for elastic and lucene. I think we should create 2 methods:
   1. one for passing queries  and enable this method. 
   2. Separate method for failing queries and annotate it with ignore.
   With this we will have one active test.



-- 
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