usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [16/50] [abbrv] incubator-usergrid git commit: Temporarily removed test. Need to rebuild with plugin structure.
Date Thu, 19 Mar 2015 23:26:33 GMT
Temporarily removed test.  Need to rebuild with plugin structure.


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

Branch: refs/heads/USERGRID-480
Commit: 12c503591cb1d37301533d95075fe1d27d5bbf39
Parents: d3ce4e7
Author: Todd Nine <tnine@apigee.com>
Authored: Wed Mar 4 11:53:24 2015 -0700
Committer: Todd Nine <tnine@apigee.com>
Committed: Wed Mar 4 11:53:24 2015 -0700

----------------------------------------------------------------------
 .../migration/EntityTypeMappingMigrationIT.java | 211 +++++++++----------
 .../migration/MigrationTestRule.java            |  98 ---------
 2 files changed, 95 insertions(+), 214 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12c50359/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
index 99fb139..35608d5 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
@@ -20,42 +20,20 @@
 package org.apache.usergrid.corepersistence.migration;
 
 
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.core.rx.AllEntitiesInSystemObservable;
-import org.apache.usergrid.persistence.core.scope.ApplicationEntityGroup;
-import org.apache.usergrid.persistence.core.scope.EntityIdScope;
 import org.junit.Before;
 import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
 
 import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.cassandra.SpringResource;
-import org.apache.usergrid.corepersistence.EntityWriteHelper;
 import org.apache.usergrid.corepersistence.ManagerCache;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.map.impl.MapSerializationImpl;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import com.google.inject.Injector;
 import com.netflix.astyanax.Keyspace;
 
 import net.jcip.annotations.NotThreadSafe;
 
-import rx.functions.Action1;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 
 @NotThreadSafe
 public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
@@ -71,24 +49,25 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
     private DataMigrationManager dataMigrationManager;
 
 
-    /**
-     * Rule to do the resets we need
-     */
-    @Rule
-    public MigrationTestRule migrationTestRule = new MigrationTestRule(
-            app,  SpringResource.getInstance().getBean( Injector.class ) ,EntityTypeMappingMigration.class
 );
-    private AllEntitiesInSystemObservable allEntitiesInSystemObservable;
+//    /**
+//     * Rule to do the resets we need
+//     */
+//    @Rule
+//    public MigrationTestRule migrationTestRule = new MigrationTestRule(
+//            app,  SpringResource.getInstance().getBean( Injector.class ) ,EntityTypeMappingMigration.class
 );
+//    private AllEntitiesInSystemObservable allEntitiesInSystemObservable;
 
 
+    //TODO USERGRID-405
     @Before
     public void setup() {
-        injector =  SpringResource.getInstance().getBean( Injector.class );
-        emf = setup.getEmf();
-        entityTypeMappingMigration = injector.getInstance( EntityTypeMappingMigration.class
);
-        keyspace = injector.getInstance( Keyspace.class );
-        managerCache = injector.getInstance( ManagerCache.class );
-        dataMigrationManager = injector.getInstance( DataMigrationManager.class );
-        allEntitiesInSystemObservable = injector.getInstance(AllEntitiesInSystemObservable.class);
+//        injector =  SpringResource.getInstance().getBean( Injector.class );
+//        emf = setup.getEmf();
+//        entityTypeMappingMigration = injector.getInstance( EntityTypeMappingMigration.class
);
+//        keyspace = injector.getInstance( Keyspace.class );
+//        managerCache = injector.getInstance( ManagerCache.class );
+//        dataMigrationManager = injector.getInstance( DataMigrationManager.class );
+//        allEntitiesInSystemObservable = injector.getInstance(AllEntitiesInSystemObservable.class);
     }
 
 
