Blame SOURCES/0002-tests-read-stdin-in-callout-test-scripts.patch

12de6f
From 70ba0298a49ccffc085da051ad553a1242f0bfe1 Mon Sep 17 00:00:00 2001
12de6f
From: Jonathon Jongsma <jjongsma@redhat.com>
12de6f
Date: Wed, 1 Dec 2021 16:39:06 -0600
12de6f
Subject: [PATCH 2/2] tests: read stdin in callout test scripts
12de6f
12de6f
Callout scripts are intended to be passed a JSON device configuration
12de6f
string on stdin. For our simple callout tests, we used single-line
12de6f
test scripts that unconditionally returned a constant response code
12de6f
(either error or success). This sometimes causes the tests to fail due
12de6f
to the following error:
12de6f
12de6f
    [2021-12-01T20:33:25Z DEBUG mdevctl::callouts] failed to execute callout script "/tmp/mdevctl-testZg8CPd/etc/mdevctl.d/scripts.d/callouts/rc1.sh": Failed to write to stdin of command
12de6f
12de6f
        Caused by:
12de6f
            Broken pipe (os error 32)
12de6f
12de6f
What seems to be happening is that mdevctl spawns the callout script and
12de6f
then attempts to write the JSON device configuration to its stdin pipe.
12de6f
However, the test scripts are so short that they may have exited before
12de6f
mdevctl can finish writing to stdin, which results in the command
12de6f
failing with a broken pipe error. In order to avoid this, make sure that
12de6f
the test scripts read from stdin before exiting.
12de6f
12de6f
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
12de6f
---
12de6f
 tests/callouts/rc0.sh | 1 +
12de6f
 tests/callouts/rc1.sh | 1 +
12de6f
 tests/callouts/rc2.sh | 1 +
12de6f
 3 files changed, 3 insertions(+)
12de6f
12de6f
diff --git a/tests/callouts/rc0.sh b/tests/callouts/rc0.sh
12de6f
index 039e4d0..669d0ec 100755
12de6f
--- a/tests/callouts/rc0.sh
12de6f
+++ b/tests/callouts/rc0.sh
12de6f
@@ -1,2 +1,3 @@
12de6f
 #!/usr/bin/env bash
12de6f
+json=$(
12de6f
 exit 0
12de6f
diff --git a/tests/callouts/rc1.sh b/tests/callouts/rc1.sh
12de6f
index ecdbef9..3863171 100755
12de6f
--- a/tests/callouts/rc1.sh
12de6f
+++ b/tests/callouts/rc1.sh
12de6f
@@ -1,2 +1,3 @@
12de6f
 #!/usr/bin/env bash
12de6f
+json=$(
12de6f
 exit 1
12de6f
diff --git a/tests/callouts/rc2.sh b/tests/callouts/rc2.sh
12de6f
index 5c66540..f2ec274 100755
12de6f
--- a/tests/callouts/rc2.sh
12de6f
+++ b/tests/callouts/rc2.sh
12de6f
@@ -1,2 +1,3 @@
12de6f
 #!/usr/bin/env bash
12de6f
+json=$(
12de6f
 exit 2
12de6f
-- 
12de6f
2.33.1
12de6f