Search in sources :

Example 6 with CassandraData

use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.

the class CassandraDataTest method testCassandraDataEntitiesEmptyRenameNonEmptySholdFail.

@Test
public // --entities="" --rename=whatever non empty  -> invalid
void testCassandraDataEntitiesEmptyRenameNonEmptySholdFail() {
    CassandraData parsed = new CassandraData(tableIdsMap, paths);
    parsed.setDatabaseEntitiesFromRequest(DatabaseEntities.parse(""));
    parsed.setRenamedEntitiesFromRequest(RenamedEntities.parse(new HashMap<String, String>() {

        {
            put("ks1.tb2", "ks1.tb3");
        }
    }));
    try {
        parsed.validate();
        fail("setting rename entities but not setting entities should fail");
    } catch (final Exception ex) {
    // ok
    }
}
Also used : CassandraData(com.instaclustr.esop.impl.CassandraData) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 7 with CassandraData

use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.

the class CassandraDataTest method testRenamedEntitiesWithDatabaseEntities.

@Test
public void testRenamedEntitiesWithDatabaseEntities() {
    CassandraData parsed = new CassandraData(tableIdsMap, paths);
    DatabaseEntities entities = DatabaseEntities.parse("ks1.tb1,ks1.tb2");
    parsed.setDatabaseEntitiesFromRequest(entities);
    parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {

        {
            put("ks1.tb2", "ks1.tb3");
        }
    });
}
Also used : CassandraData(com.instaclustr.esop.impl.CassandraData) DatabaseEntities(com.instaclustr.esop.impl.DatabaseEntities) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 8 with CassandraData

use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.

the class CassandraDataTest method testCassandraDataToInRenamingEntitiesIsPresentInEntitiesShouldFail.

@Test
public // --entities=ks1.tb1,ks1.tb2 --rename=ks1.tb2=ks1.tb1 -> invalid as "to" is in entities
void testCassandraDataToInRenamingEntitiesIsPresentInEntitiesShouldFail() {
    CassandraData parsed = new CassandraData(tableIdsMap, paths);
    parsed.setDatabaseEntitiesFromRequest(DatabaseEntities.parse("ks1.tb1,   ks1.tb2"));
    parsed.setRenamedEntitiesFromRequest(RenamedEntities.parse(new HashMap<String, String>() {

        {
            put("ks1.tb2", "ks1.tb1");
        }
    }));
    try {
        parsed.validate();
        fail("setting rename entities where 'to' is present in entities should fail");
    } catch (final Exception ex) {
    // ok
    }
}
Also used : CassandraData(com.instaclustr.esop.impl.CassandraData) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 9 with CassandraData

use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.

the class CassandraDataTest method testRenamedEntities.

@Test
public void testRenamedEntities() throws Exception {
    CassandraData parsed = new CassandraData(tableIdsMap, paths);
    try {
        parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {

            {
                put("ks3.  tb4", "ks1.  tb2");
            }
        });
        Assert.fail("should fail on non-existing ks3.tb4");
    } catch (Exception ex) {
        assertEquals(ex.getMessage(), "There is not keyspace ks3 to rename an entity from!");
    }
    try {
        parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {

            {
                put("ks1.tb5", "ks1.tb2");
            }
        });
        Assert.fail("should fail on non-existing ks1.tb5");
    } catch (Exception ex) {
        assertEquals(ex.getMessage(), "There is not table ks1.tb5 to rename an entity from!");
    }
    try {
        parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {

            {
                put("ks1.  tb1", "ks3  . tb1");
            }
        });
        Assert.fail("should fail on non-existing ks3.tb1");
    } catch (Exception ex) {
        assertEquals(ex.getMessage(), "There is not keyspace ks3 to rename an entity to!");
    }
    try {
        parsed.setRenamedEntitiesFromRequest(new HashMap<String, String>() {

            {
                put("ks1   .tb1", "ks2.  tb5");
            }
        });
        Assert.fail("should fail on non-existing ks2.tb5");
    } catch (Exception ex) {
        assertEquals(ex.getMessage(), "There is not table ks2.tb5 to rename an entity to!");
    }
}
Also used : CassandraData(com.instaclustr.esop.impl.CassandraData) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 10 with CassandraData

use of com.instaclustr.esop.impl.CassandraData in project esop by instaclustr.

the class CassandraDataTest method testCassandraDataKeyspaceEntitiesNotEmptyRenameNonEmptySholdFail.

@Test
public // --entities=ks1 --rename=whatever non empty -> invalid
void testCassandraDataKeyspaceEntitiesNotEmptyRenameNonEmptySholdFail() {
    CassandraData parsed = new CassandraData(tableIdsMap, paths);
    parsed.setDatabaseEntitiesFromRequest(DatabaseEntities.parse("ks1"));
    parsed.setRenamedEntitiesFromRequest(RenamedEntities.parse(new HashMap<String, String>() {

        {
            put("ks1.tb2", "ks1.tb3");
        }
    }));
    try {
        parsed.validate();
        fail("setting rename entities with set keyspace entities should fail");
    } catch (final Exception ex) {
    // ok
    }
}
Also used : CassandraData(com.instaclustr.esop.impl.CassandraData) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

CassandraData (com.instaclustr.esop.impl.CassandraData)10 BeforeTest (org.testng.annotations.BeforeTest)9 Test (org.testng.annotations.Test)9 HashMap (java.util.HashMap)5 DatabaseEntities (com.instaclustr.esop.impl.DatabaseEntities)4 List (java.util.List)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 CassandraVersion (com.instaclustr.cassandra.CassandraVersion)1 BackuperFactory (com.instaclustr.esop.guice.BackuperFactory)1 BucketServiceFactory (com.instaclustr.esop.guice.BucketServiceFactory)1 Session (com.instaclustr.esop.impl.AbstractTracker.Session)1 BucketService (com.instaclustr.esop.impl.BucketService)1 Manifest (com.instaclustr.esop.impl.Manifest)1 Manifest.getLocalManifestPath (com.instaclustr.esop.impl.Manifest.getLocalManifestPath)1 Manifest.getManifestAsManifestEntry (com.instaclustr.esop.impl.Manifest.getManifestAsManifestEntry)1 ManifestEntry (com.instaclustr.esop.impl.ManifestEntry)1 Snapshots (com.instaclustr.esop.impl.Snapshots)1 Snapshot (com.instaclustr.esop.impl.Snapshots.Snapshot)1 BackupOperationRequest (com.instaclustr.esop.impl.backup.BackupOperationRequest)1 Backuper (com.instaclustr.esop.impl.backup.Backuper)1