usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject incubator-usergrid git commit: Added test to prove issue
Date Wed, 18 Mar 2015 22:07:49 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-492 407a4f55e -> 143692fe9


Added test to prove issue


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/143692fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/143692fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/143692fe

Branch: refs/heads/USERGRID-492
Commit: 143692fe9e8d06e1a006636b713a68591377fc1d
Parents: 407a4f5
Author: Todd Nine <tnine@apigee.com>
Authored: Wed Mar 18 16:07:46 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Wed Mar 18 16:07:46 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/StaleIndexCleanupTest.java  | 48 ++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/143692fe/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 4bde50e..1becee4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -127,6 +127,54 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
     }
 
 
+
+    /**
+     * USERGRID-492 test for ordering
+     */
+    @Test
+    public void testUpdateVersionMaxFirst() throws Exception {
+
+        // turn off post processing stuff that cleans up stale entities
+        System.setProperty( EVENTS_DISABLED, "true" );
+
+        final EntityManager em = app.getEntityManager();
+
+        Entity thing = em.create( "thing", new HashMap<String, Object>() {{
+            put( "ordinal", 0 );
+        }} );
+
+        em.refreshIndex();
+
+        assertEquals( 1, queryCollectionCp( "things", "thing", "select *" ).size() );
+
+        em.updateProperties( thing, new HashMap<String, Object>() {{
+            put( "ordinal", 1 );
+        }} );
+        em.refreshIndex();
+
+        UUID newVersion =  getCpEntity( thing ).getVersion();
+
+
+        assertEquals( 2, queryCollectionCp( "things", "thing", "select * order by ordinal
desc" ).size() );
+
+        //now run enable events and ensure we clean up
+        System.setProperty( EVENTS_DISABLED, "false" );
+
+        final Results results = queryCollectionEm( "things", "select * order by ordinal desc"
);
+
+        assertEquals( 1, results.size() );
+        assertEquals(1, results.getEntities().get( 0 ).getProperty( "ordinal" ));
+
+        em.refreshIndex();
+
+        //ensure it's actually gone
+        final CandidateResults candidates =  queryCollectionCp( "things", "thing", "select
* order by ordinal desc" );
+        assertEquals( 1, candidates.size() );
+
+        assertEquals(newVersion, candidates.get( 0 ).getVersion());
+    }
+
+
     /**
      * Test that the CpRelationManager cleans up and stale indexes that it finds when
      * it is building search results.


Mime
View raw message