use of com.synopsys.integration.wait.ResilientJobConfig in project blackduck-alert by blackducksoftware.
the class ComponentUnknownVersionNotificationSerializationTest method testNotificationSerialization.
@Test
// performance test
@Ignore
@Disabled
void testNotificationSerialization() throws IntegrationException, InterruptedException {
LocalDateTime searchStartTime = LocalDateTime.now().minusMinutes(1);
AlertRequestUtility alertRequestUtility = IntegrationPerformanceTestRunner.createAlertRequestUtility(webApplicationContext);
BlackDuckProviderService blackDuckProviderService = new BlackDuckProviderService(alertRequestUtility, gson);
configureJob(alertRequestUtility, blackDuckProviderService);
ExternalId externalId = new ExternalId(Forge.MAVEN);
externalId.setGroup("commons-fileupload");
externalId.setName("commons-fileupload");
Predicate<ProjectVersionComponentVersionView> componentFilter = (component) -> component.getComponentName().equals("Apache Commons FileUpload");
blackDuckProviderService.triggerBlackDuckNotification(() -> externalId, componentFilter);
try {
ResilientJobConfig resilientJobConfig = new ResilientJobConfig(intLogger, 300, searchStartTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20);
NotificationReceivedWaitJobTask notificationWaitJobTask = new NotificationReceivedWaitJobTask(notificationAccessor, searchStartTime, "Apache Commons FileUpload", null, NotificationType.COMPONENT_UNKNOWN_VERSION);
boolean isComplete = WaitJob.waitFor(resilientJobConfig, notificationWaitJobTask, "notification serialization test notification wait");
if (isComplete) {
String notificationContent = notificationWaitJobTask.getNotificationContent().orElseThrow(() -> new IllegalStateException("Expected notification is missing."));
BlackDuckResponseResolver resolver = blackDuckProviderService.getBlackDuckServicesFactory().getBlackDuckResponseResolver();
ComponentUnknownVersionNotificationView notificationView = resolver.resolve(notificationContent, ComponentUnknownVersionNotificationView.class);
assertNotNull(notificationView.getContent());
assertTrue(StringUtils.isNotBlank(notificationView.getContent().getComponentName()));
BlackDuckApiClient apiClient = blackDuckProviderService.getBlackDuckServicesFactory().getBlackDuckApiClient();
Optional<HttpUrl> componentUrl = HttpUrl.createSafely(notificationView.getContent().getBomComponent());
if (componentUrl.isPresent()) {
apiClient.delete(componentUrl.get());
}
}
} catch (InterruptedException ex) {
// if a timeout happens that's ok we are trying to ensure deserialization is correct.
}
}
use of com.synopsys.integration.wait.ResilientJobConfig in project blackduck-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, waitTimeoutInSeconds, 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);
}
use of com.synopsys.integration.wait.ResilientJobConfig in project blackduck-alert by blackducksoftware.
the class IntegrationPerformanceTestRunnerV2 method waitForJobToFinish.
private void waitForJobToFinish(Set<String> jobIds, LocalDateTime startingNotificationTime, int numberOfExpectedAuditEntries, NotificationType notificationType) throws IntegrationException, InterruptedException {
ResilientJobConfig resilientJobConfig = new ResilientJobConfig(intLogger, waitTimeoutInSeconds, startingNotificationTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 2);
AuditProcessingWaitJobTask notificationWaitJobTask = new AuditProcessingWaitJobTask(intLogger, dateTimeFormatter, gson, alertRequestUtility, startingNotificationTime, numberOfExpectedAuditEntries, notificationType, jobIds);
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);
}
Aggregations