chef 15.11.3-universal-mingw32 → 16.1.16-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -7
- data/README.md +1 -1
- data/Rakefile +44 -16
- data/chef.gemspec +6 -4
- data/distro/powershell/chef/chef.psm1 +3 -3
- data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
- data/lib/chef/action_collection.rb +16 -5
- data/lib/chef/application.rb +33 -54
- data/lib/chef/application/apply.rb +18 -1
- data/lib/chef/application/base.rb +8 -3
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_class.rb +4 -4
- data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +6 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +3 -3
- data/lib/chef/client.rb +16 -14
- data/lib/chef/config.rb +1 -1
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook/gem_installer.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +45 -22
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +38 -3
- data/lib/chef/data_collector.rb +1 -1
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/data_collector/run_end_message.rb +7 -1
- data/lib/chef/decorator/lazy_array.rb +2 -2
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/digester.rb +4 -4
- data/lib/chef/dist.rb +8 -0
- data/lib/chef/dsl/chef_vault.rb +84 -0
- data/lib/chef/dsl/declare_resource.rb +7 -5
- data/lib/chef/dsl/platform_introspection.rb +3 -2
- data/lib/chef/dsl/recipe.rb +7 -12
- data/lib/chef/dsl/universal.rb +3 -7
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/formatters/base.rb +1 -1
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/formatters/indentable_output_stream.rb +7 -16
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/decompressor.rb +1 -1
- data/lib/chef/http/http_request.rb +3 -2
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife.rb +2 -4
- data/lib/chef/knife/acl_add.rb +57 -0
- data/lib/chef/knife/acl_base.rb +183 -0
- data/lib/chef/knife/acl_bulk_add.rb +78 -0
- data/lib/chef/knife/acl_bulk_remove.rb +83 -0
- data/lib/chef/knife/acl_remove.rb +62 -0
- data/lib/chef/knife/acl_show.rb +56 -0
- data/lib/chef/knife/bootstrap.rb +84 -90
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +2 -2
- data/lib/chef/knife/bootstrap/client_builder.rb +2 -2
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +11 -11
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +12 -12
- data/lib/chef/knife/core/bootstrap_context.rb +63 -60
- data/lib/chef/knife/core/generic_presenter.rb +4 -3
- data/lib/chef/knife/core/hashed_command_loader.rb +1 -1
- data/lib/chef/knife/core/node_presenter.rb +2 -2
- data/lib/chef/knife/core/status_presenter.rb +5 -5
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/ui.rb +17 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +44 -42
- data/lib/chef/knife/data_bag_secret_options.rb +18 -45
- data/lib/chef/knife/group_add.rb +55 -0
- data/lib/chef/knife/{cookbook_site_download.rb → group_create.rb} +21 -12
- data/lib/chef/knife/group_destroy.rb +53 -0
- data/lib/chef/knife/{cookbook_site_list.rb → group_list.rb} +14 -11
- data/lib/chef/knife/group_remove.rb +56 -0
- data/lib/chef/knife/{cookbook_site_install.rb → group_show.rb} +21 -12
- data/lib/chef/knife/key_create_base.rb +1 -1
- data/lib/chef/knife/key_edit_base.rb +1 -1
- data/lib/chef/knife/ssh.rb +12 -31
- data/lib/chef/knife/status.rb +3 -3
- data/lib/chef/knife/supermarket_download.rb +1 -2
- data/lib/chef/knife/supermarket_install.rb +2 -3
- data/lib/chef/knife/supermarket_list.rb +1 -2
- data/lib/chef/knife/supermarket_search.rb +1 -2
- data/lib/chef/knife/supermarket_share.rb +1 -2
- data/lib/chef/knife/supermarket_show.rb +1 -2
- data/lib/chef/knife/supermarket_unshare.rb +1 -2
- data/lib/chef/knife/{cookbook_site_show.rb → user_dissociate.rb} +15 -13
- data/lib/chef/knife/{cookbook_site_search.rb → user_invite_add.rb} +16 -13
- data/lib/chef/knife/user_invite_list.rb +34 -0
- data/lib/chef/knife/user_invite_rescind.rb +63 -0
- data/lib/chef/knife/yaml_convert.rb +91 -0
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/mixin/checksum.rb +0 -1
- data/lib/chef/mixin/openssl_helper.rb +4 -4
- data/lib/chef/mixin/powershell_exec.rb +10 -1
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/mixin/properties.rb +16 -2
- data/lib/chef/mixin/shell_out.rb +1 -5
- data/lib/chef/monkey_patches/net_http.rb +0 -4
- data/lib/chef/node.rb +18 -6
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node/immutable_collections.rb +1 -1
- data/lib/chef/node/mixin/immutablize_array.rb +4 -0
- data/lib/chef/node/mixin/immutablize_hash.rb +3 -0
- data/lib/chef/node_map.rb +5 -31
- data/lib/chef/platform/priority_map.rb +4 -4
- data/lib/chef/platform/query_helpers.rb +6 -34
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/powershell.rb +14 -0
- data/lib/chef/property.rb +24 -6
- data/lib/chef/provider.rb +40 -6
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/directory.rb +3 -3
- data/lib/chef/provider/dsc_resource.rb +1 -1
- data/lib/chef/provider/dsc_script.rb +1 -1
- data/lib/chef/provider/execute.rb +3 -9
- data/lib/chef/provider/file.rb +6 -6
- data/lib/chef/provider/git.rb +84 -27
- data/lib/chef/provider/group.rb +4 -4
- data/lib/chef/provider/http_request.rb +6 -6
- data/lib/chef/provider/ifconfig.rb +4 -4
- data/lib/chef/provider/launchd.rb +45 -64
- data/lib/chef/provider/link.rb +2 -2
- data/lib/chef/provider/mount.rb +5 -5
- data/lib/chef/provider/osx_profile.rb +7 -3
- data/lib/chef/provider/package.rb +2 -2
- data/lib/chef/provider/package/cab.rb +5 -6
- data/lib/chef/provider/package/chocolatey.rb +1 -3
- data/lib/chef/provider/package/dnf.rb +66 -10
- data/lib/chef/provider/package/dnf/dnf_helper.py +85 -26
- data/lib/chef/provider/package/dnf/python_helper.rb +79 -36
- data/lib/chef/provider/package/dnf/version.rb +5 -1
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +2 -1
- data/lib/chef/provider/package/homebrew.rb +107 -43
- data/lib/chef/provider/package/macports.rb +0 -2
- data/lib/chef/provider/package/msu.rb +4 -1
- data/lib/chef/provider/package/pacman.rb +25 -34
- data/lib/chef/provider/package/portage.rb +1 -0
- data/lib/chef/provider/package/powershell.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +30 -3
- data/lib/chef/provider/package/windows.rb +29 -53
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +1 -9
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +0 -1
- data/lib/chef/provider/powershell_script.rb +5 -11
- data/lib/chef/provider/registry_key.rb +4 -4
- data/lib/chef/provider/remote_directory.rb +5 -5
- data/lib/chef/provider/remote_file/ftp.rb +3 -2
- data/lib/chef/provider/remote_file/local_file.rb +2 -1
- data/lib/chef/provider/remote_file/sftp.rb +3 -2
- data/lib/chef/provider/route.rb +5 -3
- data/lib/chef/provider/ruby_block.rb +1 -1
- data/lib/chef/provider/script.rb +2 -2
- data/lib/chef/provider/service.rb +8 -8
- data/lib/chef/provider/service/aixinit.rb +1 -1
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +30 -28
- data/lib/chef/provider/service/macosx.rb +16 -10
- data/lib/chef/provider/service/systemd.rb +12 -12
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/service/windows.rb +5 -11
- data/lib/chef/provider/subversion.rb +25 -5
- data/lib/chef/provider/systemd_unit.rb +26 -25
- data/lib/chef/provider/user.rb +6 -6
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +6 -6
- data/lib/chef/provider/user/mac.rb +20 -15
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/provider/windows_env.rb +3 -3
- data/lib/chef/provider/windows_script.rb +2 -2
- data/lib/chef/provider/windows_task.rb +10 -10
- data/lib/chef/providers.rb +0 -6
- data/lib/chef/recipe.rb +36 -0
- data/lib/chef/resource.rb +44 -57
- data/lib/chef/resource/action_class.rb +24 -22
- data/lib/chef/resource/alternatives.rb +210 -0
- data/lib/chef/resource/apt_package.rb +33 -3
- data/lib/chef/resource/apt_preference.rb +103 -7
- data/lib/chef/resource/apt_repository.rb +357 -18
- data/lib/chef/resource/apt_update.rb +58 -5
- data/lib/chef/resource/archive_file.rb +6 -5
- data/lib/chef/resource/bash.rb +3 -1
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +10 -2
- data/lib/chef/resource/breakpoint.rb +1 -2
- data/lib/chef/resource/build_essential.rb +49 -51
- data/lib/chef/resource/cab_package.rb +9 -2
- data/lib/chef/resource/chef_client_cron.rb +228 -0
- data/lib/chef/resource/chef_client_scheduled_task.rb +201 -0
- data/lib/chef/resource/chef_client_systemd_timer.rb +180 -0
- data/lib/chef/resource/chef_gem.rb +15 -18
- data/lib/chef/resource/chef_handler.rb +5 -4
- data/lib/chef/resource/chef_sleep.rb +7 -5
- data/lib/chef/resource/chef_vault_secret.rb +135 -0
- data/lib/chef/resource/chocolatey_config.rb +8 -4
- data/lib/chef/resource/chocolatey_feature.rb +7 -4
- data/lib/chef/resource/chocolatey_package.rb +7 -4
- data/lib/chef/resource/chocolatey_source.rb +7 -4
- data/lib/chef/resource/cookbook_file.rb +4 -3
- data/lib/chef/resource/cron.rb +34 -80
- data/lib/chef/resource/cron_access.rb +10 -6
- data/lib/chef/resource/cron_d.rb +44 -95
- data/lib/chef/resource/csh.rb +3 -1
- data/lib/chef/resource/directory.rb +3 -3
- data/lib/chef/resource/dmg_package.rb +22 -19
- data/lib/chef/resource/dnf_package.rb +3 -4
- data/lib/chef/resource/dpkg_package.rb +3 -2
- data/lib/chef/resource/dsc_resource.rb +6 -4
- data/lib/chef/resource/dsc_script.rb +3 -2
- data/lib/chef/resource/execute.rb +15 -14
- data/lib/chef/resource/file.rb +14 -9
- data/lib/chef/resource/freebsd_package.rb +3 -2
- data/lib/chef/resource/gem_package.rb +19 -11
- data/lib/chef/resource/group.rb +5 -2
- data/lib/chef/resource/helpers/cron_validations.rb +98 -0
- data/lib/chef/resource/homebrew_cask.rb +3 -2
- data/lib/chef/resource/homebrew_package.rb +5 -3
- data/lib/chef/resource/homebrew_tap.rb +3 -2
- data/lib/chef/resource/hostname.rb +26 -20
- data/lib/chef/resource/http_request.rb +1 -2
- data/lib/chef/resource/ifconfig.rb +8 -8
- data/lib/chef/resource/ips_package.rb +11 -3
- data/lib/chef/resource/kernel_module.rb +30 -30
- data/lib/chef/resource/ksh.rb +3 -1
- data/lib/chef/resource/launchd.rb +3 -3
- data/lib/chef/resource/link.rb +5 -27
- data/lib/chef/resource/locale.rb +60 -26
- data/lib/chef/resource/log.rb +13 -2
- data/lib/chef/resource/lwrp_base.rb +1 -1
- data/lib/chef/resource/macos_userdefaults.rb +18 -10
- data/lib/chef/resource/macosx_service.rb +3 -2
- data/lib/chef/resource/macports_package.rb +10 -2
- data/lib/chef/resource/mdadm.rb +63 -3
- data/lib/chef/resource/mount.rb +4 -1
- data/lib/chef/resource/msu_package.rb +19 -2
- data/lib/chef/resource/notify_group.rb +8 -3
- data/lib/chef/resource/ohai.rb +20 -4
- data/lib/chef/resource/ohai_hint.rb +4 -13
- data/lib/chef/resource/openbsd_package.rb +10 -2
- data/lib/chef/resource/openssl_dhparam.rb +11 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +24 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +22 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +21 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +23 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +38 -2
- data/lib/chef/resource/openssl_x509_crl.rb +13 -2
- data/lib/chef/resource/openssl_x509_request.rb +38 -2
- data/lib/chef/resource/osx_profile.rb +4 -3
- data/lib/chef/resource/package.rb +3 -2
- data/lib/chef/resource/pacman_package.rb +3 -2
- data/lib/chef/resource/paludis_package.rb +13 -4
- data/lib/chef/resource/perl.rb +3 -1
- data/lib/chef/resource/plist.rb +207 -0
- data/lib/chef/resource/portage_package.rb +14 -4
- data/lib/chef/resource/powershell_package.rb +2 -4
- data/lib/chef/resource/powershell_package_source.rb +4 -2
- data/lib/chef/resource/powershell_script.rb +8 -18
- data/lib/chef/resource/python.rb +3 -1
- data/lib/chef/resource/reboot.rb +1 -2
- data/lib/chef/resource/registry_key.rb +2 -3
- data/lib/chef/resource/remote_directory.rb +3 -1
- data/lib/chef/resource/remote_file.rb +3 -2
- data/lib/chef/resource/rhsm_errata.rb +1 -4
- data/lib/chef/resource/rhsm_errata_level.rb +1 -2
- data/lib/chef/resource/rhsm_register.rb +3 -3
- data/lib/chef/resource/rhsm_repo.rb +4 -3
- data/lib/chef/resource/rhsm_subscription.rb +5 -4
- data/lib/chef/resource/route.rb +6 -2
- data/lib/chef/resource/rpm_package.rb +13 -3
- data/lib/chef/resource/ruby.rb +3 -1
- data/lib/chef/resource/ruby_block.rb +2 -5
- data/lib/chef/resource/scm/_scm.rb +49 -0
- data/lib/chef/resource/{scm.rb → scm/git.rb} +16 -30
- data/lib/chef/resource/{subversion.rb → scm/subversion.rb} +10 -7
- data/lib/chef/resource/script.rb +7 -4
- data/lib/chef/resource/service.rb +7 -8
- data/lib/chef/resource/smartos_package.rb +10 -2
- data/lib/chef/resource/snap_package.rb +4 -2
- data/lib/chef/resource/solaris_package.rb +10 -2
- data/lib/chef/resource/ssh_known_hosts_entry.rb +6 -3
- data/lib/chef/resource/sudo.rb +11 -11
- data/lib/chef/resource/support/cron.d.erb +1 -1
- data/lib/chef/resource/support/cron_access.erb +1 -1
- data/lib/chef/resource/support/sudoer.erb +1 -2
- data/lib/chef/resource/support/ulimit.erb +41 -0
- data/lib/chef/resource/swap_file.rb +7 -5
- data/lib/chef/resource/sysctl.rb +63 -4
- data/lib/chef/resource/systemd_unit.rb +6 -4
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +8 -19
- data/lib/chef/resource/user.rb +3 -5
- data/lib/chef/resource/user/aix_user.rb +0 -2
- data/lib/chef/resource/user/dscl_user.rb +1 -1
- data/lib/chef/resource/user/linux_user.rb +0 -2
- data/lib/chef/resource/user/mac_user.rb +1 -1
- data/lib/chef/resource/user/pw_user.rb +0 -2
- data/lib/chef/resource/user/solaris_user.rb +0 -2
- data/lib/chef/resource/user/windows_user.rb +0 -2
- data/lib/chef/resource/user_ulimit.rb +116 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +20 -7
- data/lib/chef/resource/windows_auto_run.rb +2 -3
- data/lib/chef/resource/windows_certificate.rb +3 -3
- data/lib/chef/resource/windows_dfs_folder.rb +1 -2
- data/lib/chef/resource/windows_dfs_namespace.rb +1 -2
- data/lib/chef/resource/windows_dfs_server.rb +2 -3
- data/lib/chef/resource/windows_dns_record.rb +0 -1
- data/lib/chef/resource/windows_dns_zone.rb +0 -1
- data/lib/chef/resource/windows_env.rb +12 -4
- data/lib/chef/resource/windows_feature.rb +59 -4
- data/lib/chef/resource/windows_feature_dism.rb +24 -24
- data/lib/chef/resource/windows_feature_powershell.rb +44 -78
- data/lib/chef/resource/windows_firewall_rule.rb +121 -8
- data/lib/chef/resource/windows_font.rb +10 -2
- data/lib/chef/resource/windows_package.rb +76 -7
- data/lib/chef/resource/windows_pagefile.rb +31 -4
- data/lib/chef/resource/windows_path.rb +18 -2
- data/lib/chef/resource/windows_printer.rb +26 -7
- data/lib/chef/resource/windows_printer_port.rb +29 -2
- data/lib/chef/resource/windows_script.rb +3 -4
- data/lib/chef/resource/windows_security_policy.rb +119 -0
- data/lib/chef/resource/windows_service.rb +46 -32
- data/lib/chef/resource/windows_share.rb +22 -6
- data/lib/chef/resource/windows_shortcut.rb +13 -3
- data/lib/chef/resource/windows_task.rb +129 -16
- data/lib/chef/resource/windows_uac.rb +20 -2
- data/lib/chef/resource/windows_user_privilege.rb +199 -0
- data/lib/chef/resource/windows_workgroup.rb +19 -4
- data/lib/chef/resource/yum_package.rb +91 -7
- data/lib/chef/resource/yum_repository.rb +30 -12
- data/lib/chef/resource/zypper_package.rb +32 -5
- data/lib/chef/resource/zypper_repository.rb +19 -6
- data/lib/chef/resource_builder.rb +8 -0
- data/lib/chef/resource_inspector.rb +3 -2
- data/lib/chef/resource_resolver.rb +7 -14
- data/lib/chef/resources.rb +11 -3
- data/lib/chef/run_context/cookbook_compiler.rb +29 -5
- data/lib/chef/scan_access_control.rb +1 -1
- data/lib/chef/shell.rb +22 -0
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +2 -2
- data/lib/chef/win32/api/error.rb +3 -1
- data/lib/chef/win32/api/file.rb +1 -1
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/win32/api/security.rb +6 -0
- data/lib/chef/win32/file.rb +1 -9
- data/lib/chef/win32/mutex.rb +1 -1
- data/lib/chef/win32/net.rb +1 -0
- data/lib/chef/win32/security.rb +40 -2
- data/lib/chef/win32/security/sid.rb +4 -4
- data/spec/functional/assets/inittest +8 -7
- data/spec/functional/knife/ssh_spec.rb +23 -19
- data/spec/functional/resource/cron_spec.rb +10 -29
- data/spec/functional/resource/dnf_package_spec.rb +441 -156
- data/spec/functional/resource/git_spec.rb +184 -134
- data/spec/functional/resource/insserv_spec.rb +1 -1
- data/spec/functional/resource/launchd_spec.rb +232 -0
- data/spec/functional/resource/link_spec.rb +3 -3
- data/spec/functional/resource/locale_spec.rb +13 -2
- data/spec/functional/resource/msu_package_spec.rb +5 -2
- data/spec/functional/resource/powershell_script_spec.rb +7 -68
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/windows_security_policy_spec.rb +90 -0
- data/spec/functional/resource/windows_task_spec.rb +4 -4
- data/spec/functional/resource/windows_user_privilege_spec.rb +193 -0
- data/spec/functional/run_lock_spec.rb +1 -1
- data/spec/functional/shell_spec.rb +1 -1
- data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/registry_spec.rb +0 -6
- data/spec/functional/win32/security_spec.rb +22 -0
- data/spec/integration/client/client_spec.rb +123 -2
- data/spec/integration/knife/cookbook_show_spec.rb +28 -26
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +34 -6
- data/spec/integration/knife/redirection_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +32 -3
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +3 -3
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +49 -20
- data/spec/integration/recipes/notifying_block_spec.rb +8 -5
- data/spec/integration/recipes/provider_choice.rb +2 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +45 -143
- data/spec/integration/recipes/resource_action_spec.rb +16 -11
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +1 -1
- data/spec/integration/recipes/resource_load_spec.rb +133 -12
- data/spec/integration/recipes/use_partial_spec.rb +112 -0
- data/spec/integration/solo/solo_spec.rb +3 -3
- data/spec/spec_helper.rb +18 -3
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/lib/chef/resource/zen_follower.rb +2 -0
- data/spec/support/platform_helpers.rb +2 -20
- data/spec/support/recipe_dsl_helper.rb +83 -0
- data/spec/support/shared/functional/http.rb +2 -2
- data/spec/support/shared/functional/windows_script.rb +3 -16
- data/spec/support/shared/integration/knife_support.rb +9 -6
- data/spec/support/shared/unit/mock_shellout.rb +1 -1
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +4 -4
- data/spec/unit/application/apply_spec.rb +3 -0
- data/spec/unit/application/client_spec.rb +5 -1
- data/spec/unit/application_spec.rb +1 -2
- data/spec/unit/client_spec.rb +7 -5
- data/spec/unit/cookbook/gem_installer_spec.rb +2 -2
- data/spec/unit/cookbook/metadata_spec.rb +38 -19
- data/spec/unit/data_collector_spec.rb +39 -18
- data/spec/unit/file_access_control_spec.rb +1 -1
- data/spec/unit/json_compat_spec.rb +1 -1
- data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +15 -15
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +9 -9
- data/spec/unit/knife/bootstrap_spec.rb +20 -38
- data/spec/unit/knife/cookbook_show_spec.rb +1 -0
- data/spec/unit/knife/core/bootstrap_context_spec.rb +23 -43
- data/spec/unit/knife/core/ui_spec.rb +16 -0
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +9 -63
- data/spec/unit/knife/data_bag_secret_options_spec.rb +22 -14
- data/spec/unit/knife/ssh_spec.rb +8 -111
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife_spec.rb +18 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +4 -4
- data/spec/unit/mixin/powershell_exec_spec.rb +10 -0
- data/spec/unit/mixin/shell_out_spec.rb +25 -31
- data/spec/unit/node/attribute_spec.rb +3 -3
- data/spec/unit/node_spec.rb +24 -0
- data/spec/unit/platform/query_helpers_spec.rb +0 -143
- data/spec/unit/property/state_spec.rb +12 -7
- data/spec/unit/property/validation_spec.rb +25 -1
- data/spec/unit/property_spec.rb +12 -9
- data/spec/unit/provider/apt_preference_spec.rb +14 -10
- data/spec/unit/provider/apt_repository_spec.rb +34 -36
- data/spec/unit/provider/apt_update_spec.rb +12 -11
- data/spec/unit/provider/cookbook_file_spec.rb +4 -4
- data/spec/unit/provider/cron_spec.rb +2 -2
- data/spec/unit/provider/directory_spec.rb +4 -15
- data/spec/unit/provider/file_spec.rb +4 -4
- data/spec/unit/provider/git_spec.rb +41 -1
- data/spec/unit/provider/group/groupadd_spec.rb +1 -1
- data/spec/unit/provider/launchd_spec.rb +8 -50
- data/spec/unit/provider/link_spec.rb +0 -1
- data/spec/unit/provider/log_spec.rb +3 -3
- data/spec/unit/provider/mdadm_spec.rb +3 -3
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
- data/spec/unit/provider/package/homebrew_spec.rb +280 -174
- data/spec/unit/provider/package/pacman_spec.rb +65 -147
- data/spec/unit/provider/package/portage_spec.rb +2 -2
- data/spec/unit/provider/package/powershell_spec.rb +3 -2
- data/spec/unit/provider/package/rubygems_spec.rb +211 -26
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/powershell_script_spec.rb +21 -61
- data/spec/unit/provider/remote_file_spec.rb +3 -4
- data/spec/unit/provider/service/debian_service_spec.rb +34 -13
- data/spec/unit/provider/service/macosx_spec.rb +210 -214
- data/spec/unit/provider/service/systemd_service_spec.rb +23 -23
- data/spec/unit/provider/subversion_spec.rb +4 -2
- data/spec/unit/provider/template_spec.rb +3 -4
- data/spec/unit/provider/zypper_repository_spec.rb +17 -17
- data/spec/unit/provider_resolver_spec.rb +4 -4
- data/spec/unit/recipe_spec.rb +68 -0
- data/spec/unit/resource/alternatives_spec.rb +120 -0
- data/spec/unit/resource/apt_preference_spec.rb +0 -18
- data/spec/unit/resource/apt_repository_spec.rb +0 -18
- data/spec/unit/resource/apt_update_spec.rb +0 -18
- data/spec/unit/resource/chef_client_cron_spec.rb +119 -0
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +102 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +70 -0
- data/spec/unit/resource/chef_vault_secret_spec.rb +40 -0
- data/spec/unit/resource/chocolatey_source_spec.rb +2 -1
- data/spec/unit/resource/cron_d_spec.rb +6 -48
- data/spec/unit/resource/cron_spec.rb +4 -10
- data/spec/unit/resource/gem_package_spec.rb +3 -3
- data/spec/unit/resource/helpers/cron_validations_spec.rb +77 -0
- data/spec/unit/resource/link_spec.rb +0 -4
- data/spec/unit/resource/locale_spec.rb +0 -34
- data/spec/unit/resource/msu_package_spec.rb +4 -0
- data/spec/unit/resource/ohai_spec.rb +56 -2
- data/spec/unit/resource/plist_spec.rb +130 -0
- data/spec/unit/resource/powershell_script_spec.rb +0 -5
- data/spec/unit/resource/{git_spec.rb → scm/git_spec.rb} +50 -2
- data/spec/unit/resource/{scm_spec.rb → scm/scm.rb} +1 -52
- data/spec/unit/resource/{subversion_spec.rb → scm/subversion_spec.rb} +2 -3
- data/spec/unit/resource/service_spec.rb +4 -0
- data/spec/unit/resource/user_spec.rb +2 -2
- data/spec/unit/resource/user_ulimit_spec.rb +53 -0
- data/spec/unit/resource/windows_feature_dism_spec.rb +2 -17
- data/spec/unit/resource/windows_feature_powershell_spec.rb +2 -17
- data/spec/unit/resource/windows_firewall_rule_spec.rb +88 -41
- data/spec/unit/resource/windows_package_spec.rb +14 -0
- data/spec/unit/resource/windows_service_spec.rb +9 -0
- data/spec/unit/resource_reporter_spec.rb +2 -6
- data/spec/unit/resource_spec.rb +10 -3
- data/spec/unit/run_lock_spec.rb +1 -1
- data/spec/unit/scan_access_control_spec.rb +1 -1
- data/spec/unit/search/query_spec.rb +1 -1
- data/spec/unit/win32/registry_spec.rb +1 -1
- data/tasks/rspec.rb +6 -14
- metadata +92 -37
- data/lib/chef/dsl/core.rb +0 -52
- data/lib/chef/knife/cookbook_site_share.rb +0 -41
- data/lib/chef/knife/cookbook_site_unshare.rb +0 -41
- data/lib/chef/provider/apt_preference.rb +0 -93
- data/lib/chef/provider/apt_repository.rb +0 -358
- data/lib/chef/provider/apt_update.rb +0 -79
- data/lib/chef/provider/log.rb +0 -43
- data/lib/chef/provider/mdadm.rb +0 -85
- data/lib/chef/provider/ohai.rb +0 -45
- data/lib/chef/resource/git.rb +0 -37
- data/spec/unit/provider/ohai_spec.rb +0 -84
@@ -50,8 +50,8 @@ describe Chef::Knife::Ssh do
|
|
50
50
|
describe "identity file" do
|
51
51
|
context "when knife[:ssh_identity_file] is set" do
|
52
52
|
before do
|
53
|
-
setup_knife(["*:*", "uptime"])
|
54
53
|
Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/aws.rsa"
|
54
|
+
setup_knife(["*:*", "uptime"])
|
55
55
|
end
|
56
56
|
|
57
57
|
it "uses the ssh_identity_file" do
|
@@ -62,8 +62,8 @@ describe Chef::Knife::Ssh do
|
|
62
62
|
|
63
63
|
context "when knife[:ssh_identity_file] is set and frozen" do
|
64
64
|
before do
|
65
|
-
setup_knife(["*:*", "uptime"])
|
66
65
|
Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/aws.rsa".freeze
|
66
|
+
setup_knife(["*:*", "uptime"])
|
67
67
|
end
|
68
68
|
|
69
69
|
it "uses the ssh_identity_file" do
|
@@ -74,8 +74,8 @@ describe Chef::Knife::Ssh do
|
|
74
74
|
|
75
75
|
context "when -i is provided" do
|
76
76
|
before do
|
77
|
-
setup_knife(["-i ~/.ssh/aws.rsa", "*:*", "uptime"])
|
78
77
|
Chef::Config[:knife][:ssh_identity_file] = nil
|
78
|
+
setup_knife(["-i ~/.ssh/aws.rsa", "*:*", "uptime"])
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should use the value on the command line" do
|
@@ -85,6 +85,7 @@ describe Chef::Knife::Ssh do
|
|
85
85
|
|
86
86
|
it "should override what is set in knife.rb" do
|
87
87
|
Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/other.rsa"
|
88
|
+
@knife.merge_configs
|
88
89
|
@knife.run
|
89
90
|
expect(@knife.config[:ssh_identity_file]).to eq("~/.ssh/aws.rsa")
|
90
91
|
end
|
@@ -92,8 +93,8 @@ describe Chef::Knife::Ssh do
|
|
92
93
|
|
93
94
|
context "when knife[:ssh_identity_file] is not provided]" do
|
94
95
|
before do
|
95
|
-
setup_knife(["*:*", "uptime"])
|
96
96
|
Chef::Config[:knife][:ssh_identity_file] = nil
|
97
|
+
setup_knife(["*:*", "uptime"])
|
97
98
|
end
|
98
99
|
|
99
100
|
it "uses the default" do
|
@@ -119,8 +120,8 @@ describe Chef::Knife::Ssh do
|
|
119
120
|
describe "user" do
|
120
121
|
context "when knife[:ssh_user] is set" do
|
121
122
|
before do
|
122
|
-
setup_knife(["*:*", "uptime"])
|
123
123
|
Chef::Config[:knife][:ssh_user] = "ubuntu"
|
124
|
+
setup_knife(["*:*", "uptime"])
|
124
125
|
end
|
125
126
|
|
126
127
|
it "uses the ssh_user" do
|
@@ -131,8 +132,8 @@ describe Chef::Knife::Ssh do
|
|
131
132
|
|
132
133
|
context "when knife[:ssh_user] is set and frozen" do
|
133
134
|
before do
|
134
|
-
setup_knife(["*:*", "uptime"])
|
135
135
|
Chef::Config[:knife][:ssh_user] = "ubuntu".freeze
|
136
|
+
setup_knife(["*:*", "uptime"])
|
136
137
|
end
|
137
138
|
|
138
139
|
it "uses the ssh_user" do
|
@@ -143,8 +144,8 @@ describe Chef::Knife::Ssh do
|
|
143
144
|
|
144
145
|
context "when -x is provided" do
|
145
146
|
before do
|
146
|
-
setup_knife(["-x ubuntu", "*:*", "uptime"])
|
147
147
|
Chef::Config[:knife][:ssh_user] = nil
|
148
|
+
setup_knife(["-x ubuntu", "*:*", "uptime"])
|
148
149
|
end
|
149
150
|
|
150
151
|
it "should use the value on the command line" do
|
@@ -154,6 +155,7 @@ describe Chef::Knife::Ssh do
|
|
154
155
|
|
155
156
|
it "should override what is set in knife.rb" do
|
156
157
|
Chef::Config[:knife][:ssh_user] = "root"
|
158
|
+
@knife.merge_configs
|
157
159
|
@knife.run
|
158
160
|
expect(@knife.config[:ssh_user]).to eq("ubuntu")
|
159
161
|
end
|
@@ -161,8 +163,8 @@ describe Chef::Knife::Ssh do
|
|
161
163
|
|
162
164
|
context "when knife[:ssh_user] is not provided]" do
|
163
165
|
before do
|
164
|
-
setup_knife(["*:*", "uptime"])
|
165
166
|
Chef::Config[:knife][:ssh_user] = nil
|
167
|
+
setup_knife(["*:*", "uptime"])
|
166
168
|
end
|
167
169
|
|
168
170
|
it "uses the default (current user)" do
|
@@ -175,8 +177,8 @@ describe Chef::Knife::Ssh do
|
|
175
177
|
describe "attribute" do
|
176
178
|
context "when knife[:ssh_attribute] is set" do
|
177
179
|
before do
|
178
|
-
setup_knife(["*:*", "uptime"])
|
179
180
|
Chef::Config[:knife][:ssh_attribute] = "ec2.public_hostname"
|
181
|
+
setup_knife(["*:*", "uptime"])
|
180
182
|
end
|
181
183
|
|
182
184
|
it "uses the ssh_attribute" do
|
@@ -187,8 +189,8 @@ describe Chef::Knife::Ssh do
|
|
187
189
|
|
188
190
|
context "when knife[:ssh_attribute] is not provided" do
|
189
191
|
before do
|
190
|
-
setup_knife(["*:*", "uptime"])
|
191
192
|
Chef::Config[:knife][:ssh_attribute] = nil
|
193
|
+
setup_knife(["*:*", "uptime"])
|
192
194
|
end
|
193
195
|
|
194
196
|
it "uses the default" do
|
@@ -199,8 +201,8 @@ describe Chef::Knife::Ssh do
|
|
199
201
|
|
200
202
|
context "when -a ec2.public_public_hostname is provided" do
|
201
203
|
before do
|
202
|
-
setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
|
203
204
|
Chef::Config[:knife][:ssh_attribute] = nil
|
205
|
+
setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
|
204
206
|
end
|
205
207
|
|
206
208
|
it "should use the value on the command line" do
|
@@ -211,6 +213,7 @@ describe Chef::Knife::Ssh do
|
|
211
213
|
it "should override what is set in knife.rb" do
|
212
214
|
# This is the setting imported from knife.rb
|
213
215
|
Chef::Config[:knife][:ssh_attribute] = "fqdn"
|
216
|
+
@knife.merge_configs
|
214
217
|
# Then we run knife with the -a flag, which sets the above variable
|
215
218
|
setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
|
216
219
|
@knife.run
|
@@ -222,8 +225,8 @@ describe Chef::Knife::Ssh do
|
|
222
225
|
describe "prefix" do
|
223
226
|
context "when knife[:prefix_attribute] is set" do
|
224
227
|
before do
|
225
|
-
setup_knife(["*:*", "uptime"])
|
226
228
|
Chef::Config[:knife][:prefix_attribute] = "name"
|
229
|
+
setup_knife(["*:*", "uptime"])
|
227
230
|
end
|
228
231
|
|
229
232
|
it "uses the prefix_attribute" do
|
@@ -234,8 +237,8 @@ describe Chef::Knife::Ssh do
|
|
234
237
|
|
235
238
|
context "when knife[:prefix_attribute] is not provided" do
|
236
239
|
before do
|
237
|
-
setup_knife(["*:*", "uptime"])
|
238
240
|
Chef::Config[:knife][:prefix_attribute] = nil
|
241
|
+
setup_knife(["*:*", "uptime"])
|
239
242
|
end
|
240
243
|
|
241
244
|
it "falls back to nil" do
|
@@ -246,8 +249,8 @@ describe Chef::Knife::Ssh do
|
|
246
249
|
|
247
250
|
context "when --prefix-attribute ec2.public_public_hostname is provided" do
|
248
251
|
before do
|
249
|
-
setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
|
250
252
|
Chef::Config[:knife][:prefix_attribute] = nil
|
253
|
+
setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
|
251
254
|
end
|
252
255
|
|
253
256
|
it "should use the value on the command line" do
|
@@ -258,6 +261,7 @@ describe Chef::Knife::Ssh do
|
|
258
261
|
it "should override what is set in knife.rb" do
|
259
262
|
# This is the setting imported from knife.rb
|
260
263
|
Chef::Config[:knife][:prefix_attribute] = "fqdn"
|
264
|
+
@knife.merge_configs
|
261
265
|
# Then we run knife with the -b flag, which sets the above variable
|
262
266
|
setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
|
263
267
|
@knife.run
|
@@ -269,8 +273,8 @@ describe Chef::Knife::Ssh do
|
|
269
273
|
describe "gateway" do
|
270
274
|
context "when knife[:ssh_gateway] is set" do
|
271
275
|
before do
|
272
|
-
setup_knife(["*:*", "uptime"])
|
273
276
|
Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname"
|
277
|
+
setup_knife(["*:*", "uptime"])
|
274
278
|
end
|
275
279
|
|
276
280
|
it "uses the ssh_gateway" do
|
@@ -282,8 +286,8 @@ describe Chef::Knife::Ssh do
|
|
282
286
|
|
283
287
|
context "when -G user@ec2.public_hostname is provided" do
|
284
288
|
before do
|
285
|
-
setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
|
286
289
|
Chef::Config[:knife][:ssh_gateway] = nil
|
290
|
+
setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
|
287
291
|
end
|
288
292
|
|
289
293
|
it "uses the ssh_gateway" do
|
@@ -295,9 +299,9 @@ describe Chef::Knife::Ssh do
|
|
295
299
|
|
296
300
|
context "when knife[:ssh_gateway_identity] is set" do
|
297
301
|
before do
|
298
|
-
setup_knife(["*:*", "uptime"])
|
299
302
|
Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname"
|
300
303
|
Chef::Config[:knife][:ssh_gateway_identity] = "~/.ssh/aws-gateway.rsa"
|
304
|
+
setup_knife(["*:*", "uptime"])
|
301
305
|
end
|
302
306
|
|
303
307
|
it "uses the ssh_gateway_identity file" do
|
@@ -309,9 +313,9 @@ describe Chef::Knife::Ssh do
|
|
309
313
|
|
310
314
|
context "when -ssh-gateway-identity is provided and knife[:ssh_gateway] is set" do
|
311
315
|
before do
|
312
|
-
setup_knife(["--ssh-gateway-identity", "~/.ssh/aws-gateway.rsa", "*:*", "uptime"])
|
313
316
|
Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname"
|
314
317
|
Chef::Config[:knife][:ssh_gateway_identity] = nil
|
318
|
+
setup_knife(["--ssh-gateway-identity", "~/.ssh/aws-gateway.rsa", "*:*", "uptime"])
|
315
319
|
end
|
316
320
|
|
317
321
|
it "uses the ssh_gateway_identity file" do
|
@@ -323,8 +327,8 @@ describe Chef::Knife::Ssh do
|
|
323
327
|
|
324
328
|
context "when the gateway requires a password" do
|
325
329
|
before do
|
326
|
-
setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
|
327
330
|
Chef::Config[:knife][:ssh_gateway] = nil
|
331
|
+
setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"])
|
328
332
|
allow(@knife.session).to receive(:via) do |host, user, options|
|
329
333
|
raise Net::SSH::AuthenticationFailed unless options[:password]
|
330
334
|
end
|
@@ -55,17 +55,8 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
|
|
55
55
|
# Actual tests
|
56
56
|
let(:new_resource) do
|
57
57
|
new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context)
|
58
|
-
new_resource.user
|
59
|
-
|
60
|
-
if ohai[:platform] == "solaris2" || ohai[:platform] == "aix"
|
61
|
-
new_resource.minute "0 * * * *"
|
62
|
-
else
|
63
|
-
new_resource.minute "@hourly"
|
64
|
-
end
|
65
|
-
new_resource.hour ""
|
66
|
-
new_resource.day ""
|
67
|
-
new_resource.month ""
|
68
|
-
new_resource.weekday ""
|
58
|
+
new_resource.user "root"
|
59
|
+
new_resource.minute "0"
|
69
60
|
new_resource.command "/bin/true"
|
70
61
|
new_resource
|
71
62
|
end
|
@@ -106,7 +97,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
|
|
106
97
|
|
107
98
|
exclude_solaris = %w{solaris opensolaris solaris2 omnios}.include?(ohai[:platform])
|
108
99
|
describe "create action with various attributes", external: exclude_solaris do
|
109
|
-
def
|
100
|
+
def create_and_validate_with_property(resource, attribute, value)
|
110
101
|
if ohai[:platform] == "aix"
|
111
102
|
expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./)
|
112
103
|
else
|
@@ -130,28 +121,28 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
|
|
130
121
|
|
131
122
|
it "should create a crontab entry for mailto attribute" do
|
132
123
|
new_resource.mailto "cheftest@example.com"
|
133
|
-
|
124
|
+
create_and_validate_with_property(new_resource, "mailto", "cheftest@example.com")
|
134
125
|
end
|
135
126
|
|
136
127
|
it "should create a crontab entry for path attribute" do
|
137
128
|
new_resource.path "/usr/local/bin"
|
138
|
-
|
129
|
+
create_and_validate_with_property(new_resource, "path", "/usr/local/bin")
|
139
130
|
end
|
140
131
|
|
141
132
|
it "should create a crontab entry for shell attribute" do
|
142
133
|
new_resource.shell "/bin/bash"
|
143
|
-
|
134
|
+
create_and_validate_with_property(new_resource, "shell", "/bin/bash")
|
144
135
|
end
|
145
136
|
|
146
137
|
it "should create a crontab entry for home attribute" do
|
147
138
|
new_resource.home "/home/opscode"
|
148
|
-
|
139
|
+
create_and_validate_with_property(new_resource, "home", "/home/opscode")
|
149
140
|
end
|
150
141
|
|
151
142
|
%i{ home mailto path shell }.each do |attr|
|
152
143
|
it "supports an empty string for #{attr} attribute" do
|
153
144
|
new_resource.send(attr, "")
|
154
|
-
|
145
|
+
create_and_validate_with_property(new_resource, attr.to_s, "")
|
155
146
|
end
|
156
147
|
end
|
157
148
|
end
|
@@ -161,20 +152,10 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
|
|
161
152
|
new_resource.run_action(:delete)
|
162
153
|
end
|
163
154
|
|
164
|
-
def cron_create_should_raise_exception
|
165
|
-
expect { new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron)
|
166
|
-
cron_should_not_exists(new_resource.name)
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should not create cron with invalid minute" do
|
170
|
-
new_resource.minute "invalid"
|
171
|
-
cron_create_should_raise_exception
|
172
|
-
end
|
173
|
-
|
174
155
|
it "should not create cron with invalid user" do
|
175
156
|
new_resource.user "1-really-really-invalid-user-name"
|
176
|
-
|
157
|
+
expect { new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron)
|
158
|
+
cron_should_not_exists(new_resource.name)
|
177
159
|
end
|
178
|
-
|
179
160
|
end
|
180
161
|
end
|
@@ -21,9 +21,13 @@ require "chef/mixin/shell_out"
|
|
21
21
|
|
22
22
|
# run this test only for following platforms.
|
23
23
|
exclude_test = !(%w{rhel fedora amazon}.include?(ohai[:platform_family]) && File.exist?("/usr/bin/dnf"))
|
24
|
-
describe Chef::Resource::
|
24
|
+
describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do
|
25
25
|
include Chef::Mixin::ShellOut
|
26
26
|
|
27
|
+
# NOTE: every single test here either needs to explicitly call flush_cache or needs to explicitly
|
28
|
+
# call preinstall (which explicitly calls flush_cache). It is your responsibility to do one or the
|
29
|
+
# other in order to minimize calling flush_cache a half dozen times per test.
|
30
|
+
|
27
31
|
def flush_cache
|
28
32
|
# needed on at least fc23/fc24 sometimes to deal with the dnf cache getting out of sync with the rpm db
|
29
33
|
FileUtils.rm_f "/var/cache/dnf/@System.solv"
|
@@ -37,6 +41,10 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
37
41
|
flush_cache
|
38
42
|
end
|
39
43
|
|
44
|
+
before(:all) do
|
45
|
+
shell_out!("dnf -y install dnf-plugins-core")
|
46
|
+
end
|
47
|
+
|
40
48
|
before(:each) do
|
41
49
|
File.open("/etc/yum.repos.d/chef-dnf-localtesting.repo", "w+") do |f|
|
42
50
|
f.write <<~EOF
|
@@ -47,17 +55,24 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
47
55
|
gpgcheck=0
|
48
56
|
EOF
|
49
57
|
end
|
50
|
-
shell_out!("rpm -qa | grep chef_rpm | xargs -r rpm -e")
|
58
|
+
shell_out!("rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | grep chef_rpm | xargs -r rpm -e")
|
59
|
+
# next line is useful cleanup if you happen to have been testing both yum + dnf func tests on the same box and
|
60
|
+
# have some yum garbage left around
|
61
|
+
FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo"
|
51
62
|
end
|
52
63
|
|
53
64
|
after(:all) do
|
54
|
-
shell_out!("rpm -qa | grep chef_rpm | xargs -r rpm -e")
|
65
|
+
shell_out!("rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | grep chef_rpm | xargs -r rpm -e")
|
55
66
|
FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
|
56
67
|
end
|
57
68
|
|
58
69
|
let(:package_name) { "chef_rpm" }
|
59
70
|
let(:dnf_package) { Chef::Resource::DnfPackage.new(package_name, run_context) }
|
60
71
|
|
72
|
+
def pkg_arch
|
73
|
+
ohai[:kernel][:machine]
|
74
|
+
end
|
75
|
+
|
61
76
|
describe ":install" do
|
62
77
|
context "vanilla use case" do
|
63
78
|
let(:package_name) { "chef_rpm" }
|
@@ -66,47 +81,47 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
66
81
|
flush_cache
|
67
82
|
dnf_package.run_action(:install)
|
68
83
|
expect(dnf_package.updated_by_last_action?).to be true
|
69
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
84
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
70
85
|
end
|
71
86
|
|
72
87
|
it "does not install if the package is installed" do
|
73
|
-
preinstall("chef_rpm-1.10-1.
|
88
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
74
89
|
dnf_package.run_action(:install)
|
75
90
|
expect(dnf_package.updated_by_last_action?).to be false
|
76
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
91
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
77
92
|
end
|
78
93
|
|
79
94
|
it "does not install twice" do
|
80
95
|
flush_cache
|
81
96
|
dnf_package.run_action(:install)
|
82
97
|
expect(dnf_package.updated_by_last_action?).to be true
|
83
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
98
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
84
99
|
dnf_package.run_action(:install)
|
85
100
|
expect(dnf_package.updated_by_last_action?).to be false
|
86
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
101
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
87
102
|
end
|
88
103
|
|
89
104
|
it "does not install if the prior version package is installed" do
|
90
|
-
preinstall("chef_rpm-1.2-1.
|
105
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
91
106
|
dnf_package.run_action(:install)
|
92
107
|
expect(dnf_package.updated_by_last_action?).to be false
|
93
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
108
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
94
109
|
end
|
95
110
|
|
96
|
-
it "does not install if the i686 package is installed" do
|
97
|
-
skip "FIXME: do nothing, or install the
|
111
|
+
it "does not install if the i686 package is installed", :intel_64bit do
|
112
|
+
skip "FIXME: do nothing, or install the #{pkg_arch} version?"
|
98
113
|
preinstall("chef_rpm-1.10-1.i686.rpm")
|
99
114
|
dnf_package.run_action(:install)
|
100
115
|
expect(dnf_package.updated_by_last_action?).to be false
|
101
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
116
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
|
102
117
|
end
|
103
118
|
|
104
|
-
it "does not install if the prior version i686 package is installed" do
|
105
|
-
skip "FIXME: do nothing, or install the
|
119
|
+
it "does not install if the prior version i686 package is installed", :intel_64bit do
|
120
|
+
skip "FIXME: do nothing, or install the #{pkg_arch} version?"
|
106
121
|
preinstall("chef_rpm-1.2-1.i686.rpm")
|
107
122
|
dnf_package.run_action(:install)
|
108
123
|
expect(dnf_package.updated_by_last_action?).to be false
|
109
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
124
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.i686$")
|
110
125
|
end
|
111
126
|
end
|
112
127
|
|
@@ -116,7 +131,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
116
131
|
dnf_package.package_name("chef_rpm-1.10")
|
117
132
|
dnf_package.run_action(:install)
|
118
133
|
expect(dnf_package.updated_by_last_action?).to be true
|
119
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
134
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
120
135
|
end
|
121
136
|
|
122
137
|
it "works with an older version" do
|
@@ -124,15 +139,23 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
124
139
|
dnf_package.package_name("chef_rpm-1.2")
|
125
140
|
dnf_package.run_action(:install)
|
126
141
|
expect(dnf_package.updated_by_last_action?).to be true
|
127
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
142
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "works with an evra" do
|
146
|
+
flush_cache
|
147
|
+
dnf_package.package_name("chef_rpm-0:1.2-1.#{pkg_arch}")
|
148
|
+
dnf_package.run_action(:install)
|
149
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
150
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
128
151
|
end
|
129
152
|
|
130
|
-
it "works with
|
153
|
+
it "works with version and release" do
|
131
154
|
flush_cache
|
132
|
-
dnf_package.package_name("chef_rpm-
|
155
|
+
dnf_package.package_name("chef_rpm-1.2-1")
|
133
156
|
dnf_package.run_action(:install)
|
134
157
|
expect(dnf_package.updated_by_last_action?).to be true
|
135
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
158
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
136
159
|
end
|
137
160
|
|
138
161
|
it "works with a version glob" do
|
@@ -140,7 +163,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
140
163
|
dnf_package.package_name("chef_rpm-1*")
|
141
164
|
dnf_package.run_action(:install)
|
142
165
|
expect(dnf_package.updated_by_last_action?).to be true
|
143
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
166
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
144
167
|
end
|
145
168
|
|
146
169
|
it "works with a name glob + version glob" do
|
@@ -148,7 +171,23 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
148
171
|
dnf_package.package_name("chef_rp*-1*")
|
149
172
|
dnf_package.run_action(:install)
|
150
173
|
expect(dnf_package.updated_by_last_action?).to be true
|
151
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
174
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "upgrades when the installed version does not match the version string" do
|
178
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
179
|
+
dnf_package.package_name("chef_rpm-1.10")
|
180
|
+
dnf_package.run_action(:install)
|
181
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
182
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}")
|
183
|
+
end
|
184
|
+
|
185
|
+
it "downgrades when the installed version is higher than the package_name version" do
|
186
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
187
|
+
dnf_package.package_name("chef_rpm-1.2")
|
188
|
+
dnf_package.run_action(:install)
|
189
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
190
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
152
191
|
end
|
153
192
|
end
|
154
193
|
|
@@ -160,7 +199,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
160
199
|
dnf_package.version("1.10")
|
161
200
|
dnf_package.run_action(:install)
|
162
201
|
expect(dnf_package.updated_by_last_action?).to be true
|
163
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
202
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
164
203
|
end
|
165
204
|
|
166
205
|
it "matches with a glob" do
|
@@ -169,7 +208,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
169
208
|
dnf_package.version("1*")
|
170
209
|
dnf_package.run_action(:install)
|
171
210
|
expect(dnf_package.updated_by_last_action?).to be true
|
172
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
211
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
173
212
|
end
|
174
213
|
|
175
214
|
it "matches the vr" do
|
@@ -178,7 +217,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
178
217
|
dnf_package.version("1.10-1")
|
179
218
|
dnf_package.run_action(:install)
|
180
219
|
expect(dnf_package.updated_by_last_action?).to be true
|
181
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
220
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
182
221
|
end
|
183
222
|
|
184
223
|
it "matches the evr" do
|
@@ -187,58 +226,47 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
187
226
|
dnf_package.version("0:1.10-1")
|
188
227
|
dnf_package.run_action(:install)
|
189
228
|
expect(dnf_package.updated_by_last_action?).to be true
|
190
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
229
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
191
230
|
end
|
192
231
|
|
193
|
-
# only works on rhel >= 8, was broken on old dnf
|
194
232
|
it "matches with a vr glob", :rhel_gte_8 do
|
195
233
|
flush_cache
|
196
234
|
dnf_package.package_name("chef_rpm")
|
197
235
|
dnf_package.version("1.10-1*")
|
198
236
|
dnf_package.run_action(:install)
|
199
237
|
expect(dnf_package.updated_by_last_action?).to be true
|
200
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
238
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
201
239
|
end
|
202
240
|
|
203
|
-
# only works on rhel >= 8, was broken on old dnf
|
204
241
|
it "matches with an evr glob", :rhel_gte_8 do
|
205
242
|
flush_cache
|
206
243
|
dnf_package.package_name("chef_rpm")
|
207
244
|
dnf_package.version("0:1.10-1*")
|
208
245
|
dnf_package.run_action(:install)
|
209
246
|
expect(dnf_package.updated_by_last_action?).to be true
|
210
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
247
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
211
248
|
end
|
212
249
|
end
|
213
250
|
|
214
251
|
context "downgrades" do
|
215
|
-
it "
|
216
|
-
|
217
|
-
|
218
|
-
dnf_package.
|
219
|
-
|
220
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to eql("chef_rpm-1.2-1.x86_64")
|
221
|
-
end
|
222
|
-
|
223
|
-
it "throws a deprecation warning with allow_downgrade" do
|
224
|
-
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
225
|
-
expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
|
226
|
-
preinstall("chef_rpm-1.10-1.x86_64.rpm")
|
227
|
-
dnf_package.version("1.2")
|
252
|
+
it "downgrades the package when allow_downgrade" do
|
253
|
+
flush_cache
|
254
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
255
|
+
dnf_package.package_name("chef_rpm")
|
256
|
+
dnf_package.version("1.2-1")
|
228
257
|
dnf_package.run_action(:install)
|
229
|
-
dnf_package.allow_downgrade true
|
230
258
|
expect(dnf_package.updated_by_last_action?).to be true
|
231
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
259
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
232
260
|
end
|
233
261
|
end
|
234
262
|
|
235
|
-
context "with arches" do
|
263
|
+
context "with arches", :intel_64bit do
|
236
264
|
it "installs with 64-bit arch in the name" do
|
237
265
|
flush_cache
|
238
|
-
dnf_package.package_name("chef_rpm
|
266
|
+
dnf_package.package_name("chef_rpm.#{pkg_arch}")
|
239
267
|
dnf_package.run_action(:install)
|
240
268
|
expect(dnf_package.updated_by_last_action?).to be true
|
241
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
269
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
242
270
|
end
|
243
271
|
|
244
272
|
it "installs with 32-bit arch in the name" do
|
@@ -246,16 +274,16 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
246
274
|
dnf_package.package_name("chef_rpm.i686")
|
247
275
|
dnf_package.run_action(:install)
|
248
276
|
expect(dnf_package.updated_by_last_action?).to be true
|
249
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
277
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
|
250
278
|
end
|
251
279
|
|
252
280
|
it "installs with 64-bit arch in the property" do
|
253
281
|
flush_cache
|
254
282
|
dnf_package.package_name("chef_rpm")
|
255
|
-
dnf_package.arch(
|
283
|
+
dnf_package.arch((pkg_arch).to_s)
|
256
284
|
dnf_package.run_action(:install)
|
257
285
|
expect(dnf_package.updated_by_last_action?).to be true
|
258
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
286
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
259
287
|
end
|
260
288
|
|
261
289
|
it "installs with 32-bit arch in the property" do
|
@@ -264,7 +292,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
264
292
|
dnf_package.arch("i686")
|
265
293
|
dnf_package.run_action(:install)
|
266
294
|
expect(dnf_package.updated_by_last_action?).to be true
|
267
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
295
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
|
268
296
|
end
|
269
297
|
end
|
270
298
|
|
@@ -274,23 +302,23 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
274
302
|
dnf_package.package_name("chef_rpm >= 1.2")
|
275
303
|
dnf_package.run_action(:install)
|
276
304
|
expect(dnf_package.updated_by_last_action?).to be true
|
277
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
305
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
278
306
|
end
|
279
307
|
|
280
308
|
it "when it is met, it does nothing" do
|
281
|
-
preinstall("chef_rpm-1.2-1.
|
309
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
282
310
|
dnf_package.package_name("chef_rpm >= 1.2")
|
283
311
|
dnf_package.run_action(:install)
|
284
312
|
expect(dnf_package.updated_by_last_action?).to be false
|
285
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
313
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
286
314
|
end
|
287
315
|
|
288
316
|
it "when it is met, it does nothing" do
|
289
|
-
preinstall("chef_rpm-1.10-1.
|
317
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
290
318
|
dnf_package.package_name("chef_rpm >= 1.2")
|
291
319
|
dnf_package.run_action(:install)
|
292
320
|
expect(dnf_package.updated_by_last_action?).to be false
|
293
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
321
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
294
322
|
end
|
295
323
|
|
296
324
|
it "with nothing installed, it installs the latest version" do
|
@@ -298,23 +326,39 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
298
326
|
dnf_package.package_name("chef_rpm > 1.2")
|
299
327
|
dnf_package.run_action(:install)
|
300
328
|
expect(dnf_package.updated_by_last_action?).to be true
|
301
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
329
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
302
330
|
end
|
303
331
|
|
304
332
|
it "when it is not met by an installed rpm, it upgrades" do
|
305
|
-
preinstall("chef_rpm-1.2-1.
|
333
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
306
334
|
dnf_package.package_name("chef_rpm > 1.2")
|
307
335
|
dnf_package.run_action(:install)
|
308
336
|
expect(dnf_package.updated_by_last_action?).to be true
|
309
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
337
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
338
|
+
end
|
339
|
+
|
340
|
+
it "with an equality constraint, when it is not met by an installed rpm, it upgrades" do
|
341
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
342
|
+
dnf_package.package_name("chef_rpm = 1.10")
|
343
|
+
dnf_package.run_action(:install)
|
344
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
345
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
346
|
+
end
|
347
|
+
|
348
|
+
it "with an equality constraint, when it is met by an installed rpm, it does nothing" do
|
349
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
350
|
+
dnf_package.package_name("chef_rpm = 1.2")
|
351
|
+
dnf_package.run_action(:install)
|
352
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
353
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
310
354
|
end
|
311
355
|
|
312
356
|
it "when it is met by an installed rpm, it does nothing" do
|
313
|
-
preinstall("chef_rpm-1.10-1.
|
357
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
314
358
|
dnf_package.package_name("chef_rpm > 1.2")
|
315
359
|
dnf_package.run_action(:install)
|
316
360
|
expect(dnf_package.updated_by_last_action?).to be false
|
317
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
361
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
318
362
|
end
|
319
363
|
|
320
364
|
it "when there is no solution to the contraint" do
|
@@ -324,10 +368,34 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
324
368
|
end
|
325
369
|
|
326
370
|
it "when there is no solution to the contraint but an rpm is preinstalled" do
|
327
|
-
preinstall("chef_rpm-1.10-1.
|
371
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
328
372
|
dnf_package.package_name("chef_rpm > 2.0")
|
329
373
|
expect { dnf_package.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
|
330
374
|
end
|
375
|
+
|
376
|
+
it "with a less than constraint, when nothing is installed, it installs" do
|
377
|
+
flush_cache
|
378
|
+
dnf_package.package_name("chef_rpm < 1.10")
|
379
|
+
dnf_package.run_action(:install)
|
380
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
381
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
382
|
+
end
|
383
|
+
|
384
|
+
it "with a less than constraint, when the install version matches, it does nothing" do
|
385
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
386
|
+
dnf_package.package_name("chef_rpm < 1.10")
|
387
|
+
dnf_package.run_action(:install)
|
388
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
389
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
390
|
+
end
|
391
|
+
|
392
|
+
it "with a less than constraint, when the install version fails, it should downgrade" do
|
393
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
394
|
+
dnf_package.package_name("chef_rpm < 1.10")
|
395
|
+
dnf_package.run_action(:install)
|
396
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
397
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
398
|
+
end
|
331
399
|
end
|
332
400
|
|
333
401
|
context "with source arguments" do
|
@@ -349,163 +417,237 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
349
417
|
flush_cache
|
350
418
|
dnf_package.name "something"
|
351
419
|
dnf_package.package_name "somethingelse"
|
352
|
-
dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
420
|
+
dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
353
421
|
dnf_package.run_action(:install)
|
354
422
|
expect(dnf_package.updated_by_last_action?).to be true
|
355
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
423
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
356
424
|
end
|
357
425
|
|
358
426
|
it "installs the package when the name is a path to a file" do
|
359
427
|
flush_cache
|
360
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
428
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
361
429
|
dnf_package.run_action(:install)
|
362
430
|
expect(dnf_package.updated_by_last_action?).to be true
|
363
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
431
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
432
|
+
end
|
433
|
+
|
434
|
+
it "downgrade on a local file with allow_downgrade true works" do
|
435
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
436
|
+
dnf_package.version "1.2-1"
|
437
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
438
|
+
dnf_package.run_action(:install)
|
439
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
440
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
364
441
|
end
|
365
442
|
|
366
443
|
it "does not downgrade the package with :install" do
|
367
|
-
preinstall("chef_rpm-1.10-1.
|
368
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
444
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
445
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
369
446
|
dnf_package.run_action(:install)
|
370
447
|
expect(dnf_package.updated_by_last_action?).to be false
|
371
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
448
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
372
449
|
end
|
373
450
|
|
374
451
|
it "does not upgrade the package with :install" do
|
375
|
-
preinstall("chef_rpm-1.2-1.
|
376
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.
|
452
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
453
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
377
454
|
dnf_package.run_action(:install)
|
378
455
|
expect(dnf_package.updated_by_last_action?).to be false
|
379
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
456
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
380
457
|
end
|
381
458
|
|
382
459
|
it "is idempotent when the package is already installed" do
|
383
|
-
preinstall("chef_rpm-1.2-1.
|
384
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
460
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
461
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
385
462
|
dnf_package.run_action(:install)
|
386
463
|
expect(dnf_package.updated_by_last_action?).to be false
|
387
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
464
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
465
|
+
end
|
466
|
+
|
467
|
+
it "is idempotent when the package is already installed and there is a version string" do
|
468
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
469
|
+
dnf_package.version "1.2-1"
|
470
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
471
|
+
dnf_package.run_action(:install)
|
472
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
473
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
474
|
+
end
|
475
|
+
|
476
|
+
it "is idempotent when the package is already installed and there is a version string with arch" do
|
477
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
478
|
+
dnf_package.version "1.2-1.#{pkg_arch}"
|
479
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
480
|
+
dnf_package.run_action(:install)
|
481
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
482
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
388
483
|
end
|
389
484
|
end
|
390
485
|
|
391
486
|
context "with no available version" do
|
392
487
|
it "works when a package is installed" do
|
393
488
|
FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
|
394
|
-
preinstall("chef_rpm-1.2-1.
|
489
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
395
490
|
dnf_package.run_action(:install)
|
396
491
|
expect(dnf_package.updated_by_last_action?).to be false
|
397
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
492
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
398
493
|
end
|
399
494
|
|
400
495
|
it "works with a local source" do
|
401
496
|
FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
|
402
497
|
flush_cache
|
403
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
498
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
404
499
|
dnf_package.run_action(:install)
|
405
500
|
expect(dnf_package.updated_by_last_action?).to be true
|
406
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
501
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
407
502
|
end
|
408
503
|
end
|
409
504
|
|
410
|
-
context "multipackage with arches" do
|
505
|
+
context "multipackage with arches", :intel_64bit do
|
411
506
|
it "installs two rpms" do
|
412
507
|
flush_cache
|
413
|
-
dnf_package.package_name([ "chef_rpm
|
508
|
+
dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
|
414
509
|
dnf_package.run_action(:install)
|
415
510
|
expect(dnf_package.updated_by_last_action?).to be true
|
416
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
417
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
511
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
|
512
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
|
418
513
|
end
|
419
514
|
|
420
515
|
it "does nothing if both are installed" do
|
421
|
-
preinstall("chef_rpm-1.10-1.
|
516
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm", "chef_rpm-1.10-1.i686.rpm")
|
422
517
|
flush_cache
|
423
|
-
dnf_package.package_name([ "chef_rpm
|
518
|
+
dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
|
424
519
|
dnf_package.run_action(:install)
|
425
520
|
expect(dnf_package.updated_by_last_action?).to be false
|
426
521
|
end
|
427
522
|
|
428
523
|
it "installs the second rpm if the first is installed" do
|
429
|
-
preinstall("chef_rpm-1.10-1.
|
430
|
-
dnf_package.package_name([ "chef_rpm
|
524
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
525
|
+
dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
|
431
526
|
dnf_package.run_action(:install)
|
432
527
|
expect(dnf_package.updated_by_last_action?).to be true
|
433
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
434
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
528
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
|
529
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
|
435
530
|
end
|
436
531
|
|
437
532
|
it "installs the first rpm if the second is installed" do
|
438
533
|
preinstall("chef_rpm-1.10-1.i686.rpm")
|
439
|
-
dnf_package.package_name([ "chef_rpm
|
534
|
+
dnf_package.package_name([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] )
|
440
535
|
dnf_package.run_action(:install)
|
441
536
|
expect(dnf_package.updated_by_last_action?).to be true
|
442
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
443
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
537
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
|
538
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
|
444
539
|
end
|
445
540
|
|
446
541
|
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
|
447
542
|
it "installs two rpms with multi-arch" do
|
448
543
|
flush_cache
|
449
544
|
dnf_package.package_name(%w{chef_rpm chef_rpm} )
|
450
|
-
dnf_package.arch(
|
545
|
+
dnf_package.arch([pkg_arch, "i686"])
|
451
546
|
dnf_package.run_action(:install)
|
452
547
|
expect(dnf_package.updated_by_last_action?).to be true
|
453
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
454
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
548
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
|
549
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
|
455
550
|
end
|
456
551
|
|
457
552
|
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
|
458
553
|
it "installs the second rpm if the first is installed (muti-arch)" do
|
459
|
-
preinstall("chef_rpm-1.10-1.
|
554
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
460
555
|
dnf_package.package_name(%w{chef_rpm chef_rpm} )
|
461
|
-
dnf_package.arch(
|
556
|
+
dnf_package.arch([pkg_arch, "i686"])
|
462
557
|
dnf_package.run_action(:install)
|
463
558
|
expect(dnf_package.updated_by_last_action?).to be true
|
464
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
465
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
559
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
|
560
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
|
466
561
|
end
|
467
562
|
|
468
563
|
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
|
469
564
|
it "installs the first rpm if the second is installed (muti-arch)" do
|
470
|
-
preinstall("chef_rpm-1.10-1.
|
565
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
471
566
|
dnf_package.package_name(%w{chef_rpm chef_rpm} )
|
472
|
-
dnf_package.arch(
|
567
|
+
dnf_package.arch([pkg_arch, "i686"])
|
473
568
|
dnf_package.run_action(:install)
|
474
569
|
expect(dnf_package.updated_by_last_action?).to be true
|
475
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
476
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match(
|
570
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.#{pkg_arch}$/)
|
571
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match(/^chef_rpm-1.10-1.i686$/)
|
477
572
|
end
|
478
573
|
|
479
574
|
# unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
|
480
575
|
it "does nothing if both are installed (muti-arch)" do
|
481
|
-
preinstall("chef_rpm-1.10-1.
|
576
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm", "chef_rpm-1.10-1.i686.rpm")
|
482
577
|
dnf_package.package_name(%w{chef_rpm chef_rpm} )
|
483
|
-
dnf_package.arch(
|
578
|
+
dnf_package.arch([pkg_arch, "i686"])
|
484
579
|
dnf_package.run_action(:install)
|
485
580
|
expect(dnf_package.updated_by_last_action?).to be false
|
486
581
|
end
|
487
582
|
end
|
583
|
+
|
584
|
+
context "repo controls" do
|
585
|
+
it "should fail with the repo disabled" do
|
586
|
+
flush_cache
|
587
|
+
dnf_package.options("--disablerepo=chef-dnf-localtesting")
|
588
|
+
expect { dnf_package.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
|
589
|
+
end
|
590
|
+
|
591
|
+
it "should work with disablerepo first" do
|
592
|
+
flush_cache
|
593
|
+
dnf_package.options(["--disablerepo=*", "--enablerepo=chef-dnf-localtesting"])
|
594
|
+
dnf_package.run_action(:install)
|
595
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
596
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
597
|
+
end
|
598
|
+
|
599
|
+
it "should work to enable a disabled repo" do
|
600
|
+
shell_out!("dnf config-manager --set-disabled chef-dnf-localtesting")
|
601
|
+
flush_cache
|
602
|
+
expect { dnf_package.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
|
603
|
+
flush_cache
|
604
|
+
dnf_package.options("--enablerepo=chef-dnf-localtesting")
|
605
|
+
dnf_package.run_action(:install)
|
606
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
607
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
608
|
+
end
|
609
|
+
|
610
|
+
it "when an idempotent install action is run, does not leave repos disabled" do
|
611
|
+
flush_cache
|
612
|
+
# this is a bit tricky -- we need this action to be idempotent, so that it doesn't recycle any
|
613
|
+
# caches, but need it to hit whatavailable with the repo disabled. using :upgrade like this
|
614
|
+
# accomplishes both those goals (it would be easier if we had other rpms in this repo, but with
|
615
|
+
# one rpm we need to do this).
|
616
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
617
|
+
dnf_package.options("--disablerepo=chef-dnf-localtesting")
|
618
|
+
dnf_package.run_action(:upgrade)
|
619
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
620
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
621
|
+
# now we're still using the same cache in the dnf_helper.py cache and we test to see if the
|
622
|
+
# repo that we temporarily disabled is enabled on this pass.
|
623
|
+
dnf_package.package_name("chef_rpm-1.10-1.#{pkg_arch}")
|
624
|
+
dnf_package.options(nil)
|
625
|
+
dnf_package.run_action(:install)
|
626
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
627
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
628
|
+
end
|
629
|
+
end
|
488
630
|
end
|
489
631
|
|
490
632
|
describe ":upgrade" do
|
491
633
|
context "downgrades" do
|
492
634
|
it "just work with DNF" do
|
493
|
-
preinstall("chef_rpm-1.10-1.
|
635
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
494
636
|
dnf_package.version("1.2")
|
495
637
|
dnf_package.run_action(:install)
|
496
638
|
expect(dnf_package.updated_by_last_action?).to be true
|
497
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
639
|
+
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}")
|
498
640
|
end
|
499
641
|
|
500
642
|
it "throws a deprecation warning with allow_downgrade" do
|
501
643
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
502
644
|
expect(Chef).to receive(:deprecated).with(:dnf_package_allow_downgrade, /^the allow_downgrade property on the dnf_package provider is not used/)
|
503
|
-
preinstall("chef_rpm-1.10-1.
|
645
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
504
646
|
dnf_package.version("1.2")
|
505
647
|
dnf_package.run_action(:install)
|
506
648
|
dnf_package.allow_downgrade true
|
507
649
|
expect(dnf_package.updated_by_last_action?).to be true
|
508
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
650
|
+
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}")
|
509
651
|
end
|
510
652
|
end
|
511
653
|
|
@@ -514,62 +656,144 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
514
656
|
flush_cache
|
515
657
|
dnf_package.name "something"
|
516
658
|
dnf_package.package_name "somethingelse"
|
517
|
-
dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
659
|
+
dnf_package.source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
518
660
|
dnf_package.run_action(:upgrade)
|
519
661
|
expect(dnf_package.updated_by_last_action?).to be true
|
520
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
662
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
521
663
|
end
|
522
664
|
|
523
665
|
it "installs the package when the name is a path to a file" do
|
524
666
|
flush_cache
|
525
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
667
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
526
668
|
dnf_package.run_action(:upgrade)
|
527
669
|
expect(dnf_package.updated_by_last_action?).to be true
|
528
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
670
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
529
671
|
end
|
530
672
|
|
531
|
-
it "downgrades the package" do
|
532
|
-
preinstall("chef_rpm-1.10-1.
|
533
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
673
|
+
it "downgrades the package when allow_downgrade is true" do
|
674
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
675
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
534
676
|
dnf_package.run_action(:upgrade)
|
535
677
|
expect(dnf_package.updated_by_last_action?).to be true
|
536
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
678
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
537
679
|
end
|
538
680
|
|
539
681
|
it "upgrades the package" do
|
540
|
-
preinstall("chef_rpm-1.2-1.
|
541
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.
|
682
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
683
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
542
684
|
dnf_package.run_action(:upgrade)
|
543
685
|
expect(dnf_package.updated_by_last_action?).to be true
|
544
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
686
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
545
687
|
end
|
546
688
|
|
547
689
|
it "is idempotent when the package is already installed" do
|
548
|
-
preinstall("chef_rpm-1.2-1.
|
549
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
690
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
691
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
550
692
|
dnf_package.run_action(:upgrade)
|
551
693
|
expect(dnf_package.updated_by_last_action?).to be false
|
552
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
694
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
553
695
|
end
|
554
696
|
end
|
555
697
|
|
556
698
|
context "with no available version" do
|
557
699
|
it "works when a package is installed" do
|
558
700
|
FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
|
559
|
-
preinstall("chef_rpm-1.2-1.
|
560
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
701
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
702
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
561
703
|
dnf_package.run_action(:upgrade)
|
562
704
|
expect(dnf_package.updated_by_last_action?).to be false
|
563
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
705
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
564
706
|
end
|
565
707
|
|
566
708
|
it "works with a local source" do
|
567
709
|
FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
|
568
710
|
flush_cache
|
569
|
-
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.
|
711
|
+
dnf_package.package_name("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
570
712
|
dnf_package.run_action(:upgrade)
|
571
713
|
expect(dnf_package.updated_by_last_action?).to be true
|
572
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
714
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
715
|
+
end
|
716
|
+
end
|
717
|
+
|
718
|
+
context "version pinning" do
|
719
|
+
it "with an equality pin in the name it upgrades a prior package" do
|
720
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
721
|
+
dnf_package.package_name("chef_rpm-1.10")
|
722
|
+
dnf_package.run_action(:upgrade)
|
723
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
724
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
725
|
+
end
|
726
|
+
|
727
|
+
it "with a prco equality pin in the name it upgrades a prior package" do
|
728
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
729
|
+
dnf_package.package_name("chef_rpm = 1.10")
|
730
|
+
dnf_package.run_action(:upgrade)
|
731
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
732
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
733
|
+
end
|
734
|
+
|
735
|
+
it "with an equality pin in the name it downgrades a later package" do
|
736
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
737
|
+
dnf_package.package_name("chef_rpm-1.2")
|
738
|
+
dnf_package.run_action(:upgrade)
|
739
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
740
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
741
|
+
end
|
742
|
+
|
743
|
+
it "with a prco equality pin in the name it downgrades a later package" do
|
744
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
745
|
+
dnf_package.package_name("chef_rpm = 1.2")
|
746
|
+
dnf_package.run_action(:upgrade)
|
747
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
748
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
749
|
+
end
|
750
|
+
|
751
|
+
it "with a > pin in the name and no rpm installed it installs" do
|
752
|
+
flush_cache
|
753
|
+
dnf_package.package_name("chef_rpm > 1.2")
|
754
|
+
dnf_package.run_action(:upgrade)
|
755
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
756
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
757
|
+
end
|
758
|
+
|
759
|
+
it "with a < pin in the name and no rpm installed it installs" do
|
760
|
+
flush_cache
|
761
|
+
dnf_package.package_name("chef_rpm < 1.10")
|
762
|
+
dnf_package.run_action(:upgrade)
|
763
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
764
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
765
|
+
end
|
766
|
+
|
767
|
+
it "with a > pin in the name and matching rpm installed it does nothing" do
|
768
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
769
|
+
dnf_package.package_name("chef_rpm > 1.2")
|
770
|
+
dnf_package.run_action(:upgrade)
|
771
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
772
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
773
|
+
end
|
774
|
+
|
775
|
+
it "with a < pin in the name and no rpm installed it installs" do
|
776
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
777
|
+
dnf_package.package_name("chef_rpm < 1.10")
|
778
|
+
dnf_package.run_action(:upgrade)
|
779
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
780
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
781
|
+
end
|
782
|
+
|
783
|
+
it "with a > pin in the name and non-matching rpm installed it upgrades" do
|
784
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
785
|
+
dnf_package.package_name("chef_rpm > 1.2")
|
786
|
+
dnf_package.run_action(:upgrade)
|
787
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
788
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
789
|
+
end
|
790
|
+
|
791
|
+
it "with a < pin in the name and non-matching rpm installed it downgrades" do
|
792
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
793
|
+
dnf_package.package_name("chef_rpm < 1.10")
|
794
|
+
dnf_package.run_action(:upgrade)
|
795
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
796
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}$")
|
573
797
|
end
|
574
798
|
end
|
575
799
|
end
|
@@ -581,106 +805,167 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
|
|
581
805
|
flush_cache
|
582
806
|
dnf_package.run_action(:remove)
|
583
807
|
expect(dnf_package.updated_by_last_action?).to be false
|
584
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
808
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
585
809
|
end
|
586
810
|
|
587
811
|
it "removes the package if the package is installed" do
|
588
|
-
preinstall("chef_rpm-1.10-1.
|
812
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
589
813
|
dnf_package.run_action(:remove)
|
590
814
|
expect(dnf_package.updated_by_last_action?).to be true
|
591
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
815
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
592
816
|
end
|
593
817
|
|
594
818
|
it "does not remove the package twice" do
|
595
|
-
preinstall("chef_rpm-1.10-1.
|
819
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
596
820
|
dnf_package.run_action(:remove)
|
597
821
|
expect(dnf_package.updated_by_last_action?).to be true
|
598
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
822
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
599
823
|
dnf_package.run_action(:remove)
|
600
824
|
expect(dnf_package.updated_by_last_action?).to be false
|
601
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
825
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
602
826
|
end
|
603
827
|
|
604
828
|
it "removes the package if the prior version package is installed" do
|
605
|
-
preinstall("chef_rpm-1.2-1.
|
829
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
606
830
|
dnf_package.run_action(:remove)
|
607
831
|
expect(dnf_package.updated_by_last_action?).to be true
|
608
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
832
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
609
833
|
end
|
610
834
|
|
611
|
-
it "removes the package if the i686 package is installed" do
|
835
|
+
it "removes the package if the i686 package is installed", :intel_64bit do
|
612
836
|
skip "FIXME: should this be fixed or is the current behavior correct?"
|
613
837
|
preinstall("chef_rpm-1.10-1.i686.rpm")
|
614
838
|
dnf_package.run_action(:remove)
|
615
839
|
expect(dnf_package.updated_by_last_action?).to be true
|
616
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
840
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
617
841
|
end
|
618
842
|
|
619
|
-
it "removes the package if the prior version i686 package is installed" do
|
843
|
+
it "removes the package if the prior version i686 package is installed", :intel_64bit do
|
620
844
|
skip "FIXME: should this be fixed or is the current behavior correct?"
|
621
845
|
preinstall("chef_rpm-1.2-1.i686.rpm")
|
622
846
|
dnf_package.run_action(:remove)
|
623
847
|
expect(dnf_package.updated_by_last_action?).to be true
|
624
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
848
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
625
849
|
end
|
626
850
|
end
|
627
851
|
|
628
|
-
context "with 64-bit arch" do
|
629
|
-
let(:package_name) { "chef_rpm
|
852
|
+
context "with 64-bit arch", :intel_64bit do
|
853
|
+
let(:package_name) { "chef_rpm.#{pkg_arch}" }
|
630
854
|
it "does nothing if the package is not installed" do
|
631
855
|
flush_cache
|
632
856
|
dnf_package.run_action(:remove)
|
633
857
|
expect(dnf_package.updated_by_last_action?).to be false
|
634
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
858
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
635
859
|
end
|
636
860
|
|
637
861
|
it "removes the package if the package is installed" do
|
638
|
-
preinstall("chef_rpm-1.10-1.
|
862
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
639
863
|
dnf_package.run_action(:remove)
|
640
864
|
expect(dnf_package.updated_by_last_action?).to be true
|
641
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
865
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
642
866
|
end
|
643
867
|
|
644
868
|
it "removes the package if the prior version package is installed" do
|
645
|
-
preinstall("chef_rpm-1.2-1.
|
869
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
646
870
|
dnf_package.run_action(:remove)
|
647
871
|
expect(dnf_package.updated_by_last_action?).to be true
|
648
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
872
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
649
873
|
end
|
650
874
|
|
651
875
|
it "does nothing if the i686 package is installed" do
|
652
876
|
preinstall("chef_rpm-1.10-1.i686.rpm")
|
653
877
|
dnf_package.run_action(:remove)
|
654
878
|
expect(dnf_package.updated_by_last_action?).to be false
|
655
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
879
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.i686$")
|
656
880
|
end
|
657
881
|
|
658
882
|
it "does nothing if the prior version i686 package is installed" do
|
659
883
|
preinstall("chef_rpm-1.2-1.i686.rpm")
|
660
884
|
dnf_package.run_action(:remove)
|
661
885
|
expect(dnf_package.updated_by_last_action?).to be false
|
662
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
886
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.i686$")
|
663
887
|
end
|
664
888
|
end
|
665
889
|
|
666
|
-
context "with 32-bit arch" do
|
890
|
+
context "with 32-bit arch", :intel_64bit do
|
667
891
|
let(:package_name) { "chef_rpm.i686" }
|
668
892
|
it "removes only the 32-bit arch if both are installed" do
|
669
|
-
preinstall("chef_rpm-1.10-1.
|
893
|
+
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm", "chef_rpm-1.10-1.i686.rpm")
|
670
894
|
dnf_package.run_action(:remove)
|
671
895
|
expect(dnf_package.updated_by_last_action?).to be true
|
672
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
896
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
673
897
|
end
|
674
898
|
end
|
675
899
|
|
676
900
|
context "with no available version" do
|
677
901
|
it "works when a package is installed" do
|
678
902
|
FileUtils.rm_f "/etc/yum.repos.d/chef-dnf-localtesting.repo"
|
679
|
-
preinstall("chef_rpm-1.2-1.
|
903
|
+
preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
|
680
904
|
dnf_package.run_action(:remove)
|
681
905
|
expect(dnf_package.updated_by_last_action?).to be true
|
682
|
-
expect(shell_out("rpm -q chef_rpm").stdout.chomp).to
|
906
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
683
907
|
end
|
684
908
|
end
|
685
909
|
end
|
910
|
+
|
911
|
+
describe ":lock and :unlock" do
|
912
|
+
before(:all) do
|
913
|
+
shell_out("dnf -y install python3-dnf-plugin-versionlock")
|
914
|
+
end
|
915
|
+
|
916
|
+
before(:each) do
|
917
|
+
shell_out("dnf versionlock delete 'chef_rpm-*'") # will exit with error when nothing is locked, we don't care
|
918
|
+
end
|
919
|
+
|
920
|
+
it "locks an rpm" do
|
921
|
+
flush_cache
|
922
|
+
dnf_package.package_name("chef_rpm")
|
923
|
+
dnf_package.run_action(:lock)
|
924
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
925
|
+
expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
|
926
|
+
end
|
927
|
+
|
928
|
+
it "does not lock if its already locked" do
|
929
|
+
flush_cache
|
930
|
+
shell_out!("dnf versionlock add chef_rpm")
|
931
|
+
dnf_package.package_name("chef_rpm")
|
932
|
+
dnf_package.run_action(:lock)
|
933
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
934
|
+
expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
|
935
|
+
end
|
936
|
+
|
937
|
+
it "unlocks an rpm" do
|
938
|
+
flush_cache
|
939
|
+
shell_out!("dnf versionlock add chef_rpm")
|
940
|
+
dnf_package.package_name("chef_rpm")
|
941
|
+
dnf_package.run_action(:unlock)
|
942
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
943
|
+
expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
|
944
|
+
end
|
945
|
+
|
946
|
+
it "does not unlock an already locked rpm" do
|
947
|
+
flush_cache
|
948
|
+
dnf_package.package_name("chef_rpm")
|
949
|
+
dnf_package.run_action(:unlock)
|
950
|
+
expect(dnf_package.updated_by_last_action?).to be false
|
951
|
+
expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
|
952
|
+
end
|
953
|
+
|
954
|
+
it "check that we can lock based on provides" do
|
955
|
+
flush_cache
|
956
|
+
dnf_package.package_name("chef_rpm_provides")
|
957
|
+
dnf_package.run_action(:lock)
|
958
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
959
|
+
expect(shell_out("dnf versionlock list").stdout.chomp).to match("^chef_rpm-0:")
|
960
|
+
end
|
961
|
+
|
962
|
+
it "check that we can unlock based on provides" do
|
963
|
+
flush_cache
|
964
|
+
shell_out!("dnf versionlock add chef_rpm")
|
965
|
+
dnf_package.package_name("chef_rpm_provides")
|
966
|
+
dnf_package.run_action(:unlock)
|
967
|
+
expect(dnf_package.updated_by_last_action?).to be true
|
968
|
+
expect(shell_out("dnf versionlock list").stdout.chomp).not_to match("^chef_rpm-0:")
|
969
|
+
end
|
970
|
+
end
|
686
971
|
end
|