Search in sources :

Example 11 with ResilientJobConfig

use of com.synopsys.integration.wait.ResilientJobConfig in project synopsys-detect by blackducksoftware.

the class RapidModeWaitOperation method waitForScans.

public List<DeveloperScanComponentResultView> waitForScans(List<HttpUrl> uploadedScans, long timeoutInSeconds, int waitIntervalInSeconds) throws IntegrationException, InterruptedException {
    ResilientJobConfig waitJobConfig = new ResilientJobConfig(new Slf4jIntLogger(logger), timeoutInSeconds, System.currentTimeMillis(), waitIntervalInSeconds);
    DetectRapidScanWaitJob waitJob = new DetectRapidScanWaitJob(blackDuckApiClient, uploadedScans);
    ResilientJobExecutor jobExecutor = new ResilientJobExecutor(waitJobConfig);
    return jobExecutor.executeJob(waitJob);
}
Also used : DetectRapidScanWaitJob(com.synopsys.integration.detect.workflow.blackduck.developer.blackduck.DetectRapidScanWaitJob) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Example 12 with ResilientJobConfig

use of com.synopsys.integration.wait.ResilientJobConfig in project hub-alert by blackducksoftware.

the class IntegrationPerformanceTestRunner method runTest.

public void runTest(Runnable createGlobalConfigFunction, Map<String, FieldValueModel> channelFields, String jobName) throws IntegrationException, InterruptedException {
    intLogger.info(String.format("Starting time %s", dateTimeFormatter.format(LocalDateTime.now())));
    String blackDuckProviderID = createBlackDuckConfiguration();
    createGlobalConfigFunction.run();
    LocalDateTime jobStartingTime = LocalDateTime.now();
    String jobId = configurationManager.createJob(channelFields, jobName, blackDuckProviderID, blackDuckProviderService.getBlackDuckProjectName());
    String jobMessage = String.format("Creating the Job %s jobs took", jobName);
    logTimeElapsedWithMessage(jobMessage + " %s", jobStartingTime, LocalDateTime.now());
    LocalDateTime startingSearchDateTime = LocalDateTime.now();
    // trigger BD notification
    blackDuckProviderService.triggerBlackDuckNotification();
    intLogger.info("Triggered the Black Duck notification.");
    ResilientJobConfig resilientJobConfig = new ResilientJobConfig(intLogger, 600, startingSearchDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20);
    NotificationWaitJobTask notificationWaitJobTask = new NotificationWaitJobTask(intLogger, dateTimeFormatter, gson, alertRequestUtility, startingSearchDateTime, jobId);
    boolean isComplete = WaitJob.waitFor(resilientJobConfig, notificationWaitJobTask, "int performance test runner notification wait");
    intLogger.info("Finished waiting for the notification to be processed: " + isComplete);
    assertTrue(isComplete);
}
Also used : LocalDateTime(java.time.LocalDateTime) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Example 13 with ResilientJobConfig

use of com.synopsys.integration.wait.ResilientJobConfig in project hub-alert by blackducksoftware.

the class IntegrationPerformanceTestRunnerV2 method runTest.

public void runTest(Map<String, FieldValueModel> channelFields, String jobName) throws IntegrationException, InterruptedException {
    intLogger.info(String.format("Starting time %s", dateTimeFormatter.format(LocalDateTime.now())));
    String blackDuckProviderID = createBlackDuckConfiguration();
    LocalDateTime jobStartingTime = LocalDateTime.now();
    String jobId = configurationManager.createJob(channelFields, jobName, blackDuckProviderID, blackDuckProviderService.getBlackDuckProjectName());
    String jobMessage = String.format("Creating the Job %s jobs took", jobName);
    loggingUtility.logTimeElapsedWithMessage(jobMessage + " %s", jobStartingTime, LocalDateTime.now());
    LocalDateTime startingSearchDateTime = LocalDateTime.now();
    // trigger BD notification
    blackDuckProviderService.triggerBlackDuckNotification();
    intLogger.info("Triggered the Black Duck notification.");
    ResilientJobConfig resilientJobConfig = new ResilientJobConfig(intLogger, 600, startingSearchDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20);
    NotificationWaitJobTask notificationWaitJobTask = new NotificationWaitJobTask(intLogger, dateTimeFormatter, gson, alertRequestUtility, startingSearchDateTime, jobId);
    boolean isComplete = WaitJob.waitFor(resilientJobConfig, notificationWaitJobTask, "int performance test runner notification wait");
    intLogger.info("Finished waiting for the notification to be processed: " + isComplete);
    assertTrue(isComplete);
}
Also used : LocalDateTime(java.time.LocalDateTime) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Example 14 with ResilientJobConfig

use of com.synopsys.integration.wait.ResilientJobConfig in project blackduck-common by blackducksoftware.

the class Bdio2FileUploadService method uploadFiles.

