Skip to content

Commit

Permalink
[Backport 2.x] Fix core refactor: StreamIO from common to core.common (
Browse files Browse the repository at this point in the history
…opensearch-project#707) (opensearch-project#719)

* Fix core refactor: StreamIO from common to core.common (opensearch-project#707)

Signed-off-by: Hailong Cui <[email protected]>
(cherry picked from commit fd8fe22)

* fix gradle run (opensearch-project#717)

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am authored Jul 25, 2023
1 parent 8938d08 commit 120a976
Show file tree
Hide file tree
Showing 56 changed files with 68 additions and 70 deletions.
3 changes: 3 additions & 0 deletions notifications/build-tools/merged-coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ allprojects {

task jacocoReport(type: JacocoReport, group: 'verification') {
description = 'Generates an aggregate report from all subprojects'
onlyIf {
gradle.taskGraph.hasTask("jacocoTestReport")
}
gradle.projectsEvaluated {
subprojects.each {
jacocoReport.dependsOn it.tasks.withType(JacocoReport)
Expand Down
4 changes: 2 additions & 2 deletions notifications/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
}
opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT","")
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
kotlin_version = System.getProperty("kotlin.version", "1.6.10")
kotlin_version = System.getProperty("kotlin.version", "1.8.21")
junit_version = System.getProperty("junit.version", "5.7.2")
aws_version = System.getProperty("aws.version", "1.12.48")
}
Expand All @@ -39,7 +39,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.22.0"
classpath "org.jacoco:org.jacoco.agent:0.8.5"
classpath "org.jacoco:org.jacoco.agent:0.8.7"
}
}

Expand Down
2 changes: 0 additions & 2 deletions notifications/core-spi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ repositories {
}

apply plugin: 'opensearch.java'
apply plugin: 'opensearch.testclusters'
apply plugin: 'opensearch.java-rest-test'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.allopen'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

package org.opensearch.notifications.spi.model

import org.opensearch.common.settings.SecureString
import org.opensearch.core.common.settings.SecureString

data class SecureDestinationSettings(val emailUsername: SecureString, val emailPassword: SecureString)
13 changes: 5 additions & 8 deletions notifications/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ publishing {
}
}

tasks.register('integTest', RestIntegTestTask) {
description = "Run tests against a cluster that has security enabled"
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
systemProperty 'tests.security.manager', 'false'
}

tasks.named("check").configure { dependsOn(integTest) }
check.dependsOn jacocoTestReport

// turn off javadoc as it barfs on Kotlin code
Expand All @@ -107,6 +99,11 @@ test {
systemProperty 'tests.security.manager', 'false'
}

// disable for core, we don't need to run test cluster
run {
onlyIf { false }
}

//TODO: see if this can be only set at top level and apply to subprojects, or we remove from top project if possible
configurations.configureEach {
if (it.state != Configuration.State.UNRESOLVED) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ package org.opensearch.notifications.core
import org.opensearch.client.Client
import org.opensearch.cluster.metadata.IndexNameExpressionResolver
import org.opensearch.cluster.service.ClusterService
import org.opensearch.common.io.stream.NamedWriteableRegistry
import org.opensearch.common.settings.Setting
import org.opensearch.common.settings.Settings
import org.opensearch.core.common.io.stream.NamedWriteableRegistry
import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.env.Environment
import org.opensearch.env.NodeEnvironment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager
import org.apache.http.util.EntityUtils
import org.opensearch.common.xcontent.XContentFactory
import org.opensearch.common.xcontent.XContentType
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.setting.PluginSettings
import org.opensearch.notifications.core.utils.OpenForTesting
import org.opensearch.notifications.core.utils.logger
Expand All @@ -32,7 +33,6 @@ import org.opensearch.notifications.spi.model.destination.ChimeDestination
import org.opensearch.notifications.spi.model.destination.CustomWebhookDestination
import org.opensearch.notifications.spi.model.destination.SlackDestination
import org.opensearch.notifications.spi.model.destination.WebhookDestination
import org.opensearch.rest.RestStatus
import java.io.IOException
import java.nio.charset.StandardCharsets
import java.util.Collections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.amazonaws.services.simpleemail.model.MailFromDomainNotVerifiedExcepti
import com.amazonaws.services.simpleemail.model.MessageRejectedException
import com.amazonaws.services.simpleemail.model.RawMessage
import com.amazonaws.services.simpleemail.model.SendRawEmailRequest
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCorePlugin.Companion.LOG_PREFIX
import org.opensearch.notifications.core.credentials.SesClientFactory
import org.opensearch.notifications.core.setting.PluginSettings
Expand All @@ -23,7 +24,6 @@ import org.opensearch.notifications.core.utils.logger
import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.SesDestination
import org.opensearch.rest.RestStatus
import java.io.ByteArrayOutputStream
import java.nio.ByteBuffer
import java.util.Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
package org.opensearch.notifications.core.client

import com.sun.mail.util.MailConnectException
import org.opensearch.common.settings.SecureString
import org.opensearch.core.common.settings.SecureString
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.setting.PluginSettings
import org.opensearch.notifications.core.utils.SecurityAccess
import org.opensearch.notifications.core.utils.logger
import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.SecureDestinationSettings
import org.opensearch.notifications.spi.model.destination.SmtpDestination
import org.opensearch.rest.RestStatus
import java.util.Properties
import javax.mail.Authenticator
import javax.mail.Message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import com.amazonaws.services.sns.model.KMSThrottlingException
import com.amazonaws.services.sns.model.NotFoundException
import com.amazonaws.services.sns.model.PlatformApplicationDisabledException
import com.amazonaws.services.sns.model.PublishResult
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCorePlugin.Companion.LOG_PREFIX
import org.opensearch.notifications.core.credentials.SnsClientFactory
import org.opensearch.notifications.core.utils.logger
import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.SnsDestination
import org.opensearch.rest.RestStatus

/**
* This class handles the SNS connections to the given Destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ package org.opensearch.notifications.core.setting
import org.opensearch.bootstrap.BootstrapInfo
import org.opensearch.cluster.service.ClusterService
import org.opensearch.common.settings.SecureSetting
import org.opensearch.common.settings.SecureString
import org.opensearch.common.settings.Setting
import org.opensearch.common.settings.Setting.Property.Deprecated
import org.opensearch.common.settings.Setting.Property.Dynamic
import org.opensearch.common.settings.Setting.Property.Final
import org.opensearch.common.settings.Setting.Property.NodeScope
import org.opensearch.common.settings.Settings
import org.opensearch.core.common.settings.SecureString
import org.opensearch.notifications.core.NotificationCorePlugin.Companion.LOG_PREFIX
import org.opensearch.notifications.core.NotificationCorePlugin.Companion.PLUGIN_NAME
import org.opensearch.notifications.core.utils.OpenForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

package org.opensearch.notifications.core.transport

import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.client.DestinationClientPool
import org.opensearch.notifications.core.client.DestinationSesClient
import org.opensearch.notifications.core.utils.OpenForTesting
import org.opensearch.notifications.core.utils.logger
import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.SesDestination
import org.opensearch.rest.RestStatus
import java.io.IOException
import javax.mail.MessagingException
import javax.mail.internet.AddressException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

package org.opensearch.notifications.core.transport

import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.client.DestinationClientPool
import org.opensearch.notifications.core.client.DestinationSmtpClient
import org.opensearch.notifications.core.utils.OpenForTesting
import org.opensearch.notifications.core.utils.logger
import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.SmtpDestination
import org.opensearch.rest.RestStatus
import java.io.IOException
import javax.mail.MessagingException
import javax.mail.internet.AddressException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

package org.opensearch.notifications.core.transport

import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.client.DestinationClientPool
import org.opensearch.notifications.core.client.DestinationSnsClient
import org.opensearch.notifications.core.utils.OpenForTesting
import org.opensearch.notifications.core.utils.logger
import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.SnsDestination
import org.opensearch.rest.RestStatus
import java.io.IOException

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

package org.opensearch.notifications.core.transport

import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.client.DestinationClientPool
import org.opensearch.notifications.core.client.DestinationHttpClient
import org.opensearch.notifications.core.utils.OpenForTesting
import org.opensearch.notifications.core.utils.logger
import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.WebhookDestination
import org.opensearch.rest.RestStatus
import java.io.IOException

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package org.opensearch.notifications.core.utils

import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import org.opensearch.common.bytes.BytesReference
import org.opensearch.core.common.bytes.BytesReference
import org.opensearch.core.xcontent.XContentBuilder

fun <T : Any> logger(forClass: Class<T>): Lazy<Logger> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCoreImpl
import org.opensearch.notifications.core.client.DestinationHttpClient
import org.opensearch.notifications.core.transport.DestinationTransportProvider
Expand All @@ -30,7 +31,6 @@ import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.ChimeDestination
import org.opensearch.notifications.spi.model.destination.DestinationType
import org.opensearch.rest.RestStatus
import java.net.MalformedURLException
import java.util.stream.Stream

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCoreImpl
import org.opensearch.notifications.core.client.DestinationHttpClient
import org.opensearch.notifications.core.transport.DestinationTransportProvider
Expand All @@ -33,7 +34,6 @@ import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.CustomWebhookDestination
import org.opensearch.notifications.spi.model.destination.DestinationType
import org.opensearch.rest.RestStatus
import java.net.MalformedURLException
import java.util.stream.Stream

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCoreImpl
import org.opensearch.notifications.core.client.DestinationHttpClient
import org.opensearch.notifications.core.transport.DestinationTransportProvider
Expand All @@ -30,7 +31,6 @@ import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.ChimeDestination
import org.opensearch.notifications.spi.model.destination.DestinationType
import org.opensearch.notifications.spi.model.destination.SlackDestination
import org.opensearch.rest.RestStatus
import java.net.MalformedURLException
import java.util.stream.Stream

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.junit.jupiter.MockitoExtension
import org.opensearch.common.settings.SecureString
import org.opensearch.core.common.settings.SecureString
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCoreImpl
import org.opensearch.notifications.core.client.DestinationSmtpClient
import org.opensearch.notifications.core.transport.DestinationTransportProvider
Expand All @@ -22,7 +23,6 @@ import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.SecureDestinationSettings
import org.opensearch.notifications.spi.model.destination.DestinationType
import org.opensearch.notifications.spi.model.destination.SmtpDestination
import org.opensearch.rest.RestStatus
import javax.mail.MessagingException

@ExtendWith(MockitoExtension::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import io.mockk.spyk
import org.easymock.EasyMock
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCoreImpl
import org.opensearch.notifications.core.client.DestinationSnsClient
import org.opensearch.notifications.core.credentials.SnsClientFactory
Expand All @@ -24,7 +25,6 @@ import org.opensearch.notifications.spi.model.DestinationMessageResponse
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.DestinationType
import org.opensearch.notifications.spi.model.destination.SnsDestination
import org.opensearch.rest.RestStatus

internal class SnsDestinationTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ package org.opensearch.notifications.core.smtp

import org.junit.After
import org.junit.jupiter.api.Test
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.core.NotificationCoreImpl
import org.opensearch.notifications.core.transport.DestinationTransportProvider
import org.opensearch.notifications.core.transport.SmtpDestinationTransport
import org.opensearch.notifications.spi.model.MessageContent
import org.opensearch.notifications.spi.model.destination.DestinationType
import org.opensearch.notifications.spi.model.destination.SmtpDestination
import org.opensearch.rest.RestStatus
import org.springframework.integration.test.mail.TestMailServer
import kotlin.test.assertEquals

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import org.opensearch.client.Client
import org.opensearch.cluster.metadata.IndexNameExpressionResolver
import org.opensearch.cluster.node.DiscoveryNodes
import org.opensearch.cluster.service.ClusterService
import org.opensearch.common.io.stream.NamedWriteableRegistry
import org.opensearch.common.settings.ClusterSettings
import org.opensearch.common.settings.IndexScopedSettings
import org.opensearch.common.settings.Setting
import org.opensearch.common.settings.Settings
import org.opensearch.common.settings.SettingsFilter
import org.opensearch.commons.notifications.action.NotificationsActions
import org.opensearch.commons.utils.logger
import org.opensearch.core.common.io.stream.NamedWriteableRegistry
import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.env.Environment
import org.opensearch.env.NodeEnvironment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import org.opensearch.action.ActionResponse
import org.opensearch.action.support.ActionFilters
import org.opensearch.action.support.HandledTransportAction
import org.opensearch.client.Client
import org.opensearch.common.io.stream.Writeable
import org.opensearch.common.util.concurrent.ThreadContext
import org.opensearch.commons.ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT
import org.opensearch.commons.authuser.User
import org.opensearch.commons.utils.logger
import org.opensearch.core.common.io.stream.Writeable
import org.opensearch.core.rest.RestStatus
import org.opensearch.index.IndexNotFoundException
import org.opensearch.index.engine.VersionConflictEngineException
import org.opensearch.indices.InvalidIndexNameException
import org.opensearch.notifications.NotificationPlugin.Companion.LOG_PREFIX
import org.opensearch.notifications.metrics.Metrics
import org.opensearch.rest.RestStatus
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
import java.io.IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import org.opensearch.commons.notifications.model.SmtpAccount
import org.opensearch.commons.notifications.model.Sns
import org.opensearch.commons.notifications.model.Webhook
import org.opensearch.commons.utils.logger
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.NotificationPlugin.Companion.LOG_PREFIX
import org.opensearch.notifications.metrics.Metrics
import org.opensearch.notifications.model.DocMetadata
import org.opensearch.notifications.model.NotificationConfigDoc
import org.opensearch.notifications.security.UserAccess
import org.opensearch.rest.RestStatus
import java.time.Instant

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package org.opensearch.notifications.index

import org.opensearch.commons.notifications.action.GetNotificationConfigRequest
import org.opensearch.commons.notifications.model.NotificationConfigSearchResult
import org.opensearch.core.rest.RestStatus
import org.opensearch.notifications.model.NotificationConfigDoc
import org.opensearch.notifications.model.NotificationConfigDocInfo
import org.opensearch.rest.RestStatus

/**
* Interface for config Operations.
Expand Down
Loading

0 comments on commit 120a976

Please sign in to comment.