Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump org.jacoco:jacoco-maven-plugin from 0.8.10 to 0.8.11 #452

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rhcicd/clowdapp-engine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,6 @@ parameters:
- name: NOTIFICATIONS_DRAWER_CONNECTOR_ENABLED
description: Is the drawer connector enabled to process them instead of in the engine?
value: "false"
- name: NOTIFICATIONS_AGGREGATION_BATCH_SIZE
description: Number of aggregation records loaded from the DB during each aggregation process iteration
value: "100"
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.redhat.cloud.notifications.processors.email;

import com.redhat.cloud.notifications.config.FeatureFlipper;
import com.redhat.cloud.notifications.db.repositories.EmailAggregationRepository;
import com.redhat.cloud.notifications.db.repositories.EmailSubscriptionRepository;
import com.redhat.cloud.notifications.db.repositories.EndpointRepository;
Expand Down Expand Up @@ -45,20 +44,12 @@ public class EmailAggregator {
@Inject
EmailSubscriptionRepository emailSubscriptionRepository;

@Inject
FeatureFlipper featureFlipper;

// This is manually used from the JSON payload instead of converting it to an Action and using getEventType()
private static final String EVENT_TYPE_KEY = "event_type";
private static final String RECIPIENTS_KEY = "recipients";

@ConfigProperty(name = "notifications.get.aggregation.max.page.size", defaultValue = "10000")
int aggregationMaxPageSize;

private Set<String> getEmailSubscribers(EmailAggregationKey aggregationKey, EmailSubscriptionType emailSubscriptionType) {
return Set.copyOf(emailSubscriptionRepository
.getEmailSubscribersUserId(aggregationKey.getOrgId(), aggregationKey.getBundle(), aggregationKey.getApplication(), emailSubscriptionType));
}
@ConfigProperty(name = "notifications.aggregation.batch-size", defaultValue = "10000")
int batchSize;

private Map<String, Set<String>> getEmailSubscribersGroupedByEventType(EmailAggregationKey aggregationKey, EmailSubscriptionType emailSubscriptionType) {
return emailSubscriptionRepository
Expand All @@ -84,8 +75,8 @@ public Map<User, Map<String, Object>> getAggregated(EmailAggregationKey aggregat
List<EmailAggregation> aggregations;
do {
// First, we retrieve paginated aggregations that match the given key.
aggregations = emailAggregationRepository.getEmailAggregation(aggregationKey, start, end, offset, aggregationMaxPageSize);
offset += aggregationMaxPageSize;
aggregations = emailAggregationRepository.getEmailAggregation(aggregationKey, start, end, offset, batchSize);
offset += batchSize;

// For each aggregation...
for (EmailAggregation aggregation : aggregations) {
Expand Down Expand Up @@ -122,7 +113,7 @@ public Map<User, Map<String, Object>> getAggregated(EmailAggregationKey aggregat
});
}
totalAggregatedElements += aggregations.size();
} while (aggregationMaxPageSize == aggregations.size());
} while (batchSize == aggregations.size());
Log.infof("%d elements were aggregated for key %s", totalAggregatedElements, aggregationKey);

return aggregated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class EmailAggregatorTest {

@BeforeEach
void beforeEach() {
emailAggregator.aggregationMaxPageSize = 5;
emailAggregator.batchSize = 5;
}

@Test
Expand Down Expand Up @@ -98,7 +98,7 @@ void shouldTestRecipientsFromSubscription() {
// Test user subscription based on event type
Map<User, Map<String, Object>> result = aggregate();
verify(emailAggregationRepository, times(1)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), anyInt(), anyInt());
verify(emailAggregationRepository, times(1)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), eq(0), eq(emailAggregator.aggregationMaxPageSize));
verify(emailAggregationRepository, times(1)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), eq(0), eq(emailAggregator.batchSize));
reset(emailAggregationRepository); // just reset mockito counter

// nobody subscribed to the right event type yet
Expand All @@ -108,8 +108,8 @@ void shouldTestRecipientsFromSubscription() {
// because after the previous aggregate() call the email_aggregation DB table was not purged, we already have 4 records on database
result = aggregate();
verify(emailAggregationRepository, times(2)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), anyInt(), anyInt());
verify(emailAggregationRepository, times(1)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), eq(0), eq(emailAggregator.aggregationMaxPageSize));
verify(emailAggregationRepository, times(1)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), eq(5), eq(emailAggregator.aggregationMaxPageSize));
verify(emailAggregationRepository, times(1)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), eq(0), eq(emailAggregator.batchSize));
verify(emailAggregationRepository, times(1)).getEmailAggregation(any(EmailAggregationKey.class), any(LocalDateTime.class), any(LocalDateTime.class), eq(5), eq(emailAggregator.batchSize));
assertEquals(1, result.size());
User user = result.keySet().stream().findFirst().get();
assertTrue(user.getEmail().equals("user-2"));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<checkstyle-plugin.version>3.3.0</checkstyle-plugin.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<jacoco-plugin.version>0.8.10</jacoco-plugin.version>
<jacoco-plugin.version>0.8.11</jacoco-plugin.version>
<checkstyle.version>10.12.4</checkstyle.version>

<testcontainers.version>1.19.1</testcontainers.version>
Expand Down
Loading