diff options
author | Valerij Fredriksen <valerij92@gmail.com> | 2021-04-29 15:25:17 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerij92@gmail.com> | 2021-04-29 21:07:37 +0200 |
commit | e1fad8e05389ffff936667a7f10fec27aa933982 (patch) | |
tree | 038a2f35a640745a8368a91b7aab4702a6f2d315 /controller-server/src/test/java/com/yahoo | |
parent | f4b248296b9322bbd59f8802ffe9f5d5b56c5ef0 (diff) |
Move notification level to notification
Diffstat (limited to 'controller-server/src/test/java/com/yahoo')
5 files changed, 28 insertions, 22 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java index 90d1ecb2f20..c5e35296f04 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/notification/NotificationsDbTest.java @@ -32,12 +32,12 @@ public class NotificationsDbTest { private static final TenantName tenant = TenantName.from("tenant1"); private static final List<Notification> notifications = List.of( - notification(1001, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(tenant), "tenant msg"), - notification(1101, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(TenantAndApplicationId.from(tenant.value(), "app1")), "app msg"), - notification(1201, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(ApplicationId.from(tenant.value(), "app2", "instance2")), "instance msg"), - notification(1301, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(new DeploymentId(ApplicationId.from(tenant.value(), "app2", "instance2"), ZoneId.from("prod", "us-north-2"))), "deployment msg"), - notification(1401, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(new DeploymentId(ApplicationId.from(tenant.value(), "app1", "instance1"), ZoneId.from("dev", "us-south-1")), ClusterSpec.Id.from("cluster1")), "cluster msg"), - notification(1501, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(new RunId(ApplicationId.from(tenant.value(), "app1", "instance1"), JobType.devUsEast1, 4)), "run id msg")); + notification(1001, Notification.Type.deployment, NotificationSource.from(tenant), "tenant msg"), + notification(1101, Notification.Type.deployment, NotificationSource.from(TenantAndApplicationId.from(tenant.value(), "app1")), "app msg"), + notification(1201, Notification.Type.deployment, NotificationSource.from(ApplicationId.from(tenant.value(), "app2", "instance2")), "instance msg"), + notification(1301, Notification.Type.deployment, NotificationSource.from(new DeploymentId(ApplicationId.from(tenant.value(), "app2", "instance2"), ZoneId.from("prod", "us-north-2"))), "deployment msg"), + notification(1401, Notification.Type.deployment, NotificationSource.from(new DeploymentId(ApplicationId.from(tenant.value(), "app1", "instance1"), ZoneId.from("dev", "us-south-1")), ClusterSpec.Id.from("cluster1")), "cluster msg"), + notification(1501, Notification.Type.deployment, NotificationSource.from(new RunId(ApplicationId.from(tenant.value(), "app1", "instance1"), JobType.devUsEast1, 4)), "run id msg")); private final ManualClock clock = new ManualClock(Instant.ofEpochSecond(12345)); private final MockCuratorDb curatorDb = new MockCuratorDb(); @@ -55,14 +55,14 @@ public class NotificationsDbTest { @Test public void add_test() { - Notification notification1 = notification(12345, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(ApplicationId.from(tenant.value(), "app2", "instance2")), "instance msg #2"); - Notification notification2 = notification(12345, Notification.Type.DEPLOYMENT_FAILURE, NotificationSource.from(ApplicationId.from(tenant.value(), "app3", "instance2")), "instance msg #3"); + Notification notification1 = notification(12345, Notification.Type.deployment, NotificationSource.from(ApplicationId.from(tenant.value(), "app2", "instance2")), "instance msg #2"); + Notification notification2 = notification(12345, Notification.Type.deployment, NotificationSource.from(ApplicationId.from(tenant.value(), "app3", "instance2")), "instance msg #3"); // Replace the 3rd notification - notificationsDb.setNotification(notification1.source(), notification1.type(), notification1.messages()); + notificationsDb.setNotification(notification1.source(), notification1.type(), Notification.Level.warning, notification1.messages()); // Notification for a new app, add without replacement - notificationsDb.setNotification(notification2.source(), notification2.type(), notification2.messages()); + notificationsDb.setNotification(notification2.source(), notification2.type(), Notification.Level.warning, notification2.messages()); List<Notification> expected = notificationIndices(0, 1, 3, 4, 5); expected.addAll(List.of(notification1, notification2)); @@ -72,10 +72,10 @@ public class NotificationsDbTest { @Test public void remove_single_test() { // Remove the 3rd notification - notificationsDb.removeNotification(NotificationSource.from(ApplicationId.from(tenant.value(), "app2", "instance2")), Notification.Type.DEPLOYMENT_FAILURE); + notificationsDb.removeNotification(NotificationSource.from(ApplicationId.from(tenant.value(), "app2", "instance2")), Notification.Type.deployment); // Removing something that doesn't exist is OK - notificationsDb.removeNotification(NotificationSource.from(ApplicationId.from(tenant.value(), "app3", "instance2")), Notification.Type.DEPLOYMENT_FAILURE); + notificationsDb.removeNotification(NotificationSource.from(ApplicationId.from(tenant.value(), "app3", "instance2")), Notification.Type.deployment); assertEquals(notificationIndices(0, 1, 3, 4, 5), curatorDb.readNotifications(tenant)); } @@ -102,6 +102,6 @@ public class NotificationsDbTest { } private static Notification notification(long secondsSinceEpoch, Notification.Type type, NotificationSource source, String... messages) { - return new Notification(Instant.ofEpochSecond(secondsSinceEpoch), type, source, List.of(messages)); + return new Notification(Instant.ofEpochSecond(secondsSinceEpoch), type, Notification.Level.warning, source, List.of(messages)); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/NotificationsSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/NotificationsSerializerTest.java index f3f2d10cfd0..f13f92dee85 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/NotificationsSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/NotificationsSerializerTest.java @@ -28,11 +28,13 @@ public class NotificationsSerializerTest { TenantName tenantName = TenantName.from("tenant1"); List<Notification> notifications = List.of( new Notification(Instant.ofEpochSecond(1234), - Notification.Type.APPLICATION_PACKAGE_WARNING, + Notification.Type.applicationPackage, + Notification.Level.warning, NotificationSource.from(TenantAndApplicationId.from(tenantName.value(), "app1")), List.of("Something something deprecated...")), new Notification(Instant.ofEpochSecond(2345), - Notification.Type.DEPLOYMENT_FAILURE, + Notification.Type.deployment, + Notification.Level.error, NotificationSource.from(new RunId(ApplicationId.from(tenantName.value(), "app1", "instance1"), JobType.systemTest, 12)), List.of("Failed to deploy: Out of capacity"))); @@ -40,12 +42,14 @@ public class NotificationsSerializerTest { assertEquals("{\"notifications\":[" + "{" + "\"at\":1234000," + - "\"type\":\"APPLICATION_PACKAGE_WARNING\"," + + "\"type\":\"applicationPackage\"," + + "\"level\":\"warning\"," + "\"messages\":[\"Something something deprecated...\"]," + "\"application\":\"app1\"" + "},{" + "\"at\":2345000," + - "\"type\":\"DEPLOYMENT_FAILURE\"," + + "\"type\":\"deployment\"," + + "\"level\":\"error\"," + "\"messages\":[\"Failed to deploy: Out of capacity\"]," + "\"application\":\"app1\"," + "\"instance\":\"instance1\"," + diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 0137ea7eeba..69cc2512aef 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -1641,11 +1641,13 @@ public class ApplicationApiTest extends ControllerContainerTest { private void addNotifications(TenantName tenantName) { tester.controller().notificationsDb().setNotification( NotificationSource.from(TenantAndApplicationId.from(tenantName.value(), "app1")), - Notification.Type.APPLICATION_PACKAGE_WARNING, + Notification.Type.applicationPackage, + Notification.Level.warning, "Something something deprecated..."); tester.controller().notificationsDb().setNotification( NotificationSource.from(new RunId(ApplicationId.from(tenantName.value(), "app2", "instance1"), JobType.systemTest, 12)), - Notification.Type.DEPLOYMENT_FAILURE, + Notification.Type.deployment, + Notification.Level.error, "Failed to deploy: Out of capacity"); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json index ab8262e26bd..0e0ca7405ca 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1-app2.json @@ -3,7 +3,7 @@ { "at": "(ignore)", "level": "error", - "type": "DEPLOYMENT_FAILURE", + "type": "deployment", "messages": [ "Failed to deploy: Out of capacity" ], diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json index 2b2c03bb75a..7d3dd5e672f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/notifications-tenant1.json @@ -3,7 +3,7 @@ { "at": "(ignore)", "level": "warning", - "type": "APPLICATION_PACKAGE_WARNING", + "type": "applicationPackage", "messages": [ "Something something deprecated..." ], @@ -12,7 +12,7 @@ { "at": "(ignore)", "level": "error", - "type": "DEPLOYMENT_FAILURE", + "type": "deployment", "messages": [ "Failed to deploy: Out of capacity" ], |