Search in sources :

Example 1 with DistributeReleaseBundleResponse

use of org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributeReleaseBundleResponse in project build-info by JFrogDev.

the class RemoteDistributionManagerTest method asyncDistributionTest.

@Test
public void asyncDistributionTest() throws IOException, InterruptedException {
    // Create and sign a release bundle
    distributionManager.createReleaseBundle(createRequestBuilder().build());
    distributionManager.signReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, "");
    // Distribute release bundle
    DistributeReleaseBundleResponse response = distributionManager.distributeReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, false, createDistributionRequest());
    assertNotNull(response);
    String trackerId = response.getTrackerId();
    assertTrue(StringUtils.isNotBlank(trackerId));
    // Wait for distribution
    boolean success = false;
    for (int i = 0; i < 120; i++) {
        DistributionStatusResponse status = distributionManager.getDistributionStatus(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, trackerId);
        if ("Failed".equalsIgnoreCase(status.getStatus())) {
            fail("Distribution of " + RELEASE_BUNDLE_NAME + "/" + RELEASE_BUNDLE_VERSION + " failed: " + toJsonString(status));
        }
        if ("Completed".equalsIgnoreCase(status.getStatus())) {
            success = true;
            break;
        }
        log.info("Waiting for " + RELEASE_BUNDLE_NAME + "/" + RELEASE_BUNDLE_VERSION + "...");
        TimeUnit.SECONDS.sleep(1);
    }
    assertTrue(success, "Distribution of " + RELEASE_BUNDLE_NAME + "/" + RELEASE_BUNDLE_VERSION + " failed");
    // Delete distribution and wait for deletion
    DistributeReleaseBundleResponse deleteResponse = distributionManager.deleteReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, false, createDeletionRequest());
    assertNotNull(deleteResponse);
    success = false;
    for (int i = 0; i < 120; i++) {
        DistributionStatusResponse status = distributionManager.getDistributionStatus(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, trackerId);
        if (status == null) {
            success = true;
            break;
        }
        log.info("Waiting for deletion of " + RELEASE_BUNDLE_NAME + "/" + RELEASE_BUNDLE_VERSION + "...");
        TimeUnit.SECONDS.sleep(1);
    }
    assertTrue(success, "Deletion of " + RELEASE_BUNDLE_NAME + "/" + RELEASE_BUNDLE_VERSION + " failed");
}
Also used : DistributeReleaseBundleResponse(org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributeReleaseBundleResponse) JsonUtils.toJsonString(org.jfrog.build.extractor.clientConfiguration.util.JsonUtils.toJsonString) DistributionStatusResponse(org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributionStatusResponse) Test(org.testng.annotations.Test)

Example 2 with DistributeReleaseBundleResponse

use of org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributeReleaseBundleResponse in project build-info by JFrogDev.

the class LocalDistributionManagerTest method dryRunTest.

@Test
public void dryRunTest() throws IOException {
    // Create release bundle
    distributionManager.createReleaseBundle(createRequestBuilder().dryRun(true).build());
    // Assert release bundle doesn't created
    GetReleaseBundleStatusResponse bundleInfo = distributionManager.getReleaseBundleStatus(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION);
    assertNull(bundleInfo);
    // Create and sign release bundle
    distributionManager.createReleaseBundle(createRequestBuilder().signImmediately(true).build());
    // Distribute with dry run
    DistributeReleaseBundleRequest request = new DistributeReleaseBundleRequest();
    List<DistributionRules> distributionRules = Lists.newArrayList(new DistributionRules.Builder().siteName("*").build());
    request.setDistributionRules(distributionRules);
    request.setDryRun(true);
    DistributeReleaseBundleResponse response = distributionManager.distributeReleaseBundle(RELEASE_BUNDLE_NAME, RELEASE_BUNDLE_VERSION, true, request);
    // Assert no tracker ID returned and that the target site exist
    assertTrue(StringUtils.isBlank(response.getTrackerId()));
    List<DistributionStatusResponse.TargetArtifactory> sites = response.getSites();
    assertTrue(CollectionUtils.hasElements(sites));
}
Also used : DistributionRules(org.jfrog.build.extractor.clientConfiguration.client.distribution.types.DistributionRules) GetReleaseBundleStatusResponse(org.jfrog.build.extractor.clientConfiguration.client.distribution.response.GetReleaseBundleStatusResponse) DistributeReleaseBundleRequest(org.jfrog.build.extractor.clientConfiguration.client.distribution.request.DistributeReleaseBundleRequest) DistributeReleaseBundleResponse(org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributeReleaseBundleResponse) Test(org.testng.annotations.Test)

Aggregations

DistributeReleaseBundleResponse (org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributeReleaseBundleResponse)2 Test (org.testng.annotations.Test)2 DistributeReleaseBundleRequest (org.jfrog.build.extractor.clientConfiguration.client.distribution.request.DistributeReleaseBundleRequest)1 DistributionStatusResponse (org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributionStatusResponse)1 GetReleaseBundleStatusResponse (org.jfrog.build.extractor.clientConfiguration.client.distribution.response.GetReleaseBundleStatusResponse)1 DistributionRules (org.jfrog.build.extractor.clientConfiguration.client.distribution.types.DistributionRules)1 JsonUtils.toJsonString (org.jfrog.build.extractor.clientConfiguration.util.JsonUtils.toJsonString)1