From 84726d2eb522816a76d4edeeec4366f2f7191555 Mon Sep 17 00:00:00 2001
From: Denis Pynkin <denis.pynkin@collabora.com>
Date: Fri, 26 Apr 2019 18:36:08 +0300
Subject: [PATCH] Limit I/O read speed for AUM powercut test

Use CGroups blkio to limit the read speed to 1MBps allowing to
remove the USB flash in predictable state even on extremely fast
devices.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
---
 test-cases/apertis-update-manager-powercut.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test-cases/apertis-update-manager-powercut.yaml b/test-cases/apertis-update-manager-powercut.yaml
index 006e3cb..3f0d900 100644
--- a/test-cases/apertis-update-manager-powercut.yaml
+++ b/test-cases/apertis-update-manager-powercut.yaml
@@ -45,6 +45,11 @@ run:
     - "The booted commit (started with '*') must have ID which we prepare and the initial commit ID should be marked as '(rollback)'"
     - "Remove the initial deployment"
     - $ sudo ostree admin undeploy 1
+    - "Add udev rule for limiting the maximal read speed from USB drive to 1MBps."
+    - $ sudo tee /etc/udev/rules.d/99-usblimit.rules <<"EOF"
+    - |
+        >KERNEL=="sd*", SUBSYSTEMS=="usb", ACTION=="add", ENV{DEVTYPE}=="disk", ENV{MAJOR}=="8", RUN+="/bin/sh -c 'echo $env{MAJOR}:$env{MINOR} 1048576 > /sys/fs/cgroup/blkio/blkio.throttle.read_bps_device'"
+        EOF
     - "Reboot the system"
     - "Check the current deployment"
     - $ sudo ostree admin status
-- 
GitLab