From 7f5541acf654d07a14678331efee774a7df200a9 Mon Sep 17 00:00:00 2001 From: Nabil BIZID Date: Sun, 5 Oct 2025 16:26:55 +0200 Subject: [PATCH] ci: cram: lcm: update tests to avoid hardcoded indexes Refactor LCM tests to eliminate reliance on hardcoded index values when querying the datamodel. Previously, tests depended on specific indexes, which could cause failures if indexes did not match or were altered by other tests. This update replaces ubus commands with generic ba-cli commands that use filters to query instances, making tests more robust and less prone to breakage due to index mismatches. References: PCF-2025 Signed-off-by: Nabil BIZID --- .../acceleration-plan-components/040-lcm.t | 101 +++++++++++------- .../110-data-model-mapper.t | 2 +- 2 files changed, 62 insertions(+), 41 deletions(-) diff --git a/.gitlab/tests/cram/generic/acceleration-plan-components/040-lcm.t b/.gitlab/tests/cram/generic/acceleration-plan-components/040-lcm.t index edc3b5dc9c..2c8ea3ad1d 100644 --- a/.gitlab/tests/cram/generic/acceleration-plan-components/040-lcm.t +++ b/.gitlab/tests/cram/generic/acceleration-plan-components/040-lcm.t @@ -19,38 +19,55 @@ Check that random LXC binaries work: Check Cthulhu.Config datamodel: - $ R "ubus -S call Cthulhu.Config _get" - {"Cthulhu.Config.":{"PluginLocation":"/usr/lib/amx/cthulhu/plugins","ImageLocation":"/lcm/rlyeh/images","HostObjectsMountOptions":"bind,ro,nodev,nosuid,relatime,noexec","UseOverlayFS":true,"GracefulShutdownTimeoutSeconds":10,"UseBundles":false,"StorageLocation":"/lcm/cthulhu","HostObjectsMountOptionsTmpfs":"rw,nodev,nosuid,relatime","DefaultBackend":"/usr/lib/cthulhu-lxc/cthulhu-lxc.so","BundleLocation":"/lcm/celephais/bundles","BlobLocation":"/lcm/rlyeh/blobs"}} - {} - {"amxd-error-code":0} + $ R "ubus-cli -l -j Cthulhu.Config.?0 | jsonfilter -e @[*].*.PluginLocation -e @[*].*.ImageLocation -e @[*].*.UseOverlayFS -e @[*].*.GracefulShutdownTimeoutSeconds -e @[*].*.UseBundles -e @[*].*.StorageLocation -e @[*].*.DefaultBackend -e @[*].*.BundleLocation -e @[*].*.BlobLocation | sort" + /lcm/celephais/bundles + /lcm/cthulhu + /lcm/rlyeh/blobs + /lcm/rlyeh/images + /usr/lib/amx/cthulhu/plugins + /usr/lib/cthulhu-lxc/cthulhu-lxc.so + 0 + 1 + 10 + Check Rlyeh datamodel: - $ R "ubus -S call Rlyeh _get" - {"Rlyeh.":{"PluginLocation":"/usr/lib/amx/rlyeh/plugins","ImageLocation":"/lcm/rlyeh/images","ROImageLocation":"/usr/rlyeh/images","ROStorageLocation":"/usr/rlyeh/blobs","CertificateVerification":true,"SignatureVerification":true,"RemainingDiskSpaceBytes":1000001,"StorageLocation":"/lcm/rlyeh/blobs","OnboardingFile":"/lcm/rlyeh_onboarded"}} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j Rlyeh.?0 | jsonfilter -e @[*].*.PluginLocation -e @[*].*.ImageLocation -e @[*].*.ROImageLocation -e @[*].*.ROStorageLocation -e @[*].*.CertificateVerification -e @[*].*.SignatureVerification -e @[*].*.StorageLocation -e @[*].*.RemainingDiskSpaceBytes -e @[*].*.OnboardingFile | sort" + /lcm/rlyeh/blobs + /lcm/rlyeh/images + /lcm/rlyeh_onboarded + /usr/lib/amx/rlyeh/plugins + /usr/rlyeh/blobs + /usr/rlyeh/images + 1 + 1 + 1000001 + Check SoftwareModules datamodel: - $ R "ubus -S call SoftwareModules _get" - {"SoftwareModules.":{"ExecutionUnitNumberOfEntries":0,"ExecEnvNumberOfEntries":1,"DeploymentUnitNumberOfEntries":0}} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j SoftwareModules.? | jsonfilter -e @[*].*.ExecEnvNumberOfEntries -e @[*].*.ExecutionUnitNumberOfEntries -e @[*].*.DeploymentUnitNumberOfEntries | sort" + 0 + 0 + 1 + Check Timingila datamodel: - $ R "ubus -S call Timingila _get" - {"Timingila.":{"RmAfterUninstall":true,"ContainerPluginPath":"/usr/lib/timingila-cthulhu/timingila-cthulhu.so","PackagerPluginPath":"/usr/lib/timingila-rlyeh/timingila-rlyeh.so","version":"alpha"}} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j Timingila.?0 | jsonfilter -e @[*].*.ContainerPluginPath -e @[*].*.PackagerPluginPath -e @[*].*.RmAfterUninstall -e @[*].*.version | sort" + /usr/lib/timingila-cthulhu/timingila-cthulhu.so + /usr/lib/timingila-rlyeh/timingila-rlyeh.so + 1 + alpha + Check that Rlyeh has no container images: - $ R "ubus -S call Rlyeh.Images _get" - {"Rlyeh.Images.":{}} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j 'Rlyeh.Images.?'" + + [{}] + Check that registry.gitlab.com is accessible: @@ -58,40 +75,44 @@ Check that registry.gitlab.com is accessible: Check that Rlyeh can download testing container: - $ R "ubus -S call Rlyeh pull '{\"URI\":\"docker://registry.gitlab.com/prpl-foundation/prplos/prplos/prplos-testing-container-intel_mips-xrx500:v1\",\"DUID\":\"0f032bd7-54bd-5b81-b14e-9441d730092f\"}'" - {"retval":""} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j 'Rlyeh.pull(URI = \"docker://registry.gitlab.com/prpl-foundation/prplos/prplos/prplos-testing-container-intel_mips-xrx500:v1\", DUID = \"0f032bd7-54bd-5b81-b14e-9441d730092f\")'" + + Rlyeh.pull() returned + [""] + + + $ R 'i=1; while [ $i -lt 10 ] && [ "$(ba-cli -lj "Rlyeh.Images.[DUID == \"0f032bd7-54bd-5b81-b14e-9441d730092f\"].DUID?" | jsonfilter -e @[*].*.DUID)" != "0f032bd7-54bd-5b81-b14e-9441d730092f" ]; do i=$((i+1)); sleep 1; done' - $ R "ubus -t 60 wait_for Rlyeh.Images.1" Check that Rlyeh has downloaded the testing container: - $ R "ubus -S call Rlyeh.Images _get | jsonfilter -e @[*].Name -e @[*].Status | sort" + $ R "ba-cli -l -j 'Rlyeh.Images.[DUID == \"0f032bd7-54bd-5b81-b14e-9441d730092f\"].?' | jsonfilter -e @[*].*.Name -e @[*].*.Status | sort" Downloaded prpl-foundation/prplos/prplos/prplos-testing-container-intel_mips-xrx500 Remove testing container: - $ R "ubus -S call Rlyeh remove '{\"DUID\":\"0f032bd7-54bd-5b81-b14e-9441d730092f\",\"Version\":\"v1\"}'"; sleep 5 - {"retval":""} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j 'Rlyeh.remove(DUID=\"0f032bd7-54bd-5b81-b14e-9441d730092f\", Version = \"v1\")'"; sleep 5 + + Rlyeh.remove() returned + [""] + - $ R "ubus -S call Rlyeh.Images.1 _get | jsonfilter -e @[*].MarkForRemoval" - true + $ R "ba-cli -l -j 'Rlyeh.Images.[DUID == \"0f032bd7-54bd-5b81-b14e-9441d730092f\"].?' | jsonfilter -e @[*].*.MarkForRemoval" + 1 - $ R "ubus -S call Rlyeh gc" - {"retval":""} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j 'Rlyeh.gc()'"; sleep 5 + + Rlyeh.gc() returned + [""] + Check that Rlyeh has no container images: - $ R "ubus -S call Rlyeh.Images _get" - {"Rlyeh.Images.":{}} - {} - {"amxd-error-code":0} + $ R "ba-cli -l -j 'Rlyeh.Images.?'" + + [{}] + Check that testing image is gone from the filesystem as well: diff --git a/.gitlab/tests/cram/generic/acceleration-plan-components/110-data-model-mapper.t b/.gitlab/tests/cram/generic/acceleration-plan-components/110-data-model-mapper.t index 65892b2a2a..9d3a9d32dd 100644 --- a/.gitlab/tests/cram/generic/acceleration-plan-components/110-data-model-mapper.t +++ b/.gitlab/tests/cram/generic/acceleration-plan-components/110-data-model-mapper.t @@ -178,7 +178,7 @@ Check new DeploymentUnit: SoftwareModules.DeploymentUnit.*.DUID="*" (glob) SoftwareModules.DeploymentUnit.*.Description="*" (glob) SoftwareModules.DeploymentUnit.*.ExecutionEnvRef="Device.SoftwareModules.ExecEnv.1." (glob) - SoftwareModules.DeploymentUnit.3.ExecutionUnitList="Device.SoftwareModules.ExecutionUnit.1" + SoftwareModules.DeploymentUnit.*.ExecutionUnitList="Device.SoftwareModules.ExecutionUnit.*" (glob) SoftwareModules.DeploymentUnit.*.Installed="*" (glob) SoftwareModules.DeploymentUnit.*.LastUpdate="*" (glob) SoftwareModules.DeploymentUnit.*.ModuleVersion="v1" (glob)