chef 15.17.4 → 16.0.257
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +14 -20
- data/README.md +6 -6
- data/Rakefile +18 -23
- data/chef-universal-mingw32.gemspec +4 -4
- data/chef.gemspec +10 -26
- data/lib/chef/action_collection.rb +16 -5
- data/lib/chef/api_client/registration.rb +2 -2
- data/lib/chef/application.rb +33 -54
- data/lib/chef/application/apply.rb +20 -3
- data/lib/chef/application/base.rb +8 -3
- data/lib/chef/application/exit_code.rb +2 -2
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_class.rb +4 -4
- data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.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/multiplexed_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +0 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +5 -5
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.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_version.rb +40 -5
- data/lib/chef/data_bag.rb +2 -2
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/data_collector/run_end_message.rb +7 -1
- data/lib/chef/deprecated.rb +1 -9
- 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 +2 -3
- data/lib/chef/dsl/recipe.rb +7 -12
- data/lib/chef/dsl/universal.rb +3 -7
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/exceptions.rb +0 -3
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
- data/lib/chef/formatters/indentable_output_stream.rb +7 -16
- data/lib/chef/http.rb +1 -2
- data/lib/chef/http/http_request.rb +3 -2
- data/lib/chef/knife.rb +1 -3
- 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 +93 -97
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -1
- data/lib/chef/knife/bootstrap/client_builder.rb +1 -1
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +20 -20
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +13 -15
- data/lib/chef/knife/bootstrap/train_connector.rb +0 -1
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/core/bootstrap_context.rb +63 -60
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/generic_presenter.rb +4 -3
- data/lib/chef/knife/core/hashed_command_loader.rb +2 -3
- 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 +45 -58
- data/lib/chef/knife/data_bag_secret_options.rb +18 -45
- data/lib/chef/knife/environment_compare.rb +1 -1
- data/lib/chef/knife/exec.rb +2 -2
- 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/list.rb +1 -1
- data/lib/chef/knife/ssh.rb +12 -50
- data/lib/chef/knife/status.rb +3 -3
- data/lib/chef/knife/supermarket_download.rb +1 -2
- data/lib/chef/knife/supermarket_install.rb +1 -2
- 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_recind.rb +63 -0
- data/lib/chef/knife/yaml_convert.rb +91 -0
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/create_path.rb +8 -8
- data/lib/chef/mixin/openssl_helper.rb +3 -26
- data/lib/chef/mixin/powershell_exec.rb +10 -1
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/mixin/properties.rb +13 -1
- data/lib/chef/mixin/shell_out.rb +0 -4
- data/lib/chef/mixin/template.rb +0 -1
- data/lib/chef/monkey_patches/net_http.rb +0 -4
- data/lib/chef/node.rb +18 -6
- data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
- 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 +7 -36
- data/lib/chef/platform/priority_map.rb +4 -4
- data/lib/chef/platform/query_helpers.rb +6 -34
- data/lib/chef/powershell.rb +14 -0
- data/lib/chef/property.rb +22 -4
- data/lib/chef/provider.rb +40 -6
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/directory.rb +2 -2
- data/lib/chef/provider/dsc_resource.rb +1 -1
- data/lib/chef/provider/dsc_script.rb +1 -1
- data/lib/chef/provider/execute.rb +2 -8
- data/lib/chef/provider/file.rb +5 -5
- 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 +36 -51
- data/lib/chef/provider/link.rb +2 -2
- data/lib/chef/provider/mount.rb +5 -5
- data/lib/chef/provider/mount/solaris.rb +1 -0
- data/lib/chef/provider/osx_profile.rb +7 -3
- data/lib/chef/provider/package.rb +2 -2
- data/lib/chef/provider/package/cab.rb +3 -4
- 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 +84 -30
- 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/freebsd/pkgng.rb +1 -3
- data/lib/chef/provider/package/homebrew.rb +106 -42
- data/lib/chef/provider/package/msu.rb +3 -1
- data/lib/chef/provider/package/pacman.rb +25 -34
- data/lib/chef/provider/package/powershell.rb +2 -6
- data/lib/chef/provider/package/rubygems.rb +29 -2
- data/lib/chef/provider/package/snap.rb +27 -96
- data/lib/chef/provider/package/windows.rb +3 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +0 -8
- data/lib/chef/provider/package/yum/yum_helper.py +0 -4
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/powershell_script.rb +4 -10
- data/lib/chef/provider/registry_key.rb +4 -4
- data/lib/chef/provider/remote_directory.rb +3 -3
- 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 +2 -2
- data/lib/chef/provider/service/debian.rb +31 -29
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +7 -12
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/simple.rb +3 -3
- 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/dscl.rb +3 -3
- data/lib/chef/provider/user/mac.rb +10 -9
- 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 +7 -9
- data/lib/chef/provider/yum_repository.rb +1 -1
- data/lib/chef/provider/zypper_repository.rb +11 -31
- data/lib/chef/providers.rb +0 -6
- data/lib/chef/recipe.rb +36 -0
- data/lib/chef/resource.rb +41 -56
- data/lib/chef/resource/action_class.rb +24 -22
- data/lib/chef/resource/alternatives.rb +149 -0
- data/lib/chef/resource/apt_package.rb +2 -1
- data/lib/chef/resource/apt_preference.rb +69 -2
- data/lib/chef/resource/apt_repository.rb +337 -5
- data/lib/chef/resource/apt_update.rb +52 -1
- data/lib/chef/resource/archive_file.rb +9 -29
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/bff_package.rb +9 -1
- data/lib/chef/resource/breakpoint.rb +0 -1
- data/lib/chef/resource/build_essential.rb +42 -48
- data/lib/chef/resource/cab_package.rb +8 -1
- data/lib/chef/resource/chef_client_cron.rb +225 -0
- data/lib/chef/resource/chef_client_scheduled_task.rb +198 -0
- data/lib/chef/resource/chef_client_systemd_timer.rb +177 -0
- data/lib/chef/resource/chef_gem.rb +9 -16
- data/lib/chef/resource/chef_handler.rb +2 -1
- data/lib/chef/resource/chef_sleep.rb +0 -1
- data/lib/chef/resource/chef_vault_secret.rb +135 -0
- data/lib/chef/resource/chocolatey_config.rb +3 -1
- data/lib/chef/resource/chocolatey_feature.rb +2 -1
- data/lib/chef/resource/chocolatey_package.rb +2 -1
- data/lib/chef/resource/chocolatey_source.rb +2 -1
- data/lib/chef/resource/cookbook_file.rb +1 -1
- data/lib/chef/resource/cron.rb +22 -68
- data/lib/chef/resource/cron_access.rb +8 -15
- data/lib/chef/resource/cron_d.rb +9 -75
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -2
- data/lib/chef/resource/dmg_package.rb +4 -4
- data/lib/chef/resource/dnf_package.rb +2 -3
- data/lib/chef/resource/dpkg_package.rb +2 -1
- data/lib/chef/resource/dsc_resource.rb +6 -4
- data/lib/chef/resource/dsc_script.rb +3 -2
- data/lib/chef/resource/execute.rb +13 -12
- data/lib/chef/resource/file.rb +3 -1
- data/lib/chef/resource/freebsd_package.rb +2 -1
- data/lib/chef/resource/gem_package.rb +14 -6
- data/lib/chef/resource/group.rb +4 -1
- data/lib/chef/resource/helpers/cron_validations.rb +98 -0
- data/lib/chef/resource/homebrew_cask.rb +5 -4
- data/lib/chef/resource/homebrew_package.rb +4 -2
- data/lib/chef/resource/homebrew_tap.rb +2 -1
- data/lib/chef/resource/hostname.rb +41 -36
- data/lib/chef/resource/http_request.rb +0 -1
- data/lib/chef/resource/ifconfig.rb +1 -1
- data/lib/chef/resource/ips_package.rb +10 -2
- data/lib/chef/resource/kernel_module.rb +29 -29
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/launchd.rb +6 -6
- data/lib/chef/resource/link.rb +1 -23
- data/lib/chef/resource/locale.rb +58 -24
- data/lib/chef/resource/log.rb +12 -1
- data/lib/chef/resource/lwrp_base.rb +1 -8
- data/lib/chef/resource/macos_userdefaults.rb +9 -6
- data/lib/chef/resource/macosx_service.rb +2 -1
- data/lib/chef/resource/macports_package.rb +10 -2
- data/lib/chef/resource/mdadm.rb +62 -2
- data/lib/chef/resource/mount.rb +3 -0
- data/lib/chef/resource/msu_package.rb +13 -1
- data/lib/chef/resource/notify_group.rb +8 -3
- data/lib/chef/resource/ohai.rb +19 -3
- data/lib/chef/resource/ohai_hint.rb +3 -12
- data/lib/chef/resource/openbsd_package.rb +9 -1
- data/lib/chef/resource/openssl_dhparam.rb +10 -1
- data/lib/chef/resource/openssl_ec_private_key.rb +23 -1
- data/lib/chef/resource/openssl_ec_public_key.rb +21 -1
- data/lib/chef/resource/openssl_rsa_private_key.rb +20 -1
- data/lib/chef/resource/openssl_rsa_public_key.rb +22 -1
- data/lib/chef/resource/openssl_x509_certificate.rb +37 -1
- data/lib/chef/resource/openssl_x509_crl.rb +12 -1
- data/lib/chef/resource/openssl_x509_request.rb +37 -1
- data/lib/chef/resource/osx_profile.rb +3 -2
- data/lib/chef/resource/package.rb +2 -1
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +12 -3
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/plist.rb +207 -0
- data/lib/chef/resource/portage_package.rb +13 -3
- data/lib/chef/resource/powershell_package.rb +1 -3
- data/lib/chef/resource/powershell_package_source.rb +3 -1
- data/lib/chef/resource/powershell_script.rb +7 -17
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +1 -2
- data/lib/chef/resource/remote_directory.rb +2 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/rhsm_errata.rb +0 -1
- data/lib/chef/resource/rhsm_errata_level.rb +0 -1
- data/lib/chef/resource/rhsm_register.rb +2 -1
- data/lib/chef/resource/rhsm_repo.rb +3 -1
- data/lib/chef/resource/rhsm_subscription.rb +4 -1
- data/lib/chef/resource/route.rb +5 -1
- data/lib/chef/resource/rpm_package.rb +9 -2
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +1 -1
- data/lib/chef/resource/scm/_scm.rb +48 -0
- data/lib/chef/resource/{scm.rb → scm/git.rb} +16 -30
- data/lib/chef/resource/{subversion.rb → scm/subversion.rb} +8 -5
- data/lib/chef/resource/script.rb +6 -3
- data/lib/chef/resource/service.rb +6 -7
- data/lib/chef/resource/smartos_package.rb +9 -1
- data/lib/chef/resource/snap_package.rb +3 -1
- data/lib/chef/resource/solaris_package.rb +9 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +6 -3
- data/lib/chef/resource/sudo.rb +9 -9
- 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 +5 -3
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +4 -2
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +7 -18
- data/lib/chef/resource/user.rb +1 -3
- 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 +114 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +19 -6
- data/lib/chef/resource/windows_auto_run.rb +0 -1
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_dfs_folder.rb +0 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
- data/lib/chef/resource/windows_dfs_server.rb +0 -1
- 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 +2 -3
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_dism.rb +9 -22
- data/lib/chef/resource/windows_feature_powershell.rb +17 -82
- data/lib/chef/resource/windows_firewall_rule.rb +119 -10
- data/lib/chef/resource/windows_font.rb +1 -3
- data/lib/chef/resource/windows_package.rb +13 -4
- data/lib/chef/resource/windows_pagefile.rb +0 -1
- data/lib/chef/resource/windows_path.rb +0 -1
- data/lib/chef/resource/windows_printer.rb +0 -1
- data/lib/chef/resource/windows_printer_port.rb +0 -1
- data/lib/chef/resource/windows_script.rb +3 -4
- data/lib/chef/resource/windows_security_policy.rb +90 -0
- data/lib/chef/resource/windows_service.rb +45 -31
- data/lib/chef/resource/windows_share.rb +3 -7
- data/lib/chef/resource/windows_shortcut.rb +0 -1
- data/lib/chef/resource/windows_task.rb +14 -15
- data/lib/chef/resource/windows_uac.rb +0 -1
- data/lib/chef/resource/windows_user_privilege.rb +157 -0
- data/lib/chef/resource/windows_workgroup.rb +0 -1
- data/lib/chef/resource/yum_package.rb +3 -1
- data/lib/chef/resource/yum_repository.rb +2 -1
- data/lib/chef/resource/zypper_package.rb +3 -2
- data/lib/chef/resource/zypper_repository.rb +2 -1
- data/lib/chef/resource_builder.rb +8 -0
- data/lib/chef/resource_inspector.rb +6 -6
- data/lib/chef/resource_resolver.rb +7 -14
- data/lib/chef/resources.rb +11 -3
- data/lib/chef/role.rb +2 -2
- data/lib/chef/run_context/cookbook_compiler.rb +29 -5
- data/lib/chef/shell.rb +23 -32
- data/lib/chef/shell/shell_session.rb +0 -2
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
- data/lib/chef/util/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +2 -2
- data/lib/chef/version_string.rb +1 -1
- data/lib/chef/win32/api/file.rb +18 -18
- data/lib/chef/win32/api/security.rb +6 -0
- data/lib/chef/win32/file.rb +3 -11
- data/lib/chef/win32/process.rb +2 -2
- data/lib/chef/win32/security.rb +40 -2
- data/spec/functional/assets/inittest +8 -7
- data/spec/functional/knife/ssh_spec.rb +27 -23
- data/spec/functional/resource/aix_service_spec.rb +1 -0
- data/spec/functional/resource/aixinit_service_spec.rb +8 -7
- data/spec/functional/resource/apt_package_spec.rb +1 -0
- data/spec/functional/resource/bff_spec.rb +2 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +11 -29
- data/spec/functional/resource/dnf_package_spec.rb +441 -156
- data/spec/functional/resource/dsc_resource_spec.rb +1 -1
- data/spec/functional/resource/git_spec.rb +184 -134
- data/spec/functional/resource/insserv_spec.rb +6 -5
- data/spec/functional/resource/link_spec.rb +17 -17
- data/spec/functional/resource/locale_spec.rb +13 -2
- data/spec/functional/resource/powershell_script_spec.rb +7 -68
- data/spec/functional/resource/rpm_spec.rb +2 -2
- data/spec/functional/resource/user/dscl_spec.rb +2 -2
- data/spec/functional/resource/user/mac_user_spec.rb +2 -2
- data/spec/functional/resource/windows_certificate_spec.rb +3 -3
- data/spec/functional/resource/windows_security_policy_spec.rb +90 -0
- data/spec/functional/resource/windows_task_spec.rb +8 -8
- data/spec/functional/resource/windows_user_privilege_spec.rb +193 -0
- data/spec/functional/run_lock_spec.rb +1 -2
- data/spec/functional/shell_spec.rb +6 -6
- 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/functional/win32/service_manager_spec.rb +1 -1
- 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 +30 -2
- data/spec/integration/knife/show_spec.rb +32 -3
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +5 -5
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +50 -21
- data/spec/integration/recipes/notifying_block_spec.rb +9 -6
- data/spec/integration/recipes/provider_choice.rb +2 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +46 -144
- data/spec/integration/recipes/resource_action_spec.rb +16 -11
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +1 -3
- data/spec/integration/recipes/resource_load_spec.rb +133 -13
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/integration/recipes/use_partial_spec.rb +112 -0
- data/spec/integration/solo/solo_spec.rb +3 -3
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +11 -14
- 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 +44 -19
- data/spec/support/platforms/win32/spec_service.rb +1 -1
- data/spec/support/recipe_dsl_helper.rb +83 -0
- data/spec/support/shared/functional/directory_resource.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/win32_service.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +5 -18
- data/spec/support/shared/integration/knife_support.rb +14 -8
- 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 -9
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -2
- data/spec/unit/client_spec.rb +7 -5
- data/spec/unit/cookbook/gem_installer_spec.rb +3 -4
- data/spec/unit/cookbook/metadata_spec.rb +38 -19
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/data_collector_spec.rb +38 -17
- data/spec/unit/dsl/platform_introspection_spec.rb +0 -1
- data/spec/unit/environment_spec.rb +7 -7
- data/spec/unit/event_dispatch/dispatcher_spec.rb +0 -3
- data/spec/unit/file_access_control_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 +36 -54
- data/spec/unit/knife/cookbook_download_spec.rb +4 -4
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
- data/spec/unit/knife/cookbook_show_spec.rb +1 -0
- data/spec/unit/knife/cookbook_upload_spec.rb +6 -5
- data/spec/unit/knife/core/bootstrap_context_spec.rb +23 -43
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
- data/spec/unit/knife/core/ui_spec.rb +16 -0
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +8 -68
- data/spec/unit/knife/data_bag_secret_options_spec.rb +22 -14
- data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
- data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
- data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
- data/spec/unit/knife/ssh_spec.rb +10 -113
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_share_spec.rb +3 -5
- data/spec/unit/knife_spec.rb +18 -0
- data/spec/unit/lwrp_spec.rb +4 -4
- data/spec/unit/mixin/powershell_exec_spec.rb +10 -0
- data/spec/unit/mixin/securable_spec.rb +1 -0
- data/spec/unit/mixin/user_context_spec.rb +9 -1
- data/spec/unit/node/attribute_spec.rb +2 -2
- 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 +18 -15
- data/spec/unit/provider/apt_preference_spec.rb +14 -10
- data/spec/unit/provider/apt_repository_spec.rb +9 -11
- 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 +44 -4
- 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/osx_profile_spec.rb +2 -2
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +2 -2
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
- data/spec/unit/provider/package/homebrew_spec.rb +280 -174
- data/spec/unit/provider/package/msu_spec.rb +3 -3
- data/spec/unit/provider/package/pacman_spec.rb +65 -147
- data/spec/unit/provider/package/powershell_spec.rb +88 -96
- data/spec/unit/provider/package/rubygems_spec.rb +221 -31
- data/spec/unit/provider/package/snap_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +53 -30
- 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/arch_service_spec.rb +2 -3
- data/spec/unit/provider/service/debian_service_spec.rb +35 -14
- data/spec/unit/provider/service/gentoo_service_spec.rb +8 -8
- data/spec/unit/provider/service/macosx_spec.rb +210 -214
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +23 -23
- data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
- data/spec/unit/provider/service/windows_spec.rb +6 -2
- data/spec/unit/provider/subversion_spec.rb +4 -2
- data/spec/unit/provider/systemd_unit_spec.rb +24 -28
- data/spec/unit/provider/template_spec.rb +3 -4
- data/spec/unit/provider/zypper_repository_spec.rb +25 -75
- data/spec/unit/provider_resolver_spec.rb +11 -11
- data/spec/unit/provider_spec.rb +0 -1
- 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/archive_file_spec.rb +2 -11
- 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/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_dns_record_spec.rb +3 -3
- data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
- data/spec/unit/resource/windows_feature_dism_spec.rb +2 -17
- data/spec/unit/resource/windows_feature_powershell_spec.rb +6 -47
- data/spec/unit/resource/windows_firewall_rule_spec.rb +88 -41
- data/spec/unit/resource/windows_package_spec.rb +4 -1
- data/spec/unit/resource/windows_service_spec.rb +9 -0
- data/spec/unit/resource/windows_task_spec.rb +1 -1
- data/spec/unit/resource/windows_uac_spec.rb +2 -2
- data/spec/unit/resource/yum_repository_spec.rb +21 -21
- data/spec/unit/resource_reporter_spec.rb +1 -5
- data/spec/unit/resource_spec.rb +11 -4
- data/spec/unit/role_spec.rb +11 -11
- data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +1 -1
- data/spec/unit/search/query_spec.rb +1 -1
- data/spec/unit/util/threaded_job_queue_spec.rb +0 -9
- data/spec/unit/win32/security_spec.rb +3 -4
- data/tasks/rspec.rb +1 -1
- metadata +110 -75
- 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/functional/resource/windows_font_spec.rb +0 -49
- data/spec/unit/provider/ohai_spec.rb +0 -84
@@ -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
|