Search in sources :

Example 21 with PathsPromoteRequest

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

the class PromotionManagerTest method promoteAllByPath_PushTwoArtifactsToHostedRepo_VerifyCopiedToOtherHostedRepo.

@Test
public void promoteAllByPath_PushTwoArtifactsToHostedRepo_VerifyCopiedToOtherHostedRepo() throws Exception {
    prepareHostedReposAndTwoPaths();
    final PathsPromoteResult result = manager.promotePaths(new PathsPromoteRequest(source.getKey(), target.getKey()), FAKE_BASE_URL);
    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());
    verifyExistence(true, true, true, true);
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) Test(org.junit.Test)

Example 22 with PathsPromoteRequest

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

the class HostedMetadataRemergedOnPathPromoteTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    // verify our initial state
    assertMetadataContent(a, PATH, aPreContent);
    PathsPromoteRequest request = new PathsPromoteRequest(b.getKey(), a.getKey(), new String[] { PATH, bPomPath });
    // Pre-existing maven-metadata.xml should NOT cause a failure!
    request.setFailWhenExists(true);
    PathsPromoteResult response = promote.promoteByPath(request);
    assertThat(response.succeeded(), equalTo(true));
    waitForEventPropagation();
    // Group G's metadata path P should reflect values in A and B
    assertMetadataContent(g, PATH, AFTER_PROMOTE_CONTENT);
    // Promotion to repo A should trigger re-merge of maven-metadata.xml, adding the version from repo B to that in A.
    assertMetadataContent(a, PATH, AFTER_PROMOTE_CONTENT);
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) Category(org.junit.experimental.categories.Category) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest) Test(org.junit.Test)

Example 23 with PathsPromoteRequest

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

the class HostedMetadataRemergedOnPathPromoteWithOnlyArtifactTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    // verify our initial state
    assertMetadataContent(a, PATH, aPreContent);
    PathsPromoteRequest request = new PathsPromoteRequest(b.getKey(), a.getKey(), bPomPath);
    // Pre-existing maven-metadata.xml should NOT cause a failure!
    request.setFailWhenExists(true);
    PathsPromoteResult response = promote.promoteByPath(request);
    assertThat(response.succeeded(), equalTo(true));
    waitForEventPropagation();
    // Promotion to repo A should trigger re-merge of maven-metadata.xml, adding the version from repo B to that in A.
    assertMetadataContent(a, PATH, AFTER_PROMOTE_CONTENT);
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 24 with PathsPromoteRequest

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

the class StoreAndPromoteFileToTrackedHostedRepoTest method run.

@Test
public void run() throws Exception {
    String changelog = "Create test repo";
    IndyFoloContentClientModule folo = client.module(IndyFoloContentClientModule.class);
    IndyPromoteClientModule promote = client.module(IndyPromoteClientModule.class);
    IndyFoloAdminClientModule foloAdmin = client.module(IndyFoloAdminClientModule.class);
    // 0. Create tracking id and use it as promotion source
    String trackingId = newName();
    // 1. Create source and target repositories
    HostedRepository source = new HostedRepository(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, trackingId);
    client.stores().create(source, changelog, HostedRepository.class);
    HostedRepository target = new HostedRepository(MavenPackageTypeDescriptor.MAVEN_PKG_KEY, "target");
    client.stores().create(target, changelog, HostedRepository.class);
    // 2. Store the artifact to source repo
    InputStream stream = new ByteArrayInputStream(bytes);
    folo.store(trackingId, source.getKey(), path, stream);
    // 3. Seal the record
    foloAdmin.sealTrackingRecord(trackingId);
    // 4. Promote to target repo (by path)
    PathsPromoteRequest promoteRequest = new PathsPromoteRequest(source.getKey(), target.getKey());
    promoteRequest.setFireEvents(true);
    promote.promoteByPath(promoteRequest);
    // 5. Check tracking record, the store is adjusted to target
    TrackedContentDTO trackingContent = foloAdmin.getRawTrackingContent(trackingId);
    List<TrackedContentEntryDTO> list = new ArrayList<>(trackingContent.getUploads());
    TrackedContentEntryDTO trackedContent = list.get(0);
    assertEquals(target.getKey(), trackedContent.getStoreKey());
}
Also used : IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) ArrayList(java.util.ArrayList) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) IndyPromoteClientModule(org.commonjava.indy.promote.client.IndyPromoteClientModule) HostedRepository(org.commonjava.indy.model.core.HostedRepository) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Test(org.junit.Test)

Example 25 with PathsPromoteRequest

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

the class IndyPromoteClientModule method getPromotablePaths.

public Set<String> getPromotablePaths(final StoreType type, final String name) throws IndyClientException {
    final StoreKey sk = new StoreKey(type, name);
    final PathsPromoteResult result = promoteByPath(new PathsPromoteRequest(sk, sk).setDryRun(true));
    return result.getPendingPaths();
}
Also used : PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) StoreKey(org.commonjava.indy.model.core.StoreKey)

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