private Bdio2UploadResult uploadFiles(List<BdioFileContent> bdioFiles, @Nullable NameVersion nameVersion, long timeout) throws IntegrationException, InterruptedException {
    if (bdioFiles.isEmpty()) {
        throw new IllegalArgumentException("BDIO files cannot be empty.");
    }
    BdioFileContent header = bdioFiles.stream().filter(content -> content.getFileName().equals(FILE_NAME_BDIO_HEADER_JSONLD)).findFirst().orElseThrow(() -> new BlackDuckIntegrationException("Cannot find BDIO header file" + FILE_NAME_BDIO_HEADER_JSONLD + "."));
    List<BdioFileContent> remainingFiles = bdioFiles.stream().filter(content -> !content.getFileName().equals(FILE_NAME_BDIO_HEADER_JSONLD)).collect(Collectors.toList());
    int count = remainingFiles.size();
    logger.debug("BDIO upload file count = " + count);
    BlackDuckRequestBuilderEditor editor = noOp -> {
    };
    if (nameVersion != null) {
        editor = builder -> builder.addHeader(Bdio2StreamUploader.PROJECT_NAME_HEADER, nameVersion.getName()).addHeader(Bdio2StreamUploader.VERSION_NAME_HEADER, nameVersion.getVersion());
    }
    ResilientJobConfig jobConfig = new ResilientJobConfig(logger, timeout, System.currentTimeMillis(), BD_WAIT_AND_RETRY_INTERVAL);
    Bdio2UploadJob bdio2UploadJob = new Bdio2UploadJob(bdio2Uploader, header, remainingFiles, editor, count);
    ResilientJobExecutor jobExecutor = new ResilientJobExecutor(jobConfig);
    return jobExecutor.executeJob(bdio2UploadJob);
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) DataService(com.synopsys.integration.blackduck.service.DataService) ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig) Collectors(java.util.stream.Collectors) IntLogger(com.synopsys.integration.log.IntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl) Nullable(org.jetbrains.annotations.Nullable) Bdio2ContentExtractor(com.synopsys.integration.blackduck.bdio2.util.Bdio2ContentExtractor) NameVersion(com.synopsys.integration.util.NameVersion) List(java.util.List) BlackDuckRequestBuilderEditor(com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor) BdioFileContent(com.synopsys.integration.blackduck.bdio2.model.BdioFileContent) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) UploadTarget(com.synopsys.integration.blackduck.codelocation.upload.UploadTarget) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) BlackDuckRequestBuilderEditor(com.synopsys.integration.blackduck.service.request.BlackDuckRequestBuilderEditor) BdioFileContent(com.synopsys.integration.blackduck.bdio2.model.BdioFileContent) ResilientJobExecutor(com.synopsys.integration.wait.ResilientJobExecutor) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Example 15 with ResilientJobConfig

use of com.synopsys.integration.wait.ResilientJobConfig in project blackduck-alert by blackducksoftware.

the class ScalingPerformanceTest method createAndTestJobs.

private void createAndTestJobs(AlertRequestUtility alertRequestUtility, BlackDuckProviderService blackDuckProviderService, ConfigurationManager configurationManager, LocalDateTime startingTime, List<String> jobIds, int numberOfJobsToCreate, String blackDuckProviderID) throws Exception {
    // create slack jobs
    createSlackJobs(configurationManager, startingTime, jobIds, numberOfJobsToCreate, 10, blackDuckProviderID, blackDuckProviderService.getBlackDuckProviderKey(), blackDuckProviderService.getBlackDuckProjectName());
    LocalDateTime startingNotificationSearchDateTime = LocalDateTime.now();
    // trigger BD notification
    blackDuckProviderService.triggerBlackDuckNotification();
    logTimeElapsedWithMessage("Triggering the Black Duck notification took %s", startingNotificationSearchDateTime, LocalDateTime.now());
    LocalDateTime startingNotificationWaitForTenJobs = LocalDateTime.now();
    // check that all jobs have processed the notification successfully, log how long it took
    ResilientJobConfig resilientJobConfig = new ResilientJobConfig(intLogger, 900, startingNotificationSearchDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 30);
    NotificationWaitJobTask notificationWaitJobTask = new NotificationWaitJobTask(intLogger, dateTimeFormatter, gson, alertRequestUtility, startingNotificationSearchDateTime, jobIds);
    notificationWaitJobTask.setFailOnJobFailure(false);
    boolean isComplete = WaitJob.waitFor(resilientJobConfig, notificationWaitJobTask, "scaling notification wait");
    logTimeElapsedWithMessage("Waiting for " + numberOfJobsToCreate + " jobs to process the notification took %s", startingNotificationWaitForTenJobs, LocalDateTime.now());
    intLogger.info("Finished waiting for the notification to be processed: " + isComplete);
    assertTrue(isComplete);
}
Also used : LocalDateTime(java.time.LocalDateTime) NotificationWaitJobTask(com.synopsys.integration.alert.performance.utility.NotificationWaitJobTask) ResilientJobConfig(com.synopsys.integration.wait.ResilientJobConfig)

Aggregations

ResilientJobConfig (com.synopsys.integration.wait.ResilientJobConfig)18 LocalDateTime (java.time.LocalDateTime)10 List (java.util.List)5 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)4 HttpUrl (com.synopsys.integration.rest.HttpUrl)4 Test (org.junit.jupiter.api.Test)4 Ignore (org.junit.Ignore)3 Disabled (org.junit.jupiter.api.Disabled)3 Gson (com.google.gson.Gson)2 Application (com.synopsys.integration.alert.Application)2 SlackDescriptor (com.synopsys.integration.alert.channel.slack.descriptor.SlackDescriptor)2 ChannelDescriptor (com.synopsys.integration.alert.common.descriptor.ChannelDescriptor)2 FrequencyType (com.synopsys.integration.alert.common.enumeration.FrequencyType)2 NotificationAccessor (com.synopsys.integration.alert.common.persistence.accessor.NotificationAccessor)2 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)2 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)2 PurgeTask (com.synopsys.integration.alert.component.scheduling.workflow.PurgeTask)2 ApplicationConfiguration (com.synopsys.integration.alert.configuration.ApplicationConfiguration)2 DatabaseDataSource (com.synopsys.integration.alert.database.DatabaseDataSource)2 ChannelKeys (com.synopsys.integration.alert.descriptor.api.model.ChannelKeys)2