You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2024/07/14 17:18:45 UTC
(db-jdo) branch main updated: Squashed commit of the following:
This is an automated email from the ASF dual-hosted git repository.
mbo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/db-jdo.git
The following commit(s) were added to refs/heads/main by this push:
new fd36d0c2 Squashed commit of the following:
fd36d0c2 is described below
commit fd36d0c22593a224079ee162cbcd5838d3f23f30
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sun Jul 14 19:18:37 2024 +0200
Squashed commit of the following:
commit 6a427078f77945d1d9495c62a577dedbdeb0e95c
Author: Michael Bouschen <Mi...@akquinet.de>
Date: Tue Jun 4 20:41:52 2024 +0200
JDO-836: test case takes datastore query canceling into account
- added option jdo.tck.datastore.supportsQueryCancel to RunTCK
- Changed test query to include group by and having
- Changed expected JDO exceptions in test case
commit 293e4fbebca7d4ffeb8c0752d0d6eea9e9433234
Author: Michael Bouschen <Mi...@akquinet.de>
Date: Mon Mar 4 21:09:01 2024 +0100
JDO-836: Add cancel.conf and log Statments to QueryCancel
---
.../main/java/org/apache/jdo/exectck/RunTCK.java | 19 ++++++++++
.../org/apache/jdo/tck/query/api/QueryCancel.java | 40 ++++++++++++----------
tck/src/main/resources/conf/cancel.conf | 23 +++++++++++++
3 files changed, 64 insertions(+), 18 deletions(-)
diff --git a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
index d5fafb56..b2528e13 100644
--- a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
+++ b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
@@ -154,6 +154,10 @@ public class RunTCK extends AbstractTCKMojo {
@Parameter(property = "jdo.tck.parallel.execution", defaultValue = "true", required = true)
private boolean testParallelExecution;
+ /** Whether the datastore support query canceling. */
+ @Parameter(property = "jdo.tck.datastore.supportsQueryCancel", required = false)
+ private String datastoreSupportsQueryCancel;
+
/**
* Helper method returning the trimmed value of the specified property.
*
@@ -541,6 +545,7 @@ public class RunTCK extends AbstractTCKMojo {
command.add("-cp");
command.add(cpString);
command.addAll(cfgPropsString);
+ command.add(getDatastoreSupportsQueryCancelOption());
command.add(dbproperties);
command.add(jvmproperties);
if (debugTCK) {
@@ -706,4 +711,18 @@ public class RunTCK extends AbstractTCKMojo {
private boolean disableColors() {
return !this.testRunnerColors.equalsIgnoreCase("enable");
}
+
+ private String getDatastoreSupportsQueryCancelOption() {
+ boolean support = true;
+ if (datastoreSupportsQueryCancel == null || datastoreSupportsQueryCancel.isEmpty()) {
+ // property not set -> check database
+ String db = System.getProperty("jdo.tck.database");
+ if (db != null && db.equals("derby")) {
+ support = false;
+ }
+ } else {
+ support = datastoreSupportsQueryCancel.equalsIgnoreCase("true");
+ }
+ return "-Djdo.tck.datastore.supportsQueryCancel=" + support;
+ }
}
diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java b/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java
index a2387c55..5430faa8 100644
--- a/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java
+++ b/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java
@@ -17,7 +17,6 @@
package org.apache.jdo.tck.query.api;
-import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import javax.jdo.JDOFatalException;
import javax.jdo.JDOQueryInterruptedException;
@@ -56,22 +55,27 @@ import org.opentest4j.AssertionFailedError;
public class QueryCancel extends QueryTest {
/** Time for the main thread to sleep after starting a parallel thread. */
- private static final int MAIN_SLEEP_MILLIS = 40;
+ private static final int MAIN_SLEEP_MILLIS = 100;
/** Number of instances to be created. */
private static final int NO_OF_INSTANCES = 5000;
+ protected static final boolean DATASTORE_SUPPORTS_QUERY_CANCEL =
+ System.getProperty("jdo.tck.datastore.supportsQueryCancel", "true").equalsIgnoreCase("true");
+
/** */
private static final String ASSERTION_FAILED = "Assertion A14.6.1-8 (QueryCancel) failed: ";
/** Single String JDOQL Query to be canceled. */
private static final String SSJDOQL =
- "select avg (this.x + point2.y) "
+ "select max (this.x) "
+ "from PCPoint "
- + "where this.y >= 0 && point2.x >= 0 "
- + "variables PCPoint2 point2 "
+ + "where point2.x >= 0 "
+ + "variables PCPoint point2 "
+ "import org.apache.jdo.tck.pc.mylib.PCPoint; "
- + "import org.apache.jdo.tck.pc.mylib.PCPoint2; ";
+ + "import org.apache.jdo.tck.pc.mylib.PCPoint2; "
+ + "group by this.x % 10 "
+ + "having max (this.x) > 2 ";
/**
* @throws Exception exception
@@ -79,7 +83,7 @@ public class QueryCancel extends QueryTest {
@SuppressWarnings("unchecked")
@Test
@Execution(ExecutionMode.CONCURRENT)
- public void testCancel() throws InterruptedException {
+ public void testCancel() throws Exception {
PersistenceManager pm = getPMF().getPersistenceManager();
try {
// Test query
@@ -102,17 +106,17 @@ public class QueryCancel extends QueryTest {
// cancel query
query.cancel(t);
- if (!isQueryCancelSupported()) {
+ if (!isQueryCancelSupported() || !DATASTORE_SUPPORTS_QUERY_CANCEL) {
fail(
ASSERTION_FAILED,
- "Query.cancel should throw a JDOQueryInterruptedException, "
+ "Query.cancel should throw a JDOUnsupportedOptionException, "
+ "if query canceling is not supported ");
}
- } catch (JDOUnsupportedOptionException | InterruptedException | BrokenBarrierException ex) {
- if (isQueryCancelSupported()) {
+ } catch (JDOUnsupportedOptionException ex) {
+ if (isQueryCancelSupported() && DATASTORE_SUPPORTS_QUERY_CANCEL) {
fail(
ASSERTION_FAILED,
- "Query.cancel should not result in a JDOQueryInterruptedException, "
+ "Query.cancel should not result in a JDOUnsupportedOptionException, "
+ "if query canceling is supported ");
}
}
@@ -158,17 +162,17 @@ public class QueryCancel extends QueryTest {
Thread.sleep(MAIN_SLEEP_MILLIS);
query.cancelAll();
- if (!isQueryCancelSupported()) {
+ if (!isQueryCancelSupported() || !DATASTORE_SUPPORTS_QUERY_CANCEL) {
fail(
ASSERTION_FAILED,
- "Query.cancel should throw a JDOQueryInterruptedException, "
+ "Query.cancel should throw a JDOUnsupportedOptionException, "
+ "if query canceling is not supported ");
}
} catch (JDOUnsupportedOptionException ex) {
- if (isQueryCancelSupported()) {
+ if (isQueryCancelSupported() && DATASTORE_SUPPORTS_QUERY_CANCEL) {
fail(
ASSERTION_FAILED,
- "Query.cancel should not result in a JDOQueryInterruptedException, "
+ "Query.cancel should not result in a JDOUnsupportedOptionException, "
+ "if query canceling is supported ");
}
}
@@ -209,14 +213,14 @@ public class QueryCancel extends QueryTest {
Object result = query.execute();
tx.commit();
tx = null;
- if (isQueryCancelSupported()) {
+ if (isQueryCancelSupported() && DATASTORE_SUPPORTS_QUERY_CANCEL) {
fail(
ASSERTION_FAILED,
"Query.execute should result in a JDOQueryInterruptedException, "
+ "if query canceling is supported.");
}
} catch (JDOQueryInterruptedException ex) {
- if (!isQueryCancelSupported()) {
+ if (!isQueryCancelSupported() || !DATASTORE_SUPPORTS_QUERY_CANCEL) {
fail(
ASSERTION_FAILED,
"Query.execute should not result in a JDOQueryInterruptedException, "
diff --git a/tck/src/main/resources/conf/cancel.conf b/tck/src/main/resources/conf/cancel.conf
new file mode 100644
index 00000000..40bf79a5
--- /dev/null
+++ b/tck/src/main/resources/conf/cancel.conf
@@ -0,0 +1,23 @@
+# 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.
+
+jdo.tck.description = All query tests with standard mapping, no testdata.
+jdo.tck.mapping.companyfactory =
+jdo.tck.testdata =
+jdo.tck.standarddata =
+jdo.tck.mapping = 0
+jdo.tck.requiredOptions =
+jdo.tck.classes = \
+org.apache.jdo.tck.query.api.QueryCancel