diff --git a/.gitlab/tests/cram/generic/lcm/039-lcm_dustatechange.t b/.gitlab/tests/cram/generic/lcm/039-lcm_dustatechange.t new file mode 100644 index 0000000000..e9a0011f1c --- /dev/null +++ b/.gitlab/tests/cram/generic/lcm/039-lcm_dustatechange.t @@ -0,0 +1,106 @@ +## Setup test configuration +Setup the test configuration: + + $ alias R="${CRAM_REMOTE_COMMAND:-}" + $ alias C="${CRAM_REMOTE_COPY:-}" + $ S=". /tmp/script_functions.sh" + $ C ${TESTDIR}/script_functions.sh root@${TARGET_LAN_IP}:/tmp/script_functions.sh 2>/dev/null + $ C ${TESTDIR}/event.lua root@${TARGET_LAN_IP}:/tmp/event.lua 2>/dev/null + $ C ${TESTDIR}/usp-cli/usp-cli.conf root@${TARGET_LAN_IP}:/etc/amx/cli/usp-cli.conf 2>/dev/null + $ C ${TESTDIR}/usp-cli/usp-cli.init root@${TARGET_LAN_IP}:/etc/amx/cli/usp-cli.init 2>/dev/null + $ R "if [ ! -f /usr/bin/usp-cli ] ; then ln -s amx-cli /usr/bin/usp-cli; fi" + +### DUSTATECHANGE SECTION ### + +Subscribe to the DUStateChange event + + $ R "usp-cli 'Device.LocalAgent.Subscription.+{Alias=\"DUStateChange\", ID=\"DUStateChange\", ReferenceList=\"Device.SoftwareModules.DUStateChange!\", Enable=1, NotifType=\"Event\"}'" > /dev/null + +Listen to the event + + $ R "lua /tmp/event.lua \"Device.SoftwareModules.\" \"DUStateChange!\" > /tmp/captured_event &" + +Install a container, and check the event + + $ R "${S} && install_ctr --version prplos-v1 --ee --uuid --privileged true" > /dev/null + +check the event + + $ R "cat /tmp/captured_event" + Event DUStateChange! + { + CurrentState = "Installed", + DeploymentUnitRef = "Device.SoftwareModules.DeploymentUnit.[Alias == "cpe-917362a3-86e8-5332-bcfd-a4223f0e65e6"]", + ExecutionUnitRefList = "Device.SoftwareModules.ExecutionUnit.[Alias == "cpe-917362a3-86e8-5332-bcfd-a4223f0e65e6"]", + Fault = { + FaultCode = 0, + FaultString = "" + }, + OperationPerformed = "Install", + Resolved = true, + UUID = "00000000-0000-5000-b000-000000000001", + Version = "prplos-v1", + path = "Device.SoftwareModules." + } + +Listen to the event + + $ R "lua /tmp/event.lua \"Device.SoftwareModules.\" \"DUStateChange!\" > /tmp/captured_event &" + +Update the container + + $ R "${S} && update_ctr --version prplos-v2 --ee --uuid --privileged true" > /dev/null + +check the event + + $ R "cat /tmp/captured_event" + Event DUStateChange! + { + CurrentState = "Installed", + DeploymentUnitRef = "Device.SoftwareModules.DeploymentUnit.[Alias == "cpe-917362a3-86e8-5332-bcfd-a4223f0e65e6"]", + ExecutionUnitRefList = "Device.SoftwareModules.ExecutionUnit.[Alias == "cpe-917362a3-86e8-5332-bcfd-a4223f0e65e6"]", + Fault = { + FaultCode = 0, + FaultString = "" + }, + OperationPerformed = "Update", + Resolved = true, + UUID = "00000000-0000-5000-b000-000000000001", + Version = "prplos-v2", + path = "Device.SoftwareModules." + } + +Listen to the event + + $ R "lua /tmp/event.lua \"Device.SoftwareModules.\" \"DUStateChange!\" > /tmp/captured_event &" + +Uninstall the container + + $ R "${S} && uninstall_ctr_and_check --uuid" > /dev/null + [1] + +check the event + + $ R "cat /tmp/captured_event" + Event DUStateChange! + { + CurrentState = "Uninstalled", + DeploymentUnitRef = "Device.SoftwareModules.DeploymentUnit.[Alias == "cpe-917362a3-86e8-5332-bcfd-a4223f0e65e6"]", + ExecutionUnitRefList = "Device.SoftwareModules.ExecutionUnit.[Alias == "cpe-917362a3-86e8-5332-bcfd-a4223f0e65e6"]", + Fault = { + FaultCode = 0, + FaultString = "" + }, + OperationPerformed = "Uninstall", + Resolved = true, + UUID = "00000000-0000-5000-b000-000000000001", + Version = "prplos-v2", + path = "Device.SoftwareModules." + } + +remove the subscription + + $ R "usp-cli 'Device.LocalAgent.Subscription.[ Alias==\"DUStateChange\"]-'" > /dev/null + + + diff --git a/.gitlab/tests/cram/generic/lcm/event.lua b/.gitlab/tests/cram/generic/lcm/event.lua new file mode 100644 index 0000000000..d4601ec707 --- /dev/null +++ b/.gitlab/tests/cram/generic/lcm/event.lua @@ -0,0 +1,33 @@ +#!/usr/bin/lua + +local req_object = arg[1] +local req_event = arg[2] +local lamx = require 'lamx' + +local usp_backend_config = { + usp = { + EndpointID = 'proto::local_controller' + } +} + +lamx.backend.load("/usr/bin/mods/usp/mod-amxb-usp.so") +lamx.backend.push_config(usp_backend_config) +lamx.bus.open("usp:/var/run/usp/broker_agent_path") + +local el = lamx.eventloop.new() +local print_event = function(event, data) + if event == req_event then + print("Event " .. event) + table.dump(data) + el:stop() + end +end + +local sub = lamx.bus.subscribe(req_object, print_event); + +el:start() + +--lamx.bus.ubsubscribe(sub) + +lamx.backend.remove("usp") +