Use accptst prefix so we can re-use this thing elsewhere

This commit is contained in:
Kevin van Zonneveld 2016-02-23 10:06:45 +01:00
parent fa7f217556
commit abb480c394
10 changed files with 27 additions and 27 deletions

View File

@ -15,8 +15,8 @@ scenarios="${1:-$(ls ${__dir}/scenario/|egrep -v ^prepare$)}"
__sysTmpDir="${TMPDIR:-/tmp}" __sysTmpDir="${TMPDIR:-/tmp}"
__sysTmpDir="${__sysTmpDir%/}" # <-- remove trailing slash on macosx __sysTmpDir="${__sysTmpDir%/}" # <-- remove trailing slash on macosx
__b3bpTmpDir="${__sysTmpDir}/b3bp" __accptstTmpDir="${__sysTmpDir}/accptst"
mkdir -p "${__b3bpTmpDir}" mkdir -p "${__accptstTmpDir}"
if [[ "${OSTYPE}" == "darwin"* ]]; then if [[ "${OSTYPE}" == "darwin"* ]]; then
cmdSed=gsed cmdSed=gsed
@ -53,13 +53,13 @@ for scenario in $(echo ${scenarios}); do
# Run scenario # Run scenario
(${cmdTimeout} bash ./run.sh \ (${cmdTimeout} bash ./run.sh \
> "${__b3bpTmpDir}/${scenario}.stdio" 2>&1; \ > "${__accptstTmpDir}/${scenario}.stdio" 2>&1; \
echo "${?}" > "${__b3bpTmpDir}/${scenario}.exitcode" \ echo "${?}" > "${__accptstTmpDir}/${scenario}.exitcode" \
) || true ) || true
# Clear out environmental specifics # Clear out environmental specifics
for typ in $(echo stdio exitcode); do for typ in $(echo stdio exitcode); do
curFile="${__b3bpTmpDir}/${scenario}.${typ}" curFile="${__accptstTmpDir}/${scenario}.${typ}"
"${cmdSed}" -i \ "${cmdSed}" -i \
-e "s@${__node}@{node}@g" "${curFile}" \ -e "s@${__node}@{node}@g" "${curFile}" \
-e "s@${__root}@{root}@g" "${curFile}" \ -e "s@${__root}@{root}@g" "${curFile}" \
@ -78,7 +78,7 @@ for scenario in $(echo ${scenarios}); do
-e "s@Linux@{os}@g" "${curFile}" \ -e "s@Linux@{os}@g" "${curFile}" \
|| false || false
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_REPLACE_IPS' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_REPLACE_IPS' |wc -l)" -gt 0 ]; then
"${cmdSed}" -i \ "${cmdSed}" -i \
-r 's@[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}@{ip}@g' \ -r 's@[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}@{ip}@g' \
"${curFile}" "${curFile}"
@ -89,45 +89,45 @@ for scenario in $(echo ${scenarios}); do
-r 's@\{ip\}\s+@{ip} @g' \ -r 's@\{ip\}\s+@{ip} @g' \
"${curFile}" "${curFile}"
fi fi
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_REPLACE_UUIDS' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_REPLACE_UUIDS' |wc -l)" -gt 0 ]; then
"${cmdSed}" -i \ "${cmdSed}" -i \
-r 's@[0-9a-f\-]{32,40}@{uuid}@g' \ -r 's@[0-9a-f\-]{32,40}@{uuid}@g' \
"${curFile}" "${curFile}"
fi fi
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_REPLACE_BIGINTS' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_REPLACE_BIGINTS' |wc -l)" -gt 0 ]; then
# Such as: 3811298194 # Such as: 3811298194
"${cmdSed}" -i \ "${cmdSed}" -i \
-r 's@[0-9]{7,64}@{bigint}@g' \ -r 's@[0-9]{7,64}@{bigint}@g' \
"${curFile}" "${curFile}"
fi fi
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_REPLACE_DATETIMES' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_REPLACE_DATETIMES' |wc -l)" -gt 0 ]; then
# Such as: 2016-02-10 15:38:44.420094 # Such as: 2016-02-10 15:38:44.420094
"${cmdSed}" -i \ "${cmdSed}" -i \
-r 's@[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}@{datetime}@g' \ -r 's@[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}@{datetime}@g' \
"${curFile}" "${curFile}"
fi fi
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_REPLACE_LONGTIMES' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_REPLACE_LONGTIMES' |wc -l)" -gt 0 ]; then
# Such as: 2016-02-10 15:38:44.420094 # Such as: 2016-02-10 15:38:44.420094
"${cmdSed}" -i \ "${cmdSed}" -i \
-r 's@[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}@{longtime}@g' \ -r 's@[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}@{longtime}@g' \
"${curFile}" "${curFile}"
fi fi
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_REPLACE_DURATIONS' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_REPLACE_DURATIONS' |wc -l)" -gt 0 ]; then
# Such as: 0:00:00.001991 # Such as: 0:00:00.001991
"${cmdSed}" -i \ "${cmdSed}" -i \
-r 's@[0-9]{1,2}:[0-9]{2}:[0-9]{2}.[0-9]{6}@{duration}@g' \ -r 's@[0-9]{1,2}:[0-9]{2}:[0-9]{2}.[0-9]{6}@{duration}@g' \
"${curFile}" "${curFile}"
fi fi
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_REPLACE_REMOTE_EXEC' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_REPLACE_REMOTE_EXEC' |wc -l)" -gt 0 ]; then
egrep -v 'remote-exec\): [ a-zA-Z]' "${curFile}" > "${__sysTmpDir}/b3bp-filtered.txt" egrep -v 'remote-exec\): [ a-zA-Z]' "${curFile}" > "${__sysTmpDir}/accptst-filtered.txt"
mv "${__sysTmpDir}/b3bp-filtered.txt" "${curFile}" mv "${__sysTmpDir}/accptst-filtered.txt" "${curFile}"
fi fi
done done
# Save these as new fixtures? # Save these as new fixtures?
if [ "${SAVE_FIXTURES:-}" = "true" ]; then if [ "${SAVE_FIXTURES:-}" = "true" ]; then
for typ in $(echo stdio exitcode); do for typ in $(echo stdio exitcode); do
curFile="${__b3bpTmpDir}/${scenario}.${typ}" curFile="${__accptstTmpDir}/${scenario}.${typ}"
cp -f \ cp -f \
"${curFile}" \ "${curFile}" \
"${__dir}/fixture/${scenario}.${typ}" "${__dir}/fixture/${scenario}.${typ}"
@ -136,12 +136,12 @@ for scenario in $(echo ${scenarios}); do
# Compare # Compare
for typ in $(echo stdio exitcode); do for typ in $(echo stdio exitcode); do
curFile="${__b3bpTmpDir}/${scenario}.${typ}" curFile="${__accptstTmpDir}/${scenario}.${typ}"
echo -n " comparing ${typ}.. " echo -n " comparing ${typ}.. "
if [ "${typ}" = "stdio" ]; then if [ "${typ}" = "stdio" ]; then
if [ "$(cat "${curFile}" |grep 'B3BP:STDIO_SKIP_COMPARE' |wc -l)" -gt 0 ]; then if [ "$(cat "${curFile}" |grep 'ACCPTST:STDIO_SKIP_COMPARE' |wc -l)" -gt 0 ]; then
echo "skip" echo "skip"
continue continue
fi fi
@ -155,7 +155,7 @@ for scenario in $(echo ${scenarios}); do
echo -e "\n\n==> EXPECTED STDIO: "; echo -e "\n\n==> EXPECTED STDIO: ";
cat "${__dir}/fixture/${scenario}.stdio"; cat "${__dir}/fixture/${scenario}.stdio";
echo -e "\n\n==> ACTUAL STDIO: "; echo -e "\n\n==> ACTUAL STDIO: ";
cat "${__b3bpTmpDir}/${scenario}.stdio"; cat "${__accptstTmpDir}/${scenario}.stdio";
exit 1; \ exit 1; \
) )

