pacemaker/0010-Test-cts-cli-cts-pengine-avoid-sed-i.patch
Jan Pokorný 436eae4e1e
2.0.0-0.1.rc2 - Update for new upstream tarball
... for release candidate: Pacemaker-2.0.0-rc2,
  for full details, see included ChangeLog file or
  https://github.com/ClusterLabs/pacemaker/releases/tag/Pacemaker-2.0.0-rc2

Adapt spec file more akin to upstream version including:
. out-of-tree change from 1.1.18-2 build got subsumed (508ad52e7)
. %%{_sysconfdir}/pacemaker path got properly owned
  (-cli package; f6e3ab98d)
. -libs package started to properly declare Requires(pre): shadow-utils
  (293fcc1e8 + b3d49d210)
. some build conditionals and dependencies dropped for no longer
  (snmp, esmtp; f24bdc6f2 and 1f7374884, respectively) or never
  being relevant (~bison, byacc, flex; 61aef8af4)
. some dependencies were constrained with new or higher lower bounds:
  corosync needs to be of version 2+ unconditionally (ccd58fe29),
  ditto some others components (~GLib, 1ac2e7cbb), plus both 2 and 3
  versions of Python are now (comprehensively for the auxiliary
  functionality where used) supported upstream with the latter being
  a better fit (453355f8f)
. package descriptions got to reflect the drop of legacy low-level
  cluster infrastructures (55ab749bf)

Adapt spec file akin to current packaging guidelines including:
. drop some redundant/futile expressions (defattr, "-n %%{name}-libs"
  instead of plain "libs", "timezone hack"), add some notes for future
. make -cts and -doc packages noarch (former enabled with 088a5e7d4)
. simplify "systemd_requires" macro invocation, and relax it to
  "systemd_ordering" for -remote package where possible so as not
  to drag systemd into a lightweight system setup (e.g. container)
  needlessly
. adjust, in a compatible way, common ldconfig invocation with
  post{,un} scriptlets
  (https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets)
. drop some more unuseful conditionals (upstart_job)

Apply some regression fixes on top as patches (PR #1457, #1459)

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2018-04-13 18:27:39 +02:00

107 lines
3.3 KiB
Diff

From ea62ae820b0fa71e5f582f844db21a79db268c1e Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 17:50:23 -0500
Subject: [PATCH 10/17] Test: cts-cli,cts-pengine: avoid sed -i
"sed -i" isn't POSIX, and its usage differs in GNU sed and BSD sed,
so avoid it in regression tests.
It should be handled similarly in other places where it remains, but this will
help get the BSD build working.
---
cts/cts-cli.in | 25 +++++++++----------------
cts/cts-pengine.in | 13 ++++++++++++-
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/cts/cts-cli.in b/cts/cts-cli.in
index 365f4b10b..38045b944 100755
--- a/cts/cts-cli.in
+++ b/cts/cts-cli.in
@@ -433,18 +433,6 @@ function test_dates() {
test_assert $CRM_EX_OK 0
}
-function get_epoch() {
- CIB_user=root CIB_file=$1 CIB_shadow="" cibadmin -Q | head -n 1 | sed -e 's/.* epoch=\"\([0-9]*\).*/\1/'
-}
-
-function restore_epoch() {
- infile=$1; shift
- old=$1; shift
- new=$(get_epoch $infile)
-
- sed -i 's/epoch=.$old/epoch=\"$new/g' $infile
-}
-
function test_acl_loop() {
local TMPXML="$1"
@@ -693,8 +681,11 @@ EOF
test_assert $CRM_EX_OK
SHADOWPATH="$(crm_shadow --file)"
- sed -i 's/epoch=.2/epoch=\"6/g' "$SHADOWPATH"
- sed -i 's/admin_epoch=.1/admin_epoch=\"0/g' "$SHADOWPATH"
+ # sed -i isn't portable :-(
+ cp -p "$SHADOWPATH" "${SHADOWPATH}.$$" # to keep permissions
+ sed -e 's/epoch=.2/epoch=\"6/g' -e 's/admin_epoch=.1/admin_epoch=\"0/g' \
+ "$SHADOWPATH" > "${SHADOWPATH}.$$"
+ mv -- "${SHADOWPATH}.$$" "$SHADOWPATH"
test_acl_loop "$TMPXML"
@@ -845,7 +836,8 @@ for t in $tests; do
eval TMPFILE_$t="$TMPFILE"
test_$t > "$TMPFILE"
- sed -i -e 's/cib-last-written.*>/>/'\
+ # sed -i isn't portable :-(
+ sed -e 's/cib-last-written.*>/>/'\
-e 's/ last-run=\"[0-9]*\"//'\
-e 's/crm_feature_set="[^"]*" //'\
-e 's/validate-with="[^"]*" //'\
@@ -859,7 +851,8 @@ for t in $tests; do
-e 's/schemas\.c:\([0-9][0-9]*\)/schemas.c:NNN/' \
-e 's/constraints\.:\([0-9][0-9]*\)/constraints.:NNN/' \
-e 's/\(validation ([0-9][0-9]* of \)[0-9][0-9]*\().*\)/\1X\2/' \
- "$TMPFILE"
+ "$TMPFILE" > "${TMPFILE}.$$"
+ mv -- "${TMPFILE}.$$" "$TMPFILE"
if [ $do_save -eq 1 ]; then
cp "$TMPFILE" $test_home/cli/regression.$t.exp
diff --git a/cts/cts-pengine.in b/cts/cts-pengine.in
index fb0952580..060708439 100644
--- a/cts/cts-pengine.in
+++ b/cts/cts-pengine.in
@@ -84,6 +84,17 @@ function show_test() {
printf " Test %-25s $*\n" "$name:"
}
+# Normalize policy engine output for comparison
+normalize() {
+ for NORMALIZE_FILE in "$@"; do
+ # sed -i is not portable :-(
+ sed -e 's/crm_feature_set="[^"]*"//' \
+ -e 's/batch-limit="[0-9]*"//' \
+ "$NORMALIZE_FILE" > "${NORMALIZE_FILE}.$$"
+ mv -- "${NORMALIZE_FILE}.$$" "$NORMALIZE_FILE"
+ done
+}
+
info "Test home is:\t$test_home"
create_mode="false"
@@ -332,7 +343,7 @@ do_test() {
rm -f $dot_output
fi
- sed -i -e 's/crm_feature_set="[^"]*"//' -e 's/batch-limit="[0-9]*"//' $expected $output
+ normalize "$expected" "$output"
diff $diff_opts $expected $output >/dev/null
rc2=$?
if [ $rc2 -ne 0 ]; then
--
2.17.0