From 6023dfd39e0fa3c1d6ce41d679d6dfdd6d83e8bf Mon Sep 17 00:00:00 2001
From: Denis Pynkin <denis.pynkin@collabora.com>
Date: Thu, 26 Sep 2019 10:23:30 +0000
Subject: [PATCH] AUM OTA manual: copy hint with time settings for all tests

Use timedatectl to workaround NTP issues on some networks

With battery backed devices on networks with no properly reachable NTP servers
the boards would fail to automatically get the right time, so testers set it up
manually with `date`.

However, the hardware clock need to be configured as well for the time
configuration to survive a reboot, needed by the Apertis update manager OTA
test.

Without this, the device will fail to establish any TLS connection after the
reboot since every certificate will look like they are out of their validity
period.

This is only a workaround until we ensure NTP servers are reachable on the
testers' network, see https://phabricator.apertis.org/T6115

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
---
 test-cases/apertis-update-manager-ota-api.yaml      | 10 ++++++++++
 test-cases/apertis-update-manager-ota-diskfull.yaml | 10 ++++++++++
 test-cases/apertis-update-manager-ota-rollback.yaml | 10 ++++++++++
 test-cases/apertis-update-manager-ota-signed.yaml   | 10 ++++++++++
 4 files changed, 40 insertions(+)

diff --git a/test-cases/apertis-update-manager-ota-api.yaml b/test-cases/apertis-update-manager-ota-api.yaml
index 175b611..0777273 100644
--- a/test-cases/apertis-update-manager-ota-api.yaml
+++ b/test-cases/apertis-update-manager-ota-api.yaml
@@ -11,6 +11,16 @@ metadata:
   maintainer: "Apertis Project"
   description: "Test the apertis-update-manager API for updates over the air."
 
+  pre-conditions:
+    - >
+      This test requires a properly configured time source: when testing
+      devices not carrying a battery-backed real time clock in a network which
+      prevents connections to NTP servers (and only in that case) manually
+      ensure that the time on the device is set appropriately and that it is
+      propagated to the hardware clock so it is stay set on the next reboot if
+      the power is not plugged off.
+    - $ sudo timedatectl --adjust-system-clock set-time "2019-08-21 18:49:03" # use the appropriate date
+
   resources:
     - "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"
diff --git a/test-cases/apertis-update-manager-ota-diskfull.yaml b/test-cases/apertis-update-manager-ota-diskfull.yaml
index 6fc2c48..87b8773 100644
--- a/test-cases/apertis-update-manager-ota-diskfull.yaml
+++ b/test-cases/apertis-update-manager-ota-diskfull.yaml
@@ -11,6 +11,16 @@ metadata:
   maintainer: "Apertis Project"
   description: "Ensure that failures due to disk full errors during network updates have no effect on the system"
 
+  pre-conditions:
+    - >
+      This test requires a properly configured time source: when testing
+      devices not carrying a battery-backed real time clock in a network which
+      prevents connections to NTP servers (and only in that case) manually
+      ensure that the time on the device is set appropriately and that it is
+      propagated to the hardware clock so it is stay set on the next reboot if
+      the power is not plugged off.
+    - $ sudo timedatectl --adjust-system-clock set-time "2019-08-21 18:49:03" # use the appropriate date
+
   resources:
     - "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"
diff --git a/test-cases/apertis-update-manager-ota-rollback.yaml b/test-cases/apertis-update-manager-ota-rollback.yaml
index 9f032b2..3df3ac9 100644
--- a/test-cases/apertis-update-manager-ota-rollback.yaml
+++ b/test-cases/apertis-update-manager-ota-rollback.yaml
@@ -11,6 +11,16 @@ metadata:
   maintainer: "Apertis Project"
   description: "Test the automatic rollback and blacklist mechanism of apertis-update-manager with network updates."
 
+  pre-conditions:
+    - >
+      This test requires a properly configured time source: when testing
+      devices not carrying a battery-backed real time clock in a network which
+      prevents connections to NTP servers (and only in that case) manually
+      ensure that the time on the device is set appropriately and that it is
+      propagated to the hardware clock so it is stay set on the next reboot if
+      the power is not plugged off.
+    - $ sudo timedatectl --adjust-system-clock set-time "2019-08-21 18:49:03" # use the appropriate date
+
   resources:
     - "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"
diff --git a/test-cases/apertis-update-manager-ota-signed.yaml b/test-cases/apertis-update-manager-ota-signed.yaml
index ac7df81..3ca998e 100644
--- a/test-cases/apertis-update-manager-ota-signed.yaml
+++ b/test-cases/apertis-update-manager-ota-signed.yaml
@@ -11,6 +11,16 @@ metadata:
   maintainer: "Apertis Project"
   description: "Test the apertis-update-manager uses only signed updates over the air."
 
+  pre-conditions:
+    - >
+      This test requires a properly configured time source: when testing
+      devices not carrying a battery-backed real time clock in a network which
+      prevents connections to NTP servers (and only in that case) manually
+      ensure that the time on the device is set appropriately and that it is
+      propagated to the hardware clock so it is stay set on the next reboot if
+      the power is not plugged off.
+    - $ sudo timedatectl --adjust-system-clock set-time "2019-08-21 18:49:03" # use the appropriate date
+
   resources:
     - "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"
-- 
GitLab