View File

@ -1,4 +1,4 @@
B3BP:STDIO_REPLACE_DATETIMES ACCPTST:STDIO_REPLACE_DATETIMES
{datetime} UTC [ debug] cli arg arg_f = () -> {tmpdir}/x {datetime} UTC [ debug] cli arg arg_f = () -> {tmpdir}/x
{datetime} UTC [ info] __file: {root}/main.sh {datetime} UTC [ info] __file: {root}/main.sh
{datetime} UTC [ info] __dir: {root} {datetime} UTC [ info] __dir: {root}

View File

@ -1,4 +1,4 @@
B3BP:STDIO_REPLACE_DATETIMES ACCPTST:STDIO_REPLACE_DATETIMES
Help using {root}/main.sh Help using {root}/main.sh

View File

@ -1,4 +1,4 @@
B3BP:STDIO_REPLACE_DATETIMES ACCPTST:STDIO_REPLACE_DATETIMES
{datetime} UTC [ info] arg_f: {tmpdir}/x {datetime} UTC [ info] arg_f: {tmpdir}/x
{datetime} UTC [ info] arg_f: {tmpdir}/x {datetime} UTC [ info] arg_f: {tmpdir}/x
{datetime} UTC [ info] arg_f: {tmpdir}/x {datetime} UTC [ info] arg_f: {tmpdir}/x

