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