Skip to content

Commit cd10be3

Browse files
committed
archive: fix tests after archive command changes
1 parent c8f1232 commit cd10be3

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

Diff for: test/black-box/archive/run.sh

+16-19
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ archive:
1414
path: "$(mangle_path "$archiveDir")"
1515
EOF
1616

17+
function clean_output () {
18+
echo $(echo "$@" | sed 1d | sed "s/^[ \t]*//")
19+
}
20+
1721
# fill archive
1822
run_bob build --download=no --upload root-alpha root-bravo
1923
FINGERPRINT=Alice run_bob build --force --download=no --upload root-alpha root-bravo
2024

21-
pushd $archiveDir
2225
run_bob archive scan
2326

2427
# first try to keep everything by using multiple expressions
@@ -28,13 +31,14 @@ newNum=$(/usr/bin/find -name '*.tgz' | wc -l)
2831
test $oldNum -eq $newNum
2932

3033
# Find one of the artifacts
31-
found=$(run_bob archive find 'meta.package == "root-bravo"')
34+
found=$(clean_output "$(run_bob archive find 'meta.package == "root-bravo"')")
35+
pushd $archiveDir
3236
expect_exist "$found"
37+
popd
3338

3439
# selectively keep one half
3540
run_bob archive clean --dry-run 'metaEnv.TYPE == "alpha"'
3641
run_bob archive clean -v 'metaEnv.TYPE == "alpha"'
37-
popd
3842

3943
# alpha can be downloaded, bravo must fail
4044
rm -rf work
@@ -48,29 +52,26 @@ pushd $archiveDir
4852
mkdir -p 64/ad
4953
/usr/bin/tar zcf 64/ad/6386bae45ebd6788e404758a247e26e5c778-1.tgz /dev/zero
5054
touch 64/ad/aabbcc-too-short.tgz
51-
run_bob archive scan
5255
popd
5356

57+
run_bob archive scan
5458
# Test that -v doesn't catch fire
5559
run_bob archive scan -v
5660
run_bob archive clean -v 'metaEnv.TYPE == "alpha"'
5761

58-
# Test for --fail option
62+
# Test for --fail option (--fail only reports -1 if there are no files matching the pattern xx/xx/hash-1.tgz)
63+
expect_success run_bob archive scan --fail -v
64+
expect_success run_bob archive clean --fail -v 'metaEnv.TYPE == "alpha"'
65+
rm -rf work $archiveDir/*
5966
expect_fail run_bob archive scan --fail -v
6067
expect_fail run_bob archive clean --fail -v 'metaEnv.TYPE == "alpha"'
61-
pushd $archiveDir
62-
run_bob archive scan --fail -v
63-
run_bob archive clean --fail -v 'metaEnv.TYPE == "alpha"'
64-
popd
6568

6669
# Test the "LIMIT" feature. Build a number or artifacts and keep only a portion
6770
# of them. By default the artifacts are sorted by build date and the most
6871
# recent is kept. Verify that the correct subset was retained.
6972
rm -rf "$archiveDir/"*
7073
run_bob build --download no --upload -q 'many-*'
71-
pushd $archiveDir
7274
run_bob archive clean --fail -v 'meta.recipe == "many" LIMIT 3'
73-
popd
7475
test $(/usr/bin/find $archiveDir -name '*.tgz' | wc -l) -eq 3
7576
run_bob build --download forced --force many-07 many-06 many-05
7677

@@ -79,31 +80,27 @@ run_bob build --download forced --force many-07 many-06 many-05
7980
# must not be counted.
8081
rm -rf "$archiveDir/"*
8182
run_bob build --download no --force --upload -q 'many-*'
82-
pushd $archiveDir
8383
run_bob archive clean --fail -v 'meta.recipe == "many" LIMIT 2 OrDeR By metaEnv.FUZZ ASC'
84-
popd
8584
test $(/usr/bin/find $archiveDir -name '*.tgz' | wc -l) -eq 2
8685
run_bob build --download forced --force many-01 many-03
8786

8887
# Must fail if LIMIT is zero, invalid or negative
89-
pushd $archiveDir
9088
expect_fail run_bob archive clean 'meta.recipe == "many" LIMIT 0'
9189
expect_fail run_bob archive clean 'meta.recipe == "many" LIMIT -3'
9290
expect_fail run_bob archive clean 'meta.recipe == "many" LIMIT foobar'
93-
popd
9491

9592
# Build artifacts with special audit meta keys. Try to find them later.
9693
rm -rf "$archiveDir/"* work
9794
run_bob build --upload -M my-key=one root-alpha
9895
run_bob build --upload -M my-key=two root-bravo
99-
pushd $archiveDir
10096
run_bob archive scan --fail
101-
found1=$(run_bob archive find -n 'meta.recipe == "root" && meta.my-key == "one"')
97+
found1=$(clean_output "$(run_bob archive find -n 'meta.recipe == "root" && meta.my-key == "one"')")
98+
found2=$(clean_output "$(run_bob archive find -n 'meta.recipe == "root" && meta.my-key == "two"')")
99+
pushd $archiveDir
102100
expect_exist "$found1"
103-
found2=$(run_bob archive find -n 'meta.recipe == "root" && meta.my-key == "two"')
104101
expect_exist "$found2"
105-
test "$found1" != "$found2"
106102
popd
103+
test "$found1" != "$found2"
107104

108105
# Make sure invalid audit meta keys are rejected
109106
expect_fail run_bob build -M "!nv@l1d=key" root-alpha

Diff for: test/test-lib.sh

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ expect_fail()
154154
return 1
155155
}
156156

157+
expect_success()
158+
{
159+
if "$@" 2>&1 ; then
160+
return 0
161+
fi
162+
echo "Expected command to succeed: $*" >&2
163+
return 1
164+
}
165+
157166
expect_output()
158167
{
159168
local EXP="$1"

Diff for: test/unit/test_archive.py

+6
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,12 @@ def do_MKCOL(self):
581581
self.send_response(403)
582582
self.end_headers()
583583

584+
def do_OPTIONS(self):
585+
self.send_response(200)
586+
self.send_header('DAV', '1,2')
587+
self.send_header('Allow', "OPTIONS, GET, HEAD, PUT")
588+
self.end_headers()
589+
584590
return Handler
585591

586592
class TestLocalArchive(BaseTester, TestCase):

0 commit comments

Comments
 (0)