forked from RedHatInsights/notifications-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RHCLOUD-28935] Add OCM Cluster updates email template (RedHatInsight…
…s#2339) Co-authored-by: Gwenneg Lepage <[email protected]>
- Loading branch information
Showing
5 changed files
with
169 additions
and
0 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
46 changes: 46 additions & 0 deletions
46
engine/src/main/resources/templates/OCM/clusterUpdateInstantEmailBodyV2.html
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,46 @@ | ||
{@boolean renderSection1=true} | ||
{@boolean renderSection2=true} | ||
{#include Common/insightsEmailBody} | ||
{#content-title} | ||
Cluster Manager - OpenShift | ||
{/content-title} | ||
{#content-title-section1} | ||
{#if action.events[0].payload.global_vars.upgrade_status == 'scheduled'}Upgrade scheduled{#else}Upgrade ended{/if} | ||
{/content-title-section1} | ||
{#content-body-section1} | ||
{#let global_var=action.events[0].payload.global_vars} | ||
<p> | ||
This notification is for your <a href="https://cloud.redhat.com/openshift/details/s/{action.events[0].payload.subscription_id}#overview" target="_blank" title="*|CLUSTER_DISPLAY_NAME|*">{action.events[0].payload.cluster_display_name} cluster</a>. | ||
</p> | ||
<p> | ||
Your {global_var.log_description}. | ||
</p> | ||
{#if global_var.upgrade_status == 'scheduled'} | ||
<p> | ||
<strong>What can you expect?</strong> | ||
<ul> | ||
<li>Your cluster capacity may increase briefly during the course of the upgrade but will never decrease. Your cluster will remain operational during the upgrade.</li> | ||
<li>If your applications are not designed as highly available, they may experience brief outages as we roll through the upgrade.</li> | ||
<li>We will send reminders as we get closer to the upgrade date. The maintenance window for the upgrade is variable and should take approximately 90 minutes for the control plane nodes and 10 minutes for each worker node.</li> | ||
</ul> | ||
|
||
<strong>What should you do to minimize impact?</strong> | ||
<ul> | ||
<li>You can minimize the impact on your applications by scaling your services to more than one pod. In general, for applications to be able to continue to service clients, they should be scaled.</li> | ||
<li>Some pod workloads are not appropriate for scaling, such as a single-instance, non-replicated database using a persistent volume claim. In this situation, a deployment strategy of 'recreate' will ensure the pod is restarted after migration, although a brief outage will be experienced.</li> | ||
</ul> | ||
|
||
<strong>For more information, refer to</strong> <a href="https://www.openshift.com/blog/deploying-highly-available-applications-openshift-kubernetes" target="_blank" title="OpenShift HA guide blog">our highly available deployment guide</a>. | ||
</p> | ||
{/if} | ||
{/let} | ||
{/content-body-section1} | ||
{#content-title-section2} | ||
More info | ||
{/content-title-section2} | ||
{#content-body-section2} | ||
If you have any questions, please <a href="https://access.redhat.com/support/contact/technicalSupport/" target="_blank" title="Red Hat Support">contact us</a>. Review the <a href="https://access.redhat.com/support/policy/support_process" target="_blank" title="Red Hat support process">support process</a> for guidance on working with Red Hat support. | ||
<br/><br/> | ||
Thank you for choosing Red Hat OpenShift {#switch action.events[0].payload.global_vars.subscription_plan}{#case 'OSD'}Dedicated{#case 'OSDTrial'}Dedicated Trial{#case 'MOA'}Service on AWS{/switch}. | ||
{/content-body-section2} | ||
{/include} |
1 change: 1 addition & 0 deletions
1
engine/src/main/resources/templates/OCM/clusterUpdateInstantEmailTitleV2.txt
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 @@ | ||
{action.events[0].payload.subject} |
52 changes: 52 additions & 0 deletions
52
engine/src/test/java/com/redhat/cloud/notifications/OcmTestHelpers.java
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,52 @@ | ||
package com.redhat.cloud.notifications; | ||
|
||
import com.redhat.cloud.notifications.ingress.Action; | ||
import com.redhat.cloud.notifications.ingress.Context; | ||
import com.redhat.cloud.notifications.ingress.Event; | ||
import com.redhat.cloud.notifications.ingress.Metadata; | ||
import com.redhat.cloud.notifications.ingress.Payload; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static com.redhat.cloud.notifications.TestConstants.DEFAULT_ORG_ID; | ||
|
||
public class OcmTestHelpers { | ||
|
||
public static Action createOcmAction(String clusterDisplayName, String subscriptionPlan, String logDescription, String upgradeStatus, String subject) { | ||
Action emailActionMessage = new Action(); | ||
emailActionMessage.setBundle("openshift"); | ||
emailActionMessage.setApplication("cluster-manager"); | ||
emailActionMessage.setTimestamp(LocalDateTime.now()); | ||
emailActionMessage.setEventType("testEmailSubscriptionInstant"); | ||
|
||
emailActionMessage.setContext( | ||
new Context.ContextBuilder() | ||
.withAdditionalProperty("system_check_in", "2021-07-13T15:22:42.199046") | ||
.withAdditionalProperty("tags", List.of()) | ||
.build() | ||
); | ||
Map<String, String> globalVars = Map.of( | ||
"cluster_display_name", clusterDisplayName, | ||
"subscription_id", "2XqNHRdLNEAzshh7MkkOql6fx6I", | ||
"subscription_plan", subscriptionPlan, | ||
"log_description", logDescription, | ||
"upgrade_status", upgradeStatus | ||
); | ||
emailActionMessage.setEvents(List.of( | ||
new Event.EventBuilder() | ||
.withMetadata(new Metadata.MetadataBuilder().build()) | ||
.withPayload( | ||
new Payload.PayloadBuilder() | ||
.withAdditionalProperty("global_vars", globalVars) | ||
.withAdditionalProperty("subject", subject) | ||
.build() | ||
) | ||
.build() | ||
)); | ||
|
||
emailActionMessage.setOrgId(DEFAULT_ORG_ID); | ||
|
||
return emailActionMessage; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
engine/src/test/java/com/redhat/cloud/notifications/templates/TestOcmTemplate.java
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,65 @@ | ||
package com.redhat.cloud.notifications.templates; | ||
|
||
import com.redhat.cloud.notifications.EmailTemplatesInDbHelper; | ||
import com.redhat.cloud.notifications.OcmTestHelpers; | ||
import com.redhat.cloud.notifications.TestHelpers; | ||
import com.redhat.cloud.notifications.ingress.Action; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Test; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@QuarkusTest | ||
public class TestOcmTemplate extends EmailTemplatesInDbHelper { | ||
|
||
private static final String EVENT_TYPE_NAME = "cluster-update"; | ||
|
||
@Override | ||
protected String getBundle() { | ||
return "openshift"; | ||
} | ||
|
||
@Override | ||
protected String getApp() { | ||
return "cluster-manager"; | ||
} | ||
|
||
@Override | ||
protected List<String> getUsedEventTypeNames() { | ||
return List.of(EVENT_TYPE_NAME); | ||
} | ||
|
||
@Test | ||
public void testUpgradeEmailTitle() { | ||
Action action = OcmTestHelpers.createOcmAction("Batcave", "OSDTrial", "<b>Batmobile</b> need a revision", "scheduled", "Awesome subject"); | ||
|
||
String result = generateEmailSubject(EVENT_TYPE_NAME, action); | ||
assertEquals("Awesome subject", result); | ||
} | ||
|
||
@Test | ||
public void testUpgradeScheduledInstantEmailBody() { | ||
Action action = OcmTestHelpers.createOcmAction("Batcave", "OSDTrial", "<b>Batmobile</b> need a revision", "scheduled", "Awesome subject"); | ||
String result = generateEmailBody(EVENT_TYPE_NAME, action); | ||
assertTrue(result.contains(TestHelpers.HCC_LOGO_TARGET)); | ||
assertTrue(result.contains("Upgrade scheduled")); | ||
assertTrue(result.contains(((Map<String, String>) action.getEvents().get(0).getPayload().getAdditionalProperties().get("global_vars")).get("log_description"))); | ||
assertTrue(result.contains("What can you expect")); | ||
assertTrue(result.contains("Thank you for choosing Red Hat OpenShift Dedicated Trial.")); | ||
} | ||
|
||
@Test | ||
public void testUpgradeEndedInstantEmailBody() { | ||
Action action = OcmTestHelpers.createOcmAction("Batcave", "MOA", "<b>Batmobile</b> is ready to go", "ended", "Awesome subject"); | ||
String result = generateEmailBody(EVENT_TYPE_NAME, action); | ||
assertTrue(result.contains(TestHelpers.HCC_LOGO_TARGET)); | ||
assertTrue(result.contains("Upgrade ended")); | ||
assertTrue(result.contains(((Map<String, String>) action.getEvents().get(0).getPayload().getAdditionalProperties().get("global_vars")).get("log_description"))); | ||
assertFalse(result.contains("What can you expect")); | ||
assertTrue(result.contains("Thank you for choosing Red Hat OpenShift Service on AWS.")); | ||
} | ||
} |