Search in sources :

Example 1 with DbSchema

use of com.emc.storageos.db.common.schema.DbSchema 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 DbSchema

use of com.emc.storageos.db.common.schema.DbSchema 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 DbSchema

use of com.emc.storageos.db.common.schema.DbSchema 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)

Example 4 with DbSchema

use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.

the class DbSchemaCheckerTest method testGeoNewAnnotationOnNewField.

@Test
public void testGeoNewAnnotationOnNewField() {
    DbSchema srcGeoSchema = new DataObjectSchema(GeoClassUT.class);
    srcSchemas.addSchema(srcGeoSchema);
    tgtSchema = new DataObjectSchema(GeoNewField.class);
    tgtSchema.setType(srcSchema.getType());
    tgtSchemas.addSchema(tgtSchema);
    tgtSchemas.addSchema(srcSchema);
    DbSchemasDiff diff = new DbSchemasDiff(srcSchemas, tgtSchemas);
    // Adding index on new field of 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)

Example 5 with DbSchema

use of com.emc.storageos.db.common.schema.DbSchema in project coprhd-controller by CoprHD.

the class DbSchemaChecker method removeUnusedSchemaIfExists.

/**
 * drop schema from db is not allowed, but we have special cases to drop schema such as:
 * Data Service separation, we drop schema used by Data Service to perform cleanup,
 * during migration we convert xml-based schema stored in db to DbSchemas object as previous
 * schema, the dropped schema needs to be skipped before schema comparison in order to removed
 * schema , otherwise migration will fail because of unsupported schema change.
 *
 * @param schemas
 * @param ignoreSchemaNames, the list of schema names which needs to be removed from schemas
 * @return
 */
private static void removeUnusedSchemaIfExists(DbSchemas schemas, List<String> ignoreSchemaNames) {
    Iterator<DbSchema> it = schemas.getSchemas().iterator();
    while (it.hasNext()) {
        DbSchema schema = it.next();
        if (ignoreSchemaNames.contains(schema.getName())) {
            log.info("skip schema:{} since it's removed", schema.getName());
            it.remove();
        }
    }
}
Also used : DbSchema(com.emc.storageos.db.common.schema.DbSchema)

Aggregations

DbSchema (com.emc.storageos.db.common.schema.DbSchema)10 DbSchemasDiff (com.emc.storageos.db.common.diff.DbSchemasDiff)6 DataObjectSchema (com.emc.storageos.db.common.schema.DataObjectSchema)6 Test (org.junit.Test)5 DbKeyspace (com.emc.storageos.db.client.model.DbKeyspace)1 TimeSeries (com.emc.storageos.db.client.model.TimeSeries)1 TimeSeriesSerializer (com.emc.storageos.db.client.model.TimeSeriesSerializer)1 AnnotationType (com.emc.storageos.db.common.schema.AnnotationType)1 AnnotationValue (com.emc.storageos.db.common.schema.AnnotationValue)1 DataPointSchema (com.emc.storageos.db.common.schema.DataPointSchema)1 DbSchemas (com.emc.storageos.db.common.schema.DbSchemas)1 FieldInfo (com.emc.storageos.db.common.schema.FieldInfo)1 TimeSeriesSchema (com.emc.storageos.db.common.schema.TimeSeriesSchema)1 ArrayList (java.util.ArrayList)1