View File

@ -1,4 +1,4 @@
B3BP:STDIO_REPLACE_DATETIMES ACCPTST:STDIO_REPLACE_DATETIMES
{datetime} UTC [ debug] cli arg arg_f = () -> {tmpdir}/x {datetime} UTC [ debug] cli arg arg_f = () -> {tmpdir}/x
{datetime} UTC [ info] __file: {root}/main.sh {datetime} UTC [ info] __file: {root}/main.sh
{datetime} UTC [ info] __dir: {root} {datetime} UTC [ info] __dir: {root}

View File

@ -10,7 +10,7 @@ __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)" __base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)" __root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)"
# echo "B3BP:STDIO_REPLACE_DATETIMES" # echo "ACCPTST:STDIO_REPLACE_DATETIMES"
# Use as standalone: # Use as standalone:

View File

@ -10,6 +10,6 @@ __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)" __base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)" __root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)"
echo "B3BP:STDIO_REPLACE_DATETIMES" echo "ACCPTST:STDIO_REPLACE_DATETIMES"
env LOG_LEVEL=8 bash "${__root}/main.sh" -f /tmp/x env LOG_LEVEL=8 bash "${__root}/main.sh" -f /tmp/x

View File

@ -10,6 +10,6 @@ __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)" __base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)" __root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)"
echo "B3BP:STDIO_REPLACE_DATETIMES" echo "ACCPTST:STDIO_REPLACE_DATETIMES"
bash "${__root}/main.sh" -h bash "${__root}/main.sh" -h

View File

@ -10,7 +10,7 @@ __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)" __base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)" __root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)"
echo "B3BP:STDIO_REPLACE_DATETIMES" echo "ACCPTST:STDIO_REPLACE_DATETIMES"
(env LOG_LEVEL=6 bash "${__root}/main.sh" --file /tmp/x; (env LOG_LEVEL=6 bash "${__root}/main.sh" --file /tmp/x;
env LOG_LEVEL=6 bash "${__root}/main.sh" --file=/tmp/x; env LOG_LEVEL=6 bash "${__root}/main.sh" --file=/tmp/x;

View File

@ -10,6 +10,6 @@ __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)" __base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)" __root="$(cd "$(dirname $(dirname $(dirname "${__dir}")))" && pwd)"
echo "B3BP:STDIO_REPLACE_DATETIMES" echo "ACCPTST:STDIO_REPLACE_DATETIMES"
env LOG_LEVEL=8 NO_COLOR=true bash "${__root}/main.sh" -f /tmp/x env LOG_LEVEL=8 NO_COLOR=true bash "${__root}/main.sh" -f /tmp/x