Search in sources :

Example 1 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class BaseDbSchemaCheckerTest method testMoveFieldToBaseClass.

@Test
public void testMoveFieldToBaseClass() {
    srcSchemas.setSchemas(new ArrayList<DbSchema>());
    tgtSchemas.setSchemas(new ArrayList<DbSchema>());
    srcSchema = new DataObjectSchema(ChildClassUTBefore.class);
    srcSchema.setType(srcSchema.getType());
    srcSchemas.addSchema(srcSchema);
    tgtSchema = new DataObjectSchema(ChildClassUTAfter1.class);
    tgtSchema.setType(tgtSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    tgtSchema = new DataObjectSchema(ChildClassUTAfter2.class);
    tgtSchema.setType(tgtSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    Assert.assertTrue(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchema(com.emc.storageos.db.common.schema.DbSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 2 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class BaseDbSchemaCheckerTest method testCustomMigrationPreUpgrade.

@Test
public void testCustomMigrationPreUpgrade() {
    srcSchemas.setSchemas(new ArrayList<DbSchema>());
    tgtSchemas.setSchemas(new ArrayList<DbSchema>());
    srcSchema = new DataObjectSchema(CustomMigrationExistingField.class);
    srcSchema.setType(srcSchema.getType());
    srcSchemas.addSchema(srcSchema);
    tgtSchema = new DataObjectSchema(CustomMigrationExistingAndNewField.class);
    tgtSchema.setType(tgtSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    Assert.assertTrue(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchema(com.emc.storageos.db.common.schema.DbSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 3 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class DbSchemaCheckerTest method testNewFieldAnnotationValue.

@Test
public void testNewFieldAnnotationValue() {
    tgtSchema = new DataObjectSchema(WithChangedAnnotationValue.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    Assert.assertFalse(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 4 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class DbSchemaCheckerTest method testMultipleIllegalUpgradeChanges.

@Test
public void testMultipleIllegalUpgradeChanges() {
    srcSchema = new DataObjectSchema(WithIndexAnnotation.class);
    srcSchema.setType(srcSchema.getType());
    srcSchemas.addSchema(srcSchema);
    srcSchema = new DataObjectSchema(ClassUT7.class);
    srcSchema.setType(srcSchema.getType());
    srcSchemas.addSchema(srcSchema);
    srcSchema = new DataObjectSchema(ClassUT4.class);
    srcSchema.setType(srcSchema.getType());
    srcSchemas.addSchema(srcSchema);
    srcSchema = new DataObjectSchema(ClassUT5.class);
    srcSchema.setType(srcSchema.getType());
    srcSchemas.addSchema(srcSchema);
    tgtSchema = new DataObjectSchema(WithRemovedIndexAnnotation.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    tgtSchema = new DataObjectSchema(ClassUT3.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    tgtSchema = new DataObjectSchema(ClassUT6.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    Assert.assertFalse(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Example 5 with DbSchemasDiff

use of com.emc.storageos.db.common.diff.DbSchemasDiff in project coprhd-controller by CoprHD.

the class DbSchemaCheckerTest method testGeoNewAnnotationOnNewCF.

@Test
public void testGeoNewAnnotationOnNewCF() {
    DbSchema srcGeoSchema = new DataObjectSchema(GeoClassUT.class);
    srcSchemas.addSchema(srcGeoSchema);
    tgtSchemas.addSchema(srcGeoSchema);
    tgtSchema = new DataObjectSchema(GeoNewCF.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    tgtSchemas.addSchema(srcSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    // Adding index of new Geo object is allowed
    Assert.assertTrue(diff.isUpgradable());
    Assert.assertTrue(diff.isChanged());
}
Also used : DataObjectSchema(com.emc.storageos.db.common.schema.DataObjectSchema) DbSchema(com.emc.storageos.db.common.schema.DbSchema) DbSchemasDiff(com.emc.storageos.db.common.diff.DbSchemasDiff) Test(org.junit.Test)

Aggregations

DbSchemasDiff (com.emc.storageos.db.common.diff.DbSchemasDiff)24 DataObjectSchema (com.emc.storageos.db.common.schema.DataObjectSchema)21 Test (org.junit.Test)21 DbSchema (com.emc.storageos.db.common.schema.DbSchema)6 DbSchemas (com.emc.storageos.db.common.schema.DbSchemas)3 ArrayList (java.util.ArrayList)2 MigrationStatus (com.emc.storageos.coordinator.client.model.MigrationStatus)1 FatalCoordinatorException (com.emc.storageos.coordinator.exceptions.FatalCoordinatorException)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 FatalDatabaseException (com.emc.storageos.db.exceptions.FatalDatabaseException)1 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 List (java.util.List)1 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)1