-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally change trigger monitoring team into a dropdown of teams en…
…umerated in a local file
- Loading branch information
Tanner Jorgensen
committed
Jan 15, 2025
1 parent
ee6d51d
commit 6bd54ea
Showing
10 changed files
with
138 additions
and
66 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
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
28 changes: 28 additions & 0 deletions
28
admin/app/com/lucidchart/piezo/admin/models/MonitoringTeams.scala
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,28 @@ | ||
package com.lucidchart.piezo.admin.models | ||
|
||
import play.api.Configuration | ||
import java.nio.file.Files | ||
import play.api.libs.json.Json | ||
import scala.util.Try | ||
import java.io.File | ||
import java.io.FileInputStream | ||
import play.api.libs.json.JsArray | ||
|
||
class MonitoringTeams(configuration: Configuration) { | ||
private val path = configuration.getOptional[String]("com.lucidchart.piezo.admin.monitoringTeams.path") | ||
|
||
val value = path.flatMap(p => | ||
Try( | ||
Json.parse(new FileInputStream(p)) | ||
.as[JsArray] | ||
.value | ||
.map(entry => (entry \ "name").as[String]) | ||
.toSeq | ||
).toOption | ||
).getOrElse(Seq.empty) | ||
|
||
def teamsDefined: Boolean = value.nonEmpty | ||
} | ||
object MonitoringTeams { | ||
def empty: MonitoringTeams = new MonitoringTeams(Configuration.empty) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(function () { | ||
var setMonitoringFieldVisibility = function() { | ||
var priority = $('#triggerMonitoringPriority option:selected').val(); | ||
if (priority === 'Off') { | ||
$('#triggerMonitoringDetails').hide(); | ||
} else { | ||
$('#triggerMonitoringDetails').show(); | ||
} | ||
}; | ||
|
||
$('#triggerMonitoringPriority').on('change', setMonitoringFieldVisibility); | ||
|
||
setMonitoringFieldVisibility(); | ||
})(); |
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
87 changes: 43 additions & 44 deletions
87
admin/test/com/lucidchart/piezo/admin/controllers/TriggersService.scala
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 |
---|---|---|
@@ -1,57 +1,56 @@ | ||
package com.lucidchart.piezo.admin.controllers | ||
|
||
import org.specs2.mutable._ | ||
|
||
import play.api.test._ | ||
import play.api.test.Helpers._ | ||
import com.lucidchart.piezo.WorkerSchedulerFactory | ||
import TestUtil._ | ||
import java.util.Properties | ||
import play.api.mvc.{AnyContentAsEmpty, Result} | ||
import scala.concurrent.Future | ||
import com.lucidchart.piezo.admin.models.MonitoringTeams | ||
|
||
/** | ||
* Add your spec here. | ||
* You can mock out a whole application including requests, plugins etc. | ||
* For more information, consult the wiki. | ||
*/ | ||
* Add your spec here. You can mock out a whole application including requests, plugins etc. For more information, | ||
* consult the wiki. | ||
*/ | ||
class TriggersService extends Specification { | ||
"Triggers" should { | ||
|
||
"send 404 on a non-existent trigger request" in { | ||
val schedulerFactory: WorkerSchedulerFactory = new WorkerSchedulerFactory() | ||
|
||
val propertiesStream = getClass().getResourceAsStream("/quartz_test.properties") | ||
val properties = new Properties | ||
properties.load(propertiesStream) | ||
schedulerFactory.initialize(properties) | ||
|
||
val triggersController = new Triggers(schedulerFactory, Helpers.stubControllerComponents()) | ||
val request: FakeRequest[AnyContentAsEmpty.type] = FakeRequest(GET, "/triggers/missinggroup/missingname") | ||
val missingTrigger: Future[Result] = triggersController.getTrigger("missinggroup", "missingname")(request) | ||
|
||
status(missingTrigger) must equalTo(NOT_FOUND) | ||
contentType(missingTrigger) must beSome.which(_ == "text/html") | ||
contentAsString(missingTrigger) must contain ("Trigger missinggroup missingname not found") | ||
} | ||
|
||
"send valid trigger details" in { | ||
val schedulerFactory: WorkerSchedulerFactory = new WorkerSchedulerFactory() | ||
val propertiesStream = getClass().getResourceAsStream("/quartz_test.properties") | ||
val properties = new Properties | ||
properties.load(propertiesStream) | ||
schedulerFactory.initialize(properties) | ||
val scheduler = schedulerFactory.getScheduler() | ||
createJob(scheduler) | ||
|
||
val triggersController = new Triggers(schedulerFactory, Helpers.stubControllerComponents()) | ||
val request: FakeRequest[AnyContentAsEmpty.type] = FakeRequest(GET, "/triggers/" + jobGroup + "/" + jobName) | ||
val validTrigger: Future[Result] = triggersController.getTrigger(triggerGroup, triggerName)(request) | ||
|
||
status(validTrigger) must equalTo(OK) | ||
contentType(validTrigger) must beSome.which(_ == "text/html") | ||
contentAsString(validTrigger) must contain (triggerGroup) | ||
contentAsString(validTrigger) must contain (triggerName) | ||
} | ||
} | ||
} | ||
"Triggers" should { | ||
|
||
"send 404 on a non-existent trigger request" in { | ||
val schedulerFactory: WorkerSchedulerFactory = new WorkerSchedulerFactory() | ||
|
||
val propertiesStream = getClass().getResourceAsStream("/quartz_test.properties") | ||
val properties = new Properties | ||
properties.load(propertiesStream) | ||
schedulerFactory.initialize(properties) | ||
|
||
val triggersController = new Triggers(schedulerFactory, Helpers.stubControllerComponents(), MonitoringTeams.empty) | ||
val request: FakeRequest[AnyContentAsEmpty.type] = FakeRequest(GET, "/triggers/missinggroup/missingname") | ||
val missingTrigger: Future[Result] = triggersController.getTrigger("missinggroup", "missingname")(request) | ||
|
||
status(missingTrigger) must equalTo(NOT_FOUND) | ||
contentType(missingTrigger) must beSome.which(_ == "text/html") | ||
contentAsString(missingTrigger) must contain("Trigger missinggroup missingname not found") | ||
} | ||
|
||
"send valid trigger details" in { | ||
val schedulerFactory: WorkerSchedulerFactory = new WorkerSchedulerFactory() | ||
val propertiesStream = getClass().getResourceAsStream("/quartz_test.properties") | ||
val properties = new Properties | ||
properties.load(propertiesStream) | ||
schedulerFactory.initialize(properties) | ||
val scheduler = schedulerFactory.getScheduler() | ||
createJob(scheduler) | ||
|
||
val triggersController = new Triggers(schedulerFactory, Helpers.stubControllerComponents(), MonitoringTeams.empty) | ||
val request: FakeRequest[AnyContentAsEmpty.type] = FakeRequest(GET, "/triggers/" + jobGroup + "/" + jobName) | ||
val validTrigger: Future[Result] = triggersController.getTrigger(triggerGroup, triggerName)(request) | ||
|
||
status(validTrigger) must equalTo(OK) | ||
contentType(validTrigger) must beSome.which(_ == "text/html") | ||
contentAsString(validTrigger) must contain(triggerGroup) | ||
contentAsString(validTrigger) must contain(triggerName) | ||
} | ||
} | ||
} |