chef 12.5.0.alpha.1 → 12.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +21 -25
- data/Gemfile +46 -0
- data/README.md +4 -4
- data/Rakefile +5 -110
- data/distro/common/html/knife_cookbook_site.html +18 -18
- data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +19 -1
- data/lib/chef/application/client.rb +11 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service_manager.rb +9 -7
- data/lib/chef/chef_class.rb +39 -0
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
- data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
- data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
- data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
- data/lib/chef/client.rb +2 -3
- data/lib/chef/config.rb +34 -2
- data/lib/chef/cookbook/metadata.rb +25 -3
- data/lib/chef/cookbook/synchronizer.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/deprecation/mixin/template.rb +1 -2
- data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
- data/lib/chef/deprecation/provider/file.rb +1 -1
- data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
- data/lib/chef/deprecation/provider/remote_file.rb +1 -2
- data/lib/chef/deprecation/provider/template.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +3 -4
- data/lib/chef/dsl/reboot_pending.rb +3 -2
- data/lib/chef/dsl/recipe.rb +6 -5
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +12 -7
- data/lib/chef/event_dispatch/dispatcher.rb +21 -6
- data/lib/chef/exceptions.rb +22 -0
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +3 -0
- data/lib/chef/formatters/doc.rb +53 -5
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
- data/lib/chef/formatters/minimal.rb +2 -2
- data/lib/chef/knife.rb +35 -55
- data/lib/chef/knife/bootstrap.rb +41 -0
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
- data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
- data/lib/chef/knife/bootstrap/templates/README.md +3 -4
- data/lib/chef/knife/cookbook_create.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +6 -6
- data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
- data/lib/chef/knife/core/bootstrap_context.rb +12 -4
- data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
- data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
- data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
- data/lib/chef/knife/core/node_presenter.rb +24 -1
- data/lib/chef/knife/core/object_loader.rb +1 -0
- data/lib/chef/knife/core/subcommand_loader.rb +131 -146
- data/lib/chef/knife/node_run_list_remove.rb +12 -1
- data/lib/chef/knife/null.rb +10 -0
- data/lib/chef/knife/rehash.rb +62 -0
- data/lib/chef/knife/search.rb +3 -3
- data/lib/chef/knife/ssh.rb +52 -30
- data/lib/chef/local_mode.rb +5 -0
- data/lib/chef/log.rb +5 -1
- data/lib/chef/mixin/deprecation.rb +8 -8
- data/lib/chef/mixin/params_validate.rb +2 -2
- data/lib/chef/mixin/template.rb +48 -0
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/mixin/wide_string.rb +72 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
- data/lib/chef/mixin/windows_env_helper.rb +4 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
- data/lib/chef/monkey_patches/win32/registry.rb +72 -0
- data/lib/chef/node.rb +97 -3
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -6
- data/lib/chef/platform/query_helpers.rb +46 -4
- data/lib/chef/platform/service_helpers.rb +30 -32
- data/lib/chef/policy_builder.rb +1 -8
- data/lib/chef/policy_builder/dynamic.rb +186 -0
- data/lib/chef/policy_builder/expand_node_object.rb +30 -15
- data/lib/chef/policy_builder/policyfile.rb +155 -18
- data/lib/chef/property.rb +38 -9
- data/lib/chef/provider.rb +104 -12
- data/lib/chef/provider/batch.rb +8 -0
- data/lib/chef/provider/deploy.rb +2 -2
- data/lib/chef/provider/directory.rb +14 -2
- data/lib/chef/provider/dsc_resource.rb +5 -9
- data/lib/chef/provider/group/pw.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/mount.rb +7 -3
- data/lib/chef/provider/package/dpkg.rb +5 -11
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +17 -5
- data/lib/chef/provider/powershell_script.rb +27 -4
- data/lib/chef/provider/remote_directory.rb +190 -102
- data/lib/chef/provider/service.rb +12 -2
- data/lib/chef/provider/service/aix.rb +1 -1
- data/lib/chef/provider/service/debian.rb +3 -5
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +3 -3
- data/lib/chef/provider/service/init.rb +3 -3
- data/lib/chef/provider/service/insserv.rb +2 -4
- data/lib/chef/provider/service/invokercd.rb +2 -4
- data/lib/chef/provider/service/openbsd.rb +2 -1
- data/lib/chef/provider/service/redhat.rb +52 -16
- data/lib/chef/provider/service/simple.rb +2 -2
- data/lib/chef/provider/service/systemd.rb +3 -5
- data/lib/chef/provider/service/upstart.rb +4 -6
- data/lib/chef/provider/subversion.rb +13 -7
- data/lib/chef/provider/template/content.rb +16 -6
- data/lib/chef/provider/user/solaris.rb +32 -4
- data/lib/chef/provider/windows_script.rb +3 -5
- data/lib/chef/provider_resolver.rb +2 -2
- data/lib/chef/resource.rb +85 -27
- data/lib/chef/resource/action_class.rb +83 -0
- data/lib/chef/resource/chef_gem.rb +3 -3
- data/lib/chef/resource/deploy.rb +8 -2
- data/lib/chef/resource/dsc_script.rb +2 -0
- data/lib/chef/resource/file/verification.rb +1 -1
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/service.rb +10 -2
- data/lib/chef/resource/subversion.rb +5 -0
- data/lib/chef/resource/windows_script.rb +6 -2
- data/lib/chef/resource/yum_package.rb +10 -1
- data/lib/chef/resource_resolver.rb +3 -3
- data/lib/chef/run_context.rb +6 -8
- data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
- data/lib/chef/run_lock.rb +30 -21
- data/lib/chef/util/powershell/ps_credential.rb +4 -0
- data/lib/chef/util/windows.rb +0 -32
- data/lib/chef/util/windows/net_group.rb +85 -106
- data/lib/chef/util/windows/net_use.rb +35 -71
- data/lib/chef/util/windows/net_user.rb +0 -1
- data/lib/chef/util/windows/volume.rb +19 -19
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api.rb +1 -0
- data/lib/chef/win32/api/file.rb +20 -0
- data/lib/chef/win32/api/net.rb +163 -43
- data/lib/chef/win32/api/registry.rb +51 -0
- data/lib/chef/win32/api/system.rb +23 -0
- data/lib/chef/win32/api/unicode.rb +0 -43
- data/lib/chef/win32/crypto.rb +2 -1
- data/lib/chef/win32/file.rb +28 -3
- data/lib/chef/win32/mutex.rb +1 -2
- data/lib/chef/win32/net.rb +162 -8
- data/lib/chef/win32/process.rb +13 -0
- data/lib/chef/win32/registry.rb +25 -28
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/token.rb +1 -1
- data/lib/chef/win32/system.rb +62 -0
- data/lib/chef/win32/unicode.rb +7 -2
- data/lib/chef/win32/version.rb +0 -4
- data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
- data/spec/data/dsc_lcm.pfx +0 -0
- data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
- data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
- data/spec/functional/knife/ssh_spec.rb +16 -0
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +2 -0
- data/spec/functional/resource/dsc_script_spec.rb +91 -2
- data/spec/functional/resource/group_spec.rb +67 -44
- data/spec/functional/resource/powershell_script_spec.rb +104 -15
- data/spec/functional/resource/windows_service_spec.rb +1 -1
- data/spec/functional/run_lock_spec.rb +368 -189
- data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +4 -23
- data/spec/integration/client/client_spec.rb +51 -0
- data/spec/integration/knife/download_spec.rb +4 -0
- data/spec/integration/knife/list_spec.rb +8 -0
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/remote_directory.rb +74 -0
- data/spec/integration/recipes/resource_action_spec.rb +42 -22
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
- data/spec/integration/recipes/resource_load_spec.rb +206 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/platform_helpers.rb +13 -0
- data/{lib/chef/mixin/wstring.rb → spec/support/shared/context/win32.rb} +15 -12
- data/spec/support/shared/functional/windows_script.rb +63 -26
- data/spec/support/shared/unit/mock_shellout.rb +46 -0
- data/spec/support/shared/unit/provider/file.rb +10 -4
- data/spec/unit/application/client_spec.rb +16 -3
- data/spec/unit/application/knife_spec.rb +2 -2
- data/spec/unit/chef_class_spec.rb +0 -4
- data/spec/unit/client_spec.rb +6 -1
- data/spec/unit/config_spec.rb +31 -0
- data/spec/unit/cookbook/metadata_spec.rb +23 -3
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/deprecation_spec.rb +3 -6
- data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
- data/spec/unit/event_dispatch/dsl_spec.rb +0 -4
- data/spec/unit/formatters/doc_spec.rb +32 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -3
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
- data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
- data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
- data/spec/unit/mixin/template_spec.rb +5 -1
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
- data/spec/unit/node_spec.rb +213 -0
- data/spec/unit/platform/query_helpers_spec.rb +146 -3
- data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
- data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
- data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
- data/spec/unit/property/validation_spec.rb +5 -0
- data/spec/unit/property_spec.rb +152 -26
- data/spec/unit/provider/deploy_spec.rb +5 -5
- data/spec/unit/provider/directory_spec.rb +35 -0
- data/spec/unit/provider/dsc_resource_spec.rb +3 -10
- data/spec/unit/provider/ifconfig_spec.rb +22 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -1
- data/spec/unit/provider/mount/mount_spec.rb +6 -0
- data/spec/unit/provider/mount/windows_spec.rb +14 -0
- data/spec/unit/provider/mount_spec.rb +12 -1
- data/spec/unit/provider/package/dpkg_spec.rb +8 -1
- data/spec/unit/provider/package/rpm_spec.rb +18 -1
- data/spec/unit/provider/package/rubygems_spec.rb +18 -0
- data/spec/unit/provider/package/yum_spec.rb +97 -24
- data/spec/unit/provider/powershell_script_spec.rb +52 -26
- data/spec/unit/provider/remote_directory_spec.rb +1 -2
- data/spec/unit/provider/service/aix_service_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
- data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
- data/spec/unit/provider/service/redhat_spec.rb +88 -8
- data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
- data/spec/unit/provider/service/windows_spec.rb +211 -200
- data/spec/unit/provider/subversion_spec.rb +50 -31
- data/spec/unit/provider/template/content_spec.rb +93 -2
- data/spec/unit/provider/user/solaris_spec.rb +66 -9
- data/spec/unit/provider_resolver_spec.rb +707 -650
- data/spec/unit/resource/deploy_spec.rb +7 -1
- data/spec/unit/resource/dsc_script_spec.rb +4 -0
- data/spec/unit/resource/file/verification_spec.rb +1 -1
- data/spec/unit/resource/powershell_script_spec.rb +17 -13
- data/spec/unit/resource/service_spec.rb +4 -4
- data/spec/unit/resource/subversion_spec.rb +4 -0
- data/spec/unit/resource/yum_package_spec.rb +10 -1
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
- data/spec/unit/win32/registry_spec.rb +394 -0
- data/tasks/external_tests.rb +47 -23
- data/tasks/maintainers.rb +155 -14
- metadata +51 -26
- data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
- data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
- data/spec/unit/registry_helper_spec.rb +0 -390
@@ -20,25 +20,6 @@
|
|
20
20
|
require 'spec_helper'
|
21
21
|
require 'chef/win32/registry'
|
22
22
|
|
23
|
-
describe Chef::Resource::RegistryKey, :unix_only do
|
24
|
-
before(:all) do
|
25
|
-
events = Chef::EventDispatch::Dispatcher.new
|
26
|
-
node = Chef::Node.new
|
27
|
-
ohai = Ohai::System.new
|
28
|
-
ohai.all_plugins
|
29
|
-
node.consume_external_attrs(ohai.data,{})
|
30
|
-
run_context = Chef::RunContext.new(node, {}, events)
|
31
|
-
@resource = Chef::Resource::RegistryKey.new("HKCU\\Software", run_context)
|
32
|
-
end
|
33
|
-
context "when load_current_resource is run on a non-windows node" do
|
34
|
-
it "throws an exception because you don't have a windows registry (derp)" do
|
35
|
-
@resource.key("HKCU\\Software\\Opscode")
|
36
|
-
@resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
|
37
|
-
expect{@resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32NotWindows)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
23
|
describe 'Chef::Win32::Registry', :windows_only do
|
43
24
|
|
44
25
|
before(:all) do
|
@@ -556,11 +537,11 @@ describe 'Chef::Win32::Registry', :windows_only do
|
|
556
537
|
end
|
557
538
|
|
558
539
|
after(:all) do
|
559
|
-
::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software
|
560
|
-
reg.delete_key("
|
540
|
+
::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software", ::Win32::Registry::KEY_ALL_ACCESS | 0x0100) do |reg|
|
541
|
+
reg.delete_key("Root", true)
|
561
542
|
end
|
562
|
-
::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software
|
563
|
-
reg.delete_key("
|
543
|
+
::Win32::Registry::HKEY_LOCAL_MACHINE.open("Software", ::Win32::Registry::KEY_ALL_ACCESS | 0x0200) do |reg|
|
544
|
+
reg.delete_key("Root", true)
|
564
545
|
end
|
565
546
|
end
|
566
547
|
|
@@ -303,6 +303,57 @@ EOM
|
|
303
303
|
|
304
304
|
end
|
305
305
|
|
306
|
+
when_the_repository "has a cookbook that generates deprecation warnings" do
|
307
|
+
before do
|
308
|
+
file 'cookbooks/x/recipes/default.rb', <<-EOM
|
309
|
+
class ::MyResource < Chef::Resource
|
310
|
+
use_automatic_resource_name
|
311
|
+
property :x, default: []
|
312
|
+
property :y, default: {}
|
313
|
+
end
|
314
|
+
|
315
|
+
my_resource 'blah' do
|
316
|
+
1.upto(10) do
|
317
|
+
x nil
|
318
|
+
end
|
319
|
+
x nil
|
320
|
+
end
|
321
|
+
EOM
|
322
|
+
end
|
323
|
+
|
324
|
+
def match_indices(regex, str)
|
325
|
+
result = []
|
326
|
+
pos = 0
|
327
|
+
while match = regex.match(str, pos)
|
328
|
+
result << match.begin(0)
|
329
|
+
pos = match.end(0) + 1
|
330
|
+
end
|
331
|
+
result
|
332
|
+
end
|
333
|
+
|
334
|
+
it "should output each deprecation warning only once, at the end of the run" do
|
335
|
+
file 'config/client.rb', <<EOM
|
336
|
+
local_mode true
|
337
|
+
cookbook_path "#{path_to('cookbooks')}"
|
338
|
+
# Mimick what happens when you are on the console
|
339
|
+
formatters << :doc
|
340
|
+
log_level :warn
|
341
|
+
EOM
|
342
|
+
|
343
|
+
ENV.delete('CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS')
|
344
|
+
|
345
|
+
result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir)
|
346
|
+
expect(result.error?).to be_falsey
|
347
|
+
|
348
|
+
# Search to the end of the client run in the output
|
349
|
+
run_complete = result.stdout.index("Running handlers complete")
|
350
|
+
expect(run_complete).to be >= 0
|
351
|
+
|
352
|
+
# Make sure there is exactly one result for each, and that it occurs *after* the complete message.
|
353
|
+
expect(match_indices(/nil currently does not overwrite the value of/, result.stdout)).to match([ be > run_complete ])
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
306
357
|
when_the_repository "has a cookbook with only an audit recipe" do
|
307
358
|
|
308
359
|
before do
|
@@ -1113,11 +1113,13 @@ Created /acls/clients/foo-validator.json
|
|
1113
1113
|
Created /acls/containers
|
1114
1114
|
Created /acls/containers/clients.json
|
1115
1115
|
Created /acls/containers/containers.json
|
1116
|
+
Created /acls/containers/cookbook_artifacts.json
|
1116
1117
|
Created /acls/containers/cookbooks.json
|
1117
1118
|
Created /acls/containers/data.json
|
1118
1119
|
Created /acls/containers/environments.json
|
1119
1120
|
Created /acls/containers/groups.json
|
1120
1121
|
Created /acls/containers/nodes.json
|
1122
|
+
Created /acls/containers/policies.json
|
1121
1123
|
Created /acls/containers/roles.json
|
1122
1124
|
Created /acls/containers/sandboxes.json
|
1123
1125
|
Created /acls/containers/x.json
|
@@ -1139,11 +1141,13 @@ Created /clients/foo-validator.json
|
|
1139
1141
|
Created /containers
|
1140
1142
|
Created /containers/clients.json
|
1141
1143
|
Created /containers/containers.json
|
1144
|
+
Created /containers/cookbook_artifacts.json
|
1142
1145
|
Created /containers/cookbooks.json
|
1143
1146
|
Created /containers/data.json
|
1144
1147
|
Created /containers/environments.json
|
1145
1148
|
Created /containers/groups.json
|
1146
1149
|
Created /containers/nodes.json
|
1150
|
+
Created /containers/policies.json
|
1147
1151
|
Created /containers/roles.json
|
1148
1152
|
Created /containers/sandboxes.json
|
1149
1153
|
Created /containers/x.json
|
@@ -702,11 +702,13 @@ foo-validator.json
|
|
702
702
|
/acls/containers:
|
703
703
|
clients.json
|
704
704
|
containers.json
|
705
|
+
cookbook_artifacts.json
|
705
706
|
cookbooks.json
|
706
707
|
data.json
|
707
708
|
environments.json
|
708
709
|
groups.json
|
709
710
|
nodes.json
|
711
|
+
policies.json
|
710
712
|
roles.json
|
711
713
|
sandboxes.json
|
712
714
|
|
@@ -733,11 +735,13 @@ foo-validator.json
|
|
733
735
|
/containers:
|
734
736
|
clients.json
|
735
737
|
containers.json
|
738
|
+
cookbook_artifacts.json
|
736
739
|
cookbooks.json
|
737
740
|
data.json
|
738
741
|
environments.json
|
739
742
|
groups.json
|
740
743
|
nodes.json
|
744
|
+
policies.json
|
741
745
|
roles.json
|
742
746
|
sandboxes.json
|
743
747
|
|
@@ -804,11 +808,13 @@ foo-validator.json
|
|
804
808
|
/acls/containers:
|
805
809
|
clients.json
|
806
810
|
containers.json
|
811
|
+
cookbook_artifacts.json
|
807
812
|
cookbooks.json
|
808
813
|
data.json
|
809
814
|
environments.json
|
810
815
|
groups.json
|
811
816
|
nodes.json
|
817
|
+
policies.json
|
812
818
|
roles.json
|
813
819
|
sandboxes.json
|
814
820
|
|
@@ -835,11 +841,13 @@ foo-validator.json
|
|
835
841
|
/containers:
|
836
842
|
clients.json
|
837
843
|
containers.json
|
844
|
+
cookbook_artifacts.json
|
838
845
|
cookbooks.json
|
839
846
|
data.json
|
840
847
|
environments.json
|
841
848
|
groups.json
|
842
849
|
nodes.json
|
850
|
+
policies.json
|
843
851
|
roles.json
|
844
852
|
sandboxes.json
|
845
853
|
|
@@ -119,7 +119,7 @@ describe "Recipe DSL methods" do
|
|
119
119
|
recipe = converge {
|
120
120
|
backcompat_thingy 'blah' do; end
|
121
121
|
}
|
122
|
-
expect(recipe.logged_warnings).to match(/Class Chef::Provider::BackcompatThingy does not declare '
|
122
|
+
expect(recipe.logged_warnings).to match(/Class Chef::Provider::BackcompatThingy does not declare 'provides :backcompat_thingy'./)
|
123
123
|
expect(BaseThingy.created_resource).not_to be_nil
|
124
124
|
end
|
125
125
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'support/shared/integration/integration_helper'
|
2
|
+
|
3
|
+
describe Chef::Resource::RemoteDirectory do
|
4
|
+
include IntegrationSupport
|
5
|
+
include Chef::Mixin::ShellOut
|
6
|
+
|
7
|
+
# Until Cheffish::RSpec has cookbook support, we have to run the whole client
|
8
|
+
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") }
|
9
|
+
|
10
|
+
# Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
|
11
|
+
# following constraints are satisfied:
|
12
|
+
# * Windows: windows can only run batch scripts as bare executables. Rubygems
|
13
|
+
# creates batch wrappers for installed gems, but we don't have batch wrappers
|
14
|
+
# in the source tree.
|
15
|
+
# * Other `chef-client` in PATH: A common case is running the tests on a
|
16
|
+
# machine that has omnibus chef installed. In that case we need to ensure
|
17
|
+
# we're running `chef-client` from the source tree and not the external one.
|
18
|
+
# cf. CHEF-4914
|
19
|
+
let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" }
|
20
|
+
|
21
|
+
when_the_repository "has a cookbook with a source_dir with two subdirectories, each with one file and subdir in a different alphabetical order" do
|
22
|
+
before do
|
23
|
+
file 'config/client.rb', <<-EOM
|
24
|
+
local_mode true
|
25
|
+
cookbook_path "#{path_to('cookbooks')}"
|
26
|
+
EOM
|
27
|
+
directory "cookbooks/test" do
|
28
|
+
directory "files/default/source_dir" do
|
29
|
+
directory "sub1" do
|
30
|
+
file "aaa", ""
|
31
|
+
file "zzz/file", ""
|
32
|
+
end
|
33
|
+
directory "sub2" do
|
34
|
+
file "aaa/file", ""
|
35
|
+
file "zzz", ""
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "and a recipe is run with a remote_directory that syncs source_dir with different mode and file_mode" do
|
42
|
+
let!(:dest_dir) { path_to("dest_dir") }
|
43
|
+
before do
|
44
|
+
directory "cookbooks/test" do
|
45
|
+
file "recipes/default.rb", <<-EOM
|
46
|
+
remote_directory #{dest_dir.inspect} do
|
47
|
+
source "source_dir"
|
48
|
+
mode "0754"
|
49
|
+
files_mode 0777
|
50
|
+
end
|
51
|
+
EOM
|
52
|
+
end
|
53
|
+
shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'test::default'", :cwd => chef_dir)
|
54
|
+
end
|
55
|
+
|
56
|
+
def mode_of(path)
|
57
|
+
path = path_to(path)
|
58
|
+
stat = File.stat(path)
|
59
|
+
(stat.mode & 0777).to_s(8)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "creates all directories and files with the correct permissions" do
|
63
|
+
expect(mode_of("dest_dir/sub1")).to eq "754"
|
64
|
+
expect(mode_of("dest_dir/sub1/aaa")).to eq "777"
|
65
|
+
expect(mode_of("dest_dir/sub1/zzz")).to eq "754"
|
66
|
+
expect(mode_of("dest_dir/sub1/zzz/file")).to eq "777"
|
67
|
+
expect(mode_of("dest_dir/sub2")).to eq "754"
|
68
|
+
expect(mode_of("dest_dir/sub2/aaa")).to eq "754"
|
69
|
+
expect(mode_of("dest_dir/sub2/aaa/file")).to eq "777"
|
70
|
+
expect(mode_of("dest_dir/sub2/zzz")).to eq "777"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -3,18 +3,8 @@ require 'support/shared/integration/integration_helper'
|
|
3
3
|
describe "Resource.action" do
|
4
4
|
include IntegrationSupport
|
5
5
|
|
6
|
-
def converge(str=nil, file=nil, line=nil, &block)
|
7
|
-
if block
|
8
|
-
super(&block)
|
9
|
-
else
|
10
|
-
super() do
|
11
|
-
eval(str, nil, file, line)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
6
|
shared_context "ActionJackson" do
|
17
|
-
it "
|
7
|
+
it "the default action is the first declared action" do
|
18
8
|
converge <<-EOM, __FILE__, __LINE__+1
|
19
9
|
#{resource_dsl} 'hi' do
|
20
10
|
foo 'foo!'
|
@@ -24,7 +14,7 @@ describe "Resource.action" do
|
|
24
14
|
expect(ActionJackson.succeeded).to eq true
|
25
15
|
end
|
26
16
|
|
27
|
-
it "
|
17
|
+
it "the action can access recipe DSL" do
|
28
18
|
converge <<-EOM, __FILE__, __LINE__+1
|
29
19
|
#{resource_dsl} 'hi' do
|
30
20
|
foo 'foo!'
|
@@ -35,7 +25,7 @@ describe "Resource.action" do
|
|
35
25
|
expect(ActionJackson.succeeded).to eq true
|
36
26
|
end
|
37
27
|
|
38
|
-
it "
|
28
|
+
it "the action can access attributes" do
|
39
29
|
converge <<-EOM, __FILE__, __LINE__+1
|
40
30
|
#{resource_dsl} 'hi' do
|
41
31
|
foo 'foo!'
|
@@ -46,7 +36,7 @@ describe "Resource.action" do
|
|
46
36
|
expect(ActionJackson.succeeded).to eq 'foo!'
|
47
37
|
end
|
48
38
|
|
49
|
-
it "
|
39
|
+
it "the action can access public methods" do
|
50
40
|
converge <<-EOM, __FILE__, __LINE__+1
|
51
41
|
#{resource_dsl} 'hi' do
|
52
42
|
foo 'foo!'
|
@@ -57,7 +47,7 @@ describe "Resource.action" do
|
|
57
47
|
expect(ActionJackson.succeeded).to eq 'foo_public!'
|
58
48
|
end
|
59
49
|
|
60
|
-
it "
|
50
|
+
it "the action can access protected methods" do
|
61
51
|
converge <<-EOM, __FILE__, __LINE__+1
|
62
52
|
#{resource_dsl} 'hi' do
|
63
53
|
foo 'foo!'
|
@@ -68,7 +58,7 @@ describe "Resource.action" do
|
|
68
58
|
expect(ActionJackson.succeeded).to eq 'foo_protected!'
|
69
59
|
end
|
70
60
|
|
71
|
-
it "
|
61
|
+
it "the action cannot access private methods" do
|
72
62
|
expect {
|
73
63
|
converge(<<-EOM, __FILE__, __LINE__+1)
|
74
64
|
#{resource_dsl} 'hi' do
|
@@ -80,7 +70,7 @@ describe "Resource.action" do
|
|
80
70
|
expect(ActionJackson.ran_action).to eq :access_private_method
|
81
71
|
end
|
82
72
|
|
83
|
-
it "
|
73
|
+
it "the action cannot access resource instance variables" do
|
84
74
|
converge <<-EOM, __FILE__, __LINE__+1
|
85
75
|
#{resource_dsl} 'hi' do
|
86
76
|
foo 'foo!'
|
@@ -91,7 +81,7 @@ describe "Resource.action" do
|
|
91
81
|
expect(ActionJackson.succeeded).to be_nil
|
92
82
|
end
|
93
83
|
|
94
|
-
it "
|
84
|
+
it "the action does not compile until the prior resource has converged" do
|
95
85
|
converge <<-EOM, __FILE__, __LINE__+1
|
96
86
|
ruby_block 'wow' do
|
97
87
|
block do
|
@@ -108,7 +98,7 @@ describe "Resource.action" do
|
|
108
98
|
expect(ActionJackson.succeeded).to eq 'ruby_block_converged!'
|
109
99
|
end
|
110
100
|
|
111
|
-
it "
|
101
|
+
it "the action's resources converge before the next resource converges" do
|
112
102
|
converge <<-EOM, __FILE__, __LINE__+1
|
113
103
|
#{resource_dsl} 'hi' do
|
114
104
|
foo 'foo!'
|
@@ -212,6 +202,11 @@ describe "Resource.action" do
|
|
212
202
|
let(:resource_dsl) { :action_jackson }
|
213
203
|
end
|
214
204
|
|
205
|
+
it "Can retrieve ancestors of action class without crashing" do
|
206
|
+
converge { action_jackson 'hi' }
|
207
|
+
expect { ActionJackson.action_class.ancestors.join(",") }.not_to raise_error
|
208
|
+
end
|
209
|
+
|
215
210
|
context "And 'action_jackgrandson' inheriting from ActionJackson and changing nothing" do
|
216
211
|
before(:context) {
|
217
212
|
class ActionJackgrandson < ActionJackson
|
@@ -224,7 +219,7 @@ describe "Resource.action" do
|
|
224
219
|
end
|
225
220
|
end
|
226
221
|
|
227
|
-
context "And 'action_jackalope' inheriting from ActionJackson with an extra attribute and
|
222
|
+
context "And 'action_jackalope' inheriting from ActionJackson with an extra attribute, action and custom method" do
|
228
223
|
before(:context) {
|
229
224
|
class ActionJackalope < ActionJackson
|
230
225
|
use_automatic_resource_name
|
@@ -238,6 +233,7 @@ describe "Resource.action" do
|
|
238
233
|
@bar
|
239
234
|
end
|
240
235
|
class <<self
|
236
|
+
attr_accessor :load_current_resource_ran
|
241
237
|
attr_accessor :jackalope_ran
|
242
238
|
end
|
243
239
|
action :access_jackalope do
|
@@ -253,6 +249,7 @@ describe "Resource.action" do
|
|
253
249
|
}
|
254
250
|
before do
|
255
251
|
ActionJackalope.jackalope_ran = nil
|
252
|
+
ActionJackalope.load_current_resource_ran = nil
|
256
253
|
end
|
257
254
|
|
258
255
|
context "action_jackson still behaves the same" do
|
@@ -261,7 +258,7 @@ describe "Resource.action" do
|
|
261
258
|
end
|
262
259
|
end
|
263
260
|
|
264
|
-
it "
|
261
|
+
it "the default action remains the same even though new actions were specified first" do
|
265
262
|
converge {
|
266
263
|
action_jackalope 'hi' do
|
267
264
|
foo 'foo!'
|
@@ -330,7 +327,7 @@ describe "Resource.action" do
|
|
330
327
|
end
|
331
328
|
end
|
332
329
|
}
|
333
|
-
it "
|
330
|
+
it "the default action is :nothing" do
|
334
331
|
converge {
|
335
332
|
no_action_jackson 'hi' do
|
336
333
|
foo 'foo!'
|
@@ -340,4 +337,27 @@ describe "Resource.action" do
|
|
340
337
|
expect(NoActionJackson.action_was).to eq [:nothing]
|
341
338
|
end
|
342
339
|
end
|
340
|
+
|
341
|
+
context "With a resource with action a-b-c d" do
|
342
|
+
before(:context) {
|
343
|
+
class WeirdActionJackson < Chef::Resource
|
344
|
+
use_automatic_resource_name
|
345
|
+
|
346
|
+
class <<self
|
347
|
+
attr_accessor :action_was
|
348
|
+
end
|
349
|
+
|
350
|
+
action "a-b-c d" do
|
351
|
+
WeirdActionJackson.action_was = action
|
352
|
+
end
|
353
|
+
end
|
354
|
+
}
|
355
|
+
|
356
|
+
it "Running the action works" do
|
357
|
+
expect_recipe {
|
358
|
+
weird_action_jackson 'hi'
|
359
|
+
}.to be_up_to_date
|
360
|
+
expect(WeirdActionJackson.action_was).to eq :"a-b-c d"
|
361
|
+
end
|
362
|
+
end
|
343
363
|
end
|
@@ -0,0 +1,423 @@
|
|
1
|
+
require 'support/shared/integration/integration_helper'
|
2
|
+
|
3
|
+
describe "Resource::ActionClass#converge_if_changed" do
|
4
|
+
include IntegrationSupport
|
5
|
+
|
6
|
+
module Namer
|
7
|
+
extend self
|
8
|
+
attr_accessor :current_index
|
9
|
+
def incrementing_value
|
10
|
+
@incrementing_value += 1
|
11
|
+
@incrementing_value
|
12
|
+
end
|
13
|
+
attr_writer :incrementing_value
|
14
|
+
end
|
15
|
+
|
16
|
+
before(:all) { Namer.current_index = 1 }
|
17
|
+
before { Namer.current_index += 1 }
|
18
|
+
before { Namer.incrementing_value = 0 }
|
19
|
+
|
20
|
+
context "when the resource has identity, state and control properties" do
|
21
|
+
let(:resource_name) { :"converge_if_changed_dsl#{Namer.current_index}" }
|
22
|
+
let(:resource_class) {
|
23
|
+
result = Class.new(Chef::Resource) do
|
24
|
+
def self.to_s; resource_name; end
|
25
|
+
def self.inspect; resource_name.inspect; end
|
26
|
+
property :identity1, identity: true, default: 'default_identity1'
|
27
|
+
property :control1, desired_state: false, default: 'default_control1'
|
28
|
+
property :state1, default: 'default_state1'
|
29
|
+
property :state2, default: 'default_state2'
|
30
|
+
attr_accessor :converged
|
31
|
+
def initialize(*args)
|
32
|
+
super
|
33
|
+
@converged = 0
|
34
|
+
end
|
35
|
+
end
|
36
|
+
result.resource_name resource_name
|
37
|
+
result
|
38
|
+
}
|
39
|
+
let(:converged_recipe) { converge(converge_recipe) }
|
40
|
+
let(:resource) { converged_recipe.resources.first }
|
41
|
+
|
42
|
+
context "and converge_if_changed with no parameters" do
|
43
|
+
before :each do
|
44
|
+
resource_class.action :create do
|
45
|
+
converge_if_changed do
|
46
|
+
new_resource.converged += 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "and current_resource with state1=current, state2=current" do
|
52
|
+
before :each do
|
53
|
+
resource_class.load_current_value do
|
54
|
+
state1 'current_state1'
|
55
|
+
state2 'current_state2'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "and nothing is set" do
|
60
|
+
let(:converge_recipe) { "#{resource_name} 'blah'" }
|
61
|
+
|
62
|
+
it "the resource updates nothing" do
|
63
|
+
expect(resource.converged).to eq 0
|
64
|
+
expect(resource.updated?).to be_falsey
|
65
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
66
|
+
* #{resource_name}[blah] action create (up to date)
|
67
|
+
EOM
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "and state1 is set to a new value" do
|
72
|
+
let(:converge_recipe) {
|
73
|
+
<<-EOM
|
74
|
+
#{resource_name} 'blah' do
|
75
|
+
state1 'new_state1'
|
76
|
+
end
|
77
|
+
EOM
|
78
|
+
}
|
79
|
+
|
80
|
+
it "the resource updates state1" do
|
81
|
+
expect(resource.converged).to eq 1
|
82
|
+
expect(resource.updated?).to be_truthy
|
83
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
84
|
+
* #{resource_name}[blah] action create
|
85
|
+
- update default_identity1
|
86
|
+
- set state1 to "new_state1" (was "current_state1")
|
87
|
+
EOM
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "and state1 and state2 are set to new values" do
|
92
|
+
let(:converge_recipe) {
|
93
|
+
<<-EOM
|
94
|
+
#{resource_name} 'blah' do
|
95
|
+
state1 'new_state1'
|
96
|
+
state2 'new_state2'
|
97
|
+
end
|
98
|
+
EOM
|
99
|
+
}
|
100
|
+
|
101
|
+
it "the resource updates state1 and state2" do
|
102
|
+
expect(resource.converged).to eq 1
|
103
|
+
expect(resource.updated?).to be_truthy
|
104
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
105
|
+
* #{resource_name}[blah] action create
|
106
|
+
- update default_identity1
|
107
|
+
- set state1 to "new_state1" (was "current_state1")
|
108
|
+
- set state2 to "new_state2" (was "current_state2")
|
109
|
+
EOM
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "and state1 is set to its current value but state2 is set to a new value" do
|
114
|
+
let(:converge_recipe) {
|
115
|
+
<<-EOM
|
116
|
+
#{resource_name} 'blah' do
|
117
|
+
state1 'current_state1'
|
118
|
+
state2 'new_state2'
|
119
|
+
end
|
120
|
+
EOM
|
121
|
+
}
|
122
|
+
|
123
|
+
it "the resource updates state2" do
|
124
|
+
expect(resource.converged).to eq 1
|
125
|
+
expect(resource.updated?).to be_truthy
|
126
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
127
|
+
* #{resource_name}[blah] action create
|
128
|
+
- update default_identity1
|
129
|
+
- set state2 to "new_state2" (was "current_state2")
|
130
|
+
EOM
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "and state1 and state2 are set to their current values" do
|
135
|
+
let(:converge_recipe) {
|
136
|
+
<<-EOM
|
137
|
+
#{resource_name} 'blah' do
|
138
|
+
state1 'current_state1'
|
139
|
+
state2 'current_state2'
|
140
|
+
end
|
141
|
+
EOM
|
142
|
+
}
|
143
|
+
|
144
|
+
it "the resource updates nothing" do
|
145
|
+
expect(resource.converged).to eq 0
|
146
|
+
expect(resource.updated?).to be_falsey
|
147
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
148
|
+
* #{resource_name}[blah] action create (up to date)
|
149
|
+
EOM
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context "and identity1 and control1 are set to new values" do
|
154
|
+
let(:converge_recipe) {
|
155
|
+
<<-EOM
|
156
|
+
#{resource_name} 'blah' do
|
157
|
+
identity1 'new_identity1'
|
158
|
+
control1 'new_control1'
|
159
|
+
end
|
160
|
+
EOM
|
161
|
+
}
|
162
|
+
|
163
|
+
# Because the identity value is copied over to the new resource, by
|
164
|
+
# default they do not register as "changed"
|
165
|
+
it "the resource updates nothing" do
|
166
|
+
expect(resource.converged).to eq 0
|
167
|
+
expect(resource.updated?).to be_falsey
|
168
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
169
|
+
* #{resource_name}[blah] action create (up to date)
|
170
|
+
EOM
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context "and current_resource with identity1=current, control1=current" do
|
176
|
+
before :each do
|
177
|
+
resource_class.load_current_value do
|
178
|
+
identity1 'current_identity1'
|
179
|
+
control1 'current_control1'
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context "and identity1 and control1 are set to new values" do
|
184
|
+
let(:converge_recipe) {
|
185
|
+
<<-EOM
|
186
|
+
#{resource_name} 'blah' do
|
187
|
+
identity1 'new_identity1'
|
188
|
+
control1 'new_control1'
|
189
|
+
end
|
190
|
+
EOM
|
191
|
+
}
|
192
|
+
|
193
|
+
# Control values are not desired state and are therefore not considered
|
194
|
+
# a reason for converging.
|
195
|
+
it "the resource updates identity1" do
|
196
|
+
expect(resource.converged).to eq 1
|
197
|
+
expect(resource.updated?).to be_truthy
|
198
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
199
|
+
* #{resource_name}[blah] action create
|
200
|
+
- update current_identity1
|
201
|
+
- set identity1 to "new_identity1" (was "current_identity1")
|
202
|
+
EOM
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context "and has no current_resource" do
|
208
|
+
before :each do
|
209
|
+
resource_class.load_current_value do
|
210
|
+
current_value_does_not_exist!
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context "and nothing is set" do
|
215
|
+
let(:converge_recipe) { "#{resource_name} 'blah'" }
|
216
|
+
|
217
|
+
it "the resource is created" do
|
218
|
+
expect(resource.converged).to eq 1
|
219
|
+
expect(resource.updated?).to be_truthy
|
220
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
221
|
+
* #{resource_name}[blah] action create
|
222
|
+
- create default_identity1
|
223
|
+
- set identity1 to "default_identity1" (default value)
|
224
|
+
- set state1 to "default_state1" (default value)
|
225
|
+
- set state2 to "default_state2" (default value)
|
226
|
+
EOM
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context "and state1 and state2 are set" do
|
231
|
+
let(:converge_recipe) {
|
232
|
+
<<-EOM
|
233
|
+
#{resource_name} 'blah' do
|
234
|
+
state1 'new_state1'
|
235
|
+
state2 'new_state2'
|
236
|
+
end
|
237
|
+
EOM
|
238
|
+
}
|
239
|
+
|
240
|
+
it "the resource is created" do
|
241
|
+
expect(resource.converged).to eq 1
|
242
|
+
expect(resource.updated?).to be_truthy
|
243
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
244
|
+
* #{resource_name}[blah] action create
|
245
|
+
- create default_identity1
|
246
|
+
- set identity1 to "default_identity1" (default value)
|
247
|
+
- set state1 to "new_state1"
|
248
|
+
- set state2 to "new_state2"
|
249
|
+
EOM
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
context "and separate converge_if_changed :state1 and converge_if_changed :state2" do
|
256
|
+
before :each do
|
257
|
+
resource_class.action :create do
|
258
|
+
converge_if_changed :state1 do
|
259
|
+
new_resource.converged += 1
|
260
|
+
end
|
261
|
+
converge_if_changed :state2 do
|
262
|
+
new_resource.converged += 1
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
context "and current_resource with state1=current, state2=current" do
|
268
|
+
before :each do
|
269
|
+
resource_class.load_current_value do
|
270
|
+
state1 'current_state1'
|
271
|
+
state2 'current_state2'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context "and nothing is set" do
|
276
|
+
let(:converge_recipe) { "#{resource_name} 'blah'" }
|
277
|
+
|
278
|
+
it "the resource updates nothing" do
|
279
|
+
expect(resource.converged).to eq 0
|
280
|
+
expect(resource.updated?).to be_falsey
|
281
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
282
|
+
* #{resource_name}[blah] action create (up to date)
|
283
|
+
EOM
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
context "and state1 is set to a new value" do
|
288
|
+
|
289
|
+
let(:converge_recipe) {
|
290
|
+
<<-EOM
|
291
|
+
#{resource_name} 'blah' do
|
292
|
+
state1 'new_state1'
|
293
|
+
end
|
294
|
+
EOM
|
295
|
+
}
|
296
|
+
|
297
|
+
it "the resource updates state1" do
|
298
|
+
expect(resource.converged).to eq 1
|
299
|
+
expect(resource.updated?).to be_truthy
|
300
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
301
|
+
* #{resource_name}[blah] action create
|
302
|
+
- update default_identity1
|
303
|
+
- set state1 to "new_state1" (was "current_state1")
|
304
|
+
EOM
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context "and state1 and state2 are set to new values" do
|
309
|
+
let(:converge_recipe) {
|
310
|
+
<<-EOM
|
311
|
+
#{resource_name} 'blah' do
|
312
|
+
state1 'new_state1'
|
313
|
+
state2 'new_state2'
|
314
|
+
end
|
315
|
+
EOM
|
316
|
+
}
|
317
|
+
|
318
|
+
it "the resource updates state1 and state2" do
|
319
|
+
expect(resource.converged).to eq 2
|
320
|
+
expect(resource.updated?).to be_truthy
|
321
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
322
|
+
* #{resource_name}[blah] action create
|
323
|
+
- update default_identity1
|
324
|
+
- set state1 to "new_state1" (was "current_state1")
|
325
|
+
- update default_identity1
|
326
|
+
- set state2 to "new_state2" (was "current_state2")
|
327
|
+
EOM
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context "and state1 is set to its current value but state2 is set to a new value" do
|
332
|
+
let(:converge_recipe) {
|
333
|
+
<<-EOM
|
334
|
+
#{resource_name} 'blah' do
|
335
|
+
state1 'current_state1'
|
336
|
+
state2 'new_state2'
|
337
|
+
end
|
338
|
+
EOM
|
339
|
+
}
|
340
|
+
|
341
|
+
it "the resource updates state2" do
|
342
|
+
expect(resource.converged).to eq 1
|
343
|
+
expect(resource.updated?).to be_truthy
|
344
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
345
|
+
* #{resource_name}[blah] action create
|
346
|
+
- update default_identity1
|
347
|
+
- set state2 to "new_state2" (was "current_state2")
|
348
|
+
EOM
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
context "and state1 and state2 are set to their current values" do
|
353
|
+
let(:converge_recipe) {
|
354
|
+
<<-EOM
|
355
|
+
#{resource_name} 'blah' do
|
356
|
+
state1 'current_state1'
|
357
|
+
state2 'current_state2'
|
358
|
+
end
|
359
|
+
EOM
|
360
|
+
}
|
361
|
+
|
362
|
+
it "the resource updates nothing" do
|
363
|
+
expect(resource.converged).to eq 0
|
364
|
+
expect(resource.updated?).to be_falsey
|
365
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
366
|
+
* #{resource_name}[blah] action create (up to date)
|
367
|
+
EOM
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
context "and no current_resource" do
|
373
|
+
before :each do
|
374
|
+
resource_class.load_current_value do
|
375
|
+
current_value_does_not_exist!
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
context "and nothing is set" do
|
380
|
+
let(:converge_recipe) {
|
381
|
+
"#{resource_name} 'blah'"
|
382
|
+
}
|
383
|
+
|
384
|
+
it "the resource is created" do
|
385
|
+
expect(resource.converged).to eq 2
|
386
|
+
expect(resource.updated?).to be_truthy
|
387
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
388
|
+
* #{resource_name}[blah] action create
|
389
|
+
- create default_identity1
|
390
|
+
- set state1 to "default_state1" (default value)
|
391
|
+
- create default_identity1
|
392
|
+
- set state2 to "default_state2" (default value)
|
393
|
+
EOM
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
context "and state1 and state2 are set to new values" do
|
398
|
+
let(:converge_recipe) {
|
399
|
+
<<-EOM
|
400
|
+
#{resource_name} 'blah' do
|
401
|
+
state1 'new_state1'
|
402
|
+
state2 'new_state2'
|
403
|
+
end
|
404
|
+
EOM
|
405
|
+
}
|
406
|
+
|
407
|
+
it "the resource is created" do
|
408
|
+
expect(resource.converged).to eq 2
|
409
|
+
expect(resource.updated?).to be_truthy
|
410
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
411
|
+
* #{resource_name}[blah] action create
|
412
|
+
- create default_identity1
|
413
|
+
- set state1 to "new_state1"
|
414
|
+
- create default_identity1
|
415
|
+
- set state2 to "new_state2"
|
416
|
+
EOM
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
end
|
423
|
+
end
|