use of org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributionStatusResponse 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.DistributionStatusResponse in project build-info by JFrogDev.
the class DistributeReleaseBundle method waitForDistribution.
private void waitForDistribution(JFrogHttpClient client) throws IOException {
String trackerId = result.getTrackerId();
GetDistributionStatus getDistributionStatusService = new GetDistributionStatus(name, version, trackerId, log);
for (int timeElapsed = 0; timeElapsed < DEFAULT_MAX_WAIT_MINUTES * 60; timeElapsed += DEFAULT_SYNC_SLEEP_INTERVAL) {
if (timeElapsed % 60 == 0) {
log.info(String.format("Sync: Distributing %s/%s...", name, version));
}
DistributionStatusResponse statusResponse = getDistributionStatusService.execute(client);
if (statusResponse.getStatus().equalsIgnoreCase("Failed")) {
throw new IOException("JFrog service failed. Received " + statusCode + ": " + toJsonString(statusResponse));
}
if (statusResponse.getStatus().equalsIgnoreCase("Completed")) {
log.info("Distribution Completed!");
return;
}
try {
TimeUnit.SECONDS.sleep(DEFAULT_SYNC_SLEEP_INTERVAL);
} catch (InterruptedException e) {
throw new IOException("Fail to wait for Distribution sync", e);
}
}
throw new IOException("Timeout for sync distribution");
}
use of org.jfrog.build.extractor.clientConfiguration.client.distribution.response.DistributionStatusResponse in project build-info by JFrogDev.
the class DeleteReleaseBundle method waitForDeletion.
void waitForDeletion(JFrogHttpClient client) throws IOException {
String trackerId = result.getTrackerId();
GetDistributionStatus statusService = new GetDistributionStatus(name, version, trackerId, log);
for (int timeElapsed = 0; timeElapsed < DEFAULT_MAX_WAIT_MINUTES * 60; timeElapsed += DEFAULT_SYNC_SLEEP_INTERVAL) {
if (timeElapsed % 60 == 0) {
log.info(String.format("Sync: Deleting %s/%s...", name, version));
}
DistributionStatusResponse statusResponse = statusService.execute(client);
if (statusResponse == null || statusResponse.getStatus().equalsIgnoreCase("Completed")) {
log.info("Sync: Distribution deleted successfully");
return;
}
log.debug("Sync: Received status " + statusResponse.getStatus());
try {
TimeUnit.SECONDS.sleep(DEFAULT_SYNC_SLEEP_INTERVAL);
} catch (InterruptedException e) {
throw new IOException("Fail to wait for deletion sync", e);
}
}
throw new IOException("Timeout for sync deletion");
}
Aggregations