@@ -96,85 +75,85 @@ public class EntityTypeMappingMigrationIT extends AbstractCoreIT {
     @Ignore("Ignored awaiting fix for USERGRID-268")
     public void testIdMapping() throws Throwable {
 
-        assertEquals( "version 1 expected", 1, entityTypeMappingMigration.getVersion() );
-        assertEquals( "Previous version expected", 0, dataMigrationManager.getCurrentVersion());
-
-        final EntityManager newAppEm = app.getEntityManager();
-
-        final String type1 = "type1thing";
-        final String type2 = "type2thing";
-        final int size = 10;
-
-        final Set<Id> type1Identities = EntityWriteHelper.createTypes( newAppEm, type1,
size );
-        final Set<Id> type2Identities = EntityWriteHelper.createTypes( newAppEm, type2,
size );
-
-
-        final Set<Id> allEntities = new HashSet<>();
-        allEntities.addAll( type1Identities );
-        allEntities.addAll( type2Identities );
-
-
-        /**
-         * Drop our map keyspace to ensure we have no entries before migrating after doing
our writes.
-         * This will ensure we have the data
-         */
-        keyspace.truncateColumnFamily( MapSerializationImpl.MAP_ENTRIES );
-        keyspace.truncateColumnFamily( MapSerializationImpl.MAP_KEYS );
-
-        app.createApplication(
-                GraphShardVersionMigrationIT.class.getSimpleName()+ UUIDGenerator.newTimeUUID(),
-                "migrationTest" );
-
-
-
-        final TestProgressObserver progressObserver = new TestProgressObserver();
-
-        entityTypeMappingMigration.migrate(allEntitiesInSystemObservable.getAllEntitiesInSystem(1000),
progressObserver).toBlocking().last();
-
-        allEntitiesInSystemObservable.getAllEntitiesInSystem(1000)
-            .doOnNext(new Action1<ApplicationEntityGroup<CollectionScope>>()
{
-                @Override
-                public void call(
-                    final ApplicationEntityGroup<CollectionScope> entity) {
-                    //ensure that each one has a type
-
-                    final EntityManager em = emf.getEntityManager(
-                        entity.applicationScope.getApplication().getUuid());
-
-                    for (final EntityIdScope<CollectionScope> idScope : entity.entityIds)
{
-                        final Id id = idScope.getId();
-                        try {
-                            final Entity returned = em.get(id.getUuid());
-
-                            //we seem to occasionally get phantom edges.  If this is the
-                            // case we'll store the type _> uuid mapping, but we won't
have
-                            // anything to load
-
-                            if (returned != null) {
-                                assertEquals(id.getUuid(), returned.getUuid());
-                                assertEquals(id.getType(), returned.getType());
-                            } else {
-                                final String type = managerCache.getMapManager(CpNamingUtils
-                                    .getEntityTypeMapScope(
-                                        entity.applicationScope.getApplication()))
-                                    .getString(id.getUuid()
-                                        .toString());
-
-                                assertEquals(id.getType(), type);
-                            }
-                        } catch (Exception e) {
-                            throw new RuntimeException("Unable to get entity " + id
-                                + " by UUID, migration failed", e);
-                                    }
-
-                                    allEntities.remove(id);
-                                }
-                            }
-                        }).toBlocking().lastOrDefault(null);
-
-
-                    assertEquals("Every element should have been encountered", 0, allEntities.size());
-                    assertFalse("Progress observer should not have failed", progressObserver.getFailed());
-                    assertTrue("Progress observer should have update messages", progressObserver.getUpdates().size()
> 0);
+//        assertEquals( "version 1 expected", 1, entityTypeMappingMigration.getVersion()
);
+//        assertEquals( "Previous version expected", 0, dataMigrationManager.getCurrentVersion());
+//
+//        final EntityManager newAppEm = app.getEntityManager();
+//
+//        final String type1 = "type1thing";
+//        final String type2 = "type2thing";
+//        final int size = 10;
+//
+//        final Set<Id> type1Identities = EntityWriteHelper.createTypes( newAppEm,
type1, size );
+//        final Set<Id> type2Identities = EntityWriteHelper.createTypes( newAppEm,
type2, size );
+//
+//
+//        final Set<Id> allEntities = new HashSet<>();
+//        allEntities.addAll( type1Identities );
+//        allEntities.addAll( type2Identities );
+//
+//
+//        /**
+//         * Drop our map keyspace to ensure we have no entries before migrating after doing
our writes.
+//         * This will ensure we have the data
+//         */
+//        keyspace.truncateColumnFamily( MapSerializationImpl.MAP_ENTRIES );
+//        keyspace.truncateColumnFamily( MapSerializationImpl.MAP_KEYS );
+//
+//        app.createApplication(
+//                GraphShardVersionMigrationIT.class.getSimpleName()+ UUIDGenerator.newTimeUUID(),
+//                "migrationTest" );
+//
+//
+//
+//        final TestProgressObserver progressObserver = new TestProgressObserver();
+//
+//        entityTypeMappingMigration.migrate(allEntitiesInSystemObservable.getAllEntitiesInSystem(1000),
progressObserver).toBlocking().last();
+//
+//        allEntitiesInSystemObservable.getAllEntitiesInSystem(1000)
+//            .doOnNext(new Action1<ApplicationEntityGroup<CollectionScope>>()
{
+//                @Override
+//                public void call(
+//                    final ApplicationEntityGroup<CollectionScope> entity) {
+//                    //ensure that each one has a type
+//
+//                    final EntityManager em = emf.getEntityManager(
+//                        entity.applicationScope.getApplication().getUuid());
+//
+//                    for (final EntityIdScope<CollectionScope> idScope : entity.entityIds)
{
+//                        final Id id = idScope.getId();
+//                        try {
+//                            final Entity returned = em.get(id.getUuid());
+//
+//                            //we seem to occasionally get phantom edges.  If this is the
+//                            // case we'll store the type _> uuid mapping, but we won't
have
+//                            // anything to load
+//
+//                            if (returned != null) {
+//                                assertEquals(id.getUuid(), returned.getUuid());
+//                                assertEquals(id.getType(), returned.getType());
+//                            } else {
+//                                final String type = managerCache.getMapManager(CpNamingUtils
+//                                    .getEntityTypeMapScope(
+//                                        entity.applicationScope.getApplication()))
+//                                    .getString(id.getUuid()
+//                                        .toString());
+//
+//                                assertEquals(id.getType(), type);
+//                            }
+//                        } catch (Exception e) {
+//                            throw new RuntimeException("Unable to get entity " + id
+//                                + " by UUID, migration failed", e);
+//                                    }
+//
+//                                    allEntities.remove(id);
+//                                }
+//                            }
+//                        }).toBlocking().lastOrDefault(null);
+//
+//
+//                    assertEquals("Every element should have been encountered", 0, allEntities.size());
+//                    assertFalse("Progress observer should not have failed", progressObserver.getFailed());
+//                    assertTrue("Progress observer should have update messages", progressObserver.getUpdates().size()
> 0);
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/12c50359/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java
deleted file mode 100644
index 67f89ab..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/MigrationTestRule.java
+++ /dev/null
@@ -1,98 +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.corepersistence.migration;
-
-
-import org.junit.rules.ExternalResource;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import org.apache.usergrid.CoreApplication;
-import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationPlugin;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-
-import com.google.inject.Injector;
-
-
-/**
- * This class is required because we cannot create the system's framework on a higher version
(the default behavior is
- * the latest) then roll back to a previous version
- *
- * This rule performs the following operations.
- *
- * <ol> <li>Sets up the system's version to be the DataMigration impl's version
-1</li> <li>Creates an application using
- * that version of the schema.</li> <li>Sets the new org and app in the CoreApplication
to the app created</li> </ol>
- */
-public class MigrationTestRule extends ExternalResource {
-
-    protected final CoreApplication core;
-    protected final DataMigrationManager dataMigrationManager;
-    protected final DataMigration2 dataMigration;
-
-    protected int currentVersion;
-
-
-    /**
-     * Create a new migration test rule.
-     *
-     * @param core the CoreApplication rule used in this test
-     * @param injector The injector used in this test
-     */
-    public MigrationTestRule( final CoreApplication core, final Injector injector ) {
-        this.core = core;
-        this.dataMigrationManager = injector.getInstance( DataMigrationManager.class );
-        this.dataMigration = injector.getInstance( dataMigrationClass );
-    }
-
-
-    public void resetAndCreateApp( final String className, final String methodName ) throws
Exception {
-        dataMigrationManager.invalidate();
-        currentVersion = dataMigrationManager.getCurrentVersion();
-
-        dataMigrationManager.resetToVersion( dataMigration.getVersion() - 1 );
-        dataMigrationManager.invalidate();
-
-        core.createApplication( className + UUIDGenerator.newTimeUUID(), methodName );
-    }
-
-
-    public void resetVersion(){
-        dataMigrationManager.resetToVersion( currentVersion );
-        dataMigrationManager.invalidate();
-    }
-
-    @Override
-    public Statement apply( final Statement base, final Description description ) {
-
-        return new Statement() {
-            @Override
-            public void evaluate() throws Throwable {
-                try {
-                    resetAndCreateApp( description.getClassName(), description.getMethodName()
);
-                    base.evaluate();
-                }finally {
-                    resetVersion();
-                }
-            }
-        };
-    }
-}


Mime
View raw message