use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliBackupManagerIT method testBackupToCustomDir.
@Test
public void testBackupToCustomDir() {
startSourceCluster();
String backupName = "server-backup";
String fileName = backupName + ".zip";
File localBackupDir = new File(WORKING_DIR, "custom-dir");
localBackupDir.mkdir();
localBackupDir.setWritable(true, false);
File serverBackupDir = new File(source.driver.syncFilesToServer(0, localBackupDir.getAbsolutePath()));
source.driver.syncFilesToServer(1, localBackupDir.getAbsolutePath());
try (AeshTestConnection t = cli(source)) {
t.clear();
t.send(String.format("backup create -d %s -n %s", serverBackupDir.getPath(), backupName));
// Ensure that the backup has finished before stopping the source cluster
t.send("backup get --no-content " + backupName);
}
localBackupDir = new File(source.driver.syncFilesFromServer(0, serverBackupDir.getAbsolutePath()));
if (!localBackupDir.getName().equals("custom-dir")) {
localBackupDir = new File(localBackupDir, "custom-dir");
}
assertTrue(new File(localBackupDir, backupName + "/" + fileName).exists());
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliBackupManagerIT method testBackupUpload.
@Test
public void testBackupUpload() throws Exception {
startSourceCluster();
Path createdBackup;
try (AeshTestConnection t = cli(source)) {
t.send("create cache --template=org.infinispan.DIST_SYNC backupCache");
t.send("cd caches/backupCache");
t.send("put k1 v1");
t.send("ls");
t.assertContains("k1");
t.clear();
String backupName = "example-backup";
t.send("backup create -n " + backupName);
t.send("backup get " + backupName);
Thread.sleep(1000);
t.send("backup delete " + backupName);
String fileName = backupName + ".zip";
createdBackup = Paths.get(System.getProperty("user.dir")).resolve(fileName);
}
stopSourceCluster();
startTargetCluster();
try (AeshTestConnection t = cli(target)) {
t.send("backup restore -u " + createdBackup);
Thread.sleep(1000);
t.send("ls caches/backupCache");
t.assertContains("k1");
}
Files.delete(createdBackup);
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliBackupManagerIT method testBackupFromServerDir.
@Test
public void testBackupFromServerDir() throws Exception {
startSourceCluster();
String backupName = "server-backup";
String fileName = backupName + ".zip";
try (AeshTestConnection t = cli(source)) {
t.send("create cache --template=org.infinispan.DIST_SYNC backupCache");
t.send("cd caches/backupCache");
t.send("put k1 v1");
t.send("ls");
t.assertContains("k1");
t.clear();
t.send("backup create -n " + backupName);
// Ensure that the backup has finished before stopping the source cluster
t.send("backup get --no-content " + backupName);
}
source.driver.syncFilesFromServer(0, "data");
stopSourceCluster();
startTargetCluster();
Path createdBackup = source.driver.getRootDir().toPath().resolve("0/data/backups").resolve(backupName).resolve(fileName);
createdBackup = Paths.get(target.driver.syncFilesToServer(0, createdBackup.toString()));
try (AeshTestConnection t = cli(target)) {
t.send("backup restore " + createdBackup);
Thread.sleep(1000);
t.send("ls caches/backupCache");
t.assertContains("k1");
}
Files.deleteIfExists(createdBackup);
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliBackupManagerIT method testPartialBackup.
@Test
public void testPartialBackup() throws Exception {
startSourceCluster();
String backupName = "partial-backup";
String fileName = backupName + ".zip";
try (AeshTestConnection t = cli(source)) {
t.send("backup create --templates=* -n " + backupName);
// Ensure that the backup has finished before stopping the source cluster
t.send("backup get --no-content " + backupName);
}
source.driver.syncFilesFromServer(0, "data");
Path createdBackup = source.driver.getRootDir().toPath().resolve("0/data/backups").resolve(backupName).resolve(fileName);
try (ZipFile zip = new ZipFile(createdBackup.toFile())) {
// Ensure that only cache-configs are present
assertNotNull(zipResourceDir(TEMPLATES));
assertResourceDoesntExist(zip, CACHES, COUNTERS, PROTO_SCHEMAS, TASKS);
}
Files.delete(createdBackup);
}
use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.
the class CliBackupManagerIT method cli.
private AeshTestConnection cli(Cluster cluster) {
AeshTestConnection t = new AeshTestConnection();
CLI.main(new AeshDelegatingShell(t), new String[] {}, new Properties());
String host = cluster.driver.getServerAddress(0).getHostAddress();
int port = cluster.driver.getServerSocket(0, 11222).getPort();
t.send(String.format("connect %s:%d", host, port));
t.assertContains("//containers/default]>");
t.clear();
return t;
}
Aggregations