diff --git a/.gitignore b/.gitignore index cfc7252..6ea4fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .vagrant -Berksfile.lock *~ *# .#* @@ -7,6 +6,7 @@ Berksfile.lock .*.sw[a-z] *.un~ /cookbooks +cache_dir # Bundler Gemfile.lock @@ -16,3 +16,10 @@ bin/* VERSION .kitchen/ .kitchen.local.yml + +doc/ +.yardoc/ +berks-cookbooks/ +knife.rb +syntaxcache/ +coverage/ diff --git a/.kitchen.yml b/.kitchen.yml index bf63857..86217da 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,22 +1,36 @@ --- driver_plugin: vagrant driver_config: - require_chef_omnibus: '11.18' + customize: + cpus: 1 + memory: 512 + ssh: + insert_key: false + +provisioner: + name: chef_zero + always_update_cookbooks: true + require_chef_omnibus: 12.16.42 + log_level: info + log_file: /var/log/chef-solo.log platforms: +- name: centos-7.2 + driver_config: + box: bento/centos-7.2 +- name: centos-6.8 + driver_config: + box: bento/centos-6.8 - name: ubuntu-12.04 driver_config: - box: opscode-ubuntu-12.04 - box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box + box: bento/ubuntu-12.04 - name: ubuntu-14.04 driver_config: - box: opscode-ubuntu-14.04 - box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-14.04_provisionerless.box -- name: centos-6.8 - driver_config: - box: opscode-centos-6.8 - box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.8_provisionerless.box + box: bento/ubuntu-14.04 + suites: - name: default - run_list: ["recipe[rs-storage]"] - attributes: {} + run_list: ['recipe[apt]','recipe[rs-storage]'] + attributes: + apt: + compile_time_update: true diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..16f9cdb --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..582dba7 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,30 @@ +AllCops: + Exclude: + - 'berks-cookbooks/**/*' + - 'knife.rb' +Style/AccessorMethodName: + Exclude: + - 'Rakefile' + - 'libraries/helper.rb' +Lint/UselessAssignment: + Exclude: + - 'recipes/stripe.rb' + - 'recipes/volume.rb' +Style/PredicateName: + Exclude: + - 'libraries/helper.rb' +Lint/EndAlignment: + Exclude: + - 'recipes/default.rb' +Metrics/BlockNesting: + Exclude: + - 'recipes/default.rb' +Style/DoubleNegation: + Exclude: + - 'libraries/helper.rb' +Style/RegexpLiteral: + Exclude: + - 'libraries/helper.rb' +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'recipes/stripe.rb' diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..2bf1c1c --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.3.1 diff --git a/.travis.yml b/.travis.yml index d5089a0..4671f08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,13 @@ language: ruby rvm: -- 2.0.0 -- 1.9.3 -before_script: bundle exec berks install -script: bundle exec strainer test --except kitchen +- 2.3.1 +before_install: +- curl -L https://www.getchef.com/chef/install.sh | sudo bash -s -- -P chefdk -v 1.0.3 +- gem install bundler -v 1.11.2 +install: +- chef exec bundle install --jobs=3 --retry=3 +before_script: chef exec rake setup_test_environment +script: "./.travis_install.sh" notifications: slack: - secure: jypk2i83t2b5e1oAGGV3mcIWGesJYNk1MnH/kDsgClD16pLKfOE8rnyduhwNdNL1NlVURbFMjp9ZEGJQeYqnLs9ZXnr3ez7lDmFoM9YWVE030664tyTmaXYcksQBINfYwMrO13oih8bvXwStLshItxAbNHpKiu4/qmzDVl+rOtE= + secure: FBCQb9ApoEzqZisD4IbFmw+ZujFU6kwRkCiwES6qmJB22cgMsFqBB/+KOv3OLAFTNVjQfsTGEyzeqXFW9Chhze+xOGSxBMKOtZI/+5OVTvNithBhwOBlcb3IW546mlfGMXorWlY6JEb9NO0c1oJ7Oe9wB9WIELaQy6MaF9PS7q0= diff --git a/.travis_install.sh b/.travis_install.sh new file mode 100755 index 0000000..4564cce --- /dev/null +++ b/.travis_install.sh @@ -0,0 +1,8 @@ +set -ev +if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then + git clone https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_REPO_SLUG + cd $TRAVIS_REPO_SLUG + git checkout master + git checkout -qf $TRAVIS_COMMIT +fi +chef exec rake except_kitchen diff --git a/Berksfile b/Berksfile index 4d182e5..eafb389 100644 --- a/Berksfile +++ b/Berksfile @@ -1,6 +1,7 @@ -site :opscode +source 'https://supermarket.chef.io' -cookbook "rightscale_volume", github: 'rightscale-cookbooks/rightscale_volume' -cookbook "rightscale_backup", github: 'rightscale-cookbooks/rightscale_backup' -cookbook 'windows', '1.40.0'# keep for compatiblity with chef 11, can remove with chef 12 metadata + +cookbook 'filesystem', github: 'rightscale-cookbooks-contrib/filesystem_cookbook', branch: 'update_lvm_cookbook_dependency_3' +cookbook 'rightscale_volume', github: 'rightscale-cookbooks/rightscale_volume' +cookbook 'rightscale_backup', github: 'rightscale-cookbooks/rightscale_backup' diff --git a/Berksfile.lock b/Berksfile.lock new file mode 100644 index 0000000..861dd84 --- /dev/null +++ b/Berksfile.lock @@ -0,0 +1,53 @@ +DEPENDENCIES + filesystem + git: https://github.com/rightscale-cookbooks-contrib/filesystem_cookbook.git + revision: 9c2a21a8aa41b16d3774ed5292f9a31b018dee92 + branch: update_lvm_cookbook_dependency_3 + rightscale_backup + git: https://github.com/rightscale-cookbooks/rightscale_backup.git + revision: 454fa9f582943f0ace47dd90bf6106e7bf752a93 + rightscale_volume + git: https://github.com/rightscale-cookbooks/rightscale_volume.git + revision: 48c24ba0f0815e86200793ef50fe27dce9f09d8e + rs-storage + path: . + metadata: true + +GRAPH + apt (5.0.1) + compat_resource (>= 12.16.3) + build-essential (7.0.3) + compat_resource (>= 12.16.3) + mingw (>= 1.1) + seven_zip (>= 0.0.0) + chef_handler (2.1.0) + compat_resource (12.16.3) + filesystem (0.11.0) + lvm (~> 3.1) + xfs (>= 0.0.0) + lvm (3.1.0) + marker (1.0.1) + mingw (1.2.4) + compat_resource (>= 0.0.0) + seven_zip (>= 0.0.0) + ohai (4.2.3) + compat_resource (>= 12.14.7) + rightscale_backup (2.0.0) + build-essential (>= 0.0.0) + rightscale_volume (~> 2.0.0) + rightscale_volume (2.0.0) + build-essential (>= 0.0.0) + rs-storage (2.0.0) + apt (>= 0.0.0) + build-essential (>= 0.0.0) + chef_handler (>= 0.0.0) + filesystem (>= 0.0.0) + lvm (~> 3.1) + marker (>= 0.0.0) + rightscale_backup (~> 2.0.0) + rightscale_volume (~> 2.0.0) + seven_zip (2.0.2) + windows (>= 1.2.2) + windows (2.1.1) + ohai (>= 4.0.0) + xfs (2.0.1) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9c0c85..9106e07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,14 @@ rs-storage Cookbook CHANGELOG This file is used to list changes made in each version of the rs-storage cookbook. -v1.2.1 +v2.0.0 +------ + +- Add support for Chef 12 +- Remove support for Chef 11 +v1.2.1 +------ - pin Gems and cookbooks using Gemfile.lock and Berksfile.lock diff --git a/Gemfile b/Gemfile index c6f19d2..9ed36e1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,7 @@ source 'https://rubygems.org' -gem 'berkshelf' -gem 'thor-foodcritic' +gem 'rake' +gem 'chef', '~> 12.16' group :integration do - gem 'test-kitchen', '~> 1.2.1' - gem 'kitchen-vagrant', '0.15.0' - gem 'strainer', '~> 3.3.0' - gem 'chefspec', '~> 3.4.0' - gem 'travis-lint' - gem 'rspec-expectations', '~> 2.14.0' - gem 'buff-ignore','1.1.1' - gem 'rack', '1.6.4' - gem 'json','~> 1.8.0' - gem 'net-http-persistent', '= 2.9.4' end diff --git a/README.md b/README.md index 1644343..3ddbb2f 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,12 @@ Github Repository: [https://github.com/rightscale-cookbooks/rs-storage](https:// # Requirements -* Requires Chef 11 -* Requires Ruby 1.9 or higher +* Requires Chef 12 +* Requires Ruby 2.3.1 * Requires [RightLink 10](http://docs.rightscale.com/rl10/) See cookbook version 1.0.7 for RightLink 6 support * Platform - * Ubuntu 12.04 - * CentOS 6 + * Ubuntu 12.04, 14.04 + * CentOS 6, 7 * Cookbooks * [chef_handler](http://community.opscode.com/cookbooks/chef_handler) * [filesystem](http://community.opscode.com/cookbooks/filesystem) diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..e0fbcd0 --- /dev/null +++ b/Rakefile @@ -0,0 +1,113 @@ +require 'rspec/core/rake_task' +require 'foodcritic' +require 'kitchen' + +directory = File.expand_path(File.dirname(__FILE__)) + +desc 'Sets up knife, and vendors cookbooks' +task :setup_test_environment do + File.open('knife.rb', 'w+') do |file| + file.write <<-EOF + log_level :debug + log_location STDOUT + cookbook_path ['.', 'berks-cookbooks/' ] + EOF + end + sh('berks vendor') +end + +desc 'verifies version and changelog' +task :verify_version do + def old_version? + f = `git show master:metadata.rb` + f.each_line do |line| + if line =~ /^version/ + _k, v = line.strip.split + @old_version = v + end + end + @old_version + end + + def new_version? + f = File.read('metadata.rb') + f.each_line do |line| + if line =~ /^version/ + _k, v = line.strip.split + @new_version = v + end + end + @new_version + end + + if `git rev-parse --abbrev-ref HEAD`.strip != ('master' && 'HEAD') + old_version = old_version?.tr('\'', '') + new_version = new_version?.tr('\'', '') + puts "Verifying Metdata Version - Old:#{old_version}, New:#{new_version}" + if old_version == new_version + raise 'You need to increment version before test will pass' + end + + puts "Verifying Changelog Contains Version #{new_version}" + counter = 0 + f = File.read('CHANGELOG.md') + f.each_line do |line| + counter += 1 if line.match new_version + end + raise 'CHANGELOG update needed' if counter == 0 + end +end + +desc 'runs cookstyle' +task cookstyle: [:setup_test_environment] do + cmd = 'chef exec cookstyle -D --format offenses --display-cop-names' + puts cmd + sh(cmd) +end + +desc 'runs foodcritic' +task :foodcritic do + cmd = "chef exec foodcritic --epic-fail any #{directory}" + puts cmd + sh(cmd) +end + +desc 'runs foodcritic linttask' +task :fc_new do + FoodCritic::Rake::LintTask.new(:chef) do |t| + t.options = { + fail_tags: ['any'] + } + end +end + +desc 'runs rspec' +task :rspec do + cmd = 'chef exec rspec --color --format documentation' + puts cmd + sh(cmd) +end + +desc 'runs testkitchen' +task :kitchen do + cmd = 'chef exec kitchen test --concurrency=2' + puts cmd + sh(cmd) +end + +desc 'clean up test files' +task :clean do + cmd = 'rm -fr berks-cookbooks knife.rb' + puts cmd + sh(cmd) +end + +desc 'runs all tests except kitchen' +task except_kitchen: [:verify_version, :cookstyle, :foodcritic, :rspec] do + puts 'running all tests except kitchen' +end + +desc 'runs all tests' +task all: [:except_kitchen, :kitchen] do + puts 'running all tests' +end diff --git a/Strainerfile b/Strainerfile deleted file mode 100644 index 4493fc5..0000000 --- a/Strainerfile +++ /dev/null @@ -1,4 +0,0 @@ -knife: bundle exec knife cookbook test $COOKBOOK -# Ignore FC009 since it doesn't recognize lazy attributes -foodcritic: bundle exec foodcritic --epic-fail any --tags ~FC009 $SANDBOX/$COOKBOOK -chefspec: bundle exec rspec --format documentation --color diff --git a/Thorfile b/Thorfile deleted file mode 100644 index 46b5ae4..0000000 --- a/Thorfile +++ /dev/null @@ -1,14 +0,0 @@ -# encoding: utf-8 - -require 'bundler' -require 'bundler/setup' -require 'thor/foodcritic' -require 'thor/scmversion' -require 'berkshelf/thor' - -begin - require 'kitchen/thor_tasks' - Kitchen::ThorTasks.new -rescue LoadError - puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] -end diff --git a/Vagrantfile b/Vagrantfile index d950a89..98d8773 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,25 +1,25 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -Vagrant.configure("2") do |config| +Vagrant.configure('2') do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. - config.vm.hostname = "rs-storage-berkshelf" + config.vm.hostname = 'rs-storage-berkshelf' # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = "opscode-ubuntu-12.04" + config.vm.box = 'opscode-ubuntu-12.04' # The url from where the 'config.vm.box' box will be fetched if it # doesn't already exist on the user's system. - config.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box" + config.vm.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box' # Assign this VM to a host-only network IP, allowing you to access it # via the IP. Host-only networks can talk to the host machine as well as # any other machines on the same network, but cannot be accessed (through this # network interface) by any external networks. - config.vm.network :private_network, ip: "33.33.33.10" + config.vm.network :private_network, ip: '33.33.33.10' # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on @@ -72,24 +72,24 @@ Vagrant.configure("2") do |config| config.vm.provision :chef_solo do |chef| chef.json = { :mysql => { - :server_root_password => 'rootpass', - :server_debian_password => 'debpass', - :server_repl_password => 'replpass' + server_root_password: 'rootpass', + server_debian_password: 'debpass', + server_repl_password: 'replpass' }, :'rs-storage' => { - :backup => { - :lineage => 'testing', - :schedule => { - :enable => false, - :hour => 23, - :minute => 0 + backup: { + lineage: 'testing', + schedule: { + enable: false, + hour: 23, + minute: 0 } } } } chef.run_list = [ - "recipe[rs-storage::default]", + 'recipe[rs-storage::default]' ] end end diff --git a/libraries/helper.rb b/libraries/helper.rb index fa6b253..2ed9eef 100644 --- a/libraries/helper.rb +++ b/libraries/helper.rb @@ -33,7 +33,7 @@ def self.is_lvm_used?(mount_point) mount = shell_out!('mount') mount.stdout.each_line do |line| if line =~ /^(.+)\s+on\s+#{mount_point}\s+/ - device = $1 + device = Regexp.last_match(1) return !!(device =~ /^\/dev\/mapper/) && shell_out("lvdisplay '#{device}'").status == 0 end end @@ -68,8 +68,8 @@ def self.remove_lvm(volume_group_name) if volume_group.nil? Chef::Log.info "Volume group '#{volume_group_name}' is not found" else - logical_volume_names = volume_group.logical_volumes.map { |logical_volume| logical_volume.name } - physical_volume_names = volume_group.physical_volumes.map { |physical_volume| physical_volume.name } + logical_volume_names = volume_group.logical_volumes.map(&:name) + physical_volume_names = volume_group.physical_volumes.map(&:name) # Remove the logical volumes logical_volume_names.each do |logical_volume_name| diff --git a/metadata.rb b/metadata.rb index ed8e49b..ab3a8c0 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,163 +4,164 @@ license 'Apache 2.0' description 'Provides recipes for managing volumes on a Server in a RightScale supported cloud' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '1.2.2' - -depends 'chef_handler', '~> 1.1.6'# keep for compatiblity with chef 11, can remove with chef 12 -depends 'seven_zip','~> 2.0.0'# keep for compatiblity with chef 11, can remove with chef 12 -depends 'windows','1.40.0'# keep for compatiblity with chef 11, can remove with chef 12 -depends 'filesystem', '0.10.2'# keep for compatiblity with chef 11, can remove with chef 12 -depends 'lvm', '= 1.6.1' # keep for compatiblity with chef 11, can remove with chef 12 -depends 'marker', '~> 1.0.1' -depends 'rightscale_backup', '~> 1.2.0' -depends 'rightscale_volume', '~> 1.3.0' -depends 'apt', '~> 2.9.2' # keep for compatiblity with chef 11, can remove with chef 12 -depends 'build-essential', '~> 1.4' # keep for compatiblity with chef 11, can remove with chef 12 +version '2.0.0' +issues_url 'https://github.com/rightscale-cookbooks/rs-storage/issues' if respond_to?(:issues_url) +source_url 'https://github.com/rightscale-cookbooks/rs-storage' if respond_to?(:source_url) +chef_version '>= 12.0' if respond_to?(:chef_version) + +depends 'chef_handler' +depends 'filesystem' +depends 'lvm', '~> 3.1' +depends 'marker' +depends 'rightscale_backup', '~> 2.0.0' +depends 'rightscale_volume', '~> 2.0.0' +depends 'apt' +depends 'build-essential' recipe 'rs-storage::default', 'Sets up required dependencies for using this cookbook' recipe 'rs-storage::volume', 'Creates a volume and attaches it to the server' recipe 'rs-storage::stripe', 'Creates volumes, attaches them to the server, and sets up a striped LVM' -recipe 'rs-storage::backup', :description => 'Creates a backup', :thread => 'storage_backup' -recipe 'rs-storage::decommission', 'Destroys LVM conditionally, detaches and destroys volumes. This recipe should' + - ' be used as a decommission recipe in a RightScale ServerTemplate.' +recipe 'rs-storage::backup', description: 'Creates a backup', thread: 'storage_backup' +recipe 'rs-storage::decommission', 'Destroys LVM conditionally, detaches and destroys volumes. This recipe should' \ + ' be used as a decommission recipe in a RightScale ServerTemplate.' recipe 'rs-storage::schedule', 'Enable/disable periodic backups based on rs-storage/schedule/enable' attribute 'rs-storage/device/count', - :display_name => 'Device Count', - :description => 'The number of devices to create and use in the Logical Volume. If this value is set to more than' + - ' 1, it will create the specified number of devices and create an LVM on the devices.', - :default => '2', - :recipes => ['rs-storage::stripe', 'rs-storage::decommission'], - :required => 'recommended' + display_name: 'Device Count', + description: 'The number of devices to create and use in the Logical Volume. If this value is set to more than' \ + ' 1, it will create the specified number of devices and create an LVM on the devices.', + default: '2', + recipes: ['rs-storage::stripe', 'rs-storage::decommission'], + required: 'recommended' attribute 'rs-storage/device/mount_point', - :display_name => 'Device Mount Point', - :description => 'The mount point to mount the device on. Example: /mnt/storage', - :default => '/mnt/storage', - :recipes => ['rs-storage::volume', 'rs-storage::stripe', 'rs-storage::decommission'], - :required => 'recommended' + display_name: 'Device Mount Point', + description: 'The mount point to mount the device on. Example: /mnt/storage', + default: '/mnt/storage', + recipes: ['rs-storage::volume', 'rs-storage::stripe', 'rs-storage::decommission'], + required: 'recommended' attribute 'rs-storage/device/nickname', - :display_name => 'Device Nickname', - :description => 'Nickname for the device. rs-storage::volume uses this for the filesystem label, which is' + - ' restricted to 12 characters. If longer than 12 characters, the filesystem label will be set to the' + - ' first 12 characters. Example: data_storage', - :default => 'data_storage', - :recipes => ['rs-storage::volume', 'rs-storage::stripe', 'rs-storage::decommission'], - :required => 'recommended' + display_name: 'Device Nickname', + description: 'Nickname for the device. rs-storage::volume uses this for the filesystem label, which is' \ + ' restricted to 12 characters. If longer than 12 characters, the filesystem label will be set to the' \ + ' first 12 characters. Example: data_storage', + default: 'data_storage', + recipes: ['rs-storage::volume', 'rs-storage::stripe', 'rs-storage::decommission'], + required: 'recommended' attribute 'rs-storage/device/volume_size', - :display_name => 'Device Volume Size', - :description => 'Size of the volume or logical volume to create (in GB). Example: 10', - :default => '10', - :recipes => ['rs-storage::volume', 'rs-storage::stripe'], - :required => 'recommended' + display_name: 'Device Volume Size', + description: 'Size of the volume or logical volume to create (in GB). Example: 10', + default: '10', + recipes: ['rs-storage::volume', 'rs-storage::stripe'], + required: 'recommended' attribute 'rs-storage/device/iops', - :display_name => 'Device IOPS', - :description => 'IO Operations Per Second to use for the device. Currently this value is only used on AWS clouds.' + - ' Example: 100', - :recipes => ['rs-storage::volume', 'rs-storage::stripe'], - :required => 'optional' + display_name: 'Device IOPS', + description: 'IO Operations Per Second to use for the device. Currently this value is only used on AWS clouds.' \ + ' Example: 100', + recipes: ['rs-storage::volume', 'rs-storage::stripe'], + required: 'optional' attribute 'rs-storage/device/volume_type', - :display_name => 'Volume Type', - :description => 'Volume Type to use for creating volumes. Example: gp2', - :recipes => ['rs-storage::volume', 'rs-storage::stripe'], - :required => 'optional' + display_name: 'Volume Type', + description: 'Volume Type to use for creating volumes. Example: gp2', + recipes: ['rs-storage::volume', 'rs-storage::stripe'], + required: 'optional' attribute 'rs-storage/device/filesystem', - :display_name => 'Device Filesystem', - :description => 'The filesystem to be used on the device. Defaults are based on OS and determined in' + - ' attributes/defaults.rb. Example: ext4', - :recipes => ['rs-storage::volume', 'rs-storage::stripe'], - :required => 'optional' + display_name: 'Device Filesystem', + description: 'The filesystem to be used on the device. Defaults are based on OS and determined in' \ + ' attributes/defaults.rb. Example: ext4', + recipes: ['rs-storage::volume', 'rs-storage::stripe'], + required: 'optional' attribute 'rs-storage/device/detach_timeout', - :display_name => 'Detach Timeout', - :description => 'Amount of time (in seconds) to wait for a single volume to detach at decommission. Example: 300', - :default => '300', - :recipes => ['rs-storage::volume', 'rs-storage::stripe'], - :required => 'optional' + display_name: 'Detach Timeout', + description: 'Amount of time (in seconds) to wait for a single volume to detach at decommission. Example: 300', + default: '300', + recipes: ['rs-storage::volume', 'rs-storage::stripe'], + required: 'optional' attribute 'rs-storage/device/destroy_on_decommission', - :display_name => 'Destroy on Decommission', - :description => 'If set to true, the devices will be destroyed on decommission.', - :default => 'false', - :recipes => ['rs-storage::decommission'], - :required => 'recommended' + display_name: 'Destroy on Decommission', + description: 'If set to true, the devices will be destroyed on decommission.', + default: 'false', + recipes: ['rs-storage::decommission'], + required: 'recommended' attribute 'rs-storage/backup/lineage', - :display_name => 'Backup Lineage', - :description => 'The backup lineage. Example: production', - :recipes => ['rs-storage::backup'], - :required => 'required' + display_name: 'Backup Lineage', + description: 'The backup lineage. Example: production', + recipes: ['rs-storage::backup'], + required: 'required' attribute 'rs-storage/restore/lineage', - :display_name => 'Restore Lineage', - :description => 'The lineage name to restore backups. Example: staging', - :recipes => ['rs-storage::volume', 'rs-storage::stripe'], - :required => 'recommended' + display_name: 'Restore Lineage', + description: 'The lineage name to restore backups. Example: staging', + recipes: ['rs-storage::volume', 'rs-storage::stripe'], + required: 'recommended' attribute 'rs-storage/restore/timestamp', - :display_name => 'Restore Timestamp', - :description => 'The timestamp (in seconds since UNIX epoch) to select a backup to restore from.' + - ' The backup selected will have been created on or before this timestamp. Example: 1391473172', - :recipes => ['rs-storage::volume', 'rs-storage::stripe'], - :required => 'recommended' + display_name: 'Restore Timestamp', + description: 'The timestamp (in seconds since UNIX epoch) to select a backup to restore from.' \ + ' The backup selected will have been created on or before this timestamp. Example: 1391473172', + recipes: ['rs-storage::volume', 'rs-storage::stripe'], + required: 'recommended' attribute 'rs-storage/backup/keep/dailies', - :display_name => 'Backup Keep Dailies', - :description => 'Number of daily backups to keep. Example: 14', - :default => '14', - :recipes => ['rs-storage::backup'], - :required => 'optional' + display_name: 'Backup Keep Dailies', + description: 'Number of daily backups to keep. Example: 14', + default: '14', + recipes: ['rs-storage::backup'], + required: 'optional' attribute 'rs-storage/backup/keep/weeklies', - :display_name => 'Backup Keep Weeklies', - :description => 'Number of weekly backups to keep. Example: 6', - :default => '6', - :recipes => ['rs-storage::backup'], - :required => 'optional' + display_name: 'Backup Keep Weeklies', + description: 'Number of weekly backups to keep. Example: 6', + default: '6', + recipes: ['rs-storage::backup'], + required: 'optional' attribute 'rs-storage/backup/keep/monthlies', - :display_name => 'Backup Keep Monthlies', - :description => 'Number of monthly backups to keep. Example: 12', - :default => '12', - :recipes => ['rs-storage::backup'], - :required => 'optional' + display_name: 'Backup Keep Monthlies', + description: 'Number of monthly backups to keep. Example: 12', + default: '12', + recipes: ['rs-storage::backup'], + required: 'optional' attribute 'rs-storage/backup/keep/yearlies', - :display_name => 'Backup Keep Yearlies', - :description => 'Number of yearly backups to keep. Example: 2', - :default => '2', - :recipes => ['rs-storage::backup'], - :required => 'optional' + display_name: 'Backup Keep Yearlies', + description: 'Number of yearly backups to keep. Example: 2', + default: '2', + recipes: ['rs-storage::backup'], + required: 'optional' attribute 'rs-storage/backup/keep/keep_last', - :display_name => 'Backup Keep Last Snapshots', - :description => 'Number of snapshots to keep. Example: 60', - :default => '60', - :recipes => ['rs-storage::backup'], - :required => 'optional' + display_name: 'Backup Keep Last Snapshots', + description: 'Number of snapshots to keep. Example: 60', + default: '60', + recipes: ['rs-storage::backup'], + required: 'optional' attribute 'rs-storage/schedule/enable', - :display_name => 'Backup Schedule Enable', - :description => 'Enable or disable periodic backup schedule', - :default => 'false', - :choice => ['true', 'false'], - :recipes => ['rs-storage::schedule'], - :required => 'recommended' + display_name: 'Backup Schedule Enable', + description: 'Enable or disable periodic backup schedule', + default: 'false', + choice: %w(true false), + recipes: ['rs-storage::schedule'], + required: 'recommended' attribute 'rs-storage/schedule/hour', - :display_name => 'Backup Schedule Hour', - :description => "The hour to schedule the backup on. This value should abide by crontab syntax. Use '*' for taking' + + display_name: 'Backup Schedule Hour', + description: "The hour to schedule the backup on. This value should abide by crontab syntax. Use '*' for taking' + ' backups every hour. Example: 23", - :recipes => ['rs-storage::schedule'], - :required => 'required' + recipes: ['rs-storage::schedule'], + required: 'required' attribute 'rs-storage/schedule/minute', - :display_name => 'Backup Schedule Minute', - :description => 'The minute to schedule the backup on. This value should abide by crontab syntax. Example: 30', - :recipes => ['rs-storage::schedule'], - :required => 'required' + display_name: 'Backup Schedule Minute', + description: 'The minute to schedule the backup on. This value should abide by crontab syntax. Example: 30', + recipes: ['rs-storage::schedule'], + required: 'required' diff --git a/recipes/backup.rb b/recipes/backup.rb index 67d4c5b..72b3083 100644 --- a/recipes/backup.rb +++ b/recipes/backup.rb @@ -16,6 +16,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +def log(msg) + Chef::Log.info msg +end marker 'recipe_start_rightscale' do template 'rightscale_audit_entry.erb' diff --git a/recipes/decommission.rb b/recipes/decommission.rb index df8c5c9..309a736 100644 --- a/recipes/decommission.rb +++ b/recipes/decommission.rb @@ -17,17 +17,17 @@ # limitations under the License. # -marker "recipe_start_rightscale" do - template "rightscale_audit_entry.erb" +marker 'recipe_start_rightscale' do + template 'rightscale_audit_entry.erb' end # Check for the safety attribute first if node['rs-storage']['device']['destroy_on_decommission'] != true && - node['rs-storage']['device']['destroy_on_decommission'] != 'true' - log "rs-storage/device/destroy_on_decommission is set to '#{node['rs-storage']['device']['destroy_on_decommission']}'" + - " skipping..." + node['rs-storage']['device']['destroy_on_decommission'] != 'true' + log "rs-storage/device/destroy_on_decommission is set to '#{node['rs-storage']['device']['destroy_on_decommission']}'" \ + ' skipping...' # Check 'rs_run_state' and skip if the instance is rebooting or entering the stop state -elsif ['reboot', 'stop'].include?(node["rightscale"]["decom_reason"]) +elsif %w(reboot stop).include?(node['rightscale']['decom_reason']) log 'Skipping deletion of volumes as the instance is either rebooting or entering the stop state...' # Detach and delete the volumes if the above safety conditions are satisfied else @@ -38,7 +38,6 @@ if is_lvm_used?(node['rs-storage']['device']['mount_point']) # Remove any characters other than alphanumeric and dashes and replace with dashes sanitized_nickname = device_nickname.downcase.gsub(/[^-a-z0-9]/, '-') - # Construct the logical volume from the name of the volume group and the name of the logical volume similar to how the # lvm cookbook constructs the name during the creation of the logical volume logical_volume_device = "/dev/mapper/#{to_dm_name("#{sanitized_nickname}-vg")}-#{to_dm_name("#{sanitized_nickname}-lv")}" @@ -51,7 +50,7 @@ action [:umount, :disable] end - log "LVM is used on the device(s). Cleaning up the LVM." + log 'LVM is used on the device(s). Cleaning up the LVM.' # Clean up the LVM conditionally ruby_block 'clean up LVM' do block do diff --git a/recipes/default.rb b/recipes/default.rb index 4c002ce..7ad435e 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -17,23 +17,20 @@ # limitations under the License. # -marker "recipe_start_rightscale" do - template "rightscale_audit_entry.erb" +marker 'recipe_start_rightscale' do + template 'rightscale_audit_entry.erb' end # RHEL on some clouds take some time to add RHEL repos. # Check and wait a few seconds if RHEL repos are not yet installed. if node['platform'] == 'redhat' if !node.attribute?('cloud') || !node['cloud'].attribute?('provider') || !node.attribute?(node['cloud']['provider']) - log "Not running on a known cloud - skipping check for RHEL repo" + log 'Not running on a known cloud - skipping check for RHEL repo' else # Depending on cloud, add string returned by 'yum --cacheonly repolist' to determine if RHEL repo has been added. - case node['cloud']['provider'] - when 'rackspace' - repo_id_partial = 'rhel-x86_64-server' - else - # Check to be skipped since cloud not in list. - repo_id_partial = nil + repo_id_partial = case node['cloud']['provider'] + when 'rackspace' + 'rhel-x86_64-server' end unless repo_id_partial.nil? diff --git a/recipes/schedule.rb b/recipes/schedule.rb index 951dde5..2456160 100644 --- a/recipes/schedule.rb +++ b/recipes/schedule.rb @@ -17,8 +17,8 @@ # limitations under the License. # -marker "recipe_start_rightscale" do - template "rightscale_audit_entry.erb" +marker 'recipe_start_rightscale' do + template 'rightscale_audit_entry.erb' end schedule_enable = node['rs-storage']['schedule']['enable'] == true || node['rs-storage']['schedule']['enable'] == 'true' diff --git a/recipes/stripe.rb b/recipes/stripe.rb index 5c2d47b..41ada8d 100644 --- a/recipes/stripe.rb +++ b/recipes/stripe.rb @@ -17,8 +17,8 @@ # limitations under the License. # -marker "recipe_start_rightscale" do - template "rightscale_audit_entry.erb" +marker 'recipe_start_rightscale' do + template 'rightscale_audit_entry.erb' end device_count = node['rs-storage']['device']['count'].to_i @@ -29,7 +29,6 @@ detach_timeout = node['rs-storage']['device']['detach_timeout'].to_i * device_count - each_device_size = (size.to_f / device_count.to_f).ceil Chef::Log.info "Total size is: #{size}" diff --git a/recipes/volume.rb b/recipes/volume.rb index 09281e8..d0349c6 100644 --- a/recipes/volume.rb +++ b/recipes/volume.rb @@ -16,16 +16,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # +def log(msg) + Chef::Log.info msg +end -marker "recipe_start_rightscale" do - template "rightscale_audit_entry.erb" +marker 'recipe_start_rightscale' do + template 'rightscale_audit_entry.erb' end detach_timeout = node['rs-storage']['device']['detach_timeout'].to_i device_nickname = node['rs-storage']['device']['nickname'] size = node['rs-storage']['device']['volume_size'].to_i - # Cloud-specific volume options volume_options = {} volume_options[:iops] = node['rs-storage']['device']['iops'] if node['rs-storage']['device']['iops'] diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb index ca9ae91..67ac467 100644 --- a/spec/backup_spec.rb +++ b/spec/backup_spec.rb @@ -2,7 +2,7 @@ describe 'rs-storage::backup' do let(:chef_run) do - ChefSpec::Runner.new do |node| + ChefSpec::SoloRunner.new do |node| node.set['chef_handler']['handler_path'] = '/var/chef/handlers' node.set['rs-storage']['backup']['lineage'] = 'testing' end.converge(described_recipe) @@ -12,30 +12,30 @@ it 'sets up chef error handler' do expect(chef_run).to include_recipe('chef_handler::default') expect(chef_run).to create_cookbook_file('/var/chef/handlers/rs-storage_backup.rb').with( - source: 'backup_error_handler.rb', + source: 'backup_error_handler.rb' ) expect(chef_run).to enable_chef_handler('Rightscale::BackupErrorHandler').with( - source: '/var/chef/handlers/rs-storage_backup.rb', + source: '/var/chef/handlers/rs-storage_backup.rb' ) end it 'freezes the filesystem' do expect(chef_run).to freeze_filesystem("freeze #{nickname}").with( label: nickname, - mount: '/mnt/storage', + mount: '/mnt/storage' ) end it 'creates a backup' do expect(chef_run).to create_rightscale_backup(nickname).with( - lineage: 'testing', + lineage: 'testing' ) end it 'unfreezes the filesystem' do expect(chef_run).to unfreeze_filesystem("unfreeze #{nickname}").with( label: nickname, - mount: '/mnt/storage', + mount: '/mnt/storage' ) end @@ -46,7 +46,7 @@ dailies: 14, weeklies: 6, monthlies: 12, - yearlies: 2, + yearlies: 2 ) end end diff --git a/spec/decommission_spec.rb b/spec/decommission_spec.rb index 51fac19..9f3f043 100644 --- a/spec/decommission_spec.rb +++ b/spec/decommission_spec.rb @@ -3,7 +3,7 @@ describe 'rs-storage::decommission' do context 'rs-storage/device/destroy_on_decommission is set to false' do let(:chef_run) do - ChefSpec::Runner.new.converge(described_recipe) + ChefSpec::SoloRunner.new.converge(described_recipe) end it 'logs that it is skipping destruction' do @@ -13,19 +13,18 @@ context 'rs-storage/device/destroy_on_decommission is set to true' do let(:chef_runner) do - ChefSpec::Runner.new do |node| - node.set["rightscale"]["decom_reason"] = 'terminate' + ChefSpec::SoloRunner.new do |node| + node.set['rightscale']['decom_reason'] = 'terminate' node.set['rs-storage']['device']['destroy_on_decommission'] = true end end let(:nickname) { chef_runner.converge(described_recipe).node['rs-storage']['device']['nickname'] } context 'RightScale run state is terminate' do - context 'LVM is not used' do before do mount = double - Mixlib::ShellOut.stub(:new).with('mount').and_return(mount) + allow(Mixlib::ShellOut).to receive(:shell_out).with('mount').and_return(mount) allow(mount).to receive(:run_command) allow(mount).to receive(:error!) allow(mount).to receive(:live_stream=) @@ -38,13 +37,15 @@ end it 'unmounts and disables the volume on the instance' do + expect(chef_run).to write_log('Unmounting /mnt/storage') expect(chef_run).to umount_mount('/mnt/storage').with( - device: '/dev/sda', + device: '/dev/sda' ) expect(chef_run).to disable_mount('/mnt/storage') end it 'detaches the volume from the instance' do + expect(chef_run).to write_log('LVM was not used on the device, simply detaching the deleting the device.') expect(chef_run).to detach_rightscale_volume(nickname) end @@ -55,18 +56,12 @@ context 'LVM is used' do before do - mount = double - Mixlib::ShellOut.stub(:new).with('mount').and_return(mount) - allow(mount).to receive(:run_command) - allow(mount).to receive(:error!) - allow(mount).to receive(:live_stream=) - allow(mount).to receive(:stdout).and_return('/dev/mapper/vol-group--logical-volume-1 on /mnt/storage type ext4 (auto)') + output = '/dev/mapper/vol-group--logical-volume-1 on /mnt/storage type ext4 (auto)' + mount = double(run_command: nil, error!: nil, stdout: output, stderr: double(empty?: true), exitstatus: 0, live_stream: nil, 'live_stream=' => nil, status: 0) + allow(Mixlib::ShellOut).to receive(:new).and_return(mount) - lvdisplay = double - Mixlib::ShellOut.stub(:new).with("lvdisplay '/dev/mapper/vol-group--logical-volume-1'").and_return(lvdisplay) - allow(lvdisplay).to receive(:run_command) - allow(lvdisplay).to receive(:live_stream=) - allow(lvdisplay).to receive(:status).and_return(0) + lvdisplay = double(run_command: nil, error!: nil, stdout: output, stderr: double(empty?: true), exitstatus: 0, live_stream: nil, 'live_stream=' => nil, status: 0) + allow(Mixlib::ShellOut).to receive(:new).and_return(lvdisplay) end let(:chef_run) do @@ -79,12 +74,13 @@ it 'unmounts and disables the volume on the instance' do expect(chef_run).to umount_mount('/mnt/storage').with( - device: logical_volume_device, + device: logical_volume_device ) expect(chef_run).to disable_mount('/mnt/storage') end it 'cleans up the LVM' do + expect(chef_run).to write_log('LVM is used on the device(s). Cleaning up the LVM.') expect(chef_run).to run_ruby_block('clean up LVM') end @@ -100,11 +96,10 @@ end end - ['reboot', 'stop'].each do |state| + %w(reboot stop).each do |state| context "RightScale run state is #{state}" do - let(:chef_run) do - chef_runner.node.set["rightscale"]["decom_reason"] = state + chef_runner.node.set['rightscale']['decom_reason'] = state chef_runner.converge(described_recipe) end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index c7f94ca..3b6ec0e 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -1,7 +1,7 @@ require_relative 'spec_helper' describe 'rs-storage::default' do - let(:chef_run) { ChefSpec::Runner.new(log_level: :error).converge(described_recipe) } + let(:chef_run) { ChefSpec::SoloRunner.new(log_level: :error).converge(described_recipe) } it 'includes rightscale_volume::default recipe' do expect(chef_run).to include_recipe('rightscale_volume::default') diff --git a/spec/schedule_spec.rb b/spec/schedule_spec.rb index 99662b9..7789416 100644 --- a/spec/schedule_spec.rb +++ b/spec/schedule_spec.rb @@ -3,7 +3,7 @@ describe 'rs-storage::schedule' do context 'rs-storage/schedule/enable is true' do let(:chef_run) do - ChefSpec::Runner.new do |node| + ChefSpec::SoloRunner.new do |node| node.set['rs-storage']['schedule']['enable'] = true node.set['rs-storage']['backup']['lineage'] = 'testing' node.set['rs-storage']['schedule']['hour'] = '10' @@ -23,7 +23,7 @@ context 'rs-storage/schedule/enable is false' do let(:chef_run) do - ChefSpec::Runner.new do |node| + ChefSpec::SoloRunner.new do |node| node.set['rs-storage']['schedule']['enable'] = false node.set['rs-storage']['backup']['lineage'] = 'testing' end.converge(described_recipe) @@ -39,7 +39,7 @@ context 'rs-storage/schedule/hour or rs-storage/schedule/minute missing' do let(:chef_run) do - ChefSpec::Runner.new do |node| + ChefSpec::SoloRunner.new do |node| node.set['rs-storage']['backup']['lineage'] = 'testing' node.set['rs-storage']['schedule']['enable'] = true node.set['rs-storage']['schedule']['hour'] = '10' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1f034d7..dc70be5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: rs-storage +# Cookbook Name:: ephemeral_lvm # Spec:: spec_helper # # Copyright (C) 2014 RightScale, Inc. @@ -16,10 +16,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # +libraries_path = File.expand_path('../../libraries', __FILE__) +$LOAD_PATH.unshift(libraries_path) unless $LOAD_PATH.include?(libraries_path) require 'chefspec' require 'chefspec/berkshelf' +require 'chefspec/cacher' +require 'rspec/support' +ChefSpec::Coverage.start! RSpec.configure do |config| + config.extend(ChefSpec::Cacher) + config.platform = 'ubuntu' + config.version = '12.04' config.log_level = :error end diff --git a/spec/stripe_spec.rb b/spec/stripe_spec.rb index c930583..6efd59a 100644 --- a/spec/stripe_spec.rb +++ b/spec/stripe_spec.rb @@ -2,7 +2,7 @@ describe 'rs-storage::stripe' do let(:chef_runner) do - ChefSpec::Runner.new do |node| + ChefSpec::SoloRunner.new do |node| node.set['rightscale_volume']['data_storage_1']['device'] = '/dev/sda' node.set['rightscale_volume']['data_storage_2']['device'] = '/dev/sdb' node.set['rightscale_backup']['data_storage']['devices'] = ['/dev/sda', '/dev/sdb'] @@ -11,26 +11,23 @@ let(:nickname) { chef_run.node['rs-storage']['device']['nickname'] } let(:nickname_1) { "#{nickname}_1" } let(:nickname_2) { "#{nickname}_2" } - let(:volume_group) { "#{nickname.gsub('_', '-')}-vg" } - let(:logical_volume) { "#{nickname.gsub('_', '-')}-lv" } + let(:volume_group) { "#{nickname.tr('_', '-')}-vg" } + let(:logical_volume) { "#{nickname.tr('_', '-')}-lv" } let(:detach_timeout) do chef_runner.converge(described_recipe).node['rs-storage']['device']['detach_timeout'].to_i end - - context 'rs-storage/restore/lineage is not set' do let(:chef_run) { chef_runner.converge(described_recipe) } - it 'creates two new volumes and attaches them' do expect(chef_run).to create_rightscale_volume(nickname_1).with( size: 5, - options: {}, + options: {} ) expect(chef_run).to create_rightscale_volume(nickname_2).with( size: 5, - options: {}, + options: {} ) expect(chef_run).to attach_rightscale_volume(nickname_1) expect(chef_run).to attach_rightscale_volume(nickname_2) @@ -44,7 +41,7 @@ filesystem: 'ext4', mount_point: '/mnt/storage', stripes: 2, - stripe_size: 512, + stripe_size: 512 ) end @@ -57,11 +54,11 @@ it 'creates two new volumes with iops set to 100 and attaches them' do expect(chef_run).to create_rightscale_volume(nickname_1).with( size: 5, - options: {iops: 100}, + options: { iops: 100 } ) expect(chef_run).to create_rightscale_volume(nickname_2).with( size: 5, - options: {iops: 100}, + options: { iops: 100 } ) expect(chef_run).to attach_rightscale_volume(nickname_1) expect(chef_run).to attach_rightscale_volume(nickname_2) @@ -83,7 +80,7 @@ lineage: 'testing', timestamp: nil, size: 5, - options: {}, + options: {} ) end @@ -95,7 +92,7 @@ filesystem: 'ext4', mount_point: '/mnt/storage', stripes: 2, - stripe_size: 512, + stripe_size: 512 ) end @@ -110,7 +107,7 @@ lineage: 'testing', timestamp: nil, size: 5, - options: {iops: 100}, + options: { iops: 100 } ) end end @@ -127,7 +124,7 @@ lineage: 'testing', timestamp: timestamp, size: 5, - options: {}, + options: {} ) end end diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb index 140c902..70846c2 100644 --- a/spec/volume_spec.rb +++ b/spec/volume_spec.rb @@ -2,9 +2,10 @@ describe 'rs-storage::volume' do let(:chef_runner) do - ChefSpec::Runner.new do |node| + ChefSpec::SoloRunner.new do |node| node.set['rightscale_volume']['data_storage']['device'] = '/dev/sda' node.set['rightscale_backup']['data_storage']['devices'] = ['/dev/sda'] + node.set['rs-storage']['device']['mount_point'] = '/mnt/storage' end end let(:nickname) { chef_run.node['rs-storage']['device']['nickname'] } @@ -12,14 +13,13 @@ chef_runner.converge(described_recipe).node['rs-storage']['device']['detach_timeout'].to_i end - context 'rs-storage/restore/lineage is not set' do let(:chef_run) { chef_runner.converge(described_recipe) } it 'creates a new volume and attaches it' do expect(chef_run).to create_rightscale_volume(nickname).with( size: 10, - options: {}, + options: {} ) expect(chef_run).to attach_rightscale_volume(nickname) end @@ -28,7 +28,7 @@ expect(chef_run).to create_filesystem(nickname).with( fstype: 'ext4', mkfs_options: '-F', - mount: '/mnt/storage', + mount: '/mnt/storage' ) expect(chef_run).to enable_filesystem(nickname) expect(chef_run).to mount_filesystem(nickname) @@ -43,7 +43,7 @@ it 'creates a new volume with iops set to 100 and attaches it' do expect(chef_run).to create_rightscale_volume(nickname).with( size: 10, - options: {iops: 100}, + options: { iops: 100 } ) expect(chef_run).to attach_rightscale_volume(nickname) end @@ -65,13 +65,17 @@ lineage: 'testing', timestamp: nil, size: 10, - options: {}, + options: {} ) end + it 'creates the directory' do + expect(chef_run).to create_directory(chef_run.node['rs-storage']['device']['mount_point']) + end + it 'mounts and enables the restored volume' do expect(chef_run).to mount_mount(device).with( - fstype: 'ext4', + fstype: 'ext4' ) expect(chef_run).to enable_mount(device) end @@ -87,7 +91,7 @@ lineage: 'testing', timestamp: nil, size: 10, - options: {iops: 100}, + options: { iops: 100 } ) end end @@ -104,7 +108,7 @@ lineage: 'testing', timestamp: timestamp, size: 10, - options: {}, + options: {} ) end end