Search in sources :

Example 1 with GroupPromoteResult

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

the class GroupHostedMetadataRemergedOnPromoteTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    assertContent(g, PATH, BEFORE_GROUP_CONTENT);
    GroupPromoteRequest request = new GroupPromoteRequest(c.getKey(), g.getName());
    GroupPromoteResult response = promote.promoteToGroup(request);
    assertThat(response.succeeded(), equalTo(true));
    waitForEventPropagation();
    assertContent(g, PATH, AFTER_GROUP_CONTENT);
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) Category(org.junit.experimental.categories.Category) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest) Test(org.junit.Test)

Example 2 with GroupPromoteResult

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

the class GroupPromoteAndRollbackTest method run.

@Test
public void run() throws Exception {
    GroupPromoteResult result = client.module(IndyPromoteClientModule.class).promoteToGroup(new GroupPromoteRequest(source.getKey(), target.getName()));
    assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
    assertThat(result.getRequest().getTargetGroup(), equalTo(target.getName()));
    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));
    Group g = client.stores().load(StoreType.group, target.getName(), Group.class);
    assertThat(g.getConstituents().contains(source.getKey()), equalTo(true));
    // now rollback.
    result = client.module(IndyPromoteClientModule.class).rollbackGroupPromote(result);
    assertThat(result.getError(), nullValue());
    // wait for events to propagate and remove indexed values.
    Thread.sleep(2000);
    assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(false));
    assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(false));
    g = client.stores().load(StoreType.group, target.getName(), Group.class);
    assertThat(g.getConstituents().contains(source.getKey()), equalTo(false));
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) Group(org.commonjava.indy.model.core.Group) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) IndyPromoteClientModule(org.commonjava.indy.promote.client.IndyPromoteClientModule) Test(org.junit.Test)

Example 3 with GroupPromoteResult

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

the class ArtifactRefs_DependencyInAnotherRepoInGroup_RuleTest 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.1/valid-1.1.pom";
    String validDepPom = "org/bar/dep/1.0/dep-1.0.pom";
    String validDepJar = "org/bar/dep/1.0/dep-1.0.jar";
    String content = "this is some content";
    client.content().store(otherSource.getKey(), validDepPom, new ByteArrayInputStream(content.getBytes()));
    client.content().store(otherSource.getKey(), validDepJar, new ByteArrayInputStream(content.getBytes()));
    InputStream stream = client.content().get(other.getKey(), validDepPom);
    String retrieved = IOUtils.toString(stream);
    stream.close();
    assertThat(validDepPom + " invalid from: " + other.getKey(), retrieved, equalTo(content));
    stream = client.content().get(other.getKey(), validDepJar);
    retrieved = IOUtils.toString(stream);
    stream.close();
    assertThat(validDepJar + " invalid from: " + other.getKey(), retrieved, equalTo(content));
    deployResource(invalid, PREFIX + "invalid-external-dep.pom.xml");
    deployResource(valid, PREFIX + "valid-single-external-dep.pom.xml");
    waitForEventPropagation();
    GroupPromoteRequest request = new GroupPromoteRequest(source.getKey(), target.getName());
    GroupPromoteResult result = module.promoteToGroup(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 : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with GroupPromoteResult

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

the class FullRuleStack_GroupWithOneOfTwoHosts_RuleTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    List<String> deploy = Arrays.asList("org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1.pom", "org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1.jar", "org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1-sources.jar", "org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1-javadoc.jar");
    Stream.of(hostTarget1, hostTarget2).forEach((repo) -> {
        deploy.forEach((path) -> {
            try {
                deployResource(repo.getKey(), path, PREFIX + "valid.pom.xml");
                try (InputStream stream = client.content().get(repo.getKey(), path)) {
                    String retrieved = IOUtils.toString(stream);
                    assertThat(path + " invalid from: " + repo.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
                }
            } catch (Exception e) {
                fail("Failed to deploy: " + path + " to: " + repo);
            }
        });
    });
    //        GroupPromoteRequest request = new GroupPromoteRequest( hostTarget1.getKey(), target.getName() );
    //        GroupPromoteResult result = module.promoteToGroup( request );
    //
    //        assertThat( result, notNullValue() );
    //        assertThat( result.getValidations(), notNullValue() );
    //        assertThat( result.getValidations().isValid(), equalTo( true ) );
    target.addConstituent(hostTarget1);
    client.stores().update(target, "update target");
    deploy.forEach((path) -> {
        try {
            try (InputStream stream = client.content().get(target.getKey(), path)) {
                String retrieved = IOUtils.toString(stream);
                assertThat(path + " invalid from: " + target.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
            }
        } catch (Exception e) {
            fail("Failed to verify: " + path + " in: " + target.getKey());
        }
    });
    waitForEventPropagation();
    GroupPromoteRequest request = new GroupPromoteRequest(hostTarget2.getKey(), target.getName());
    GroupPromoteResult result = module.promoteToGroup(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( deploy ), equalTo( true ) );
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) InputStream(java.io.InputStream) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) IOException(java.io.IOException) IndyClientException(org.commonjava.indy.client.core.IndyClientException) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 5 with GroupPromoteResult

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

the class RecursiveGroupMetadataFoundAfterMemberPromotedTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    assertNullContent(hostedX, PATH);
    assertNullContent(groupA, PATH);
    assertNullContent(groupB, PATH);
    client.content().store(hostedX.getKey(), PATH, new ByteArrayInputStream(HOSTED_X_CONTENT.getBytes("UTF-8")));
    waitForEventPropagation();
    assertContent(hostedX, PATH, HOSTED_X_CONTENT);
    GroupPromoteRequest request = new GroupPromoteRequest(hostedX.getKey(), groupA.getName());
    GroupPromoteResult result = promotions.promoteToGroup(request);
    assertThat(result.succeeded(), equalTo(true));
    waitForEventPropagation();
    // Order is important here...we want to try the most ambitious one first and move down to the simpler cases.
    // This will prevent us from inadvertently triggering metadata aggregation in a lower group that might not
    // happen otherwise.
    assertContent(groupC, PATH, HOSTED_X_CONTENT);
    assertContent(groupB, PATH, HOSTED_X_CONTENT);
    assertContent(groupA, PATH, HOSTED_X_CONTENT);
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Aggregations

GroupPromoteResult (org.commonjava.indy.promote.model.GroupPromoteResult)23 GroupPromoteRequest (org.commonjava.indy.promote.model.GroupPromoteRequest)22 Test (org.junit.Test)20 ValidationResult (org.commonjava.indy.promote.model.ValidationResult)16 Category (org.junit.experimental.categories.Category)15 Group (org.commonjava.indy.model.core.Group)7 InputStream (java.io.InputStream)5 IndyPromoteClientModule (org.commonjava.indy.promote.client.IndyPromoteClientModule)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)2 IndyDataException (org.commonjava.indy.data.IndyDataException)2 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)2 HostedRepository (org.commonjava.indy.model.core.HostedRepository)2 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)2 IOException (java.io.IOException)1 IndyClientException (org.commonjava.indy.client.core.IndyClientException)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1