Tests for legacy application handling Tests for legacy application handling How to verify that the legacy app handler correctly registers the units as shutdown consumers, and that it correctly shuts them down when the Node State manager dummy tells it to. Test environment and setup Services units This test uses the "cups.service" and the "avahi-daemon.service" as units which are going to be registered as shutdown consumers. These units may or may not exist in the system, but this does not affect to the result of the tests. Starting the necessary services The NSM dummy and the Node Startup Controller services need to be started prior to running any of the tests described here. This is done using the following commands: systemctl start nsm-dummy.service systemctl start node-startup-controller.service Restarting the Node Startup Controller Between each test, the Node Startup Controller should be restarted to ensure that it is available, and that no legacy apps are lingering from the last test. It can be restarted with the following command: systemctl restart node-startup-controller.service Test Cases The following test cases for LUC management are described in this document: 1. Node Startup Controller registers itself on startup Description Every GENIVI application that is managed by the Node State Manager must register itself with the NSM as a shutdown client, and this includes the Node Startup Controller. This test verifies that the Node Startup Controller registers itself with the Node State Manager when it is started. Test commands kill -s HUP $(pidof nsm-dummy) Desired behaviour and output The DLT log should now contain the following log messages: APID CTID Payload NSMD NSMC [Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/0 shutdown mode 1 timeout 1000] NSC- CTRL [Successfully registered the node startup controller as a shutdown consumer] NSMD NSMC [Shutdown client unregistered: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController1/ShutdownConsumer/0] NSC- CTRL [Successfully unregistered the node startup controller as a shutdown consumer] 2. Registration of a fast and a normal shutdown consumer Description Shutdown Consumers can be registered with two modes - fast and normal. Fast is meant for vital applications which must be shut down gracefully, and normal applies to everything else that requires a graceful shutdown. This test registers shutdown consumers with either mode, and verifies that they are shut down by the NSM dummy. The NSM dummy will shut down the fast consumers first, then the normal consumers. Test commands /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 1 /lib/node-startup-controller-1/legacy-app-handler --unit "avahi-daemon.service" -m 2 kill -s HUP $(pidof nsm-dummy) Desired behaviour and output The DLT log should now contain the following log messages: APID CTID Payload NSMD NSMC [Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 shutdown mode 1 timeout 1000] NSMD NSMC [Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/2 shutdown mode 2 timeout 1000] NSMD NSMC [Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/2 shutdown mode 2 timeout 1000 request id XXXXXXX] NSC- LAH- [Completing a lifecycle request: request id XXXXXXX] NSMD NSMC [Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 1 timeout 1000 request id YYYYYYY] NSC- LAH- [Completing a lifecycle request: request id YYYYYYY] 3. Registration of two normal shutdown consumers Description The Node State Manager shuts down consumers in reverse order of their registration. This test verifies this by registering the consumers with the same mode. Test commands /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 1 /lib/node-startup-controller-1/legacy-app-handler --unit "avahi-daemon.service" -m 1 kill -s HUP $(pidof nsm-dummy) Desired behaviour and output The DLT log should now contain the following log messages: APID CTID Payload NSMD NSMC [Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 shutdown mode 1 timeout 1000] NSMD NSMC [Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/2 shutdown mode 1 timeout 1000] NSMD NSMC [Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/2 shutdown mode 1 timeout 1000 request id XXXXXXX] NSC- LAH- [Completing a lifecycle request: request id XXXXXXX] NSMD NSMC [Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 1 timeout 1000 request id YYYYYYY] NSC- LAH- [Completing a lifecycle request: request id YYYYYYY] 4. Registration of the same unit twice with different modes and timeouts Description The Legacy App Handler handles repeated registration (i.e. with different modes) by registering the old shutdown consumer with the Node State Manager again. The Node State Manager will register any new modes with itself, and use the new timeout. This test verifies that registering with separate modes will shut the app down in both modes with the new timeout. Test commands /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 1 -t 1500 /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 2 -t 500 kill -s HUP $(pidof nsm-dummy) Desired behaviour and output The DLT log should now contain the following log messages: APID CTID Payload NSMD NSMC [Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 shutdown mode 1 timeout 1500] NSMD NSMC [Re-registered shutdown client: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 new shutdown mode 3 new timeout 500] NSMD NSMC [Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 3 timeout 1000 request id XXXXXXX] NSMD NSMC [Waiting for client to shut down: request id XXXXXXX bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController1/ShutdownConsumer/1 shutdown mode 2] NSC- LAH- [Completing a lifecycle request: request id XXXXXXX] NSMD NSMC [Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 3 timeout 1000 request id XXXXXXX] NSMD NSMC [Waiting for client to shut down: request id XXXXXXX bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController1/ShutdownConsumer/1 shutdown mode 1] NSC- LAH- [Completing a lifecycle request: request id XXXXXXX] 5. Registration with invalid parameters Description The Legacy App Handler validates against the following rules: There must be a unit name The mode must be a combination of normal and fast, only (i.e. 1, 2 or 3) The timeout must be non-negative This test verifies that invalid input causes an error. Test commands /lib/node-startup-controller-1/legacy-app-handler --unit /lib/node-startup-controller-1/legacy-app-handler --unit cups.service -m 0 /lib/node-startup-controller-1/legacy-app-handler --unit cups.service -m 1 -t -2000 Desired behaviour and output The DLT log should now contain the following log messages: APID CTID Payload NSMD NSMC [Failed to parse command line options: Missing argument for --unit] NSMD NSMC [Failed to register legacy application: invalid shutdown mode 0] NSMD NSMC [Failed to register legacy application: shutdown timeout must be non-negative]