Skip to content

HerdDB profile for integration tests #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@

import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.jdbc.sql.DerbyDictionary;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.kernel.QueryLanguages;
import org.apache.openjpa.lib.jdbc.DelegatingConnection;
import org.apache.openjpa.persistence.detachment.model.NoDetachedStateEntityFieldAccess;
import org.apache.openjpa.persistence.detachment.model.NoDetachedStateEntityPropertyAccess;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

import static org.junit.Assume.assumeFalse;

public class TestUnwrap extends SingleEMFTestCase {

@Override
protected void setUp(Object... props) {
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you just want to skip this test for HerdDB? In which case you can simply call setUnsupportedDatabases(HerdDBDictionary.class)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@struberg thanks for the hint.
I wasn't aware of setUnsupportedDatabases

I will rework this patch

}

/**
* Tests a query can be unwrapped as an instance of a series of class or
* interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@

import javax.persistence.Query;

import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.Generator;

import static org.junit.Assume.assumeFalse;

/**
* Test for generators
*
Expand All @@ -40,6 +45,9 @@ public TestGenerators(String name)
public void setUp()
throws Exception {
deleteAll(Generator.class);
JDBCConfiguration conf = (JDBCConfiguration) getEmf().getConfiguration();
DBDictionary dict = conf.getDBDictionaryInstance();
assumeFalse(dict instanceof HerdDBDictionary);
}

public void testGet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@

import java.util.Collection;

import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.jdbc.sql.OracleDictionary;
import org.apache.openjpa.jdbc.sql.PostgresDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.AnnoTest1;
import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.AnnoTest2;

import static org.junit.Assume.assumeFalse;


/**
* Test for 1-m
Expand All @@ -41,6 +48,9 @@ public TestOneToMany(String name)
public void setUp() {
deleteAll(AnnoTest1.class);
deleteAll(AnnoTest2.class);
JDBCConfiguration conf = (JDBCConfiguration) getEmf().getConfiguration();
DBDictionary dict = conf.getDBDictionaryInstance();
assumeFalse(dict instanceof HerdDBDictionary);
}

public void testOneToMany() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@

import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.jdbc.sql.OracleDictionary;
import org.apache.openjpa.jdbc.sql.PostgresDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase;
import org.apache.openjpa.util.ExceptionInfo;

import static org.junit.Assume.assumeFalse;

//This test was created for OPENJPA-1550. In this issue the user was
//not able to get the 'failed object' (the object causing the failure) when
//batch limit was -1 or a value greater than 1. Also, they found that the
Expand Down Expand Up @@ -63,6 +66,7 @@ public EntityManagerFactory newEmf(String batchLimit) {
DBDictionary dict = conf.getDBDictionaryInstance();
isOracle = dict instanceof OracleDictionary;
isPostgres = dict instanceof PostgresDictionary;
assumeFalse(dict instanceof HerdDBDictionary);
return emf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@

import javax.persistence.EntityManager;

import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.OpenJPAPersistence;
import org.apache.openjpa.persistence.simple.AllFieldTypes;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

import static org.junit.Assume.assumeFalse;

public class TestBulkJPQLAndDataCache
extends SingleEMFTestCase {

private Object oid;

@Override
public void setUp() throws Exception {
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
setUp("openjpa.DataCache", "true",
"openjpa.QueryCache", "true",
"openjpa.RemoteCommitProvider", "sjvm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@

import org.apache.openjpa.jdbc.meta.ClassMapping;
import org.apache.openjpa.jdbc.meta.FieldMapping;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.persistence.JPAFacadeHelper;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

import static org.junit.Assume.assumeFalse;

public class TestBulkUpdatesAndVersionColumn
extends SingleEMFTestCase {

Expand All @@ -37,7 +40,7 @@ public void setUp() throws Exception {
setUp("openjpa.DataCache", "true",
"openjpa.RemoteCommitProvider", "sjvm",
OptimisticLockInstance.class, CLEAR_TABLES);

assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
OpenJPAEntityManager em = emf.createEntityManager();
em.getTransaction().begin();
OptimisticLockInstance pc = new OptimisticLockInstance("foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
import javax.persistence.Cache;
import javax.persistence.EntityManager;

import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

import static org.junit.Assume.assumeFalse;

public class TestBulkUpdatesDataCacheEviction extends SingleEMFTestCase {
Object[] props = new Object[] { CLEAR_TABLES, CachedEntityStatistics.class, "openjpa.DataCache", "true" };
Object[] noEvictProps = new Object[] { CLEAR_TABLES, CachedEntityStatistics.class
Expand All @@ -33,6 +36,7 @@ public class TestBulkUpdatesDataCacheEviction extends SingleEMFTestCase {
@Override
public void setUp() throws Exception {
super.setUp(props);
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@
package org.apache.openjpa.persistence.detachment;

import org.apache.openjpa.enhance.PersistenceCapable;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
import org.apache.openjpa.persistence.detachment.model.NoDetachedStateEntityFieldAccess;
import org.apache.openjpa.persistence.detachment.model.NoDetachedStateEntityPropertyAccess;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

import static org.junit.Assume.assumeFalse;

public class TestDetachNoStateField extends SingleEMFTestCase {

@Override
protected void setUp(Object... props) {
super.setUp(DROP_TABLES, "openjpa.DetachState", "loaded(DetachedStateField=false)",
NoDetachedStateEntityPropertyAccess.class, NoDetachedStateEntityFieldAccess.class);
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
loadDB();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
import javax.persistence.EntityTransaction;
import javax.persistence.Query;

import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.persistence.simple.EntityWithTimestampPK;
import org.apache.openjpa.persistence.test.SQLListenerTestCase;

import static org.junit.Assume.assumeFalse;

public class TestTimestampPKDeletion extends SQLListenerTestCase {

@Override
public void setUp() {
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
setUp(EntityWithTimestampPK.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
import org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedClobFieldStrategy;
import org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.meta.ClassMetaData;
import org.apache.openjpa.meta.FieldMetaData;
import org.apache.openjpa.persistence.JPAFacadeHelper;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

import static org.junit.Assume.assumeFalse;

/**
* Test for embedded
*
Expand All @@ -58,6 +61,7 @@ public void setUp() {
setUp(EmbedOwner.class, EmbedValue.class, CLEAR_TABLES
// ,"openjpa.Log","SQL=trace"
);
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
}

public void testEmbedded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
import org.apache.openjpa.jdbc.meta.ClassMapping;
import org.apache.openjpa.jdbc.meta.strats.FullClassStrategy;
import org.apache.openjpa.jdbc.meta.strats.NoneDiscriminatorStrategy;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

import static org.junit.Assume.assumeFalse;

/**
* <p>Test that InheritanceType.TABLE_PER_CLASS JPA mapping is translated
* correctly. See the <code>kodo.jdbc.meta.tableperclass</code> test package
Expand All @@ -39,6 +42,7 @@ public class TestTablePerClassInheritance
public void setUp() {
setUp(TablePerClass1.class, TablePerClass2.class, EmbedOwner.class,
EmbedValue.class, CLEAR_TABLES);
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
}

public void testMapping() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.apache.openjpa.jdbc.identifier.DBIdentifier.newTable;
import static org.apache.openjpa.jdbc.identifier.QualifiedDBIdentifier.getPath;
import static org.junit.Assume.assumeFalse;

import java.io.File;
import java.sql.SQLException;
Expand All @@ -31,6 +32,7 @@
import org.apache.openjpa.jdbc.schema.SchemaGroup;
import org.apache.openjpa.jdbc.schema.SchemaTool;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.jdbc.sql.OracleDictionary;
import org.apache.openjpa.jdbc.sql.PostgresDictionary;
import org.apache.openjpa.jdbc.sql.SQLServerDictionary;
Expand Down Expand Up @@ -76,7 +78,6 @@ protected void addProperties(Map map) {}
@Override
public void setUp() throws Exception {
super.setUp();

OpenJPAEntityManagerFactory pmf = getEmf(new HashMap());
pmf.createEntityManager();
JDBCConfiguration conf = (JDBCConfiguration) ((OpenJPAEntityManagerFactorySPI) pmf).getConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@

import org.apache.openjpa.jdbc.meta.FieldMapping;
import org.apache.openjpa.jdbc.schema.ForeignKey;
import org.apache.openjpa.jdbc.sql.HerdDBDictionary;
import org.apache.openjpa.meta.ClassMetaData;
import org.apache.openjpa.meta.MetaDataRepository;
import org.apache.openjpa.persistence.test.CombinatorialPersistenceTestCase;

import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

/**
* Tests for SQL statement ordering capabilities of different update strategies
* for a Parent-Child model against different physical database constraints.
Expand Down Expand Up @@ -103,6 +107,7 @@ private static enum PersistOrder {

@Override
public void setUp() {
assumeFalse(this.getDBDictionary() instanceof HerdDBDictionary);
// The options can also be added in setup() as well but then
// coutTestCase() will only record test methods and not multiply them
// with number of configuration combinations the same tests will run.
Expand Down
30 changes: 30 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,36 @@
</properties>
</profile>

<!-- Profile for testing with HerdDB -->
<profile>
<id>test-herddb</id>
<activation>
<property>
<name>test-herddb</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.herddb</groupId>
<artifactId>herddb-jdbc</artifactId>
<version>0.22.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<connection.driver.name>herddb.jdbc.Driver</connection.driver.name>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about a plain java test since herddb is java? docker is mainly an additional test to enable to test which looks not needed here, wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me docker is also fine. The benefit of a docker image is that you drop it and have a very well defined initial status.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main problem is about adding more jars in the classpath.

I am fine with using in-memory db as well, tests will be probably faster?

we should have both.

I would start with docker in order to not need to spend time in debugging potential problems about re-initialization of the server

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would dependency:unpack the zip/stack and just launch it with a dedicated classloader (no conflict wth openjpa)
Docker is fine but don't expect it to be ran often except on the CI from time to time - this is my main point, only Mark runs docker profiles AFAIK.


<connection.url>jdbc:herddb:local</connection.url>
<connection.username>sa</connection.username>
<connection.password>hdb</connection.password>
<jdbc.DBDictionary />

<!-- DBCP overrides for testing -->
<dbcp.maxIdle>5</dbcp.maxIdle>
<dbcp.minIdle>0</dbcp.minIdle>
</properties>
</profile>

<!-- Profile for testing with a custom DB using a system jar -->
<!--
For example, to test with Oracle, you might run:
Expand Down