summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-07-29 16:11:26 -0700
committerdanielsdeleo <dan@opscode.com>2013-08-01 09:43:37 -0700
commit108c578f137c5b109be99ec57f384c75a93b9f75 (patch)
tree0b9b1125a174aed822ff5e8a7bf135044331c801
parent3e0f5d467f063b3007074f8587ced6c077a4e026 (diff)
downloadchef-108c578f137c5b109be99ec57f384c75a93b9f75.tar.gz
Add functional tests for (apt) package resource
Repro/regression test for CHEF-4406 included but is marked pending.
-rw-r--r--spec/data/apt/chef-integration-test-1.0/debian/changelog5
-rw-r--r--spec/data/apt/chef-integration-test-1.0/debian/compat1
-rw-r--r--spec/data/apt/chef-integration-test-1.0/debian/control13
-rw-r--r--spec/data/apt/chef-integration-test-1.0/debian/copyright34
-rw-r--r--spec/data/apt/chef-integration-test-1.0/debian/files1
-rwxr-xr-xspec/data/apt/chef-integration-test-1.0/debian/rules13
-rw-r--r--spec/data/apt/chef-integration-test-1.0/debian/source/format1
-rw-r--r--spec/data/apt/chef-integration-test-1.1/debian/changelog11
-rw-r--r--spec/data/apt/chef-integration-test-1.1/debian/compat1
-rw-r--r--spec/data/apt/chef-integration-test-1.1/debian/control13
-rw-r--r--spec/data/apt/chef-integration-test-1.1/debian/copyright34
-rw-r--r--spec/data/apt/chef-integration-test-1.1/debian/files1
-rwxr-xr-xspec/data/apt/chef-integration-test-1.1/debian/rules13
-rw-r--r--spec/data/apt/chef-integration-test-1.1/debian/source/format1
-rw-r--r--spec/data/apt/chef-integration-test_1.0-1_amd64.changes22
-rw-r--r--spec/data/apt/chef-integration-test_1.0-1_amd64.debbin0 -> 1680 bytes
-rw-r--r--spec/data/apt/chef-integration-test_1.0.orig.tar.gzbin0 -> 237 bytes
-rw-r--r--spec/data/apt/chef-integration-test_1.1-1_amd64.changes22
-rw-r--r--spec/data/apt/chef-integration-test_1.1-1_amd64.debbin0 -> 1722 bytes
-rw-r--r--spec/data/apt/chef-integration-test_1.1.orig.tar.gzbin0 -> 237 bytes
-rw-r--r--spec/data/apt/var/www/apt/conf/distributions7
-rw-r--r--spec/data/apt/var/www/apt/conf/incoming4
-rw-r--r--spec/data/apt/var/www/apt/conf/pulls3
-rw-r--r--spec/data/apt/var/www/apt/db/checksums.dbbin0 -> 16384 bytes
-rw-r--r--spec/data/apt/var/www/apt/db/contents.cache.dbbin0 -> 16384 bytes
-rw-r--r--spec/data/apt/var/www/apt/db/packages.dbbin0 -> 16384 bytes
-rw-r--r--spec/data/apt/var/www/apt/db/references.dbbin0 -> 16384 bytes
-rw-r--r--spec/data/apt/var/www/apt/db/release.caches.dbbin0 -> 20480 bytes
-rw-r--r--spec/data/apt/var/www/apt/db/version4
-rw-r--r--spec/data/apt/var/www/apt/dists/sid/Release19
-rw-r--r--spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages16
-rw-r--r--spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages.gzbin0 -> 394 bytes
-rw-r--r--spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release5
-rw-r--r--spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages0
-rw-r--r--spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.debbin0 -> 1680 bytes
-rw-r--r--spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.debbin0 -> 1722 bytes
-rw-r--r--spec/data/cookbooks/preseed/files/default/preseed-file.seed1
-rw-r--r--spec/data/cookbooks/preseed/templates/default/preseed-template.seed1
-rw-r--r--spec/functional/resource/package_spec.rb300
-rw-r--r--spec/spec_helper.rb21
40 files changed, 563 insertions, 4 deletions
diff --git a/spec/data/apt/chef-integration-test-1.0/debian/changelog b/spec/data/apt/chef-integration-test-1.0/debian/changelog
new file mode 100644
index 0000000000..bb34505e65
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.0/debian/changelog
@@ -0,0 +1,5 @@
+chef-integration-test (1.0-1) unstable; urgency=low
+
+ * Initial release (Closes: #CHEF-1718)
+
+ -- Joshua Timberman <joshua@opscode.com> Thu, 30 Sep 2010 09:53:45 -0600
diff --git a/spec/data/apt/chef-integration-test-1.0/debian/compat b/spec/data/apt/chef-integration-test-1.0/debian/compat
new file mode 100644
index 0000000000..7f8f011eb7
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.0/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/spec/data/apt/chef-integration-test-1.0/debian/control b/spec/data/apt/chef-integration-test-1.0/debian/control
new file mode 100644
index 0000000000..e77b01b1d2
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.0/debian/control
@@ -0,0 +1,13 @@
+Source: chef-integration-test
+Section: ruby
+Priority: extra
+Maintainer: Joshua Timberman <Joshua Timberman <joshua@opscode.com>>
+Build-Depends: debhelper (>= 7.0.50~)
+Standards-Version: 3.8.4
+Homepage: http://tickets.opscode.com
+
+Package: chef-integration-test
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Chef integration tests for APT in Cucumber
+ This package is used for cucumber integration testing in Chef.
diff --git a/spec/data/apt/chef-integration-test-1.0/debian/copyright b/spec/data/apt/chef-integration-test-1.0/debian/copyright
new file mode 100644
index 0000000000..72b6c65542
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.0/debian/copyright
@@ -0,0 +1,34 @@
+This work was packaged by:
+
+ Joshua Timberman <Joshua Timberman <joshua@opscode.com>> on Thu, 30 Sep 2010 09:53:45 -0600
+
+Upstream Author(s):
+
+ Opscode, Inc.
+
+Copyright:
+
+ Copyright (C) 2010 Opscode, Inc
+
+License:
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+The Debian packaging is:
+
+ Copyright (C) 2010 Opscode, Inc (<legal@opscode.com>)
+
+
+and is licensed under the Apache 2.0 license.
+
+See "/usr/share/common-licenses/Apache-2.0"
diff --git a/spec/data/apt/chef-integration-test-1.0/debian/files b/spec/data/apt/chef-integration-test-1.0/debian/files
new file mode 100644
index 0000000000..536f4beabc
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.0/debian/files
@@ -0,0 +1 @@
+chef-integration-test_1.0-1_amd64.deb ruby extra
diff --git a/spec/data/apt/chef-integration-test-1.0/debian/rules b/spec/data/apt/chef-integration-test-1.0/debian/rules
new file mode 100755
index 0000000000..b760bee7f4
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.0/debian/rules
@@ -0,0 +1,13 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+%:
+ dh $@
diff --git a/spec/data/apt/chef-integration-test-1.0/debian/source/format b/spec/data/apt/chef-integration-test-1.0/debian/source/format
new file mode 100644
index 0000000000..163aaf8d82
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.0/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/spec/data/apt/chef-integration-test-1.1/debian/changelog b/spec/data/apt/chef-integration-test-1.1/debian/changelog
new file mode 100644
index 0000000000..fc693c1ec8
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.1/debian/changelog
@@ -0,0 +1,11 @@
+chef-integration-test (1.1-1) unstable; urgency=low
+
+ * New upstream release (1.1)
+
+ -- Joshua Timberman <joshua@opscode.com> Thu, 30 Sep 2010 10:09:34 -0600
+
+chef-integration-test (1.0-1) unstable; urgency=low
+
+ * Initial release (Closes: #CHEF-1718)
+
+ -- Joshua Timberman <joshua@opscode.com> Thu, 30 Sep 2010 09:53:45 -0600
diff --git a/spec/data/apt/chef-integration-test-1.1/debian/compat b/spec/data/apt/chef-integration-test-1.1/debian/compat
new file mode 100644
index 0000000000..7f8f011eb7
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.1/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/spec/data/apt/chef-integration-test-1.1/debian/control b/spec/data/apt/chef-integration-test-1.1/debian/control
new file mode 100644
index 0000000000..e77b01b1d2
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.1/debian/control
@@ -0,0 +1,13 @@
+Source: chef-integration-test
+Section: ruby
+Priority: extra
+Maintainer: Joshua Timberman <Joshua Timberman <joshua@opscode.com>>
+Build-Depends: debhelper (>= 7.0.50~)
+Standards-Version: 3.8.4
+Homepage: http://tickets.opscode.com
+
+Package: chef-integration-test
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Chef integration tests for APT in Cucumber
+ This package is used for cucumber integration testing in Chef.
diff --git a/spec/data/apt/chef-integration-test-1.1/debian/copyright b/spec/data/apt/chef-integration-test-1.1/debian/copyright
new file mode 100644
index 0000000000..72b6c65542
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.1/debian/copyright
@@ -0,0 +1,34 @@
+This work was packaged by:
+
+ Joshua Timberman <Joshua Timberman <joshua@opscode.com>> on Thu, 30 Sep 2010 09:53:45 -0600
+
+Upstream Author(s):
+
+ Opscode, Inc.
+
+Copyright:
+
+ Copyright (C) 2010 Opscode, Inc
+
+License:
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+The Debian packaging is:
+
+ Copyright (C) 2010 Opscode, Inc (<legal@opscode.com>)
+
+
+and is licensed under the Apache 2.0 license.
+
+See "/usr/share/common-licenses/Apache-2.0"
diff --git a/spec/data/apt/chef-integration-test-1.1/debian/files b/spec/data/apt/chef-integration-test-1.1/debian/files
new file mode 100644
index 0000000000..d72553c027
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.1/debian/files
@@ -0,0 +1 @@
+chef-integration-test_1.1-1_amd64.deb ruby extra
diff --git a/spec/data/apt/chef-integration-test-1.1/debian/rules b/spec/data/apt/chef-integration-test-1.1/debian/rules
new file mode 100755
index 0000000000..b760bee7f4
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.1/debian/rules
@@ -0,0 +1,13 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+%:
+ dh $@
diff --git a/spec/data/apt/chef-integration-test-1.1/debian/source/format b/spec/data/apt/chef-integration-test-1.1/debian/source/format
new file mode 100644
index 0000000000..163aaf8d82
--- /dev/null
+++ b/spec/data/apt/chef-integration-test-1.1/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/spec/data/apt/chef-integration-test_1.0-1_amd64.changes b/spec/data/apt/chef-integration-test_1.0-1_amd64.changes
new file mode 100644
index 0000000000..4746b834e5
--- /dev/null
+++ b/spec/data/apt/chef-integration-test_1.0-1_amd64.changes
@@ -0,0 +1,22 @@
+Format: 1.8
+Date: Thu, 30 Sep 2010 09:53:45 -0600
+Source: chef-integration-test
+Binary: chef-integration-test
+Architecture: amd64
+Version: 1.0-1
+Distribution: unstable
+Urgency: low
+Maintainer: Joshua Timberman <Joshua Timberman <joshua@opscode.com>>
+Changed-By: Joshua Timberman <joshua@opscode.com>
+Description:
+ chef-integration-test - Chef integration tests for APT in Cucumber
+Changes:
+ chef-integration-test (1.0-1) unstable; urgency=low
+ .
+ * Initial release (Closes: #CHEF-1718)
+Checksums-Sha1:
+ b44685ff59626bc94c67e60665f06c4643fe9767 1680 chef-integration-test_1.0-1_amd64.deb
+Checksums-Sha256:
+ da176f4405fa21fd7207d4785680c6996d395a1ca132f2d5565a61c5479b1116 1680 chef-integration-test_1.0-1_amd64.deb
+Files:
+ 713722480408ecc8e7220aea52bdd76e 1680 ruby extra chef-integration-test_1.0-1_amd64.deb
diff --git a/spec/data/apt/chef-integration-test_1.0-1_amd64.deb b/spec/data/apt/chef-integration-test_1.0-1_amd64.deb
new file mode 100644
index 0000000000..458dd026ff
--- /dev/null
+++ b/spec/data/apt/chef-integration-test_1.0-1_amd64.deb
Binary files differ
diff --git a/spec/data/apt/chef-integration-test_1.0.orig.tar.gz b/spec/data/apt/chef-integration-test_1.0.orig.tar.gz
new file mode 100644
index 0000000000..3de028d486
--- /dev/null
+++ b/spec/data/apt/chef-integration-test_1.0.orig.tar.gz
Binary files differ
diff --git a/spec/data/apt/chef-integration-test_1.1-1_amd64.changes b/spec/data/apt/chef-integration-test_1.1-1_amd64.changes
new file mode 100644
index 0000000000..f014de813b
--- /dev/null
+++ b/spec/data/apt/chef-integration-test_1.1-1_amd64.changes
@@ -0,0 +1,22 @@
+Format: 1.8
+Date: Thu, 30 Sep 2010 10:09:34 -0600
+Source: chef-integration-test
+Binary: chef-integration-test
+Architecture: amd64
+Version: 1.1-1
+Distribution: unstable
+Urgency: low
+Maintainer: Joshua Timberman <Joshua Timberman <joshua@opscode.com>>
+Changed-By: Joshua Timberman <joshua@opscode.com>
+Description:
+ chef-integration-test - Chef integration tests for APT in Cucumber
+Changes:
+ chef-integration-test (1.1-1) unstable; urgency=low
+ .
+ * New upstream release (1.1)
+Checksums-Sha1:
+ 43c5653a9a5b9419849173a4ec3a9855cf0327a3 1722 chef-integration-test_1.1-1_amd64.deb
+Checksums-Sha256:
+ 84e2f087f7e11d1b73743007ecfc6b8b34e03f6917c0993b35c0758ee59702c1 1722 chef-integration-test_1.1-1_amd64.deb
+Files:
+ 4b05bace483dbca54efc21f97ee47e1d 1722 ruby extra chef-integration-test_1.1-1_amd64.deb
diff --git a/spec/data/apt/chef-integration-test_1.1-1_amd64.deb b/spec/data/apt/chef-integration-test_1.1-1_amd64.deb
new file mode 100644
index 0000000000..c4fac10dc1
--- /dev/null
+++ b/spec/data/apt/chef-integration-test_1.1-1_amd64.deb
Binary files differ
diff --git a/spec/data/apt/chef-integration-test_1.1.orig.tar.gz b/spec/data/apt/chef-integration-test_1.1.orig.tar.gz
new file mode 100644
index 0000000000..5fda119eae
--- /dev/null
+++ b/spec/data/apt/chef-integration-test_1.1.orig.tar.gz
Binary files differ
diff --git a/spec/data/apt/var/www/apt/conf/distributions b/spec/data/apt/var/www/apt/conf/distributions
new file mode 100644
index 0000000000..285c1a88de
--- /dev/null
+++ b/spec/data/apt/var/www/apt/conf/distributions
@@ -0,0 +1,7 @@
+Origin: localhost
+Label: apt repository
+Codename: sid
+Architectures: amd64
+Components: main
+Description: Apt repository
+Pull: sid
diff --git a/spec/data/apt/var/www/apt/conf/incoming b/spec/data/apt/var/www/apt/conf/incoming
new file mode 100644
index 0000000000..d44e59c51b
--- /dev/null
+++ b/spec/data/apt/var/www/apt/conf/incoming
@@ -0,0 +1,4 @@
+Name: default
+IncomingDir: /tmp/incoming
+TempDir: /tmp
+Allow: sid unstable>sid
diff --git a/spec/data/apt/var/www/apt/conf/pulls b/spec/data/apt/var/www/apt/conf/pulls
new file mode 100644
index 0000000000..0fc3358279
--- /dev/null
+++ b/spec/data/apt/var/www/apt/conf/pulls
@@ -0,0 +1,3 @@
+Name: sid
+From: sid
+Components: main
diff --git a/spec/data/apt/var/www/apt/db/checksums.db b/spec/data/apt/var/www/apt/db/checksums.db
new file mode 100644
index 0000000000..e36ade2079
--- /dev/null
+++ b/spec/data/apt/var/www/apt/db/checksums.db
Binary files differ
diff --git a/spec/data/apt/var/www/apt/db/contents.cache.db b/spec/data/apt/var/www/apt/db/contents.cache.db
new file mode 100644
index 0000000000..04a0c4aed5
--- /dev/null
+++ b/spec/data/apt/var/www/apt/db/contents.cache.db
Binary files differ
diff --git a/spec/data/apt/var/www/apt/db/packages.db b/spec/data/apt/var/www/apt/db/packages.db
new file mode 100644
index 0000000000..43c70b0de3
--- /dev/null
+++ b/spec/data/apt/var/www/apt/db/packages.db
Binary files differ
diff --git a/spec/data/apt/var/www/apt/db/references.db b/spec/data/apt/var/www/apt/db/references.db
new file mode 100644
index 0000000000..47c99fe152
--- /dev/null
+++ b/spec/data/apt/var/www/apt/db/references.db
Binary files differ
diff --git a/spec/data/apt/var/www/apt/db/release.caches.db b/spec/data/apt/var/www/apt/db/release.caches.db
new file mode 100644
index 0000000000..0e251c5496
--- /dev/null
+++ b/spec/data/apt/var/www/apt/db/release.caches.db
Binary files differ
diff --git a/spec/data/apt/var/www/apt/db/version b/spec/data/apt/var/www/apt/db/version
new file mode 100644
index 0000000000..a6908690d9
--- /dev/null
+++ b/spec/data/apt/var/www/apt/db/version
@@ -0,0 +1,4 @@
+4.2.0
+3.3.0
+bdb4.8.30
+bdb4.8.0
diff --git a/spec/data/apt/var/www/apt/dists/sid/Release b/spec/data/apt/var/www/apt/dists/sid/Release
new file mode 100644
index 0000000000..44ccd079bf
--- /dev/null
+++ b/spec/data/apt/var/www/apt/dists/sid/Release
@@ -0,0 +1,19 @@
+Origin: localhost
+Label: apt repository
+Codename: sid
+Date: Thu, 30 Sep 2010 16:33:01 UTC
+Architectures: amd64
+Components: main
+Description: Apt repository
+MD5Sum:
+ 92ed2cc14e37e9ab23466b27857d29ac 596 main/binary-amd64/Packages
+ c7726773341137b71cc971d44ddec4f5 394 main/binary-amd64/Packages.gz
+ 46cd71c965ce0813c94ef78c836cc7d3 104 main/binary-amd64/Release
+SHA1:
+ cde25071c5fcee59cee8dcd773ca419dcb40d946 596 main/binary-amd64/Packages
+ ce04daff75d4b27371d691d645282b198045544a 394 main/binary-amd64/Packages.gz
+ 91ca9531e3afa7a540cabdc6030c6f75d315fec7 104 main/binary-amd64/Release
+SHA256:
+ af601ce143f33405425746462973adc0fda3aceb381d1c739851b95ee0814ca3 596 main/binary-amd64/Packages
+ 15e98119705a08018d4583caabc91d36ba12e6f1c8af0f799a3ec8ca5bfaa80d 394 main/binary-amd64/Packages.gz
+ 098c599ac5b0a98785336afb2bc9c47002570ffa07dd62321c6f70b9fdb74325 104 main/binary-amd64/Release
diff --git a/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages b/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages
new file mode 100644
index 0000000000..209c23cd42
--- /dev/null
+++ b/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages
@@ -0,0 +1,16 @@
+Package: chef-integration-test
+Version: 1.1-1
+Architecture: amd64
+Maintainer: Joshua Timberman <Joshua Timberman <joshua@opscode.com>>
+Installed-Size: 32
+Homepage: http://tickets.opscode.com
+Priority: extra
+Section: ruby
+Filename: pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb
+Size: 1722
+SHA256: 84e2f087f7e11d1b73743007ecfc6b8b34e03f6917c0993b35c0758ee59702c1
+SHA1: 43c5653a9a5b9419849173a4ec3a9855cf0327a3
+MD5sum: 4b05bace483dbca54efc21f97ee47e1d
+Description: Chef integration tests for APT in Cucumber
+ This package is used for cucumber integration testing in Chef.
+
diff --git a/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages.gz b/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages.gz
new file mode 100644
index 0000000000..8a2c1e8980
--- /dev/null
+++ b/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages.gz
Binary files differ
diff --git a/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release b/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release
new file mode 100644
index 0000000000..e913d702a1
--- /dev/null
+++ b/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release
@@ -0,0 +1,5 @@
+Component: main
+Origin: localhost
+Label: apt repository
+Architecture: amd64
+Description: Apt repository
diff --git a/spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages b/spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages
diff --git a/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb b/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb
new file mode 100644
index 0000000000..458dd026ff
--- /dev/null
+++ b/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb
Binary files differ
diff --git a/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb b/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb
new file mode 100644
index 0000000000..c4fac10dc1
--- /dev/null
+++ b/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb
Binary files differ
diff --git a/spec/data/cookbooks/preseed/files/default/preseed-file.seed b/spec/data/cookbooks/preseed/files/default/preseed-file.seed
new file mode 100644
index 0000000000..164da3495d
--- /dev/null
+++ b/spec/data/cookbooks/preseed/files/default/preseed-file.seed
@@ -0,0 +1 @@
+chef-integration-test chef-integration-test/sample-var string "hello world"
diff --git a/spec/data/cookbooks/preseed/templates/default/preseed-template.seed b/spec/data/cookbooks/preseed/templates/default/preseed-template.seed
new file mode 100644
index 0000000000..164da3495d
--- /dev/null
+++ b/spec/data/cookbooks/preseed/templates/default/preseed-template.seed
@@ -0,0 +1 @@
+chef-integration-test chef-integration-test/sample-var string "hello world"
diff --git a/spec/functional/resource/package_spec.rb b/spec/functional/resource/package_spec.rb
new file mode 100644
index 0000000000..98336d81b6
--- /dev/null
+++ b/spec/functional/resource/package_spec.rb
@@ -0,0 +1,300 @@
+# encoding: UTF-8
+#
+# Author:: Daniel DeLeo (<dan@opscode.com>)
+# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'spec_helper'
+require 'webrick'
+
+module AptServer
+ def enable_testing_apt_source
+ File.open("/etc/apt/sources.list.d/chef-integration-test.list", "w+") do |f|
+ f.puts "deb http://localhost:9000/ sid main"
+ end
+ # Magic to update apt cache for only our repo
+ shell_out!("apt-get update " +
+ '-o Dir::Etc::sourcelist="sources.list.d/chef-integration-test.list" ' +
+ '-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"')
+ end
+
+ def disable_testing_apt_source
+ FileUtils.rm("/etc/apt/sources.list.d/chef-integration-test.list")
+ rescue Errno::ENOENT
+ puts("Attempted to remove integration test from /etc/apt/sources.list.d but it didn't exist")
+ end
+
+ def tcp_test_port(hostname, port)
+ tcp_socket = TCPSocket.new(hostname, port)
+ true
+ rescue Errno::ETIMEDOUT
+ false
+ rescue Errno::ECONNREFUSED
+ false
+ ensure
+ tcp_socket && tcp_socket.close
+ end
+
+ def apt_server
+ @apt_server ||= WEBrick::HTTPServer.new(
+ :Port => 9000,
+ :DocumentRoot => apt_data_dir + "/var/www/apt",
+ # Make WEBrick quiet, comment out for debug.
+ :Logger => Logger.new(StringIO.new),
+ :AccessLog => [ StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT ]
+ )
+ end
+
+ def run_apt_server
+ apt_server.start
+ end
+
+ def start_apt_server
+ @apt_server_thread = Thread.new do
+ run_apt_server
+ end
+ until tcp_test_port("localhost", 9000) do
+ if @apt_server_thread.alive?
+ sleep 1
+ else
+ @apt_server_thread.join
+ raise "apt server failed to start"
+ end
+ end
+ end
+
+ def stop_apt_server
+ apt_server.shutdown
+ @apt_server_thread.join
+ end
+
+ def apt_data_dir
+ File.join(CHEF_SPEC_DATA, "apt")
+ end
+end
+
+metadata = { :unix_only => true,
+ :requires_root => true,
+ :provider => {:package => Chef::Provider::Package::Apt},
+ :arch => "x86_64" # test packages are 64bit
+}
+
+describe Chef::Resource::Package, metadata do
+ include Chef::Mixin::ShellOut
+
+ def chef_test_dpkg_installed?
+ shell_out("dpkg -l chef-integration-test").status.success?
+ end
+
+ def dpkg_should_be_installed(pkg_name)
+ shell_out!("dpkg -l #{pkg_name}")
+ end
+
+
+ context "with a remote package source" do
+
+ include AptServer
+
+ before(:all) do
+ # Disable mixlib-shellout live streams
+ Chef::Log.level = :warn
+ start_apt_server
+ enable_testing_apt_source
+ end
+
+ after(:all) do
+ stop_apt_server
+ disable_testing_apt_source
+ shell_out!("apt-get clean")
+ end
+
+
+ after do
+ shell_out!("dpkg -r chef-integration-test")
+ shell_out("dpkg --clear-avail")
+ shell_out!("apt-get clean")
+ end
+
+ let(:node) do
+ n = Chef::Node.new
+ n.consume_external_attrs(OHAI_SYSTEM.data.dup, {})
+ n
+ end
+
+ let(:events) do
+ Chef::EventDispatch::Dispatcher.new
+ end
+
+ # TODO: lots of duplication from client.rb;
+ # All of this must be setup for preseed files to get found
+ let(:cookbook_collection) do
+ cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks")
+ cl = Chef::CookbookLoader.new(cookbook_path)
+ cl.load_cookbooks
+ Chef::Cookbook::FileVendor.on_create do |manifest|
+ Chef::Cookbook::FileSystemFileVendor.new(manifest, cookbook_path)
+ end
+ Chef::CookbookCollection.new(cl)
+ end
+
+ let(:run_context) do
+ Chef::RunContext.new(node, cookbook_collection, events)
+ end
+
+ def base_resource
+ r = Chef::Resource::Package.new("chef-integration-test", run_context)
+ # The apt repository in the spec data is not gpg signed, so we need to
+ # force apt to accept the package:
+ r.options("--force-yes")
+ r
+ end
+
+ let(:package_resource) do
+ base_resource
+ end
+
+ # it "results in a usable apt server" do
+ # shell_out!("apt-get install -q -y --force-yes chef-integration-test ", :env => { "DEBIAN_FRONTEND" => "noninteractive" })
+ # shell_out!("dpkg -l chef-integration-test")
+ # end
+
+ context "when the package is not yet installed" do
+ it "installs the package with action :install" do
+ package_resource.run_action(:install)
+ shell_out!("dpkg -l chef-integration-test")
+ package_resource.should be_updated_by_last_action
+ end
+
+ it "installs the package for action :upgrade" do
+ package_resource.run_action(:upgrade)
+ shell_out!("dpkg -l chef-integration-test")
+ package_resource.should be_updated_by_last_action
+ end
+
+ it "does nothing for action :remove" do
+ package_resource.run_action(:remove)
+ shell_out!("dpkg -l chef-integration-test", :returns => [1])
+ package_resource.should_not be_updated_by_last_action
+ end
+
+ it "does nothing for action :purge" do
+ package_resource.run_action(:purge)
+ shell_out!("dpkg -l chef-integration-test", :returns => [1])
+ package_resource.should_not be_updated_by_last_action
+ end
+
+ context "and a not-available package version is specified" do
+ let(:package_resource) do
+ r = base_resource
+ r.version("2.0")
+ r
+ end
+
+ it "raises a reasonable error for action :install" do
+ expect do
+ package_resource.run_action(:install)
+ end.to raise_error(Chef::Exceptions::Exec)
+ end
+
+ end
+
+ describe "when preseeding the install" do
+
+ let(:file_cache_path) { Dir.mktmpdir }
+
+ before do
+ @old_config = Chef::Config.configuration.dup
+ Chef::Config[:file_cache_path] = file_cache_path
+ debconf_reset = 'chef-integration-test chef-integration-test/sample-var string "INVALID"'
+ shell_out!("echo #{debconf_reset} |debconf-set-selections")
+ end
+
+ after do
+ FileUtils.rm_rf(file_cache_path)
+ Chef::Config.configuration = @old_config
+ end
+
+ context "with a preseed file" do
+
+ let(:package_resource) do
+ r = base_resource
+ r.cookbook_name = "preseed"
+ r.response_file("preseed-file.seed")
+ r
+ end
+
+ it "preseeds the package, then installs it" do
+ package_resource.run_action(:install)
+ cmd = shell_out!("debconf-show chef-integration-test")
+ cmd.stdout.should include('chef-integration-test/sample-var: "hello world"')
+ package_resource.should be_updated_by_last_action
+ end
+
+ context "and the preseed file exists and is up-to-date" do
+
+ before do
+ # Code here is duplicated from the implementation. Not great, but
+ # it should at least fail if the code gets out of sync.
+ source = File.join(CHEF_SPEC_DATA, "cookbooks/preseed/files/default/preseed-file.seed")
+ file_cache_dir = Chef::FileCache.create_cache_path("preseed/preseed")
+ dest = "#{file_cache_dir}/chef-integration-test-1.1-1.seed"
+ FileUtils.cp(source, dest)
+ end
+
+ it "does not update the package configuration" do
+ package_resource.run_action(:install)
+ cmd = shell_out!("debconf-show chef-integration-test")
+ cmd.stdout.should include('chef-integration-test/sample-var: INVALID')
+ package_resource.should be_updated_by_last_action
+ end
+
+ end
+
+ end
+
+ context "with a preseed template is specified" do
+
+ let(:package_resource) do
+ r = base_resource
+ r.cookbook_name = "preseed"
+ r.response_file("preseed-template.seed")
+ r
+ end
+
+ before do
+ node.set[:preseed_value] = "FROM TEMPLATE"
+ end
+
+ it "preseeds the package, then installs it" do
+ pending("CHEF-4406")
+ Chef::Log.init(STDERR)
+ Chef::Log.level = :debug
+ package_resource.run_action(:install)
+ cmd = shell_out!("debconf-show chef-integration-test")
+ cmd.stdout.should include('chef-integration-test/sample-var: "FROM TEMPLATE"')
+ package_resource.should be_updated_by_last_action
+ end
+
+ end
+
+ end
+ end
+
+ end
+
+end
+
+
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index f47ed43393..c38c7da8ea 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -87,6 +87,8 @@ Dir["spec/support/**/*.rb"].
OHAI_SYSTEM = Ohai::System.new
OHAI_SYSTEM.require_plugin("os")
OHAI_SYSTEM.require_plugin("platform")
+TEST_PLATFORM = OHAI_SYSTEM["platform"].dup.freeze
+TEST_PLATFORM_VERSION = OHAI_SYSTEM["platform_version"].dup.freeze
RSpec.configure do |config|
config.include(Matchers)
@@ -116,15 +118,26 @@ RSpec.configure do |config|
config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root'
config.filter_run_excluding :uses_diff => true unless has_diff?
+ running_platform_arch = `uname -m`.strip
+
+ config.filter_run_excluding :architecture => lambda {|target_arch|
+ running_platform_arch != target_arch
+ }
+
# Functional Resource tests that are provider-specific:
# context "on platforms that use useradd", :provider => {:user => Chef::Provider::User::Useradd}} do #...
config.filter_run_excluding :provider => lambda {|criteria|
type, target_provider = criteria.first
- platform = OHAI_SYSTEM["platform"],
- platform_version = OHAI_SYSTEM["platform_version"]
- provider_for_running_platform = Chef::Platform.find_provider(platform, platform_version, type)
- provider_for_running_platform != target_provider
+ platform = TEST_PLATFORM.dup
+ platform_version = TEST_PLATFORM_VERSION.dup
+
+ begin
+ provider_for_running_platform = Chef::Platform.find_provider(platform, platform_version, type)
+ provider_for_running_platform != target_provider
+ rescue ArgumentError # no provider for platform
+ true
+ end
}
config.run_all_when_everything_filtered = true