metadata:
  name: apertis-update-manager-powercut
  format: "Apertis Test Definition 1.0"
  image-type: any
  image-arch: armhf
  type: functional
  exec-type: manual
  priority: medium
  maintainer: "Apertis Project"
  description: "Ensure that failures due to power losses during updates have no effect on the system"

  resources:
    - "A static update bundle file from https://images.apertis.org/updater-test/armhf-minimal/static-update.bundle"
    - "A Fat32 USB flash drive, preloaded with the update bundle at the root of the disk"
    - "The DUT u-boot environment must be clean: in u-boot, run: `env default -a` followed by `saveenv`"
    - "A PC must be connected to DUT serial port"

  expected:
    - "The update wasn't applied"
    - "System boots using the initial deployment"
    - "Possible corruption of root file system which should not affect to boot into initial OSTree deployment"

run:
  steps:
    - "Check the current deployment"
    - $ sudo ostree admin status
    - "Need to monitor the journal log to catch events in time"
    - $ sudo journalctl -ef --unit apertis-update-manager &
    - "Plug the USB flash drive into the device"
    - "The update starts automatically"
    - "Wait while the upgrade starts"
    - |
        >Dec 19 22:31:46 apertis apertis-update-[390]: mount added : /media/test
        Dec 19 22:31:46 apertis apertis-update-[390]: Ostree static delta starting
        Dec 19 22:31:46 apertis apertis-update-[390]: Cannot check the ID in black list: No such file or directory
    - "Wait for message similar to below in log and immediately unplug the power"
    - |
        >Dec 19 22:46:59 apertis apertis-update-managerd[887]: Copying /etc changes: 5 modified, 0 removed, 16 added
    - "Plug the power back and let the device boot"
    - "Check the current deployment is the same that at the beginning of the test"
    - $ sudo ostree admin status
