use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class RollbackTwoArtifactsTest method run.
@Test
public void run() throws Exception {
PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey()));
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(), first), equalTo(false));
assertThat(client.content().exists(target.getKey(), second), equalTo(false));
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromoteAllTest method run.
@Test
public void run() throws Exception {
final PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey()));
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
final Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
final Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey(), first), equalTo(true));
assertThat(client.content().exists(target.getKey(), second), equalTo(true));
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromoteAllWithPurgeAsyncTest method run.
@Test
public void run() throws Exception {
PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(getAsyncRequest(new PathsPromoteRequest(source.getKey(), target.getKey()).setPurgeSource(true)));
assertEquals(result.getResultCode(), ACCEPTED);
result = getAsyncPromoteResult(PathsPromoteResult.class);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
final Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
final Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(true));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(true));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), first), equalTo(false));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), second), equalTo(false));
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromotionValidator method getRequestStore.
private ArtifactStore getRequestStore(PromoteRequest promoteRequest, String baseUrl) throws PromotionValidationException {
final ArtifactStore store;
final Logger logger = LoggerFactory.getLogger(getClass());
logger.info("Promotion baseUrl: {} ", baseUrl);
if (needTempRepo(promoteRequest)) {
logger.info("Promotion temporary repo is needed for {}, points to {} ", promoteRequest.getSource(), baseUrl);
final PathsPromoteRequest pathsReq = (PathsPromoteRequest) promoteRequest;
String tempName = PROMOTE_REPO_PREFIX + "tmp_" + pathsReq.getSource().getName() + "_" + new SimpleDateFormat("yyyyMMdd.hhmmss.SSSZ").format(new Date());
String packageType = pathsReq.getSource().getPackageType();
final RemoteRepository tempRemote = new RemoteRepository(packageType, tempName, baseUrl);
tempRemote.setPathMaskPatterns(pathsReq.getPaths());
store = tempRemote;
try {
final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "create temp remote repository");
storeDataMgr.storeArtifactStore(tempRemote, changeSummary, false, true, new EventMetadata());
} catch (IndyDataException e) {
throw new PromotionValidationException("Can not store the temp remote repository correctly", e);
}
} else {
logger.info("Promotion temporary repo is not needed for {} ", promoteRequest.getSource());
try {
store = storeDataMgr.getArtifactStore(promoteRequest.getSource());
} catch (IndyDataException e) {
throw new PromotionValidationException("Failed to retrieve source ArtifactStore: {}. Reason: {}", e, promoteRequest.getSource(), e.getMessage());
}
}
return store;
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class NPMParsablePkgMetaRuleByPathTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
deploy(INVALID, "This is not parsable");
deployResource(VALID, "npm-parsable-pkg-meta/package.json");
assertThat(client.content().exists(source.getKey(), INVALID), equalTo(true));
assertThat(client.content().exists(source.getKey(), VALID), equalTo(true));
waitForEventPropagation();
PathsPromoteRequest request = new PathsPromoteRequest(source.getKey(), target.getKey(), VALID, INVALID);
check(request);
request = new PathsPromoteRequest(source.getKey(), target.getKey());
check(request);
}
Aggregations