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

feat: added syslog support in notification channel #180

Merged
merged 2 commits into from
Oct 16, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -232,14 +233,7 @@ void deleteConfigs() throws IOException {
verify(configStore, times(1))
.deleteConfigs(
eq(Set.of(getConfigResourceContext(context1), getConfigResourceContext(context2))));
verify(responseObserver, times(1))
.onNext(
DeleteConfigsResponse.newBuilder()
.addAllDeletedConfigs(
List.of(
buildContextSpecificConfig(context1, config1, 10L, 20L),
buildContextSpecificConfig(context2, config2, 10L, 20L)))
.build());
verify(responseObserver, times(1)).onNext(argThat(this::matchDeletedResponse));
Copy link
Contributor Author

@singhalprerana singhalprerana Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test was flaky - was failing intermittently, so fixed it (though unrelated to the actual code changes)

verify(responseObserver, times(1)).onCompleted();
verify(responseObserver, never()).onError(any(Throwable.class));

Expand All @@ -251,6 +245,13 @@ void deleteConfigs() throws IOException {
verify(responseObserver, times(1)).onError(any(Throwable.class));
}

private boolean matchDeletedResponse(DeleteConfigsResponse response) {
List<ContextSpecificConfig> configs = response.getDeletedConfigsList();
return configs.size() == 2
&& configs.contains(buildContextSpecificConfig("context1", config1, 10L, 20L))
&& configs.contains(buildContextSpecificConfig("context2", config2, 10L, 20L));
}

@Test
void deleteDefaultContextConfig() throws IOException {
ConfigStore configStore = mock(ConfigStore.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ message NotificationChannelMutableData {
repeated WebhookChannelConfig webhook_channel_config = 3;
repeated AwsS3BucketChannelConfig s3_bucket_channel_config = 4;
repeated SplunkIntegrationChannelConfig splunk_integration_channel_config = 5;
repeated SyslogIntegrationChannelConfig syslog_integration_channel_config = 6;
}

message AwsS3BucketChannelConfig {
Expand Down Expand Up @@ -55,3 +56,7 @@ message WebhookHeader {
message SplunkIntegrationChannelConfig {
string splunk_integration_id = 1;
}

message SyslogIntegrationChannelConfig {
string syslog_server_integration_id = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.hypertrace.notification.config.service.v1.GetNotificationChannelRequest;
import org.hypertrace.notification.config.service.v1.NotificationChannelMutableData;
import org.hypertrace.notification.config.service.v1.SplunkIntegrationChannelConfig;
import org.hypertrace.notification.config.service.v1.SyslogIntegrationChannelConfig;
import org.hypertrace.notification.config.service.v1.UpdateNotificationChannelRequest;
import org.hypertrace.notification.config.service.v1.WebhookChannelConfig;
import org.hypertrace.notification.config.service.v1.WebhookHeader;
Expand Down Expand Up @@ -112,14 +113,17 @@ private void validateNotificationChannelMutableData(NotificationChannelMutableDa
if (data.getEmailChannelConfigCount() == 0
&& data.getWebhookChannelConfigCount() == 0
&& data.getS3BucketChannelConfigCount() == 0
&& data.getSplunkIntegrationChannelConfigCount() == 0) {
&& data.getSplunkIntegrationChannelConfigCount() == 0
&& data.getSyslogIntegrationChannelConfigCount() == 0) {
throw Status.INVALID_ARGUMENT.withDescription("No config present").asRuntimeException();
}
data.getEmailChannelConfigList().forEach(this::validateEmailChannelConfig);
data.getWebhookChannelConfigList().forEach(this::validateWebhookChannelConfig);
data.getS3BucketChannelConfigList().forEach(this::validateS3BucketConfig);
data.getSplunkIntegrationChannelConfigList()
.forEach(this::validateSplunkIntegrationChannelConfig);
data.getSyslogIntegrationChannelConfigList()
.forEach(this::validateSyslogIntegrationChannelConfig);
}

public void validateGetAllNotificationChannelsRequest(
Expand Down Expand Up @@ -180,4 +184,11 @@ private void validateSplunkIntegrationChannelConfig(
splunkIntegrationChannelConfig,
SplunkIntegrationChannelConfig.SPLUNK_INTEGRATION_ID_FIELD_NUMBER);
}

private void validateSyslogIntegrationChannelConfig(
SyslogIntegrationChannelConfig syslogIntegrationChannelConfig) {
validateNonDefaultPresenceOrThrow(
syslogIntegrationChannelConfig,
SyslogIntegrationChannelConfig.SYSLOG_SERVER_INTEGRATION_ID_FIELD_NUMBER);
}
}