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);
}
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));
}
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));
}
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 ) );
}
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);
}
Aggregations