use of org.commonjava.indy.promote.model.PathsPromoteResult in project indy by Commonjava.
the class ArtifactRefs_PromoteWithParent_RuleTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
String child = "org/foo/child/1/child-1.pom";
String parent = "org/foo/parent/1/parent-1.pom";
deployResource(child, PREFIX + "child.pom.xml");
deployResource(parent, PREFIX + "parent.pom.xml");
waitForEventPropagation();
InputStream stream = client.content().get(source.getKey(), child);
String childRerived = IOUtils.toString(stream);
stream.close();
logger.debug("promote with parent in source: child content: {}", childRerived);
assertThat(childRerived, containsString("<artifactId>child</artifactId>"));
stream = client.content().get(source.getKey(), parent);
String parentRetrived = IOUtils.toString(stream);
stream.close();
logger.debug("promote with parent in source: parent content: {}", parentRetrived);
assertThat(parentRetrived, containsString("<artifactId>parent</artifactId>"));
PathsPromoteRequest request = new PathsPromoteRequest(source.getKey(), target.getKey(), child, parent);
PathsPromoteResult result = module.promoteByPath(request);
assertThat(result, notNullValue());
ValidationResult validations = result.getValidations();
System.out.println(validations);
assertThat(validations, notNullValue());
assertThat(validations.isValid(), equalTo(true));
stream = client.content().get(target.getKey(), child);
childRerived = IOUtils.toString(stream);
stream.close();
logger.debug("promote with parent in target: child content: {}", childRerived);
assertThat(childRerived, containsString("<artifactId>child</artifactId>"));
stream = client.content().get(target.getKey(), parent);
parentRetrived = IOUtils.toString(stream);
stream.close();
logger.debug("promote with parent in target: parent content: {}", parentRetrived);
assertThat(parentRetrived, containsString("<artifactId>parent</artifactId>"));
}
use of org.commonjava.indy.promote.model.PathsPromoteResult in project indy by Commonjava.
the class PromoteDryRunTest method run.
@Test
public void run() throws Exception {
final PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey()).setDryRun(true));
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
final Set<String> completed = result.getCompletedPaths();
assertThat(completed == null || completed.isEmpty(), equalTo(true));
final Set<String> pending = result.getPendingPaths();
assertThat(pending, notNullValue());
assertThat(pending.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(false));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(false));
}
use of org.commonjava.indy.promote.model.PathsPromoteResult in project indy by Commonjava.
the class PromoteWithPurgeThenRollbackTest method run.
@Test
public void run() throws Exception {
PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey()).setPurgeSource(true));
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
assertThat(result.getError(), nullValue());
result = client.module(IndyPromoteClientModule.class).rollbackPathPromote(result);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
completed = result.getCompletedPaths();
assertThat(completed == null || completed.isEmpty(), equalTo(true));
pending = result.getPendingPaths();
assertThat(pending, notNullValue());
assertThat(pending.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(false));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(false));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), first), equalTo(true));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), second), equalTo(true));
}
use of org.commonjava.indy.promote.model.PathsPromoteResult in project indy by Commonjava.
the class IndyPromoteClientModule method promoteByPath.
public PathsPromoteResult promoteByPath(final StoreType srcType, final String srcName, final StoreType targetType, final String targetName, final boolean purgeSource, final String... paths) throws IndyClientException {
final PathsPromoteRequest req = new PathsPromoteRequest(new StoreKey(srcType, srcName), new StoreKey(targetType, targetName), new HashSet<String>(Arrays.asList(paths))).setPurgeSource(purgeSource);
final PathsPromoteResult result = http.postWithResponse(PATHS_PROMOTE_PATH, req, PathsPromoteResult.class, HttpStatus.SC_OK);
return result;
}
use of org.commonjava.indy.promote.model.PathsPromoteResult in project indy by Commonjava.
the class PromotionManagerTest method rollback_PurgeSource_PushTwoArtifactsToHostedRepo_PromoteSuccessThenRollback_VerifyContentInSource.
@Test
public void rollback_PurgeSource_PushTwoArtifactsToHostedRepo_PromoteSuccessThenRollback_VerifyContentInSource() throws Exception {
final HostedRepository source = new HostedRepository(MAVEN_PKG_KEY, "source");
storeManager.storeArtifactStore(source, new ChangeSummary(ChangeSummary.SYSTEM_USER, "test setup"), false, true, new EventMetadata());
final String first = "/first/path";
final String second = "/second/path";
contentManager.store(source, first, new ByteArrayInputStream("This is a test".getBytes()), TransferOperation.UPLOAD, new EventMetadata());
contentManager.store(source, second, new ByteArrayInputStream("This is a test".getBytes()), TransferOperation.UPLOAD, new EventMetadata());
final HostedRepository target = new HostedRepository(MAVEN_PKG_KEY, "target");
storeManager.storeArtifactStore(target, new ChangeSummary(ChangeSummary.SYSTEM_USER, "test setup"), false, true, new EventMetadata());
PathsPromoteResult result = manager.promotePaths(new PathsPromoteRequest(source.getKey(), target.getKey()).setPurgeSource(true), FAKE_BASE_URL);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
assertThat(result.getError(), nullValue());
result = manager.rollbackPathsPromote(result);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
completed = result.getCompletedPaths();
assertThat(completed == null || completed.isEmpty(), equalTo(true));
pending = result.getPendingPaths();
assertThat(pending, notNullValue());
assertThat(pending.size(), equalTo(2));
assertThat(result.getError(), nullValue());
Transfer ref = downloadManager.getStorageReference(target, first);
assertThat(ref.exists(), equalTo(false));
ref = downloadManager.getStorageReference(target, second);
assertThat(ref.exists(), equalTo(false));
ref = downloadManager.getStorageReference(source, first);
assertThat(ref.exists(), equalTo(true));
ref = downloadManager.getStorageReference(source, second);
assertThat(ref.exists(), equalTo(true));
}
Aggregations