mirror of https://github.com/containers/podman.git
safename: consistent within same test, and, dashes
Make safename() invocations consistent within the same test. This puts the onus on the caller to add a unique element when calling multiple times, e.g. "ctr1-$(safename)". This is not too much of a burden. Major benefit is making it easy for a reader to associate containers, pods, volumes, images within a given test. And, use dashes, not underscores. "podman generate kube" removes underscores, making it very difficult to do things like "podman inspect $podname" (because we need to generate "$podname_with_underscores_removed") Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
parent
6d01ce417d
commit
380ed3a40d
|
@ -1157,14 +1157,22 @@ function random_string() {
|
||||||
# safename # Returns a pseudorandom string suitable for container/image/etc names
|
# safename # Returns a pseudorandom string suitable for container/image/etc names
|
||||||
##############
|
##############
|
||||||
#
|
#
|
||||||
# Name will include the bats test number, eg "t123_xyz123". When/if we
|
# Name will include the bats test number and a pseudorandom element,
|
||||||
# ever parallelize system tests, this will make it possible to check
|
# eg "t123-xyz123". safename() will return the same string across
|
||||||
# for leaks and identify the test that leaked.
|
# multiple invocations within a given test; this makes it easier for
|
||||||
|
# a maintainer to see common name patterns.
|
||||||
#
|
#
|
||||||
# String is lower-case so it can be used as an image name
|
# String is lower-case so it can be used as an image name
|
||||||
#
|
#
|
||||||
function safename() {
|
function safename() {
|
||||||
echo "t${BATS_SUITE_TEST_NUMBER}_$(random_string 8 | tr A-Z a-z)"
|
# FIXME: I don't think these can ever fail. Remove checks once I'm sure.
|
||||||
|
test -n "$BATS_SUITE_TMPDIR"
|
||||||
|
test -n "$BATS_SUITE_TEST_NUMBER"
|
||||||
|
safenamepath=$BATS_SUITE_TMPDIR/.safename.$BATS_SUITE_TEST_NUMBER
|
||||||
|
if [[ ! -e $safenamepath ]]; then
|
||||||
|
echo -n "t${BATS_SUITE_TEST_NUMBER}-$(random_string 8 | tr A-Z a-z)" >$safenamepath
|
||||||
|
fi
|
||||||
|
cat $safenamepath
|
||||||
}
|
}
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
|
Loading…
Reference in New Issue