From ff7d7c2d497cc6c863206f435697e0d6c938d8f7 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Mon, 8 Apr 2019 12:18:18 +0300 Subject: [PATCH] Add new sanity tests for blueprints - verify SemVer .patch number will be automatically updated when we push the blueprint a second time without changing version - verify show displays the content in TOML format and it matches what is on disk. Because of that also start with empty packages and groups fields in the initial toml. If they are missing they will be added automatically by lorax-composer and this simplifies the test - verify delete works Related: rhbz#1698366 --- tests/cli/lib/toml-compare | 20 +++++++++++++++++ tests/cli/test_blueprints_sanity.sh | 34 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 tests/cli/lib/toml-compare diff --git a/tests/cli/lib/toml-compare b/tests/cli/lib/toml-compare new file mode 100755 index 00000000..fa67d555 --- /dev/null +++ b/tests/cli/lib/toml-compare @@ -0,0 +1,20 @@ +#!/usr/bin/env python +""" + Will compare 2 blueprints for equality! + On RHEL7/Python 2 toml uses dictionaries and + blueprint show doesn't keep the order of the elements. + + For master/Python3 this is not the case. +""" + +import sys +import pytoml + +if len(sys.argv) != 3: + print("USAGE: ", __file__, " ") + sys.exit(1) + +blueprint_one = pytoml.loads(open(sys.argv[1]).read()) +blueprint_two = pytoml.loads(open(sys.argv[2]).read()) + +assert blueprint_one == blueprint_two diff --git a/tests/cli/test_blueprints_sanity.sh b/tests/cli/test_blueprints_sanity.sh index 5f33d719..ff0e5aee 100755 --- a/tests/cli/test_blueprints_sanity.sh +++ b/tests/cli/test_blueprints_sanity.sh @@ -31,6 +31,8 @@ rlJournalStart name = "beakerlib" description = "Start building tests with beakerlib." version = "0.0.1" +groups = [] +modules = [] [[modules]] name = "beakerlib" @@ -41,6 +43,35 @@ __EOF__ rlAssertEquals "pushed bp is found via list" "`$CLI blueprints list | grep beakerlib`" "beakerlib" rlPhaseEnd + rlPhaseStartTest "blueprints show" + $CLI blueprints show beakerlib > shown-beakerlib.toml + rlRun -t -c "./tests/cli/lib/toml-compare beakerlib.toml shown-beakerlib.toml" + rlPhaseEnd + + rlPhaseStartTest "SemVer .patch version is incremented automatically" + # version is still 0.0.1 + rlAssertEquals "version is 0.0.1" "`$CLI blueprints show beakerlib | grep 0.0.1`" 'version = "0.0.1"' + # add a new package to the existing blueprint + cat >> beakerlib.toml << __EOF__ + +[[packages]] +name = "php" +version = "*" +__EOF__ + # push again + rlRun -t -c "$CLI blueprints push beakerlib.toml" + # official documentation says: + # If a new blueprint is uploaded with the same version the server will + # automatically bump the PATCH level of the version. If the version + # doesn't match it will be used as is. + rlAssertEquals "version is 0.0.2" "`$CLI blueprints show beakerlib | grep 0.0.2`" 'version = "0.0.2"' + rlPhaseEnd + + rlPhaseStartTest "blueprints delete" + rlRun -t -c "$CLI blueprints delete beakerlib" + rlAssertEquals "bp not found after delete" "`$CLI blueprints list | grep beakerlib`" "" + rlPhaseEnd + rlPhaseStartTest "start a compose with deleted blueprint" cat > to-be-deleted.toml << __EOF__ name = "to-be-deleted" @@ -69,6 +100,9 @@ __EOF__ unset compose_id rlPhaseEnd + rlPhaseStartCleanup + rlRun -t -c "rm -rf beakerlib.toml shown-beakerlib.toml" + rlPhaseEnd rlJournalEnd rlJournalPrintText