Package csw.testkit
Class AlarmTestKit
java.lang.Object
csw.testkit.AlarmTestKit
- All Implemented Interfaces:
EmbeddedRedis,RedisStore
AlarmTestKit supports starting Alarm server using embedded redis internally (sentinel + master)
and registering it with location service
Example:
private val testKit = AlarmTestKit()
// starting alarm server (start sentinel and master on default ports specified in configuration file)
// it will also register AlarmService with location service
testKit.startAlarmService()
// stopping alarm server
testKit.shutdownAlarmService()
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AlarmTestKitapply(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem, io.lettuce.core.RedisClient redisClient, TestKitSettings testKitSettings) Create a AlarmTestKitprotected Connection.TcpConnectionstatic AlarmTestKitcreate(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem) Java API to create a EventTestKitstatic AlarmTestKitcreate(TestKitSettings testKitSettings) Java API to create a AlarmTestKitstatic AlarmTestKitcreate(io.lettuce.core.RedisClient redisClient) Java API to create a EventTestKitscala.concurrent.ExecutionContextec()getCurrentSeverity(Key.AlarmKey alarmKey) Fetches the severity of the given alarm from the alarm storeakka.DoneinitAlarms(com.typesafe.config.Config config, boolean reset) Loads data for all alarms in alarm store i.e.csw.location.api.scaladsl.LocationServiceprotected StringmasterId()voidShutdown Alarm servicecsw.location.api.scaladsl.RegistrationResultstartAlarmService(int sentinelPort, int serverPort) Scala API to Start Alarm servicevoidstartAlarmService(Optional<Object> sentinelPort, Optional<Object> serverPort) Java API to Start Alarm serviceakka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command>system()akka.util.Timeouttimeout()akka.actor.ActorSystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface csw.testkit.redis.EmbeddedRedis
addJvmShutdownHook, startSentinel, stopSentinelMethods inherited from interface csw.testkit.redis.RedisStore
shutdown, start, start, stopRedis
-
Constructor Details
-
AlarmTestKit
public AlarmTestKit()
-
-
Method Details
-
apply
public static AlarmTestKit apply(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem, io.lettuce.core.RedisClient redisClient, TestKitSettings testKitSettings) Create a AlarmTestKitWhen the test has completed you should shutdown the alarm service with
shutdownAlarmService().- Parameters:
actorSystem- (undocumented)redisClient- (undocumented)testKitSettings- (undocumented)- Returns:
- handle to AlarmTestKit which can be used to start and stop alarm service
-
create
public static AlarmTestKit create(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem) Java API to create a EventTestKit- Parameters:
actorSystem- (undocumented)- Returns:
- handle to EventTestKit which can be used to start and stop event service
-
create
Java API to create a AlarmTestKit- Parameters:
testKitSettings- custom testKitSettings- Returns:
- handle to AlarmTestKit which can be used to start and stop alarm service
-
create
Java API to create a EventTestKit- Parameters:
redisClient- (undocumented)- Returns:
- handle to EventTestKit which can be used to start and stop event service
-
untypedSystem
public akka.actor.ActorSystem untypedSystem()- Specified by:
untypedSystemin interfaceRedisStore
-
ec
public scala.concurrent.ExecutionContext ec()- Specified by:
ecin interfaceRedisStore
-
system
public akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> system()- Specified by:
systemin interfaceRedisStore
-
timeout
public akka.util.Timeout timeout()- Specified by:
timeoutin interfaceRedisStore
-
masterId
- Specified by:
masterIdin interfaceRedisStore
-
connection
- Specified by:
connectionin interfaceRedisStore
-
locationService
public csw.location.api.scaladsl.LocationService locationService() -
startAlarmService
public csw.location.api.scaladsl.RegistrationResult startAlarmService(int sentinelPort, int serverPort) Scala API to Start Alarm serviceIt will start redis sentinel and redis server on provided ports and then register's Alarm service with location service
- Parameters:
sentinelPort- (undocumented)serverPort- (undocumented)- Returns:
- (undocumented)
-
startAlarmService
Java API to Start Alarm serviceIt will start redis sentinel and redis server on provided ports and then register's Alarm service with location service
- Parameters:
sentinelPort- (undocumented)serverPort- (undocumented)
-
shutdownAlarmService
public void shutdownAlarmService()Shutdown Alarm serviceWhen the test has completed, make sure you shutdown Alarm service. This will terminate actor system and stop redis sentinel and redis server.
-
initAlarms
public akka.Done initAlarms(com.typesafe.config.Config config, boolean reset) Loads data for all alarms in alarm store i.e. metadata of alarms for e.g. subsystem, component, name, etc. and status of alarms for e.g. acknowledgement status, latch status, etc.- Parameters:
config- represents the data for all alarms to be loaded in alarm storereset- the alarm store before loading the data- Returns:
- Done when data is loaded successfully in alarm store or fails with
ConfigParseException
-
getCurrentSeverity
Fetches the severity of the given alarm from the alarm store- Parameters:
alarmKey- represents a unique alarm in alarm store- Returns:
- the alarm severity or fails with
KeyNotFoundException
-