use of com.orientechnologies.orient.core.db.tool.ODatabaseCompare in project orientdb by orientechnologies.
the class DbImportExportTest method testCompareDatabases.
@Test(dependsOnMethods = "testDbImport")
public void testCompareDatabases() throws IOException {
if ("remote".equals(getStorageType()) || url.startsWith("remote:")) {
String env = getTestEnv();
if (env == null || env.equals("dev"))
return;
// EXECUTES ONLY IF NOT REMOTE ON CI/RELEASE TEST ENV
}
String urlPrefix = getStorageType() + ":";
final ODatabaseCompare databaseCompare = new ODatabaseCompare(url, urlPrefix + testPath + "/" + DbImportExportTest.NEW_DB_URL, "admin", "admin", this);
databaseCompare.setCompareEntriesForAutomaticIndexes(true);
databaseCompare.setCompareIndexMetadata(true);
Assert.assertTrue(databaseCompare.compare());
}
use of com.orientechnologies.orient.core.db.tool.ODatabaseCompare in project orientdb by orientechnologies.
the class LocalPaginatedStorageRestoreFromWAL method testSimpleRestore.
public void testSimpleRestore() throws Exception {
List<Future<Void>> futures = new ArrayList<Future<Void>>();
baseDocumentTx.declareIntent(new OIntentMassiveInsert());
for (int i = 0; i < 8; i++) futures.add(executorService.submit(new DataPropagationTask()));
for (Future<Void> future : futures) future.get();
Thread.sleep(1500);
copyDataFromTestWithoutClose();
OStorage baseStorage = baseDocumentTx.getStorage();
baseDocumentTx.close();
baseStorage.close();
testDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDir.getAbsolutePath() + "/testLocalPaginatedStorageRestoreFromWAL");
testDocumentTx.open("admin", "admin");
testDocumentTx.close();
ODatabaseCompare databaseCompare = new ODatabaseCompare(testDocumentTx.getURL(), baseDocumentTx.getURL(), "admin", "admin", new OCommandOutputListener() {
@Override
public void onMessage(String text) {
System.out.println(text);
}
});
databaseCompare.setCompareIndexMetadata(true);
Assert.assertTrue(databaseCompare.compare());
}
use of com.orientechnologies.orient.core.db.tool.ODatabaseCompare in project orientdb by orientechnologies.
the class LocalPaginatedStorageRestoreFromWALAndAddAdditionalRecords method testRestoreAndAddNewItems.
public void testRestoreAndAddNewItems() throws Exception {
List<Future<Void>> futures = new ArrayList<Future<Void>>();
baseDocumentTx.declareIntent(new OIntentMassiveInsert());
Random random = new Random();
long[] seeds = new long[5];
for (int i = 0; i < 5; i++) {
seeds[i] = random.nextLong();
System.out.println("Seed [" + i + "] = " + seeds[i]);
}
for (long seed : seeds) futures.add(executorService.submit(new DataPropagationTask(seed)));
for (Future<Void> future : futures) future.get();
futures.clear();
Thread.sleep(1500);
copyDataFromTestWithoutClose();
OStorage storage = baseDocumentTx.getStorage();
baseDocumentTx.close();
storage.close();
testDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDir.getAbsolutePath() + "/testLocalPaginatedStorageRestoreFromWALAndAddAdditionalRecords");
testDocumentTx.open("admin", "admin");
testDocumentTx.close();
long dataAddSeed = random.nextLong();
System.out.println("Data add seed = " + dataAddSeed);
for (int i = 0; i < 1; i++) futures.add(executorService.submit(new DataPropagationTask(dataAddSeed)));
for (Future<Void> future : futures) future.get();
ODatabaseCompare databaseCompare = new ODatabaseCompare(testDocumentTx.getURL(), baseDocumentTx.getURL(), "admin", "admin", new OCommandOutputListener() {
@Override
public void onMessage(String text) {
System.out.println(text);
}
});
databaseCompare.setCompareIndexMetadata(true);
Assert.assertTrue(databaseCompare.compare());
}
use of com.orientechnologies.orient.core.db.tool.ODatabaseCompare in project orientdb by orientechnologies.
the class LocalPaginatedStorageRestoreTx method testSimpleRestore.
public void testSimpleRestore() throws Exception {
List<Future<Void>> futures = new ArrayList<Future<Void>>();
baseDocumentTx.declareIntent(new OIntentMassiveInsert());
for (int i = 0; i < 8; i++) futures.add(executorService.submit(new DataPropagationTask()));
for (Future<Void> future : futures) future.get();
Thread.sleep(1500);
copyDataFromTestWithoutClose();
OStorage storage = baseDocumentTx.getStorage();
baseDocumentTx.close();
storage.close();
testDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDir.getAbsolutePath() + "/testLocalPaginatedStorageRestoreFromTx");
testDocumentTx.open("admin", "admin");
testDocumentTx.close();
ODatabaseCompare databaseCompare = new ODatabaseCompare(testDocumentTx.getURL(), baseDocumentTx.getURL(), "admin", "admin", new OCommandOutputListener() {
@Override
public void onMessage(String text) {
System.out.println(text);
}
});
databaseCompare.setCompareIndexMetadata(true);
Assert.assertTrue(databaseCompare.compare());
}
use of com.orientechnologies.orient.core.db.tool.ODatabaseCompare in project orientdb by orientechnologies.
the class StorageBackupMTStateTest method testRun.
public void testRun() throws Exception {
String buildDirectory = System.getProperty("buildDirectory", ".");
String dbDirectory = buildDirectory + File.separator + StorageBackupMTStateTest.class.getSimpleName();
System.out.println("Clean up old data");
OFileUtils.deleteRecursively(new File(dbDirectory));
final String backedUpDbDirectory = buildDirectory + File.separator + StorageBackupMTStateTest.class.getSimpleName() + "BackUp";
OFileUtils.deleteRecursively(new File(backedUpDbDirectory));
backupDir = new File(buildDirectory, StorageBackupMTStateTest.class.getSimpleName() + "BackupDir");
OFileUtils.deleteRecursively(backupDir);
if (!backupDir.exists())
Assert.assertTrue(backupDir.mkdirs());
dbURL = "plocal:" + dbDirectory;
System.out.println("Create database");
ODatabaseDocumentTx databaseDocumentTx = new ODatabaseDocumentTx(dbURL);
databaseDocumentTx.create();
System.out.println("Create schema");
final OSchema schema = databaseDocumentTx.getMetadata().getSchema();
for (int i = 0; i < 3; i++) {
createClass(schema);
}
databaseDocumentTx.close();
pool = new OPartitionedDatabasePool(dbURL, "admin", "admin");
System.out.println("Start data modification");
final ExecutorService executor = Executors.newFixedThreadPool(5);
final ScheduledExecutorService backupExecutor = Executors.newSingleThreadScheduledExecutor();
final ScheduledExecutorService classCreatorExecutor = Executors.newSingleThreadScheduledExecutor();
final ScheduledExecutorService classDeleterExecutor = Executors.newSingleThreadScheduledExecutor();
classDeleterExecutor.scheduleWithFixedDelay(new ClassDeleter(), 10, 10, TimeUnit.MINUTES);
backupExecutor.scheduleWithFixedDelay(new IncrementalBackupThread(), 5, 5, TimeUnit.MINUTES);
classCreatorExecutor.scheduleWithFixedDelay(new ClassAdder(), 7, 5, TimeUnit.MINUTES);
List<Future<Void>> futures = new ArrayList<Future<Void>>();
futures.add(executor.submit(new NonTxInserter()));
futures.add(executor.submit(new NonTxInserter()));
futures.add(executor.submit(new TxInserter()));
futures.add(executor.submit(new TxInserter()));
futures.add(executor.submit(new RecordsDeleter()));
int k = 0;
while (k < 180) {
Thread.sleep(30 * 1000);
k++;
System.out.println(k * 0.5 + " minutes...");
}
stop = true;
System.out.println("Stop backup");
backupExecutor.shutdown();
System.out.println("Stop class creation/deletion");
classCreatorExecutor.shutdown();
classDeleterExecutor.shutdown();
backupExecutor.awaitTermination(15, TimeUnit.MINUTES);
classCreatorExecutor.awaitTermination(15, TimeUnit.MINUTES);
classDeleterExecutor.awaitTermination(15, TimeUnit.MINUTES);
System.out.println("Stop data threads");
for (Future<Void> future : futures) future.get();
System.out.println("All threads are stopped");
pool.close();
System.out.println("Final incremental backup");
databaseDocumentTx = new ODatabaseDocumentTx(dbURL);
databaseDocumentTx.open("admin", "admin");
databaseDocumentTx.incrementalBackup(backupDir.getAbsolutePath());
OStorage storage = databaseDocumentTx.getStorage();
databaseDocumentTx.close();
storage.close(true, false);
System.out.println("Create backup database");
final ODatabaseDocumentTx backedUpDb = new ODatabaseDocumentTx("plocal:" + backedUpDbDirectory);
backedUpDb.create(backupDir.getAbsolutePath());
final OStorage backupStorage = backedUpDb.getStorage();
backedUpDb.close();
backupStorage.close(true, false);
System.out.println("Compare databases");
final ODatabaseCompare compare = new ODatabaseCompare("plocal:" + dbDirectory, "plocal:" + backedUpDbDirectory, "admin", "admin", new OCommandOutputListener() {
@Override
public void onMessage(String iText) {
System.out.println(iText);
}
});
Assert.assertTrue(compare.compare());
System.out.println("Drop databases and backup directory");
databaseDocumentTx.open("admin", "admin");
databaseDocumentTx.drop();
backedUpDb.open("admin", "admin");
backedUpDb.drop();
OFileUtils.deleteRecursively(backupDir);
}
Aggregations