use of com.walmartlabs.concord.server.process.queue.ProcessKeyCache in project concord by walmartlabs.
the class ProcessStateManagerTest method testUpdateState.
@Test
public void testUpdateState() throws Exception {
ProcessKey processKey = new ProcessKey(UUID.randomUUID(), OffsetDateTime.now());
Path baseDir = Files.createTempDirectory("testImport");
writeTempFile(baseDir.resolve("file-1"), "123".getBytes());
writeTempFile(baseDir.resolve("file-2"), "456".getBytes());
//
ProcessKeyCache processKeyCache = new ProcessKeyCache(new ProcessQueueDao(getConfiguration(), new ConcordObjectMapper(new ObjectMapper())));
ProcessConfiguration stateCfg = new ProcessConfiguration(Duration.of(24, ChronoUnit.HOURS), Collections.singletonList(Constants.Files.CONFIGURATION_FILE_NAME));
ProcessStateManager stateManager = new ProcessStateManager(getConfiguration(), mock(SecretStoreConfiguration.class), stateCfg, mock(PolicyManager.class), mock(ProcessLogManager.class), processKeyCache);
stateManager.importPath(processKey, null, baseDir, (p, attrs) -> true);
Path tmpDir = Files.createTempDirectory("testExport");
boolean result = stateManager.export(processKey, copyTo(tmpDir));
assertTrue(result);
assertFileContent("123", tmpDir.resolve("file-1"));
assertFileContent("456", tmpDir.resolve("file-2"));
// --- update
writeTempFile(baseDir.resolve("file-1"), "123-up".getBytes());
stateManager.importPath(processKey, null, baseDir, (p, attrs) -> true);
result = stateManager.export(processKey, copyTo(tmpDir));
assertTrue(result);
assertFileContent("123-up", tmpDir.resolve("file-1"));
assertFileContent("456", tmpDir.resolve("file-2"));
}
use of com.walmartlabs.concord.server.process.queue.ProcessKeyCache in project concord by walmartlabs.
the class ProcessStateManagerTest method testLargeImport.
@Test
public void testLargeImport() throws Exception {
ProcessKey processKey = new ProcessKey(UUID.randomUUID(), OffsetDateTime.now());
int files = 100;
int chunkSize = 1024 * 1024;
int fileSize = 10 * chunkSize;
byte[] ab = new byte[chunkSize];
Arrays.fill(ab, (byte) 0);
Path baseDir = Files.createTempDirectory("test");
for (int i = 0; i < files; i++) {
Path p = baseDir.resolve("file" + i);
try (OutputStream out = Files.newOutputStream(p, StandardOpenOption.CREATE)) {
for (int j = 0; j < fileSize; j += chunkSize) {
out.write(ab);
}
}
}
ProcessKeyCache processKeyCache = new ProcessKeyCache(new ProcessQueueDao(getConfiguration(), new ConcordObjectMapper(new ObjectMapper())));
ProcessConfiguration stateCfg = new ProcessConfiguration(Duration.of(24, ChronoUnit.HOURS), Collections.singletonList(Constants.Files.CONFIGURATION_FILE_NAME));
ProcessStateManager stateManager = new ProcessStateManager(getConfiguration(), mock(SecretStoreConfiguration.class), stateCfg, mock(PolicyManager.class), mock(ProcessLogManager.class), processKeyCache);
stateManager.importPath(processKey, "/", baseDir, (p, attrs) -> true);
}
Aggregations