New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2e tests for hab pkg bulkupload, wired up into expeditor #7113
Changes from all commits
c91d90c
12121f6
1f7f175
0305d64
a85a7bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Overview | ||
|
||
The data in this directory is for e2e testing of the `hab pkg bulkupload` command. | ||
|
||
There are two packages and their associated .tar archives of the installed artifacts. | ||
The archives are signed and then passed to the `bulkupload` command. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pkg_name=testpkg1 | ||
pkg_origin=testbulkupload | ||
pkg_version="0.1.0" | ||
pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>" | ||
pkg_license=("Apache-2.0") | ||
pkg_deps=() | ||
pkg_build_deps=() | ||
do_build() { | ||
return 0 | ||
} | ||
|
||
do_install() { | ||
return 0 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pkg_name=testpkg2 | ||
pkg_origin=testbulkupload | ||
pkg_version="0.1.0" | ||
pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>" | ||
pkg_license=("Apache-2.0") | ||
pkg_deps=() | ||
pkg_build_deps=() | ||
do_build() { | ||
return 0 | ||
} | ||
|
||
do_install() { | ||
return 0 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#!/bin/bash | ||
# | ||
# Basic set of tests for the hab pkg bulkupload command | ||
# | ||
# Assumptions: | ||
# 1. ACCEPTANCE_HAB_AUTH_TOKEN or HAB_AUTH_TOKEN Environment variables are set and valid | ||
# 2. ${CACHE_DIR} can be set to a writable location on the filesystem | ||
# 3. non zero exit code from each command implies success | ||
|
||
# TODO: Future improvement would be to create a clean room Builder or origin. | ||
# Doing so would allow for more accurate validation of the bulkupload by interrogating | ||
# the Builder. Of course this introduces significant setup time cost.. | ||
|
||
set -euo pipefail | ||
|
||
export HAB_NOCOLORING=true | ||
export HAB_NONINTERACTIVE=true | ||
export HAB_ORIGIN="testbulkupload" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if we could use a more general test origin instead of specific to bulkupload.. I believe there has been some discussion already of a "habitat-test" origin |
||
export HAB_BLDR_URL=${HAB_BLDR_URL:-https://bldr.acceptance.habitat.sh} | ||
unset HAB_BLDR_CHANNEL | ||
|
||
HAB=${HAB_TEST_CMD:-hab} | ||
CACHE_DIR="test-cache" | ||
FIXTURES_DIR="test/end-to-end/fixtures/bulkupload" | ||
PKG_A_TAR="${FIXTURES_DIR}/testbulkupload-testpkg1-0.1.0-20191024190939.tar" | ||
PKG_B_TAR="${FIXTURES_DIR}/testbulkupload-testpkg2-0.1.0-20191024191005.tar" | ||
PKG_A_HART="${CACHE_DIR}/artifacts/testbulkupload-testpkg1-0.1.0-20191024190939-x86_64-linux.hart" | ||
PKG_B_HART="${CACHE_DIR}/artifacts/testbulkupload-testpkg2-0.1.0-20191024191005-x86_64-linux.hart" | ||
|
||
echo | ||
echo "--- Testing with command ${HAB}, using cache dir ${CACHE_DIR}" | ||
echo | ||
|
||
before_upload() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thing these are fine, but it seems like we're very quickly approaching a point where we need to bring in a more formal framework of some kind. For instance, all this seems like it wants to be I think these tests that you're writing are a bit different from other ones we've got, in that they're more about exercising CLI activity (others are about Supervisor functionality, which bring with them other constraints). That's a distinction that may be worth considering as we move forward. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this is just an observation / food for thought... I'm not asking for a rewrite in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, I had added this I'll bring up the CLI testing topic in the next Habitat planning session. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm +1 for merging this as is, but I think we should plan a spike near term to see if it's feasible to write a CLI test in powershell and make it work cross platform. If so, we should make that our standard going forward, and rewrite tests as a tech debt item. |
||
echo | ||
echo ">>>>> before_upload() tasks" | ||
rm -rf ${CACHE_DIR} | ||
# origin create will exit 0 if the origin already exists | ||
${HAB} origin create ${HAB_ORIGIN} | ||
${HAB} origin key download --secret ${HAB_ORIGIN} | ||
${HAB} origin key download ${HAB_ORIGIN} | ||
mkdir -p ${CACHE_DIR}/artifacts ${CACHE_DIR}/keys | ||
cp -f /hab/cache/keys/${HAB_ORIGIN}-*pub ${CACHE_DIR}/keys/ | ||
${HAB} pkg sign --origin ${HAB_ORIGIN} ${PKG_A_TAR} ${PKG_A_HART} | ||
${HAB} pkg sign --origin ${HAB_ORIGIN} ${PKG_B_TAR} ${PKG_B_HART} | ||
echo | ||
} | ||
|
||
test_expecting_fail() { | ||
DESC=$1 | ||
CMD=$2 | ||
|
||
echo | ||
echo "--- Expected failure: Testing ${DESC}" | ||
if ${CMD}; then | ||
echo "FAIL (expected error) $CMD" | ||
exit 1 | ||
else | ||
echo "PASS $CMD" | ||
fi | ||
} | ||
|
||
test_expecting_pass() { | ||
DESC=$1 | ||
CMD=$2 | ||
|
||
echo | ||
echo "--- Expected success: Testing ${DESC}" | ||
if ! ${CMD}; then | ||
echo "FAIL (expected pass) $CMD" | ||
exit 1 | ||
else | ||
echo "PASS $CMD" | ||
fi | ||
} | ||
|
||
success_upload() { | ||
before_upload | ||
|
||
CMD="${HAB} pkg bulkupload ${CACHE_DIR}" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_pass "bulkupload with no options" "${CMD}" | ||
} | ||
|
||
success_upload_force() { | ||
before_upload | ||
|
||
CMD="${HAB} pkg bulkupload --force ${CACHE_DIR}" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_pass "bulkupload with force option" "${CMD}" | ||
} | ||
|
||
success_upload_channel_promotion() { | ||
before_upload | ||
|
||
CMD="${HAB} pkg bulkupload --channel bulkuploadtest ${CACHE_DIR}" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_pass "bulkupload with channel promotion option" "${CMD}" | ||
} | ||
|
||
success_upload_auto_build() { | ||
before_upload | ||
|
||
CMD="${HAB} pkg bulkupload --auto-build ${CACHE_DIR}" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_pass "bulkupload with auto-build option" "${CMD}" | ||
} | ||
|
||
fail_no_upload_dir() { | ||
CMD="${HAB} pkg bulkupload" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_fail "bulkupload without specifying upload directory argument" "${CMD}" | ||
} | ||
|
||
fail_upload_dir_nonexistant() { | ||
CMD="${HAB} pkg bulkupload doesnotexist" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_fail "bulkupload specifying nonexistant upload directory argument" "${CMD}" | ||
} | ||
|
||
fail_bad_url() { | ||
CMD="${HAB} pkg bulkupload --url asdf ${CACHE_DIR}" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_fail "bulkupload bad url" "${CMD}" | ||
} | ||
|
||
fail_bad_auth() { | ||
CMD="${HAB} pkg bulkupload --auth asdfjkl ${CACHE_DIR}" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_fail "bulkupload bad auth" "${CMD}" | ||
} | ||
|
||
fail_missing_channel_name() { | ||
CMD="${HAB} pkg bulkupload --channel ${CACHE_DIR}" | ||
echo "Testing command line: ${CMD}" | ||
|
||
test_expecting_fail "bulkupload missing channel name" "${CMD}" | ||
} | ||
|
||
# Expecting PASS | ||
success_upload | ||
success_upload_force | ||
success_upload_channel_promotion | ||
success_upload_auto_build | ||
|
||
# Expecting FAIL | ||
fail_no_upload_dir | ||
fail_upload_dir_nonexistant | ||
fail_bad_url | ||
fail_bad_auth | ||
fail_missing_channel_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're going to need a
BUILD_PKG_TARGET
in here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in this commit e9f1516