http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java index c95f7d6..84f1c42 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/LargeEntityIT.java @@ -34,16 +34,17 @@ import org.slf4j.LoggerFactory; import org.apache.usergrid.AbstractCoreIT; import org.apache.usergrid.Application; import org.apache.usergrid.CoreApplication; -import org.apache.usergrid.cassandra.Concurrent; -import org.apache.usergrid.corepersistence.CpSetup; +import org.apache.usergrid.cassandra.SpringResource; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass; import org.apache.usergrid.utils.JsonUtils; +import com.google.inject.Injector; + import static org.junit.Assert.assertEquals; -@Concurrent() + public class LargeEntityIT extends AbstractCoreIT { private static final Logger LOG = LoggerFactory.getLogger( LargeEntityIT.class ); @@ -62,7 +63,7 @@ public class LargeEntityIT extends AbstractCoreIT { @org.junit.Before public void setUp() { - serializationFig = CpSetup.getInjector().getInstance( SerializationFig.class ); + serializationFig = SpringResource.getInstance().getBean( Injector.class ).getInstance( SerializationFig.class ); setMaxEntitySize = serializationFig.getMaxEntitySize(); }
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java index 61ac16f..c72b4ea 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java @@ -17,7 +17,6 @@ package org.apache.usergrid.persistence; -import org.apache.usergrid.persistence.index.query.Query; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -25,10 +24,13 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import org.apache.commons.lang3.RandomStringUtils; import org.junit.Test; + +import org.apache.commons.lang3.RandomStringUtils; + import org.apache.usergrid.AbstractCoreIT; +import org.apache.usergrid.persistence.index.query.Query; import org.apache.usergrid.persistence.index.query.Query.Level; import static org.junit.Assert.assertEquals; @@ -38,7 +40,7 @@ public class PathQueryIT extends AbstractCoreIT { @Test public void testUserDevicePathQuery() throws Exception { - UUID applicationId = setup.createApplication( + UUID applicationId = setup.createApplication( "testOrganization", "testUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) ); EntityManager em = setup.getEmf().getEntityManager( applicationId ); @@ -94,7 +96,7 @@ public class PathQueryIT extends AbstractCoreIT { deviceQuery.addFilter( "index >= 2" ); int expectedDeviceQuerySize = 3; - PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>( + PathQuery<EntityRef> usersPQ = new PathQuery<EntityRef>( new SimpleEntityRef( em.getApplicationRef()), userQuery ); PathQuery<Entity> devicesPQ = usersPQ.chain( deviceQuery ); HashSet set = new HashSet( expectedUserQuerySize * expectedDeviceQuerySize ); @@ -109,7 +111,7 @@ public class PathQueryIT extends AbstractCoreIT { @Test public void testGroupUserDevicePathQuery() throws Exception { - UUID applicationId = setup.createApplication( + UUID applicationId = setup.createApplication( "testOrganization", "testGroupUserDevicePathQuery" + RandomStringUtils.randomAlphabetic(20) ); EntityManager em = setup.getEmf().getEntityManager( applicationId ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityReadTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityReadTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityReadTest.java index 03d9fa8..f7435ef 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityReadTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityReadTest.java @@ -17,9 +17,11 @@ package org.apache.usergrid.persistence; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; import org.junit.After; @@ -37,14 +39,11 @@ import org.apache.usergrid.CoreApplication; import com.codahale.metrics.Meter; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Slf4jReporter; -import java.util.ArrayList; -import java.util.UUID; -import org.apache.usergrid.cassandra.Concurrent; //@RunWith(JukitoRunner.class) //@UseModules({ GuiceModule.class }) -@Concurrent() + @Ignore("Kills embedded cassandra") public class PerformanceEntityReadTest extends AbstractCoreIT { private static final Logger logger = LoggerFactory.getLogger(PerformanceEntityReadTest.class ); @@ -83,7 +82,7 @@ public class PerformanceEntityReadTest extends AbstractCoreIT { @Test public void simpleReadUUID() throws Exception { - + logger.info("Starting simpleReadUUID()"); final EntityManager em = app.getEntityManager(); @@ -105,7 +104,7 @@ public class PerformanceEntityReadTest extends AbstractCoreIT { uuids.add( created.getUuid() ); i++; - + if ( i % 1000 == 0 ) { logger.debug("simpleReadUUID() Created {} entities",i ); } @@ -121,7 +120,7 @@ public class PerformanceEntityReadTest extends AbstractCoreIT { meter.mark(); Thread.sleep( readDelayMs ); } - + registry.remove( meterName ); logger.info("Finished simpleReadUUID()"); } @@ -166,7 +165,7 @@ public class PerformanceEntityReadTest extends AbstractCoreIT { meter.mark(); Thread.sleep( readDelayMs ); } - + registry.remove( meterName ); logger.info("Finished simpleReadEntityRef()"); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java index 574d366..f8eec52 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java @@ -17,30 +17,21 @@ package org.apache.usergrid.persistence; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.usergrid.AbstractCoreIT; -import org.apache.usergrid.Application; -import org.apache.usergrid.CoreApplication; - -import com.codahale.metrics.Meter; -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.Slf4jReporter; -import com.google.inject.Injector; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.usergrid.cassandra.Concurrent; -import org.apache.usergrid.corepersistence.CpSetup; +import org.apache.usergrid.cassandra.SpringResource; import org.apache.usergrid.corepersistence.util.CpNamingUtils; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; @@ -50,13 +41,19 @@ import org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl; import org.apache.usergrid.persistence.index.query.Query; import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.entity.SimpleId; + +import com.codahale.metrics.Meter; +import com.codahale.metrics.MetricRegistry; +import com.codahale.metrics.Slf4jReporter; +import com.google.inject.Injector; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; //@RunWith(JukitoRunner.class) //@UseModules({ GuiceModule.class }) -@Concurrent() + public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT { private static final Logger logger = LoggerFactory.getLogger(PerformanceEntityRebuildIndexTest.class ); @@ -67,8 +64,6 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT { private static final long WRITE_DELAY_MS = 10; - @Rule - public Application app = new CoreApplication( setup ); @Before @@ -157,7 +152,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT { logger.info("Created {} entities", entityCount); em.refreshIndex(); - // ----------------- test that we can read them, should work fine + // ----------------- test that we can read them, should work fine logger.debug("Read the data"); readData("testTypes", entityCount ); @@ -183,7 +178,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT { final String meterName = this.getClass().getSimpleName() + ".rebuildIndex"; final Meter meter = registry.meter( meterName ); - + EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() { int counter = 0; @@ -220,16 +215,16 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT { } // ----------------- test that we can read them - + readData( "testTypes", entityCount ); } - /** + /** * Delete index for all applications, just need the one to get started. */ private void deleteIndex( UUID appUuid ) { - Injector injector = CpSetup.getInjector(); + Injector injector = SpringResource.getInstance().getBean( Injector.class ); EntityIndexFactory eif = injector.getInstance( EntityIndexFactory.class ); Id appId = new SimpleId( appUuid, "application"); @@ -277,7 +272,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT { } if ( expected != -1 && expected != count ) { - throw new RuntimeException("Did not get expected " + throw new RuntimeException("Did not get expected " + expected + " entities, instead got " + count ); } return count; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityWriteTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityWriteTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityWriteTest.java index 64342a1..341af90 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityWriteTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityWriteTest.java @@ -34,7 +34,6 @@ import org.slf4j.LoggerFactory; import org.apache.usergrid.AbstractCoreIT; import org.apache.usergrid.Application; import org.apache.usergrid.CoreApplication; -import org.apache.usergrid.cassandra.Concurrent; import com.codahale.metrics.Meter; import com.codahale.metrics.MetricRegistry; @@ -43,7 +42,7 @@ import com.codahale.metrics.Slf4jReporter; //@RunWith(JukitoRunner.class) //@UseModules({ GuiceModule.class }) -@Concurrent() + @Ignore("Kills embedded cassandra") public class PerformanceEntityWriteTest extends AbstractCoreIT { private static final Logger LOG = LoggerFactory.getLogger( PerformanceEntityWriteTest.class ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java index bdd82ea..23931e2 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java @@ -22,13 +22,14 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.UUID; -import org.apache.commons.lang3.RandomStringUtils; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import org.apache.commons.lang3.RandomStringUtils; + import org.apache.usergrid.AbstractCoreIT; -import org.apache.usergrid.cassandra.Concurrent; import org.apache.usergrid.persistence.entities.Role; import org.apache.usergrid.persistence.index.query.Query.Level; @@ -37,7 +38,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -@Concurrent() + public class PermissionsIT extends AbstractCoreIT { private static final Logger logger = LoggerFactory.getLogger( PermissionsIT.class ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java index e8cb7d4..1b4bb6f 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryTest.java @@ -17,7 +17,6 @@ package org.apache.usergrid.persistence; -import org.apache.usergrid.persistence.index.query.Query; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -25,8 +24,9 @@ import java.util.List; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.usergrid.cassandra.Concurrent; + import org.apache.usergrid.persistence.index.exceptions.QueryParseException; +import org.apache.usergrid.persistence.index.query.Query; import org.apache.usergrid.persistence.index.query.Query.SortDirection; import org.apache.usergrid.persistence.index.query.Query.SortPredicate; import org.apache.usergrid.persistence.index.query.tree.AndOperand; @@ -47,13 +47,13 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; -@Concurrent() + public class QueryTest { private static final Logger LOG = LoggerFactory.getLogger( QueryTest.class ); - @Test + @Test public void testQueryTree() throws Exception { LOG.info( "testQuery" ); @@ -204,7 +204,7 @@ public class QueryTest { } - @Test + @Test public void testFromJson() throws QueryParseException { String s = "{\"filter\":\"a contains 'ed'\"}"; Query q = Query.fromJsonString( s ); @@ -217,7 +217,7 @@ public class QueryTest { } - @Test + @Test public void testCompoundQueryWithNot() throws QueryParseException { String s = "name contains 'm' and not name contains 'grover'"; Query q = Query.fromQL( s ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/QueryUtilsTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryUtilsTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryUtilsTest.java index 4068852..d073cbe 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/QueryUtilsTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/QueryUtilsTest.java @@ -23,13 +23,12 @@ import java.util.List; import java.util.Map; import org.junit.Test; -import org.apache.usergrid.cassandra.Concurrent; import static org.junit.Assert.assertEquals; /** @author zznate */ -@Concurrent() + public class QueryUtilsTest { private static final String FAKE_QL = "select color from cat"; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/SchemaTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/SchemaTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/SchemaTest.java index 725e886..68c19d2 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/SchemaTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/SchemaTest.java @@ -23,13 +23,13 @@ import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.usergrid.persistence.entities.SampleEntity; - import org.usergrid.Simple; +import org.apache.usergrid.persistence.entities.SampleEntity; + +import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString; public class SchemaTest { http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/UtilsTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/UtilsTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/UtilsTest.java index f929146..9ef4934 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/UtilsTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/UtilsTest.java @@ -18,13 +18,13 @@ package org.apache.usergrid.persistence; import org.junit.Test; -import org.apache.usergrid.cassandra.Concurrent; + import org.apache.usergrid.persistence.index.query.CounterResolution; import static org.junit.Assert.assertEquals; -@Concurrent() + public class UtilsTest { @Test public void testCounterResolution() throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java index cbf274b..306ac35 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java @@ -35,7 +35,6 @@ import org.apache.commons.lang3.RandomStringUtils; import org.apache.usergrid.AbstractCoreIT; import org.apache.usergrid.cassandra.SpringResource; -import org.apache.usergrid.cassandra.Concurrent; import org.apache.usergrid.persistence.Entity; import org.apache.usergrid.persistence.EntityManager; import org.apache.usergrid.persistence.EntityManagerFactory; @@ -52,7 +51,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -@Concurrent() + public class EntityManagerFactoryImplIT extends AbstractCoreIT { @SuppressWarnings("PointlessBooleanExpression") http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java index fe04d23..6d1ab8a 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/QueryProcessorTest.java @@ -23,13 +23,13 @@ import java.util.UUID; import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.TokenRewriteStream; +import org.junit.Ignore; import org.junit.Test; -import org.apache.usergrid.cassandra.Concurrent; import org.apache.usergrid.mq.QueryFilterLexer; import org.apache.usergrid.mq.QueryFilterParser; -import org.apache.usergrid.persistence.index.query.Query; import org.apache.usergrid.persistence.exceptions.PersistenceException; +import org.apache.usergrid.persistence.index.query.Query; import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterLexer; import org.apache.usergrid.persistence.index.query.tree.CpQueryFilterParser; import org.apache.usergrid.persistence.query.ir.AndNode; @@ -43,16 +43,15 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import org.junit.Ignore; /** * @author tnine */ -@Concurrent() + public class QueryProcessorTest { - @Test + @Test public void equality() throws Exception { String queryString = "select * where a = 5"; @@ -130,7 +129,7 @@ public class QueryProcessorTest { } - @Test + @Test public void greaterThan() throws Exception { String queryString = "select * where a > 5"; @@ -156,7 +155,7 @@ public class QueryProcessorTest { } - @Test + @Test public void greaterThanEquals() throws Exception { String queryString = "select * where a >= 5"; @@ -182,7 +181,7 @@ public class QueryProcessorTest { } - @Test + @Test public void contains() throws Exception { String queryString = "select * where a contains 'foo'"; @@ -211,7 +210,7 @@ public class QueryProcessorTest { } - @Test + @Test public void containsLower() throws Exception { String queryString = "select * where a contains 'FOO'"; @@ -240,7 +239,7 @@ public class QueryProcessorTest { } - @Test + @Test public void containsRange() throws Exception, PersistenceException { String queryString = "select * where a contains 'foo*'"; @@ -274,7 +273,7 @@ public class QueryProcessorTest { } - @Test + @Test public void within() throws Exception { String queryString = "select * where a within .5 of 157.00, 0.00"; @@ -296,7 +295,7 @@ public class QueryProcessorTest { } - @Test + @Test public void andEquality() throws Exception { assertAndQuery( "select * where a = 1 and b = 2 and c = 3" ); assertAndQuery( "select * where a = 1 AND b = 2 and c = 3" ); @@ -350,7 +349,7 @@ public class QueryProcessorTest { } - @Test + @Test public void orEquality() throws Exception { assertOrQuery( "select * where a = 1 or b = 2" ); assertOrQuery( "select * where a = 1 OR b = 2" ); @@ -400,7 +399,7 @@ public class QueryProcessorTest { /** Tests that when properties are not siblings, they are properly assigned to a SliceNode */ - @Test + @Test public void nestedCompression() throws Exception { String queryString = "select * where (a > 1 and b > 10 and a < 10 and b < 20 ) or ( c >= 20 and d >= 30 and c <= 30 and d " @@ -467,7 +466,7 @@ public class QueryProcessorTest { /** Tests that when there are multiple or with and clauses, the tree is constructed correctly */ - @Test + @Test public void nestedOrCompression() throws Exception { String queryString = "select * where ((a > 1 and a < 10) or (b > 10 and b < 20 )) or (( c >= 20 and c <= 30 ) or (d >= 30" @@ -544,7 +543,7 @@ public class QueryProcessorTest { /** Tests that when NOT is not the root operand the tree has a different root */ - @Test + @Test public void andNot() throws Exception { String queryString = "select * where a > 1 and not b = 2"; @@ -589,7 +588,7 @@ public class QueryProcessorTest { /** Tests that when NOT is the root operand, a full scan range is performed. */ - @Test + @Test public void notRootOperand() throws Exception { String queryString = "select * where not b = 2"; @@ -618,7 +617,7 @@ public class QueryProcessorTest { } - @Test + @Test public void stringWithSpaces() throws Exception { String queryString = "select * where a = 'foo with bar'"; @@ -647,7 +646,7 @@ public class QueryProcessorTest { } - @Test + @Test public void fieldWithDash() throws Exception { String queryString = "select * where a-foo = 5"; @@ -675,7 +674,7 @@ public class QueryProcessorTest { } - @Test + @Test public void stringWithDash() throws Exception { String queryString = "select * where a = 'foo-bar'"; @@ -704,7 +703,7 @@ public class QueryProcessorTest { } - @Test + @Test public void uuidParse() throws Exception { // UUID value = UUID.fromString("4b91a9c2-86a1-11e2-b7fa-68a86d52fa56"); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java index 0c9d1f3..2618e49 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/SimpleIndexShardLocatorImplTest.java @@ -25,7 +25,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import org.junit.Test; -import org.apache.usergrid.cassandra.Concurrent; + import org.apache.usergrid.persistence.IndexBucketLocator.IndexType; import org.apache.usergrid.utils.UUIDUtils; @@ -37,7 +37,7 @@ import static org.junit.Assert.assertEquals; /** @author tnine */ -@Concurrent() + public class SimpleIndexShardLocatorImplTest { @Test public void oneBucket() { http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java index 9c7ec90..d2cf8ad 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparatorTest.java @@ -20,6 +20,7 @@ package org.apache.usergrid.persistence.geo; import java.util.UUID; import org.junit.Test; + import org.apache.usergrid.persistence.geo.model.Point; import org.apache.usergrid.utils.UUIDUtils; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java deleted file mode 100644 index 4162c60..0000000 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java +++ /dev/null @@ -1,1339 +0,0 @@ -/* - * 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.usergrid.persistence.query; - - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.usergrid.CoreApplication; -import org.apache.usergrid.CoreITSetup; -import org.apache.usergrid.CoreITSetupImpl; -import org.apache.usergrid.cassandra.SpringResource; -import org.apache.usergrid.persistence.Entity; -import org.apache.usergrid.persistence.index.impl.ElasticSearchResource; -import org.apache.usergrid.persistence.index.query.Query; -import org.apache.usergrid.persistence.Results; -import org.apache.usergrid.setup.SpringIntegrationRunner; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - - -/** @author tnine */ -@RunWith( SpringIntegrationRunner.class) -public abstract class AbstractIteratingQueryIT { - private static final Logger LOG = LoggerFactory.getLogger( AbstractIteratingQueryIT.class ); - - public static final long WRITE_DELAY = 0; // milliseconds to delay between writes in loop - - - @ClassRule - public static SpringResource springResource = SpringResource.getInstance(); - - @ClassRule - public static ElasticSearchResource elasticSearchResource = new ElasticSearchResource(); - - - @ClassRule - public static CoreITSetup setup = new CoreITSetupImpl( springResource, elasticSearchResource ); - - @Rule - public CoreApplication app = new CoreApplication( setup ); - - - public void singleOrderByMaxLimit( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = Query.MAX_LIMIT; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - entity.put( "name", String.valueOf( i ) ); - - io.writeEntity( entity ); - //we have to sleep, or we kill embedded cassandra - Thread.sleep( 10 ); - - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "created" ); - query.setLimit( queryLimit ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( String.valueOf( count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( size, count ); - } - - - protected void singleOrderByIntersection( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 700; - int queryLimit = Query.MAX_LIMIT; - - // the number of entities that should be written including an intersection - int intersectIncrement = 5; - - long start = System.currentTimeMillis(); - - List<String> expected = new ArrayList<String>( size / intersectIncrement ); - - LOG.info( "Writing {} entities.", size ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - - String name = String.valueOf( i ); - - boolean intersect = i % intersectIncrement == 0; - - entity.put( "name", String.valueOf( i ) ); - // if we hit the increment, set this to true - entity.put( "intersect", intersect ); - - io.writeEntity( entity ); - - if ( intersect ) { - expected.add( name ); - } - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "created" ); - query.addEqualityFilter( "intersect", true ); - query.setLimit( queryLimit ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( expected.size(), count ); - } - - - protected void singleOrderByComplexIntersection( IoHelper io ) throws Exception { - - int size = 5000; - int queryLimit = Query.MAX_LIMIT; - - // the number of entities that should be written including an intersection - int intersectIncrement = 5; - int secondIncrement = 9; - - long start = System.currentTimeMillis(); - - io.doSetup(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expectedResults = new ArrayList<String>( size / secondIncrement ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - - String name = String.valueOf( i ); - boolean intersect1 = i % intersectIncrement == 0; - boolean intersect2 = i % secondIncrement == 0; - entity.put( "name", name ); - // if we hit the increment, set this to true - - entity.put( "intersect", intersect1 ); - entity.put( "intersect2", intersect2 ); - io.writeEntity( entity ); - - if ( intersect1 && intersect2 ) { - expectedResults.add( name ); - } - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "created" ); - query.addEqualityFilter( "intersect", true ); - query.addEqualityFilter( "intersect2", true ); - query.setLimit( queryLimit ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expectedResults.get( count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( expectedResults.size(), count ); - } - - - protected void singleOrderByNoIntersection( IoHelper io ) throws Exception { - io.doSetup(); - - int size = 2000; - int queryLimit = Query.MAX_LIMIT; - - // the number of entities that should be written including an intersection - int secondIncrement = 9; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - entity.put( "name", String.valueOf( i ) ); - // if we hit the increment, set this to true - entity.put( "intersect", false ); - entity.put( "intersect2", i % secondIncrement == 0 ); - io.writeEntity( entity ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "created" ); - // nothing will ever match this, the search should short circuit - query.addEqualityFilter( "intersect", true ); - query.addEqualityFilter( "intersect2", true ); - query.setLimit( queryLimit ); - - start = System.currentTimeMillis(); - - Results results = io.getResults( query ); - - // now do simple ordering, should be returned in order - - stop = System.currentTimeMillis(); - - LOG.info( "Query took {} ms to return {} entities", stop - start, 0 ); - - assertEquals( 0, results.size() ); - } - - - protected void singleOrderByComplexUnion( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 2000; - int queryLimit = Query.MAX_LIMIT; - - // the number of entities that should be written including an intersection - int intersectIncrement = 5; - int secondIncrement = 9; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expectedResults = new ArrayList<String>( size / secondIncrement ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - - String name = String.valueOf( i ); - boolean intersect1 = i % intersectIncrement == 0; - boolean intersect2 = i % secondIncrement == 0; - entity.put( "name", name ); - // if we hit the increment, set this to true - - entity.put( "intersect", intersect1 ); - entity.put( "intersect2", intersect2 ); - io.writeEntity( entity ); - - if ( intersect1 || intersect2 ) { - expectedResults.add( name ); - } - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = Query.fromQL( "select * where intersect = true OR intersect2 = true order by created" ); - query.setLimit( queryLimit ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expectedResults.get( count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( expectedResults.size(), count ); - } - - - protected void singleOrderByNot( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 2000; - int queryLimit = Query.MAX_LIMIT; - - // the number of entities that should be written including an intersection - int intersectIncrement = 5; - int secondIncrement = 9; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expectedResults = new ArrayList<String>( size / secondIncrement ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - - String name = String.valueOf( i ); - boolean intersect1 = i % intersectIncrement == 0; - boolean intersect2 = i % secondIncrement == 0; - entity.put( "name", name ); - // if we hit the increment, set this to true - - entity.put( "intersect", intersect1 ); - entity.put( "intersect2", intersect2 ); - io.writeEntity( entity ); - - if ( !( intersect1 && intersect2 ) ) { - expectedResults.add( name ); - } - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = Query.fromQL( "select * where NOT (intersect = true AND intersect2 = true) order by created" ); - query.setLimit( queryLimit ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expectedResults.get( count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( expectedResults.size(), count ); - } - - - public void singleOrderByLessThanLimit( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = Query.MAX_LIMIT; - - int matchMax = queryLimit - 1; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expected = new ArrayList<String>( matchMax ); - - for ( int i = 0; i < size; i++ ) { - String name = String.valueOf( i ); - boolean searched = i < matchMax; - - Map<String, Object> entity = new HashMap<String, Object>(); - - entity.put( "name", name ); - entity.put( "searched", searched ); - io.writeEntity( entity ); - - if ( searched ) { - expected.add( name ); - } - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "created" ); - query.setLimit( queryLimit ); - query.addEqualityFilter( "searched", true ); - - int count = 0; - - start = System.currentTimeMillis(); - - // now do simple ordering, should be returned in order - Results results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( count ), results.getEntities().get( i ).getName() ); - count++; - } - - assertTrue( results.getCursor() == null ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( expected.size(), count ); - } - - - public void singleOrderBySameRangeScanLessThanEqual( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = 100; - int startValue = 400; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expected = new ArrayList<String>( size ); - - for ( int i = 0; i < size; i++ ) { - String name = String.valueOf( i ); - - Map<String, Object> entity = new HashMap<String, Object>(); - - entity.put( "name", name ); - entity.put( "index", i ); - io.writeEntity( entity ); - expected.add( name ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "index desc" ); - query.addLessThanEqualFilter( "index", startValue ); - query.setLimit( queryLimit ); - - int count = 0; - int delta = size - startValue; - - start = System.currentTimeMillis(); - - // now do simple ordering, should be returned in order - Results results; - - do { - - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( size - delta - count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.hasCursor() ); - - assertEquals( expected.size() - delta + 1, count ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - } - - - public void singleOrderBySameRangeScanLessEqual( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = 100; - int startValue = 400; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expected = new ArrayList<String>( size ); - - for ( int i = 0; i < size; i++ ) { - String name = String.valueOf( i ); - - Map<String, Object> entity = new HashMap<String, Object>(); - - entity.put( "name", name ); - entity.put( "index", i ); - io.writeEntity( entity ); - expected.add( name ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "index desc" ); - query.addLessThanFilter( "index", startValue ); - query.setLimit( queryLimit ); - - int count = 0; - int delta = size - startValue; - - start = System.currentTimeMillis(); - - // now do simple ordering, should be returned in order - Results results; - - do { - - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( size - delta - count - 1 ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.hasCursor() ); - - assertEquals( expected.size() - delta, count ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - } - - - public void singleOrderBySameRangeScanGreaterThanEqual( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = 100; - int startValue = 100; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expected = new ArrayList<String>( size ); - - for ( int i = 0; i < size; i++ ) { - String name = String.valueOf( i ); - - Map<String, Object> entity = new HashMap<String, Object>(); - - entity.put( "name", name ); - entity.put( "index", i ); - io.writeEntity( entity ); - expected.add( name ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "index desc" ); - query.addGreaterThanEqualFilter( "index", startValue ); - query.setLimit( queryLimit ); - - int count = 0; - - start = System.currentTimeMillis(); - - // now do simple ordering, should be returned in order - Results results; - - do { - - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( size - count - 1 ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.hasCursor() ); - - assertEquals( expected.size() - startValue, count ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - } - - - public void singleOrderBySameRangeScanGreater( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = 100; - int startValue = 99; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expected = new ArrayList<String>( size ); - - for ( int i = 0; i < size; i++ ) { - String name = String.valueOf( i ); - - Map<String, Object> entity = new HashMap<String, Object>(); - - entity.put( "name", name ); - entity.put( "index", i ); - io.writeEntity( entity ); - expected.add( name ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = new Query(); - query.addSort( "index desc" ); - query.addGreaterThanFilter( "index", startValue ); - query.setLimit( queryLimit ); - - int count = 0; - - start = System.currentTimeMillis(); - - // now do simple ordering, should be returned in order - Results results; - - do { - - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( size - count - 1 ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.hasCursor() ); - - assertEquals( expected.size() - startValue - 1, count ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - } - - - public void singleOrderByBoundRangeScanDesc( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = 100; - int startValue = 100; - int endValue = 400; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expected = new ArrayList<String>( size ); - - for ( int i = 0; i < size; i++ ) { - String name = String.valueOf( i ); - - Map<String, Object> entity = new HashMap<String, Object>(); - - entity.put( "name", name ); - entity.put( "index", i ); - io.writeEntity( entity ); - expected.add( name ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = Query.fromQL( - String.format( "select * where index >= %d AND index <= %d order by index desc", startValue, - endValue ) ); - query.setLimit( queryLimit ); - - int count = 0; - int delta = size - endValue; - - start = System.currentTimeMillis(); - - // now do simple ordering, should be returned in order - Results results; - - do { - - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( size - count - delta ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.hasCursor() ); - - assertEquals( expected.size() - startValue - delta + 1, count ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - } - - - public void singleOrderByBoundRangeScanAsc( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 500; - int queryLimit = 100; - int startValue = 100; - int endValue = 400; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - List<String> expected = new ArrayList<String>( size ); - - for ( int i = 0; i < size; i++ ) { - String name = String.valueOf( i ); - - Map<String, Object> entity = new HashMap<String, Object>(); - - entity.put( "name", name ); - entity.put( "index", i ); - io.writeEntity( entity ); - expected.add( name ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = Query.fromQL( - String.format( "select * where index >= %d AND index <= %d order by index asc", startValue, - endValue ) ); - query.setLimit( queryLimit ); - - int count = 0; - int delta = size - endValue; - - start = System.currentTimeMillis(); - - // now do simple ordering, should be returned in order - Results results; - - do { - - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( expected.get( delta + count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.hasCursor() ); - - assertEquals( expected.size() - startValue - delta + 1, count ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - } - - - /** - * Tests that when an empty query is issued, we page through all entities correctly - * - * @param io the io helper - */ - public void allIn( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 300; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - entity.put( "name", String.valueOf( i ) ); - - io.writeEntity( entity ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - app.getEntityManager().refreshIndex(); - - Query query = new Query(); - query.setLimit( 100 ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - assertEquals( String.valueOf( count ), results.getEntities().get( i ).getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( size, count ); - } - - - protected void multiOrderBy( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 2000; - int queryLimit = Query.MAX_LIMIT; - - // the number of entities that should be written including an intersection - - Set<Entity> sortedResults = new TreeSet<Entity>( new Comparator<Entity>() { - - @Override - public int compare( Entity o1, Entity o2 ) { - boolean o1Boolean = ( Boolean ) o1.getProperty( "boolean" ); - boolean o2Boolean = ( Boolean ) o2.getProperty( "boolean" ); - - if ( o1Boolean != o2Boolean ) { - if ( o1Boolean ) { - return -1; - } - - return 1; - } - - int o1Index = ( Integer ) o1.getProperty( "index" ); - int o2Index = ( Integer ) o2.getProperty( "index" ); - - if ( o1Index > o2Index ) { - return 1; - } - else if ( o2Index > o1Index ) { - return -1; - } - - return 0; - } - } ); - - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - - String name = String.valueOf( i ); - boolean bool = i % 2 == 0; - entity.put( "name", name ); - entity.put( "boolean", bool ); - - /** - * we want them to be ordered from the "newest" time uuid to the oldec since we - * have a low cardinality value as the first second clause. This way the test - *won't accidentally pass b/c the UUID ordering matches the index ordering. If we were - *to reverse the value of index (size-i) the test would pass incorrectly - */ - - entity.put( "index", i ); - - Entity saved = io.writeEntity( entity ); - - sortedResults.add( saved ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - app.getEntityManager().refreshIndex(); - - Query query = Query.fromQL( "select * order by boolean desc, index asc" ); - query.setLimit( queryLimit ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - Iterator<Entity> itr = sortedResults.iterator(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { - Entity expected = itr.next(); - Entity returned = results.getEntities().get( i ); - - assertEquals( "Order incorrect", expected.getName(), returned.getName() ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( sortedResults.size(), count ); - } - - - protected void multiOrderByComplexUnion( IoHelper io ) throws Exception { - - io.doSetup(); - - int size = 2000; - int queryLimit = Query.MAX_LIMIT; - - // the number of entities that should be written including an intersection - int intersectIncrement = 5; - int secondIncrement = 9; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - Set<Entity> sortedResults = new TreeSet<Entity>( new Comparator<Entity>() { - - @Override - public int compare( Entity o1, Entity o2 ) { - long o1Index = ( Long ) o1.getProperty( "created" ); - long o2Index = ( Long ) o2.getProperty( "created" ); - - if ( o1Index > o2Index ) { - return 1; - } - else if ( o2Index > o1Index ) { - return -1; - } - - - boolean o1Boolean = ( Boolean ) o1.getProperty( "intersect" ); - boolean o2Boolean = ( Boolean ) o2.getProperty( "intersect" ); - - if ( o1Boolean != o2Boolean ) { - if ( o1Boolean ) { - return -1; - } - - return 1; - } - - - return 0; - } - } ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - - String name = String.valueOf( i ); - boolean intersect1 = i % intersectIncrement == 0; - boolean intersect2 = i % secondIncrement == 0; - entity.put( "name", name ); - // if we hit the increment, set this to true - - entity.put( "intersect", intersect1 ); - entity.put( "intersect2", intersect2 ); - Entity e = io.writeEntity( entity ); - - if ( intersect1 || intersect2 ) { - sortedResults.add( e ); - } - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - app.getEntityManager().refreshIndex(); - - Query query = - Query.fromQL( "select * where intersect = true OR intersect2 = true order by created, intersect desc" ); - query.setLimit( queryLimit ); - - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - Iterator<Entity> expected = sortedResults.iterator(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( Entity result : results.getEntities() ) { - assertEquals( expected.next(), result ); - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( sortedResults.size(), count ); - } - - - /** - * Tests that when an empty query is issued, we page through all entities correctly - * - * @param io the io helper - */ - public void notOrderBy( IoHelper io ) throws Exception { - - io.doSetup(); - - /** - * Leave this as a large size. We have to write over 1k to reproduce this issue - */ - int size = 2000; - - long start = System.currentTimeMillis(); - - LOG.info( "Writing {} entities.", size ); - - for ( int i = 0; i < size; i++ ) { - Map<String, Object> entity = new HashMap<String, Object>(); - entity.put( "name", String.valueOf( i ) ); - entity.put( "boolean", !(i % 2 == 0)); - entity.put( "index", i); - - io.writeEntity( entity ); - } - - long stop = System.currentTimeMillis(); - - LOG.info( "Writes took {} ms", stop - start ); - - Query query = Query.fromQL("select * where NOT boolean = false order by index asc"); - query.setLimit( 20 ); - - int index = 0; - int count = 0; - - Results results; - - start = System.currentTimeMillis(); - - do { - - // now do simple ordering, should be returned in order - results = io.getResults( query ); - - for ( int i = 0; i < results.size(); i++ ) { -// assertEquals( String.valueOf( index ), results.getEntities().get( i ).getName() ); -// index +=2; - count++; - } - - query.setCursor( results.getCursor() ); - } - while ( results.getCursor() != null ); - - stop = System.currentTimeMillis(); - LOG.info( "Query took {} ms to return {} entities", stop - start, count ); - - assertEquals( size/2, count ); - } - - - /** - * Interface to abstract actually doing I/O targets. The same test logic can be applied to both collections and - * connections - * - * @author tnine - */ - public static interface IoHelper { - /** Perform any setup required */ - public void doSetup() throws Exception; - - /** - * Write the entity to the data store - * - * @param entity the entity - */ - public Entity writeEntity( Map<String, Object> entity ) throws Exception; - - /** - * Get the results for the query - * - * @param query the query to get results for - * - * @return the results of the query - */ - public Results getResults( Query query ) throws Exception; - } - - - public static class CollectionIoHelper implements IoHelper { - - protected final CoreApplication app; - - - public CollectionIoHelper( final CoreApplication app ) { - this.app = app; - } - - - @Override - public void doSetup() throws Exception { - } - - - @Override - public Entity writeEntity( Map<String, Object> entity ) throws Exception { - - Entity e = app.getEntityManager().create( "test", entity ); - - if ( WRITE_DELAY > 0 ) { - Thread.sleep( WRITE_DELAY ); - } - - return e; - } - - - @Override - public Results getResults( Query query ) throws Exception { - app.getEntityManager().refreshIndex(); - return app.getEntityManager().searchCollection( app.getEntityManager().getApplicationRef(), "tests", query ); - } - } - - - public static class ConnectionHelper extends CollectionIoHelper { - - /** - * - */ - protected static final String CONNECTION = "connection"; - protected Entity rootEntity; - - - public ConnectionHelper( final CoreApplication app) { - super( app ); - } - - - @Override - public void doSetup() throws Exception { - Map<String, Object> data = new HashMap<String, Object>(); - data.put( "name", "rootentity" ); - rootEntity = app.getEntityManager().create( "root", data ); - } - - - @Override - public Entity writeEntity( Map<String, Object> entity ) throws Exception { - - // write to the collection - Entity created = super.writeEntity( entity ); - app.getEntityManager().createConnection( rootEntity, CONNECTION, created ); - - if ( WRITE_DELAY > 0 ) { - Thread.sleep( WRITE_DELAY ); - } - - return created; - } - - - /* - * (non-Javadoc) - * - * @see - * org.apache.usergrid.persistence.query.SingleOrderByMaxLimitCollection.CollectionIoHelper# - * getResults(org.apache.usergrid.persistence.Query) - */ - @Override - public Results getResults( Query query ) throws Exception { - - app.getEntityManager().refreshIndex(); - query.setConnectionType( CONNECTION ); - query.setEntityType( "test" ); - - return app.getEntityManager().searchConnectedEntities( rootEntity, query ); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInCollectionIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInCollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInCollectionIT.java deleted file mode 100644 index 1f29d46..0000000 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInCollectionIT.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.usergrid.persistence.query; - - -import org.junit.Test; - - -/** @author tnine */ -public class AllInCollectionIT extends AbstractIteratingQueryIT { - @Test - public void allInCollection() throws Exception { - allIn( new CollectionIoHelper( app ) ); - } -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionIT.java deleted file mode 100644 index 35cd63f..0000000 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionIT.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.usergrid.persistence.query; - - -import org.junit.Test; - - -/** @author tnine */ -public class AllInConnectionIT extends AbstractIteratingQueryIT { - @Test - public void allInConnection() throws Exception { - allIn( new ConnectionHelper(app) ); - } -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java deleted file mode 100644 index 6046962..0000000 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.usergrid.persistence.query; - - -import org.junit.Test; -import org.apache.usergrid.CoreApplication; -import org.apache.usergrid.persistence.index.query.Query; -import org.apache.usergrid.persistence.Results; - - -/** @author tnine */ -public class AllInConnectionNoTypeIT extends AbstractIteratingQueryIT { - - @Test - public void allInConnectionNoType() throws Exception { - allIn( new ConnectionNoTypeHelper(app) ); - } - - - class ConnectionNoTypeHelper extends ConnectionHelper { - - public ConnectionNoTypeHelper( final CoreApplication app ) { - super( app ); - } - - /** - * (non-Javadoc) @see - * org.apache.usergrid.persistence.query.SingleOrderByMaxLimitCollection.ConnectionHelper#getResults - * (org.apache.usergrid.persistence.Query) - */ - @Override - public Results getResults( Query query ) throws Exception { - query.setConnectionType( CONNECTION ); - // don't set it on purpose - query.setEntityType( null ); - return app.getEntityManager().searchConnectedEntities( rootEntity, query ); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java new file mode 100644 index 0000000..109ec14 --- /dev/null +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java @@ -0,0 +1,61 @@ +/* + * 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.usergrid.persistence.query; + + +import java.util.Map; + +import org.apache.usergrid.CoreApplication; +import org.apache.usergrid.persistence.Entity; +import org.apache.usergrid.persistence.Results; +import org.apache.usergrid.persistence.index.query.Query; + + +/** + * Helper for creating entities and writing them into collections + */ +public class CollectionIoHelper implements IoHelper { + + protected final CoreApplication app; + + + public CollectionIoHelper( final CoreApplication app ) { + this.app = app; + } + + + @Override + public void doSetup() throws Exception { + } + + + @Override + public Entity writeEntity( Map<String, Object> entity ) throws Exception { + + return app.getEntityManager().create( "test", entity ); + } + + + @Override + public Results getResults( Query query ) throws Exception { + app.getEntityManager().refreshIndex(); + return app.getEntityManager().searchCollection( app.getEntityManager().getApplicationRef(), "tests", query ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java new file mode 100644 index 0000000..aca1778 --- /dev/null +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java @@ -0,0 +1,85 @@ +/* + * 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.usergrid.persistence.query; + + +import java.util.HashMap; +import java.util.Map; + +import org.apache.usergrid.CoreApplication; +import org.apache.usergrid.persistence.Entity; +import org.apache.usergrid.persistence.Results; +import org.apache.usergrid.persistence.index.query.Query; + + +/** + * Helper class for creating entiites, then writing them to a connection + */ +public class ConnectionHelper extends CollectionIoHelper { + + /** + * + */ + protected static final String CONNECTION = "connection"; + protected Entity rootEntity; + + + public ConnectionHelper( final CoreApplication app ) { + super( app ); + } + + + @Override + public void doSetup() throws Exception { + Map<String, Object> data = new HashMap<String, Object>(); + data.put( "name", "rootentity" ); + rootEntity = app.getEntityManager().create( "root", data ); + } + + + @Override + public Entity writeEntity( Map<String, Object> entity ) throws Exception { + + // write to the collection + Entity created = super.writeEntity( entity ); + app.getEntityManager().createConnection( rootEntity, CONNECTION, created ); + + + return created; + } + + + /* + * (non-Javadoc) + * + * @see + * org.apache.usergrid.persistence.query.SingleOrderByMaxLimitCollection.CollectionIoHelper# + * getResults(org.apache.usergrid.persistence.Query) + */ + @Override + public Results getResults( Query query ) throws Exception { + + app.getEntityManager().refreshIndex(); + query.setConnectionType( CONNECTION ); + query.setEntityType( "test" ); + + return app.getEntityManager().searchConnectedEntities( rootEntity, query ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java index 88a2304..af7c401 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java @@ -23,10 +23,15 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.apache.usergrid.CoreApplication; +import org.apache.usergrid.CoreITSetup; +import org.apache.usergrid.CoreITSetupImpl; import org.apache.usergrid.persistence.Results; import org.apache.usergrid.persistence.index.query.Query; @@ -36,7 +41,7 @@ import static org.junit.Assert.assertEquals; /** * */ -public class IntersectionTransitivePagingIT extends AbstractIteratingQueryIT { +public class IntersectionTransitivePagingIT{ private static final Logger LOG = LoggerFactory.getLogger( IntersectionTransitivePagingIT.class ); @@ -46,6 +51,14 @@ public class IntersectionTransitivePagingIT extends AbstractIteratingQueryIT { private static final int PAGE_SIZE = 300; + + + @ClassRule + public static CoreITSetup setup = new CoreITSetupImpl(); + + @Rule + public CoreApplication app = new CoreApplication( setup ); + @Test public void testUnionPagingCollection() throws Exception { @@ -77,7 +90,7 @@ public class IntersectionTransitivePagingIT extends AbstractIteratingQueryIT { io.doSetup(); - int writeSize = PAGE_SIZE*4; + int writeSize =200; List<UUID> expected = new ArrayList<UUID>(writeSize); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java index 4dc4170..146b591 100644 --- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java @@ -23,13 +23,18 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import org.apache.usergrid.CoreApplication; +import org.apache.usergrid.CoreITSetup; +import org.apache.usergrid.CoreITSetupImpl; import org.apache.usergrid.persistence.Entity; -import org.apache.usergrid.persistence.index.query.Query; import org.apache.usergrid.persistence.Results; -import org.apache.usergrid.persistence.cassandra.QueryProcessor; +import org.apache.usergrid.persistence.index.query.Query; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -38,7 +43,7 @@ import static org.junit.Assert.assertTrue; /** * */ -public class IntersectionUnionPagingIT extends AbstractIteratingQueryIT { +public class IntersectionUnionPagingIT { private static final Logger LOG = LoggerFactory.getLogger( IntersectionUnionPagingIT.class ); @@ -50,6 +55,14 @@ public class IntersectionUnionPagingIT extends AbstractIteratingQueryIT { private static final int PAGE_SIZE = 300; + + @ClassRule + public static CoreITSetup setup = new CoreITSetupImpl( ); + + @Rule + public CoreApplication app = new CoreApplication( setup ); + + @Test public void testUnionPagingCollection() throws Exception { @@ -80,7 +93,7 @@ public class IntersectionUnionPagingIT extends AbstractIteratingQueryIT { private Set<String> performSetup( final IoHelper io ) throws Exception { io.doSetup(); - int size = ( int ) ( QueryProcessor.PAGE_SIZE*2.5); + int size = 200; long start = System.currentTimeMillis(); @@ -118,8 +131,6 @@ public class IntersectionUnionPagingIT extends AbstractIteratingQueryIT { LOG.debug("Writing entity with id '{}'", saved.getUuid()); - try { Thread.sleep( WRITE_DELAY ); } catch (Exception ignored) {} - } long stop = System.currentTimeMillis(); @@ -130,12 +141,12 @@ public class IntersectionUnionPagingIT extends AbstractIteratingQueryIT { } - private void testUnionPaging( final IoHelper io, final String queryString, + private void testUnionPaging( final IoHelper io, final String queryString, final Set<String> expectedResults ) throws Exception { Set<String> newSets = new HashSet<String>( expectedResults ); - //our field1Or has a result size < our page size, so it shouldn't blow up when the + //our field1Or has a result size < our page size, so it shouldn't blow up when the // cursor is getting created the leaf iterator should insert it's own "no value left" i // not the cursor Query query = Query.fromQL( queryString ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1fbe3e54/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java ---------------------------------------------------------------------- diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java new file mode 100644 index 0000000..1032bd0 --- /dev/null +++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IoHelper.java @@ -0,0 +1,57 @@ +/* + * 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.usergrid.persistence.query; + + +import java.util.Map; + +import org.apache.usergrid.persistence.Entity; +import org.apache.usergrid.persistence.Results; +import org.apache.usergrid.persistence.index.query.Query; + + +/** + * Interface to abstract actually doing I/O targets. The same test logic can be applied to both collections and + * connections + * + * @author tnine + */ +public interface IoHelper { + /** Perform any setup required */ + public void doSetup() throws Exception; + + /** + * Write the entity to the data store + * + * @param entity the entity + */ + public Entity writeEntity( Map<String, Object> entity ) throws Exception; + + /** + * Get the results for the query + * + * @param query the query to get results for + * + * @return the results of the query + */ + public Results getResults( Query query ) throws Exception; +} + +