use of com.walmartlabs.concord.common.TemporaryPath in project concord by walmartlabs.
the class RunTest method run.
private static int run(String payload, Map<String, Object> extraVars) throws Exception {
URI uri = RunTest.class.getResource(payload).toURI();
Path source = Paths.get(uri);
try (TemporaryPath dst = IOUtils.tempDir("cli-tests")) {
IOUtils.copy(source, dst.path());
App app = new App();
CommandLine cmd = new CommandLine(app);
List<String> args = new ArrayList<>();
args.add("run");
for (Map.Entry<String, Object> e : extraVars.entrySet()) {
args.add("-e");
args.add(e.getKey() + "=" + e.getValue());
}
args.add(dst.path().toString());
return cmd.execute(args.toArray(new String[0]));
}
}
use of com.walmartlabs.concord.common.TemporaryPath in project concord by walmartlabs.
the class AttachmentsUploader method upload.
public void upload(UUID instanceId, Path workDir) throws Exception {
Path attachmentsDir = workDir.resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME);
if (!Files.exists(attachmentsDir)) {
return;
}
try (TemporaryPath tmp = IOUtils.tempFile("attachments", ".zip")) {
try (ZipArchiveOutputStream zip = new ZipArchiveOutputStream(Files.newOutputStream(tmp.path()))) {
IOUtils.zip(zip, attachmentsDir);
}
String path = "/api/v1/process/" + instanceId + "/attachment";
ClientUtils.withRetry(AgentConstants.API_CALL_MAX_RETRIES, AgentConstants.API_CALL_RETRY_DELAY, () -> {
ClientUtils.postData(apiClient, path, tmp.path().toFile());
return null;
});
}
}
use of com.walmartlabs.concord.common.TemporaryPath in project concord by walmartlabs.
the class GitClientFetch2Test method testFetchByPrevCommit.
@Test
public void testFetchByPrevCommit() throws Exception {
Path repo = GitUtils.createBareRepository(resourceToPath("/master"));
RevCommit commit0 = GitUtils.addContent(repo, resourceToPath("/test5/0_concord.yml"));
GitUtils.addContent(repo, resourceToPath("/test5/1_concord.yml"));
try (TemporaryPath repoPath = IOUtils.tempDir("git-client-test")) {
// fetch master
fetch(repo.toString(), "master", null, repoPath.path());
assertContent(repoPath, "master.txt", "master");
assertContent(repoPath, "0_concord.yml", "0-concord-content");
assertContent(repoPath, "1_concord.yml", "1-concord-content");
System.out.println("fetching prev commit");
// fetch prev commitId
fetch(repo.toString(), null, commit0.name(), repoPath.path());
assertNoContent(repoPath, "1_concord.yml");
}
}
use of com.walmartlabs.concord.common.TemporaryPath in project concord by walmartlabs.
the class GitClientFetch2Test method testFetchByBranchAndPrevCommit.
@Test
public void testFetchByBranchAndPrevCommit() throws Exception {
Path repo = GitUtils.createBareRepository(resourceToPath("/master"));
RevCommit commit0 = GitUtils.addContent(repo, resourceToPath("/test5/0_concord.yml"));
GitUtils.addContent(repo, resourceToPath("/test5/1_concord.yml"));
try (TemporaryPath repoPath = IOUtils.tempDir("git-client-test")) {
// fetch master
fetch(repo.toString(), "master", null, repoPath.path());
assertContent(repoPath, "master.txt", "master");
assertContent(repoPath, "0_concord.yml", "0-concord-content");
assertContent(repoPath, "1_concord.yml", "1-concord-content");
// fetch master+prev commitId
fetch(repo.toString(), "master", commit0.name(), repoPath.path());
assertNoContent(repoPath, "1_concord.yml");
}
}
use of com.walmartlabs.concord.common.TemporaryPath in project concord by walmartlabs.
the class GitClientFetch2Test method testReFetch.
@Test
public void testReFetch() throws Exception {
Path repo = GitUtils.createBareRepository(resourceToPath("/master"));
RevCommit commit0 = GitUtils.addContent(repo, resourceToPath("/test5/0_concord.yml"));
GitUtils.addContent(repo, resourceToPath("/test5/1_concord.yml"));
try (TemporaryPath repoPath = IOUtils.tempDir("git-client-test")) {
// fetch master
fetch(repo.toString(), "master", null, repoPath.path());
assertContent(repoPath, "master.txt", "master");
assertContent(repoPath, "0_concord.yml", "0-concord-content");
assertContent(repoPath, "1_concord.yml", "1-concord-content");
System.out.println("refetching");
// refetch master
fetch(repo.toString(), "master", null, repoPath.path());
assertContent(repoPath, "1_concord.yml", "1-concord-content");
}
}
Aggregations