-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aniruddh <[email protected]>
- Loading branch information
Showing
6 changed files
with
97 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Bump bwc version | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
type: string | ||
required: true | ||
push: | ||
tags: | ||
- '*.*.*.*' | ||
|
||
permissions: {} | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: GitHub App token | ||
id: github_app_token | ||
uses: tibdex/[email protected] | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
installation_id: 22958780 | ||
|
||
- uses: actions/checkout@v4 | ||
- name: Fetch Tag and Version Information | ||
run: | | ||
if [ -n ${{ inputs.tag }} ]; then | ||
TAG=${{ inputs.tag }} | ||
else | ||
TAG=$(echo "${GITHUB_REF#refs/*/}") | ||
fi | ||
CURRENT_VERSION_ARRAY=($(echo "$TAG" | tr . '\n')) | ||
CURRENT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") | ||
CURRENT_VERSION_ARRAY[1]=$((CURRENT_VERSION_ARRAY[1]+1)) | ||
NEXT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") | ||
echo "TAG=$TAG" >> $GITHUB_ENV | ||
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | ||
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
|
||
- name: Bump bwc version for main branch | ||
run: | | ||
echo Bumping bwc version to $NEXT_VERSION | ||
sed -i "s/def bwcVersionShort = \"$CURRENT_VERSION\"/def bwcVersionShort = \"$NEXT_VERSION\"/g" notifications/notifications/build.gradle | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
base: main | ||
branch: 'create-pull-request/patch-main' | ||
commit-message: Bump bwc version to ${{ env.NEXT_VERSION }} | ||
signoff: true | ||
delete-branch: true | ||
labels: | | ||
autocut | ||
title: '[AUTO] [main] Bump bwc version to ${{ env.NEXT_VERSION }}.' | ||
body: | | ||
I've noticed that a new tag ${{ env.TAG }} was pushed, and bump bwc version to ${{ env.NEXT_VERSION }}. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ | |
|
||
package org.opensearch.notifications.core.smtp | ||
|
||
import org.junit.After | ||
import com.icegreen.greenmail.util.GreenMail | ||
import com.icegreen.greenmail.util.ServerSetupTest | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.opensearch.core.rest.RestStatus | ||
import org.opensearch.notifications.core.NotificationCoreImpl | ||
|
@@ -14,28 +17,29 @@ 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.springframework.integration.test.mail.TestMailServer | ||
import kotlin.test.assertEquals | ||
|
||
class SmtpEmailTests { | ||
|
||
internal companion object { | ||
private const val smtpPort = 10255 // use non-standard port > 1024 to avoid permission issue | ||
private val smtpServer = TestMailServer.smtp(smtpPort) | ||
private lateinit var greenMail: GreenMail | ||
|
||
@BeforeEach | ||
fun setUpServer() { | ||
greenMail = GreenMail(ServerSetupTest.SMTP) | ||
greenMail.start() | ||
} | ||
|
||
@After | ||
@AfterEach | ||
fun tearDownServer() { | ||
smtpServer.stop() | ||
smtpServer.resetServer() | ||
greenMail.stop() | ||
} | ||
|
||
@Test | ||
fun `test send email to one recipient over smtp server`() { | ||
val smtpDestination = SmtpDestination( | ||
"testAccountName", | ||
"localhost", | ||
smtpPort, | ||
ServerSetupTest.SMTP.port, | ||
"none", | ||
"[email protected]", | ||
"[email protected]" | ||
|
@@ -53,14 +57,15 @@ class SmtpEmailTests { | |
val response = NotificationCoreImpl.sendMessage(smtpDestination, message, "ref") | ||
assertEquals("Success", response.statusText) | ||
assertEquals(RestStatus.OK.status, response.statusCode) | ||
assertEquals(1, greenMail.receivedMessages.size) // Indicates retrieval of notification. | ||
} | ||
|
||
@Test | ||
fun `test send email with non-available host`() { | ||
val smtpDestination = SmtpDestination( | ||
"testAccountName", | ||
"invalidHost", | ||
smtpPort, | ||
ServerSetupTest.SMTP.port, | ||
"none", | ||
"[email protected]", | ||
"[email protected]" | ||
|
@@ -77,7 +82,7 @@ class SmtpEmailTests { | |
DestinationTransportProvider.destinationTransportMap = mapOf(DestinationType.SMTP to SmtpDestinationTransport()) | ||
val response = NotificationCoreImpl.sendMessage(smtpDestination, message, "ref") | ||
assertEquals( | ||
"sendEmail Error, status:Couldn't connect to host, port: invalidHost, $smtpPort; timeout -1", | ||
"sendEmail Error, status:Couldn't connect to host, port: invalidHost, ${ServerSetupTest.SMTP.port}; timeout -1", | ||
response.statusText | ||
) | ||
assertEquals(RestStatus.SERVICE_UNAVAILABLE.status, response.statusCode) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters