diff --git a/bat/lib/mixerlib.bash b/bat/lib/mixerlib.bash index 070ba20..f25863a 100755 --- a/bat/lib/mixerlib.bash +++ b/bat/lib/mixerlib.bash @@ -54,11 +54,15 @@ mixer-build-all() { } mixer-build-format-bump-new() { - sudo -E mixer $MIXARGS build format-bump new --native=true + sudo -E mixer $MIXARGS build format-bump new --new-format $1 --native=true } mixer-build-format-bump-old() { - sudo -E mixer $MIXARGS build format-bump old --native=true + sudo -E mixer $MIXARGS build format-bump old --new-format $1 --native=true +} + +mixer-build-format-bump() { + sudo -E mixer $MIXARGS build format-bump --new-format $1 --native=true } mixer-add-rpms() { diff --git a/bat/tests/06-test-format-bump/run.bats b/bat/tests/06-test-format-bump/run.bats index 2800a64..3449d0e 100755 --- a/bat/tests/06-test-format-bump/run.bats +++ b/bat/tests/06-test-format-bump/run.bats @@ -7,45 +7,137 @@ setup() { global_setup } -# TODO: This test should run 'mixer build upstream-format' instead -# once the tooling required to run custom test docker images for -# is ready. -@test "Perform upstream format bump on last format boundary" { +@test "Perform format bump using individual build format-bump " { upstreamver=$(get-last-format-boundary) mixer-init-stripped-down $upstreamver 10 - - #Create initial version in the old format - mixer-build-all > $LOGDIR/build_all.log - - #Save initial format format=$(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) - #Update to new upstream in the new format - mixer-upstream-update $(($upstreamver + 10)) > $LOGDIR/upstream_update.log + # create deprecated bundle + cat << EOF > local-bundles/editors +# [TITLE]: editors +# [DESCRIPTION]: Run popular terminal text editors +# [STATUS]: Deprecated +# [CAPABILITIES]: +# [MAINTAINER]: Test Master +EOF + mixer bundle add editors - #Build +20 - mixer-build-format-bump-new > $LOGDIR/build_formatbump_new.log + #Create initial version in the old format + mixer-build-bundles > $LOGDIR/build_bundles.log - #Reset upstream for +10 build - echo -n "$upstreamver" > upstreamversion + mixer-build-update > $LOGDIR/build_update.log #Build +10 - mixer-build-format-bump-old > $LOGDIR/build_formatbump_old.log + format=$((format+1)) + mixer-build-format-bump-old $format > $LOGDIR/build_formatbump_new.log - #restore upstrean - mv upstreamversion.bump upstreamversion + #Build +20 + mixer-build-format-bump-new $format > $LOGDIR/build_formatbump_old.log #check if LAST_VER is set to +20 test $(< update/image/LAST_VER) -eq 30 + #check if deprecated bundle is marked deleted in +10 + awk ' + $4 == "editors" { + found = 1; exit $3 != 20 + } + END { + if (found != 1) + exit 1 + }' update/www/20/Manifest.MoM + + #editors bundle should have all files marked as deleted in +10 (0's) + result="$(grep -E "(10|20)" update/www/20/Manifest.editors | grep -Ev "(version|previous|000000000)" | wc -l)" + [ "$result" -eq 0 ] + + #editors bundle should not exist in +20 + if [ -f update/www/30/Manifest.editors ]; then + exit 1 + fi + + #editors bundle should not exist in +20 MoM + if grep "editors" update/www/30/Manifest.MoM; then + exit 1 + fi + + #check if +10 previous version is set to +0 + awk '$1 == "previous:" { exit $2 != 10}' update/www/20/Manifest.MoM + #check if +20 previous version is set to +0 awk '$1 == "previous:" { exit $2 != 10}' update/www/30/Manifest.MoM - #check if +10 previous version is set to +0 - awk '$1 == "previous:" { exit $2 != 10}' update/www/30/Manifest.MoM + #check if +20 format is set to formatN + awk -v f=$format '$1 == "MANIFEST" {exit $2 != f}' update/www/30/Manifest.MoM - #check if builder.conf has the +20 format - test $(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) -eq $(($format + 1)) + format=$((format-1)) + #check if +10 format is set to formatN+1 + awk -v f=$format '$1 == "MANIFEST" {exit $2 != f}' update/www/20/Manifest.MoM } +@test "Perform format bump using top level command" { + upstreamver=$(get-last-format-boundary) + mixer-init-stripped-down $upstreamver 10 + format=$(sed -n 's/[ ]*FORMAT[ ="]*\([0-9]\+\)[ "]*/\1/p' mixer.state) + + # create deprecated bundle + cat << EOF > local-bundles/editors +# [TITLE]: editors +# [DESCRIPTION]: Run popular terminal text editors +# [STATUS]: Deprecated +# [CAPABILITIES]: +# [MAINTAINER]: Test Master +EOF + mixer bundle add editors + + #Create initial version in the old format + mixer-build-bundles > $LOGDIR/build_bundles.log + + mixer-build-update > $LOGDIR/build_update.log + + #Build +10 + format=$((format+1)) + mixer-build-format-bump $format > $LOGDIR/build_formatbump_new.log + + #check if LAST_VER is set to +20 + test $(< update/image/LAST_VER) -eq 30 + + #check if deprecated bundle is marked deleted in +10 + awk ' + $4 == "editors" { + found = 1; exit $3 != 20 + } + END { + if (found != 1) + exit 1 + }' update/www/20/Manifest.MoM + + #editors bundle should have all files marked as deleted in +10 (0's) + result="$(grep -E "(10|20)" update/www/20/Manifest.editors | grep -Ev "(version|previous|000000000)" | wc -l)" + [ "$result" -eq 0 ] + + + #editors bundle should not exist in +20 + if [ -f update/www/30/Manifest.editors ]; then + exit 1 + fi + + #editors bundle should not exist in +20 MoM + if grep "editors" update/www/30/Manifest.MoM; then + exit 1 + fi + + #check if +10 previous version is set to +0 + awk '$1 == "previous:" { exit $2 != 10}' update/www/20/Manifest.MoM + + #check if +20 previous version is set to +0 + awk '$1 == "previous:" { exit $2 != 10}' update/www/30/Manifest.MoM + + #check if +20 format is set to formatN + awk -v f=$format '$1 == "MANIFEST" {exit $2 != f}' update/www/30/Manifest.MoM + + format=$((format-1)) + #check if +10 format is set to formatN+1 + awk -v f=$format '$1 == "MANIFEST" {exit $2 != f}' update/www/20/Manifest.MoM +} # vi: ft=sh ts=8 sw=2 sts=2 et tw=80