diff --git a/.gitlab/tests/cram/generic/lcm/000-lcm-setup.t b/.gitlab/tests/cram/generic/lcm/000-lcm-setup.t index 23812c90a9..bd07deb890 100644 --- a/.gitlab/tests/cram/generic/lcm/000-lcm-setup.t +++ b/.gitlab/tests/cram/generic/lcm/000-lcm-setup.t @@ -4,9 +4,9 @@ Setup the test configuration: $ alias R="${CRAM_REMOTE_COMMAND:-}" $ alias C="${CRAM_REMOTE_COPY:-}" -Setup the test env by overrinding some default parameters values and restarting Cthulhu to +Setup the test env by overriding some default parameters values and restarting Cthulhu to take them into account. -Restating cthulhu would allow to workaround USP functionality after obuspa restart (LCM-835): +Restarting cthulhu would allow to workaround USP functionality after obuspa restart (LCM-835): $ C ${TESTDIR}/zzz-ci-defaults.odl root@${TARGET_LAN_IP}:/etc/amx/cthulhu/extensions Warning: Permanently added '*' (*) to the list of known hosts* (glob) diff --git a/.gitlab/tests/cram/generic/lcm/039-lcm-lpm.t b/.gitlab/tests/cram/generic/lcm/039-lcm-lpm.t new file mode 100644 index 0000000000..555e00c129 --- /dev/null +++ b/.gitlab/tests/cram/generic/lcm/039-lcm-lpm.t @@ -0,0 +1,262 @@ +## Setup test configuration +Set-up 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 + $ R "mkdir -p /etc/amx/cthulhu/onboard" + +### INSTALL onboarded containers ### + $ R "${S} && install_ctr --url_arch 3_16_alpine_copy --ee --uuid --privileged true" + + SoftwareModules.InstallDU() returned + ["",{"err_code":0,"err_msg":""}] + + $ R "${S} && install_ctr --version prplos-v2 --ee --uuid \"00000000-0000-5000-b000-000000000006\" --privileged true" + + SoftwareModules.InstallDU() returned + ["",{"err_code":0,"err_msg":""}] + + $ R "rm -rf /usr/rlyeh_save" + $ R "cp -R /lcm/rlyeh /usr/rlyeh_save" + $ R "ba-cli 'SoftwareModules.DeploymentUnit.*.Uninstall()'" + * SoftwareModules.DeploymentUnit.*.Uninstall() (glob) + SoftwareModules.DeploymentUnit.*.Uninstall() returned (glob) + [ + "" + ] + SoftwareModules.DeploymentUnit.*.Uninstall() returned (glob) + [ + "" + ] + + $ R "/etc/init.d/cthulhu stop" + $ R "/etc/init.d/rlyeh stop" + $ R "/etc/init.d/timingila stop" + +wait for cthulhu to terminate all containers and itself, before clear its data + + $ R "while [ -n \"$(pidof cthulhu)\" ]; do sleep 1; done" + $ R "rm -rf /lcm/*" + $ R "rm -rf /etc/config/cthulhu/*" + $ R "find /usr/rlyeh_save" | sort + /usr/rlyeh_save + /usr/rlyeh_save/blobs + /usr/rlyeh_save/blobs/sha256 + /usr/rlyeh_save/blobs/sha256/3dae0518e749f9d581ecf3cda7ea260e4a87c1413599b7248a60554e9ae3a3ac + /usr/rlyeh_save/blobs/sha256/40d6aa7e0cc7bf477eb2963fb057649e76d698ca80e8bd932fe6ac205a19c5f8 + /usr/rlyeh_save/blobs/sha256/73ab068ac4acca454294ecb8ec50f2331953a546a60ff241b0dc5f2f42de0d25 + /usr/rlyeh_save/blobs/sha256/74346feadcbed0c80ccfb8c88063b7629b0cc0ef7f5eed36ab8f33c466d8a95e + /usr/rlyeh_save/blobs/sha256/8282ae194fdb8233c361bceb846f5bf7c65e19d1ffae178af604e548a8bffeff + /usr/rlyeh_save/blobs/sha256/d16ea174931d66d44d3129998cc3fcabc781f646ce513a3cc74762d450a54d9e + /usr/rlyeh_save/images + /usr/rlyeh_save/images/prpl-foundation + /usr/rlyeh_save/images/prpl-foundation/prplos + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/lcm_tests + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/lcm_tests/arm32v7_3_16_alpine_copy + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/lcm_tests/arm32v7_3_16_alpine_copy/index.json + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/lcm_tests/arm32v7_3_16_alpine_copy/oci-layout + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/prplos + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/prplos/lcm-test-ipq807x-generic + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/prplos/lcm-test-ipq807x-generic/index.json + /usr/rlyeh_save/images/prpl-foundation/prplos/prplos/prplos/lcm-test-ipq807x-generic/oci-layout + $ R "find /lcm/" + /lcm/ + +### restart lcm ### + + $ R "/etc/init.d/rlyeh start" + $ R "/etc/init.d/cthulhu start" + $ R "/etc/init.d/timingila start" + $ R "sleep 1" + $ R "ba-cli -l 'Device.SoftwareModules.DeploymentUnitNumberOfEntries?'" + + 0 + + $ R "ba-cli -l 'Device.SoftwareModules.ExecEnvNumberOfEntries?'" + + 1 + + $ R "ba-cli -l 'Device.SoftwareModules.ExecutionUnitNumberOfEntries?'" + + 0 + + $ R "ba-cli 'Device.SoftwareModules.ExecEnv.1.Status?'" + ? Device.SoftwareModules.ExecEnv.1.Status? (glob) + Device.SoftwareModules.ExecEnv.1.Status="Up" + + $ R "lxc-ls -f" + +### INSTALL current containers ### + + $ R "${S} && install_ctr --url_arch 3_16_alpine --ee --uuid --privileged true --moduleversion 3.16.0" + + SoftwareModules.InstallDU() returned + ["",{"err_code":0,"err_msg":""}] + + $ R "${S} && install_ctr --url_arch 3_14_alpine --ee --uuid \"00000000-0000-5000-b000-000000000002\" --privileged true --moduleversion 1.0.0 --envvar '[{Key = \"EnvVar1\", Value = \"VarValue1\"}, {Key = \"EnvVar2\" , Value = \"VarValue2\"}]' " + + SoftwareModules.InstallDU() returned + ["",{"err_code":0,"err_msg":""}] + + $ R "${S} && install_ctr --url_arch 3_16_alpine_libcap_shadow --ee --uuid \"00000000-0000-5000-b000-000000000004\" --privileged true --moduleversion 0.1.0" + + SoftwareModules.InstallDU() returned + ["",{"err_code":0,"err_msg":""}] + + $ R "sleep 3" + $ R "lxc-ls -f" + NAME STATE AUTOSTART GROUPS IPV4 IPV6 UNPRIVILEGED + 917362a3-86e8-5332-bcfd-a4223f0e65e6 RUNNING 0 - - - false + 9904df79-0144-514d-8028-98a5eaffc674 RUNNING 0 - - - false + e61c304b-b5e4-5fdb-9836-60001e90a127 RUNNING 0 - - - false + $ R "ba-cli 'Device.SoftwareModules.DeploymentUnit.*.Status?'" + * Device.SoftwareModules.DeploymentUnit.*.Status? (glob) + Device.SoftwareModules.DeploymentUnit.*.Status="Installed" (glob) + Device.SoftwareModules.DeploymentUnit.*.Status="Installed" (glob) + Device.SoftwareModules.DeploymentUnit.*.Status="Installed" (glob) + + $ R "ba-cli 'Device.SoftwareModules.ExecutionUnit.*.Status?'" + * Device.SoftwareModules.ExecutionUnit.*.Status? (glob) + Device.SoftwareModules.ExecutionUnit.*.Status="Active" (glob) + Device.SoftwareModules.ExecutionUnit.*.Status="Active" (glob) + Device.SoftwareModules.ExecutionUnit.*.Status="Active" (glob) + + +### perform backup ### + + $ R "ba-cli 'Device.X_PRPLWARE-COM_PersistentConfiguration.Service.cthulhu_Cthulhu.ImportStatus=\"None\"'" + * Device.X_PRPLWARE-COM_PersistentConfiguration.Service.cthulhu_Cthulhu.ImportStatus="None" (glob) + Device.X_PRPLWARE-COM_PersistentConfiguration.Service.*. (glob) + Device.X_PRPLWARE-COM_PersistentConfiguration.Service.*.ImportStatus="None" (glob) + + $ R "ba-cli 'Device.X_PRPLWARE-COM_PersistentConfiguration.Service.cthulhu_Cthulhu.ExportStatus=\"None\"'" + * Device.X_PRPLWARE-COM_PersistentConfiguration.Service.cthulhu_Cthulhu.ExportStatus="None" (glob) + Device.X_PRPLWARE-COM_PersistentConfiguration.Service.*. (glob) + Device.X_PRPLWARE-COM_PersistentConfiguration.Service.*.ExportStatus="None" (glob) + + $ R "ba-cli 'Device.X_PRPLWARE-COM_PersistentConfiguration.Backup()'" + * Device.X_PRPLWARE-COM_PersistentConfiguration.Backup() (glob) + Device.X_PRPLWARE-COM_PersistentConfiguration.Backup() returned + [ + "" + ] + +### terminate LCM and remove all boot-persistent data that is not upgrade-persistent. ### + + $ R "ls -l /cfg/pcm/cthulhu*" + -rw-r--r-- 1 root * /cfg/pcm/cthulhu_Cthulhu.json (glob) + $ R "/etc/init.d/cthulhu stop" + $ R "/etc/init.d/rlyeh stop" + $ R "/etc/init.d/timingila stop" + +wait for cthulhu to terminate all containers and itself, before clear its data + + $ R "while [ -n \"$(pidof cthulhu)\" ]; do sleep 1; done" + $ R "rm -rf /etc/config/cthulhu/*" + $ R "rm -rf /etc/config/lxc/*" + $ R "rm -rf /etc/config/rlyeh/*" + +### install policy and pre-embedded container descriptors ### + + $ R 'cat > /etc/amx/cthulhu/extensions/plugin-lpm/policy.json < { + > "containerpolicy": { + > "global": { + > "onNew": "INSTALL", + > "onExisting": "IGNORE", + > "onExistingUpgrade": "UPDATE", + > "onExistingDowngrade": "IGNORE", + > "onUnknown": "IGNORE" + > }, + > "applications": [ + > { + > "uuid": "00000000-0000-5000-b000-000000000002", + > "description": "alpine 3.16", + > "onUnknown": "UNINSTALL", + > "onExisting": "UNINSTALL" + > } + > ] + > } + > } + > EOF' + + $ R "${S} && add_containers_descriptors" + +### put the pre-embedded container images in the right place and verify ### + + $ R "rm -rf /usr/rlyeh" + $ R "mv /usr/rlyeh_save /usr/rlyeh" + $ R "ls -l /etc/amx/cthulhu/onboard/" + -rw-r--r-- 1 root * 70a9bf70-9df9-5221-b51b-184c74d022e3.json (glob) + -rw-r--r-- 1 root * 917362a3-86e8-5332-bcfd-a4223f0e65e6.json (glob) + $ R "ls -l /etc/amx/cthulhu/extensions/plugin-lpm/policy.json" + -rw-r--r-- 1 root * /etc/amx/cthulhu/extensions/plugin-lpm/policy.json (glob) + $ R "ls -l /usr/rlyeh/" + drwxr-xr-x 3 root * blobs (glob) + drwxr-xr-x 3 root * images (glob) + +### Simulate reboot after upgrade ### + + $ R "/etc/init.d/cthulhu start" + $ R "/etc/init.d/rlyeh start" + $ R "/etc/init.d/timingila start" + $ while ! R ba-cli 'SoftwareModules.ExecEnv.? | grep "SoftwareModules\.ExecEnv\.1\." | head -n 1 | grep "SoftwareModules\.ExecEnv\.1\."' ; do sleep 1 ; done + SoftwareModules.ExecEnv.1. + +## check state after the simulated reboot + + $ R "ba-cli 'Device.SoftwareModules.DeploymentUnit.[UUID == \"00000000-0000-5000-b000-000000000001\"].ModuleVersion?'" + ? Device.SoftwareModules.DeploymentUnit.[UUID == "00000000-0000-5000-b000-000000000001"].ModuleVersion? (glob) + Device.SoftwareModules.DeploymentUnit.*.ModuleVersion="3.16.1" (glob) + + $ R "ba-cli 'Device.SoftwareModules.DeploymentUnit.[UUID == \"00000000-0000-5000-b000-000000000002\"].?'" + ? Device.SoftwareModules.DeploymentUnit.[UUID == "00000000-0000-5000-b000-000000000002"].? (glob) + No data found + + $ R "ba-cli 'Device.SoftwareModules.DeploymentUnit.[UUID == \"00000000-0000-5000-b000-000000000004\"].Status?'" + ? Device.SoftwareModules.DeploymentUnit.[UUID == "00000000-0000-5000-b000-000000000004"].Status? (glob) + Device.SoftwareModules.DeploymentUnit.*.Status="Installed" (glob) + + $ R "ba-cli 'Device.SoftwareModules.DeploymentUnit.[UUID == \"00000000-0000-5000-b000-000000000006\"].Status?'" + ? Device.SoftwareModules.DeploymentUnit.[UUID == "00000000-0000-5000-b000-000000000006"].Status? (glob) + Device.SoftwareModules.DeploymentUnit.*.Status="Installed" (glob) + + $ R "ba-cli 'Device.SoftwareModules.ExecutionUnit.*.Status?'" + ? Device.SoftwareModules.ExecutionUnit.*.Status? (glob) + Device.SoftwareModules.ExecutionUnit.*.Status="Active" (glob) + Device.SoftwareModules.ExecutionUnit.*.Status="Active" (glob) + Device.SoftwareModules.ExecutionUnit.*.Status="Active" (glob) + + $ R "ba-cli 'Device.SoftwareModules.LocalManagement.Action.?'" + * Device.SoftwareModules.LocalManagement.Action.? (glob) + Device.SoftwareModules.LocalManagement.Action.*. (glob) + Device.SoftwareModules.LocalManagement.Action.*.Action="Update" (glob) + Device.SoftwareModules.LocalManagement.Action.*.Alias="cpe-00000000-0000-5000-b000-000000000001" (glob) + Device.SoftwareModules.LocalManagement.Action.*.CurrentModuleVersion="3.16.1" (glob) + Device.SoftwareModules.LocalManagement.Action.*.ExecEnvName="generic" (glob) + Device.SoftwareModules.LocalManagement.Action.*.FaultMessage="" (glob) + Device.SoftwareModules.LocalManagement.Action.*.PreviousModuleVersion="3.16.0" (glob) + Device.SoftwareModules.LocalManagement.Action.*.Status="Success" (glob) + Device.SoftwareModules.LocalManagement.Action.*.UUID="00000000-0000-5000-b000-000000000001" (glob) + Device.SoftwareModules.LocalManagement.Action.*. (glob) + Device.SoftwareModules.LocalManagement.Action.*.Action="Uninstall" (glob) + Device.SoftwareModules.LocalManagement.Action.*.Alias="cpe-00000000-0000-5000-b000-000000000002" (glob) + Device.SoftwareModules.LocalManagement.Action.*.CurrentModuleVersion="" (glob) + Device.SoftwareModules.LocalManagement.Action.*.ExecEnvName="" (glob) + Device.SoftwareModules.LocalManagement.Action.*.FaultMessage="" (glob) + Device.SoftwareModules.LocalManagement.Action.*.PreviousModuleVersion="1.0.0" (glob) + Device.SoftwareModules.LocalManagement.Action.*.Status="Success" (glob) + Device.SoftwareModules.LocalManagement.Action.*.UUID="00000000-0000-5000-b000-000000000002" (glob) + Device.SoftwareModules.LocalManagement.Action.*. (glob) + Device.SoftwareModules.LocalManagement.Action.*.Action="Install" (glob) + Device.SoftwareModules.LocalManagement.Action.*.Alias="cpe-00000000-0000-5000-b000-000000000006" (glob) + Device.SoftwareModules.LocalManagement.Action.*.CurrentModuleVersion="2.0.0" (glob) + Device.SoftwareModules.LocalManagement.Action.*.ExecEnvName="generic" (glob) + Device.SoftwareModules.LocalManagement.Action.*.FaultMessage="" (glob) + Device.SoftwareModules.LocalManagement.Action.*.PreviousModuleVersion="" (glob) + Device.SoftwareModules.LocalManagement.Action.*.Status="Success" (glob) + Device.SoftwareModules.LocalManagement.Action.*.UUID="00000000-0000-5000-b000-000000000006" (glob) + diff --git a/.gitlab/tests/cram/generic/lcm/script_functions.sh b/.gitlab/tests/cram/generic/lcm/script_functions.sh index 5b654f1b05..2d1e917d59 100755 --- a/.gitlab/tests/cram/generic/lcm/script_functions.sh +++ b/.gitlab/tests/cram/generic/lcm/script_functions.sh @@ -71,6 +71,26 @@ get_container_by_name() { echo "${hw_ctr_name}" } +get_arch_name() { + board_name=$(cut -d',' -f2 /etc/amx/cthulhu/onboard/917362a3-86e8-5332-bcfd-a4223f0e65e6.json + + echo " + { + \"Bundle\": \"prpl-foundation/prplos/prplos/prplos/lcm-test-ipq807x-generic\", + \"Autostart\": 1, + \"DiskLocation\": \"${DISK_LOCATION2}\", + \"LinkedUUID\": \"00000000-0000-5000-b000-000000000006\", + \"BundleVersion\": \"prplos-v2\", + \"ModuleVersion\": \"2.0.0\", + \"Description\": \"\", + \"ContainerId\": \"70a9bf70-9df9-5221-b51b-184c74d022e3\", + \"AllocatedCPUPercent\": 50, + \"Sandbox\": \"generic\", + \"Privileged\": 1 + }" > /etc/amx/cthulhu/onboard/70a9bf70-9df9-5221-b51b-184c74d022e3.json +}