Search in sources :

Example 6 with PathsPromoteRequest

use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.

the class PromoteWithPurgeThenRollbackAsyncTest 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()));
    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);
    assertEquals(result.getResultCode(), ACCEPTED);
    result = getAsyncPromoteResult(PathsPromoteResult.class);
    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));
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) IndyPromoteClientModule(org.commonjava.indy.promote.client.IndyPromoteClientModule) Test(org.junit.Test)

Example 7 with PathsPromoteRequest

use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.

the class PromoteAllAsyncTest method run.

@Test
public void run() throws Exception {
    PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(getAsyncRequest(new PathsPromoteRequest(source.getKey(), target.getKey())));
    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(), first), equalTo(true));
    assertThat(client.content().exists(target.getKey(), second), equalTo(true));
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) IndyPromoteClientModule(org.commonjava.indy.promote.client.IndyPromoteClientModule) Test(org.junit.Test)

Example 8 with PathsPromoteRequest

use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.

the class NoPreExistingPaths_IdempotentPromotion_RuleTest method run.

@Test
public void run() throws Exception {
    String path = "org/foo/valid/1.1/valid-1.1.pom";
    // Deploy the resource before promotion
    deployResource(target.getKey(), path, PREFIX + "valid.pom.xml");
    try (InputStream stream = client.content().get(target.getKey(), path)) {
        String retrieved = IOUtils.toString(stream);
        assertThat(path + " path from: " + target.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
    }
    deployResource(path, PREFIX + "valid.pom.xml");
    waitForEventPropagation();
    // Promotion the same file(with the same checksum)
    PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey(), path).setPurgeSource(true));
    assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
    assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
    assertThat(result.getError(), nullValue());
    Set<String> pending = result.getPendingPaths();
    assertThat(pending == null || pending.isEmpty(), equalTo(true));
    Set<String> skipped = result.getSkippedPaths();
    assertThat(skipped, notNullValue());
    assertThat(skipped.size(), equalTo(1));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) IndyPromoteClientModule(org.commonjava.indy.promote.client.IndyPromoteClientModule) AbstractAsyncPromotionManagerTest(org.commonjava.indy.promote.ftest.AbstractAsyncPromotionManagerTest) Test(org.junit.Test) AbstractPromotionManagerTest(org.commonjava.indy.promote.ftest.AbstractPromotionManagerTest)

Example 9 with PathsPromoteRequest

use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.

the class ParsablePomRuleByPathTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    String invalid = "org/foo/invalid/1/invalid-1.pom";
    String valid = "org/foo/valid/1/valid-1.pom";
    deploy(invalid, "This is not parsable");
    deploy(valid, "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>valid</artifactId><version>1</version></project>");
    waitForEventPropagation();
    PathsPromoteRequest request = new PathsPromoteRequest(source.getKey(), target.getKey());
    request.setPaths(new HashSet(Arrays.asList(invalid, valid)));
    PathsPromoteResult result = module.promoteByPath(request);
    assertThat(result, notNullValue());
    ValidationResult validations = result.getValidations();
    assertThat(validations, notNullValue());
    Map<String, String> validatorErrors = validations.getValidatorErrors();
    assertThat(validatorErrors, notNullValue());
    System.out.println(validatorErrors);
    String errors = validatorErrors.get(RULE);
    assertThat(errors, notNullValue());
    System.out.println(validatorErrors);
    assertThat(errors.contains(valid), equalTo(false));
    assertThat(errors.contains(invalid), equalTo(true));
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) HashSet(java.util.HashSet) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 10 with PathsPromoteRequest

use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.

the class PromoteAllWithPurgeTest method run.

@Test
public void run() throws Exception {
    final 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()));
    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));
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) IndyPromoteClientModule(org.commonjava.indy.promote.client.IndyPromoteClientModule) Test(org.junit.Test)

Aggregations

PathsPromoteRequest (org.commonjava.indy.promote.model.PathsPromoteRequest)47 PathsPromoteResult (org.commonjava.indy.promote.model.PathsPromoteResult)40 Test (org.junit.Test)34 IndyPromoteClientModule (org.commonjava.indy.promote.client.IndyPromoteClientModule)15 Category (org.junit.experimental.categories.Category)10 InputStream (java.io.InputStream)8 StoreKey (org.commonjava.indy.model.core.StoreKey)8 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 HashSet (java.util.HashSet)6 IndyDataException (org.commonjava.indy.data.IndyDataException)6 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)6 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)6 IOException (java.io.IOException)5 HostedRepository (org.commonjava.indy.model.core.HostedRepository)5 PromotionValidationException (org.commonjava.indy.promote.validate.PromotionValidationException)5 Transfer (org.commonjava.maven.galley.model.Transfer)5 ExecutionException (java.util.concurrent.ExecutionException)4 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)4 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)4