puppet 3.2.4 → 3.3.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/COMMITTERS.md +101 -42
- data/Gemfile +15 -4
- data/README.md +5 -1
- data/README_DEVELOPER.md +117 -54
- data/Rakefile +4 -0
- data/ext/build_defaults.yaml +3 -2
- data/ext/debian/puppet-common.manpages +33 -1
- data/ext/gentoo/init.d/puppet +1 -1
- data/ext/gentoo/init.d/puppetmaster +1 -1
- data/ext/redhat/puppet.spec.erb +0 -1
- data/install.rb +2 -1
- data/lib/hiera/backend/puppet_backend.rb +1 -1
- data/lib/puppet/application.rb +10 -9
- data/lib/puppet/application/agent.rb +87 -93
- data/lib/puppet/application/apply.rb +0 -2
- data/lib/puppet/application/device.rb +3 -3
- data/lib/puppet/application/kick.rb +2 -2
- data/lib/puppet/application/master.rb +41 -19
- data/lib/puppet/application/queue.rb +5 -3
- data/lib/puppet/bindings.rb +147 -0
- data/lib/puppet/configurer.rb +25 -15
- data/lib/puppet/configurer/fact_handler.rb +2 -9
- data/lib/puppet/daemon.rb +44 -33
- data/lib/puppet/defaults.rb +57 -26
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/external/dot.rb +2 -2
- data/lib/puppet/external/nagios/base.rb +1 -6
- data/lib/puppet/external/pson/common.rb +2 -2
- data/lib/puppet/external/pson/pure/generator.rb +2 -2
- data/lib/puppet/external/pson/pure/parser.rb +1 -1
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/face/help.rb +2 -2
- data/lib/puppet/face/module/list.rb +2 -2
- data/lib/puppet/feature/rails.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +0 -1
- data/lib/puppet/file_serving/base.rb +1 -1
- data/lib/puppet/file_serving/configuration/parser.rb +20 -14
- data/lib/puppet/forge.rb +0 -32
- data/lib/puppet/forge/cache.rb +1 -1
- data/lib/puppet/forge/errors.rb +3 -3
- data/lib/puppet/forge/repository.rb +7 -42
- data/lib/puppet/graph.rb +11 -0
- data/lib/puppet/graph/key.rb +26 -0
- data/lib/puppet/graph/prioritizer.rb +29 -0
- data/lib/puppet/graph/random_prioritizer.rb +16 -0
- data/lib/puppet/{rb_tree_map.rb → graph/rb_tree_map.rb} +3 -3
- data/lib/puppet/graph/relationship_graph.rb +246 -0
- data/lib/puppet/graph/sequential_prioritizer.rb +31 -0
- data/lib/puppet/{simple_graph.rb → graph/simple_graph.rb} +22 -3
- data/lib/puppet/graph/title_hash_prioritizer.rb +16 -0
- data/lib/puppet/indirector.rb +2 -2
- data/lib/puppet/indirector/catalog/compiler.rb +10 -7
- data/lib/puppet/indirector/catalog/static_compiler.rb +50 -0
- data/lib/puppet/indirector/certificate/rest.rb +1 -1
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/facts/inventory_active_record.rb +0 -1
- data/lib/puppet/indirector/facts/network_device.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +0 -1
- data/lib/puppet/indirector/indirection.rb +2 -2
- data/lib/puppet/indirector/memory.rb +9 -0
- data/lib/puppet/indirector/node/ldap.rb +2 -4
- data/lib/puppet/indirector/report/processor.rb +1 -2
- data/lib/puppet/indirector/report/rest.rb +1 -1
- data/lib/puppet/indirector/request.rb +32 -10
- data/lib/puppet/indirector/resource/rest.rb +1 -1
- data/lib/puppet/indirector/resource_type/parser.rb +31 -12
- data/lib/puppet/interface.rb +1 -1
- data/lib/puppet/interface/documentation.rb +7 -11
- data/lib/puppet/interface/option.rb +1 -1
- data/lib/puppet/interface/option_builder.rb +1 -1
- data/lib/puppet/metatype/manager.rb +2 -2
- data/lib/puppet/module.rb +7 -1
- data/lib/puppet/module_tool.rb +1 -1
- data/lib/puppet/module_tool/applications/application.rb +10 -0
- data/lib/puppet/module_tool/applications/installer.rb +6 -3
- data/lib/puppet/module_tool/dependency.rb +2 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +25 -13
- data/lib/puppet/module_tool/modulefile.rb +7 -7
- data/lib/puppet/module_tool/shared_behaviors.rb +4 -2
- data/lib/puppet/module_tool/skeleton.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +5 -5
- data/lib/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +5 -4
- data/lib/puppet/network/auth_config_parser.rb +3 -0
- data/lib/puppet/network/authconfig.rb +0 -1
- data/lib/puppet/network/authorization.rb +1 -1
- data/lib/puppet/network/authstore.rb +2 -2
- data/lib/puppet/network/format_handler.rb +25 -114
- data/lib/puppet/network/format_support.rb +106 -0
- data/lib/puppet/network/formats.rb +10 -4
- data/lib/puppet/network/http/compression.rb +1 -1
- data/lib/puppet/network/http/connection.rb +76 -32
- data/lib/puppet/network/http/handler.rb +122 -61
- data/lib/puppet/network/http/rack/rest.rb +1 -1
- data/lib/puppet/network/http/webrick/rest.rb +9 -3
- data/lib/puppet/network/http_pool.rb +2 -2
- data/lib/puppet/network/resolver.rb +1 -0
- data/lib/puppet/network/server.rb +5 -81
- data/lib/puppet/node/environment.rb +256 -13
- data/lib/puppet/node/facts.rb +28 -2
- data/lib/puppet/parameter.rb +27 -18
- data/lib/puppet/parameter/boolean.rb +20 -0
- data/lib/puppet/parameter/path.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter/value_collection.rb +1 -1
- data/lib/puppet/parser/ast/arithmetic_operator.rb +8 -0
- data/lib/puppet/parser/ast/casestatement.rb +0 -3
- data/lib/puppet/parser/ast/lambda.rb +25 -6
- data/lib/puppet/parser/ast/leaf.rb +10 -3
- data/lib/puppet/parser/ast/nop.rb +1 -1
- data/lib/puppet/parser/ast/resource_override.rb +0 -2
- data/lib/puppet/parser/compiler.rb +92 -34
- data/lib/puppet/parser/files.rb +0 -5
- data/lib/puppet/parser/functions/create_resources.rb +23 -46
- data/lib/puppet/parser/functions/each.rb +0 -2
- data/lib/puppet/parser/functions/extlookup.rb +2 -2
- data/lib/puppet/parser/functions/foreach.rb +0 -2
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +44 -0
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/grammar.ra +0 -1
- data/lib/puppet/parser/lexer.rb +0 -1
- data/lib/puppet/parser/parser.rb +0 -1
- data/lib/puppet/parser/parser_factory.rb +3 -2
- data/lib/puppet/parser/parser_support.rb +1 -1
- data/lib/puppet/parser/relationship.rb +1 -1
- data/lib/puppet/parser/scope.rb +49 -24
- data/lib/puppet/parser/type_loader.rb +13 -18
- data/lib/puppet/pops.rb +45 -0
- data/lib/puppet/pops/adaptable.rb +2 -2
- data/lib/puppet/pops/adapters.rb +4 -0
- data/lib/puppet/pops/binder/binder.rb +421 -0
- data/lib/puppet/pops/binder/binder_issues.rb +142 -0
- data/lib/puppet/pops/binder/bindings_checker.rb +217 -0
- data/lib/puppet/pops/binder/bindings_composer.rb +241 -0
- data/lib/puppet/pops/binder/bindings_factory.rb +847 -0
- data/lib/puppet/pops/binder/bindings_label_provider.rb +46 -0
- data/lib/puppet/pops/binder/bindings_loader.rb +79 -0
- data/lib/puppet/pops/binder/bindings_model.rb +215 -0
- data/lib/puppet/pops/binder/bindings_model_dumper.rb +205 -0
- data/lib/puppet/pops/binder/bindings_validator_factory.rb +28 -0
- data/lib/puppet/pops/binder/config/binder_config.rb +139 -0
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +183 -0
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +32 -0
- data/lib/puppet/pops/binder/config/issues.rb +106 -0
- data/lib/puppet/pops/binder/hiera2.rb +10 -0
- data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +148 -0
- data/lib/puppet/pops/binder/hiera2/config.rb +69 -0
- data/lib/puppet/pops/binder/hiera2/config_checker.rb +68 -0
- data/lib/puppet/pops/binder/hiera2/diagnostic_producer.rb +36 -0
- data/lib/puppet/pops/binder/hiera2/issues.rb +67 -0
- data/lib/puppet/pops/binder/hiera2/json_backend.rb +18 -0
- data/lib/puppet/pops/binder/hiera2/yaml_backend.rb +21 -0
- data/lib/puppet/pops/binder/injector.rb +688 -0
- data/lib/puppet/pops/binder/injector_entry.rb +53 -0
- data/lib/puppet/pops/binder/key_factory.rb +61 -0
- data/lib/puppet/pops/binder/producers.rb +829 -0
- data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +67 -0
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +34 -0
- data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +92 -0
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +84 -0
- data/lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb +54 -0
- data/lib/puppet/pops/binder/system_bindings.rb +72 -0
- data/lib/puppet/pops/issue_reporter.rb +75 -0
- data/lib/puppet/pops/issues.rb +9 -5
- data/lib/puppet/pops/model/ast_transformer.rb +4 -4
- data/lib/puppet/pops/model/ast_tree_dumper.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +25 -13
- data/lib/puppet/pops/model/model.rb +1 -1
- data/lib/puppet/pops/model/tree_dumper.rb +2 -2
- data/lib/puppet/pops/parser/egrammar.ra +0 -1
- data/lib/puppet/pops/parser/eparser.rb +1 -2
- data/lib/puppet/pops/parser/evaluating_parser.rb +162 -0
- data/lib/puppet/pops/parser/lexer.rb +8 -6
- data/lib/puppet/pops/types/class_loader.rb +118 -0
- data/lib/puppet/pops/types/type_calculator.rb +557 -0
- data/lib/puppet/pops/types/type_factory.rb +147 -0
- data/lib/puppet/pops/types/type_parser.rb +117 -0
- data/lib/puppet/pops/types/types.rb +132 -0
- data/lib/puppet/pops/validation.rb +146 -17
- data/lib/puppet/pops/validation/checker3_1.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_3_1.rb +6 -16
- data/lib/puppet/property.rb +3 -3
- data/lib/puppet/property/keyvalue.rb +1 -1
- data/lib/puppet/provider.rb +2 -2
- data/lib/puppet/provider/aixobject.rb +19 -21
- data/lib/puppet/provider/augeas/augeas.rb +3 -1
- data/lib/puppet/provider/command.rb +2 -2
- data/lib/puppet/provider/group/aix.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +1 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +3 -8
- data/lib/puppet/provider/mcx/mcxcontent.rb +7 -1
- data/lib/puppet/provider/mount.rb +8 -3
- data/lib/puppet/provider/nameservice.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +86 -32
- data/lib/puppet/provider/package/fink.rb +0 -2
- data/lib/puppet/provider/package/freebsd.rb +0 -2
- data/lib/puppet/provider/package/openbsd.rb +57 -10
- data/lib/puppet/provider/package/opkg.rb +0 -1
- data/lib/puppet/provider/package/pacman.rb +0 -1
- data/lib/puppet/provider/package/pip.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +17 -6
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +9 -1
- data/lib/puppet/provider/package/ports.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +29 -12
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +11 -15
- data/lib/puppet/provider/package/windows/exe_package.rb +1 -1
- data/lib/puppet/provider/package/windows/package.rb +1 -26
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +22 -3
- data/lib/puppet/provider/parsedfile.rb +1 -12
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -1
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +3 -3
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +14 -20
- data/lib/puppet/provider/service/openrc.rb +3 -1
- data/lib/puppet/provider/service/redhat.rb +5 -8
- data/lib/puppet/provider/service/runit.rb +3 -2
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +0 -2
- data/lib/puppet/provider/user/aix.rb +25 -12
- data/lib/puppet/provider/user/directoryservice.rb +4 -7
- data/lib/puppet/provider/user/ldap.rb +0 -1
- data/lib/puppet/provider/user/user_role_add.rb +2 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -2
- data/lib/puppet/reference/metaparameter.rb +1 -1
- data/lib/puppet/reference/type.rb +1 -1
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +16 -4
- data/lib/puppet/resource/catalog.rb +111 -173
- data/lib/puppet/resource/status.rb +42 -3
- data/lib/puppet/resource/type.rb +33 -46
- data/lib/puppet/resource/type_collection.rb +19 -15
- data/lib/puppet/run.rb +5 -1
- data/lib/puppet/scheduler/scheduler.rb +14 -15
- data/lib/puppet/settings.rb +78 -41
- data/lib/puppet/settings/boolean_setting.rb +0 -2
- data/lib/puppet/settings/config_file.rb +0 -2
- data/lib/puppet/settings/directory_setting.rb +0 -2
- data/lib/puppet/settings/duration_setting.rb +0 -2
- data/lib/puppet/settings/enum_setting.rb +16 -0
- data/lib/puppet/settings/file_setting.rb +0 -2
- data/lib/puppet/settings/path_setting.rb +0 -2
- data/lib/puppet/settings/string_setting.rb +0 -3
- data/lib/puppet/settings/terminus_setting.rb +0 -2
- data/lib/puppet/ssl/certificate_authority.rb +102 -9
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/transaction.rb +130 -292
- data/lib/puppet/transaction/additional_resource_generator.rb +126 -0
- data/lib/puppet/transaction/event.rb +16 -1
- data/lib/puppet/transaction/report.rb +34 -14
- data/lib/puppet/transaction/resource_harness.rb +16 -19
- data/lib/puppet/type.rb +59 -53
- data/lib/puppet/type/component.rb +0 -2
- data/lib/puppet/type/cron.rb +13 -2
- data/lib/puppet/type/exec.rb +5 -7
- data/lib/puppet/type/file.rb +9 -32
- data/lib/puppet/type/file/content.rb +4 -1
- data/lib/puppet/type/file/ctime.rb +3 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +0 -1
- data/lib/puppet/type/file/mtime.rb +2 -1
- data/lib/puppet/type/group.rb +7 -9
- data/lib/puppet/type/host.rb +1 -2
- data/lib/puppet/type/mcx.rb +0 -1
- data/lib/puppet/type/mount.rb +38 -6
- data/lib/puppet/type/package.rb +2 -2
- data/lib/puppet/type/resources.rb +5 -4
- data/lib/puppet/type/schedule.rb +1 -4
- data/lib/puppet/type/selmodule.rb +1 -1
- data/lib/puppet/type/service.rb +1 -3
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/user.rb +9 -13
- data/lib/puppet/type/yumrepo.rb +11 -7
- data/lib/puppet/util.rb +14 -7
- data/lib/puppet/util/autoload.rb +0 -1
- data/lib/puppet/util/backups.rb +1 -3
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/command_line/puppet_option_parser.rb +1 -3
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/constant_inflector.rb +1 -2
- data/lib/puppet/util/errors.rb +1 -0
- data/lib/puppet/util/file_watcher.rb +28 -0
- data/lib/puppet/util/fileparsing.rb +1 -3
- data/lib/puppet/util/filetype.rb +0 -1
- data/lib/puppet/util/http_proxy.rb +38 -0
- data/lib/puppet/util/ldap/manager.rb +1 -2
- data/lib/puppet/util/log.rb +31 -10
- data/lib/puppet/util/log/destinations.rb +0 -50
- data/lib/puppet/util/metric.rb +8 -1
- data/lib/puppet/util/monkey_patches.rb +14 -148
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +6 -9
- data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
- data/lib/puppet/util/pidlock.rb +3 -0
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +0 -1
- data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +50 -42
- data/lib/puppet/util/retryaction.rb +0 -1
- data/lib/puppet/util/symbolic_file_mode.rb +5 -1
- data/lib/puppet/util/tagging.rb +0 -2
- data/lib/puppet/util/warnings.rb +3 -0
- data/lib/puppet/util/watched_file.rb +37 -0
- data/lib/puppet/util/watcher.rb +17 -0
- data/lib/puppet/util/watcher/change_watcher.rb +33 -0
- data/lib/puppet/util/watcher/periodic_watcher.rb +37 -0
- data/lib/puppet/util/watcher/timer.rb +19 -0
- data/lib/puppet/util/windows/user.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppetx.rb +109 -0
- data/lib/puppetx/puppet/bindings_scheme_handler.rb +130 -0
- data/lib/puppetx/puppet/hiera2_backend.rb +31 -0
- data/lib/puppetx/puppet/syntax_checker.rb +91 -0
- data/lib/puppetx/puppetlabs/syntax_checkers/json.rb +39 -0
- data/lib/semver.rb +1 -1
- data/man/man8/puppet-kick.8 +1 -1
- data/spec/fixtures/integration/provider/cron/crontab/unspecialized +15 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/binder_config.yaml +18 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/hiera.yaml +10 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/binder_config.yaml +19 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/hiera.yaml +11 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/localhost.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/common.yaml +3 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/hiera.yaml +13 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppet/bindings/awesome/default.rb +4 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_backend.rb +11 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_scheme_handler.rb +18 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/localhost.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/common.yaml +3 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/hiera_config.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/common.yaml +2 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/hiera.yaml +11 -0
- data/spec/fixtures/unit/pops/binder/config/binder_config/ok/binder_config.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/hiera.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.json +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.yaml +5 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/bad_syntax/hiera.yaml +10 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/malformed_hierarchy/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/missing/foo.txt +1 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/no_backends/hiera.yaml +7 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/no_hierarchy/hiera.yaml +4 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/not_a_hash/hiera.yaml +2 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/ok/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/empty/common.yaml +0 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/invalid/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/ok/common.yaml +2 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo_flavors.list +2 -0
- data/spec/integration/agent/logging_spec.rb +178 -0
- data/spec/integration/configurer_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +0 -6
- data/spec/integration/network/authconfig_spec.rb +19 -0
- data/spec/integration/network/server/webrick_spec.rb +10 -11
- data/spec/integration/parser/catalog_spec.rb +85 -0
- data/spec/integration/provider/cron/crontab_spec.rb +11 -0
- data/spec/integration/provider/mount_spec.rb +1 -0
- data/spec/integration/transaction_spec.rb +8 -8
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +58 -11
- data/spec/lib/matchers/include_in_order.rb +21 -0
- data/spec/lib/matchers/include_in_order_spec.rb +30 -0
- data/spec/lib/matchers/relationship_graph_matchers.rb +48 -0
- data/spec/lib/puppet_spec/compiler.rb +24 -0
- data/spec/lib/puppet_spec/pops.rb +16 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/application/agent_spec.rb +145 -145
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/doc_spec.rb +1 -1
- data/spec/unit/application/face_base_spec.rb +3 -3
- data/spec/unit/application/facts_spec.rb +1 -0
- data/spec/unit/application/master_spec.rb +0 -15
- data/spec/unit/application/queue_spec.rb +6 -12
- data/spec/unit/application/resource_spec.rb +1 -1
- data/spec/unit/configurer/fact_handler_spec.rb +19 -50
- data/spec/unit/configurer_spec.rb +23 -7
- data/spec/unit/daemon_spec.rb +97 -121
- data/spec/unit/defaults_spec.rb +44 -0
- data/spec/unit/face/node_spec.rb +2 -2
- data/spec/unit/file_serving/configuration/parser_spec.rb +23 -33
- data/spec/unit/file_serving/configuration_spec.rb +2 -2
- data/spec/unit/file_serving/mount/file_spec.rb +4 -4
- data/spec/unit/forge/repository_spec.rb +9 -29
- data/spec/unit/graph/key_spec.rb +41 -0
- data/spec/unit/{rb_tree_map_spec.rb → graph/rb_tree_map_spec.rb} +7 -7
- data/spec/unit/graph/relationship_graph_spec.rb +393 -0
- data/spec/unit/graph/sequential_prioritizer_spec.rb +32 -0
- data/spec/unit/{simple_graph_spec.rb → graph/simple_graph.rb} +42 -254
- data/spec/unit/graph/title_hash_prioritizer_spec.rb +49 -0
- data/spec/unit/hiera_puppet_spec.rb +1 -1
- data/spec/unit/indirector/catalog/active_record_spec.rb +4 -2
- data/spec/unit/indirector/catalog/compiler_spec.rb +20 -26
- data/spec/unit/indirector/face_spec.rb +1 -1
- data/spec/unit/indirector/facts/facter_spec.rb +11 -1
- data/spec/unit/indirector/facts/network_device_spec.rb +11 -1
- data/spec/unit/indirector/hiera_spec.rb +1 -1
- data/spec/unit/indirector/instrumentation_data/local_spec.rb +1 -1
- data/spec/unit/indirector/instrumentation_listener/local_spec.rb +1 -1
- data/spec/unit/indirector/request_spec.rb +92 -39
- data/spec/unit/indirector/rest_spec.rb +1 -0
- data/spec/unit/indirector_spec.rb +2 -2
- data/spec/unit/interface/option_builder_spec.rb +1 -0
- data/spec/unit/interface/option_spec.rb +1 -0
- data/spec/unit/interface_spec.rb +2 -2
- data/spec/unit/module_tool/applications/installer_spec.rb +49 -2
- data/spec/unit/module_tool/metadata_spec.rb +13 -0
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/format_handler_spec.rb +33 -282
- data/spec/unit/network/format_support_spec.rb +199 -0
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http/connection_spec.rb +88 -7
- data/spec/unit/network/http/handler_spec.rb +271 -249
- data/spec/unit/network/http/rack/rest_spec.rb +1 -1
- data/spec/unit/network/http/webrick/rest_spec.rb +73 -22
- data/spec/unit/network/http_pool_spec.rb +40 -0
- data/spec/unit/network/server_spec.rb +18 -207
- data/spec/unit/node/facts_spec.rb +68 -17
- data/spec/unit/other/selinux_spec.rb +24 -20
- data/spec/unit/parameter/boolean_spec.rb +25 -0
- data/spec/unit/parameter/value_collection_spec.rb +7 -7
- data/spec/unit/parameter_spec.rb +10 -13
- data/spec/unit/parser/ast/function_spec.rb +4 -4
- data/spec/unit/parser/ast/leaf_spec.rb +45 -6
- data/spec/unit/parser/collector_spec.rb +3 -3
- data/spec/unit/parser/compiler_spec.rb +4 -3
- data/spec/unit/parser/functions/create_resources_spec.rb +9 -25
- data/spec/unit/parser/functions/extlookup_spec.rb +2 -2
- data/spec/unit/parser/functions/hiera_include_spec.rb +12 -0
- data/spec/unit/parser/functions/lookup_spec.rb +96 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +2 -2
- data/spec/unit/parser/functions/split_spec.rb +2 -2
- data/spec/unit/parser/functions/sprintf_spec.rb +1 -1
- data/spec/unit/parser/functions/versioncmp_spec.rb +2 -2
- data/spec/unit/parser/functions_spec.rb +7 -7
- data/spec/unit/parser/lexer_spec.rb +1 -1
- data/spec/unit/parser/methods/collect_spec.rb +43 -0
- data/spec/unit/parser/resource_spec.rb +9 -9
- data/spec/unit/parser/scope_spec.rb +45 -2
- data/spec/unit/parser/type_loader_spec.rb +159 -175
- data/spec/unit/pops/binder/binder_spec.rb +62 -0
- data/spec/unit/pops/binder/bindings_checker_spec.rb +196 -0
- data/spec/unit/pops/binder/bindings_composer_spec.rb +89 -0
- data/spec/unit/pops/binder/bindings_validator_factory_spec.rb +18 -0
- data/spec/unit/pops/binder/config/binder_config_spec.rb +48 -0
- data/spec/unit/pops/binder/hiera2/bindings_provider_spec.rb +74 -0
- data/spec/unit/pops/binder/hiera2/config_spec.rb +61 -0
- data/spec/unit/pops/binder/hiera2/yaml_backend_spec.rb +33 -0
- data/spec/unit/pops/binder/injector_spec.rb +789 -0
- data/spec/unit/pops/containment_spec.rb +1 -0
- data/spec/unit/pops/issues_spec.rb +1 -1
- data/spec/unit/pops/parser/evaluating_parser_spec.rb +88 -0
- data/spec/unit/pops/parser/lexer_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_calls_spec.rb +4 -0
- data/spec/unit/pops/parser/parser_spec.rb +1 -1
- data/spec/unit/pops/types/type_calculator_spec.rb +484 -0
- data/spec/unit/pops/types/type_factory_spec.rb +65 -0
- data/spec/unit/pops/types/type_parser_spec.rb +93 -0
- data/spec/unit/property/list_spec.rb +1 -1
- data/spec/unit/property/ordered_list_spec.rb +1 -1
- data/spec/unit/provider/aixobject_spec.rb +101 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +14 -3
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +52 -16
- data/spec/unit/provider/mount/parsed_spec.rb +44 -56
- data/spec/unit/provider/mount_spec.rb +11 -2
- data/spec/unit/provider/naginator_spec.rb +8 -0
- data/spec/unit/provider/package/apt_spec.rb +5 -1
- data/spec/unit/provider/package/aptitude_spec.rb +9 -5
- data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
- data/spec/unit/provider/package/dpkg_spec.rb +274 -99
- data/spec/unit/provider/package/openbsd_spec.rb +84 -1
- data/spec/unit/provider/package/opkg_spec.rb +3 -3
- data/spec/unit/provider/package/pip_spec.rb +16 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +62 -7
- data/spec/unit/provider/package/rpm_spec.rb +112 -21
- data/spec/unit/provider/package/urpmi.rb +80 -0
- data/spec/unit/provider/package/windows/exe_package_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +85 -0
- data/spec/unit/provider/package/zypper_spec.rb +25 -6
- data/spec/unit/provider/parsedfile_spec.rb +3 -2
- data/spec/unit/provider/service/init_spec.rb +10 -10
- data/spec/unit/provider/service/openrc_spec.rb +16 -0
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/redhat_spec.rb +7 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
- data/spec/unit/provider/user/aix_spec.rb +89 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +11 -4
- data/spec/unit/provider/user/user_role_add_spec.rb +18 -0
- data/spec/unit/provider_spec.rb +2 -13
- data/spec/unit/reports/http_spec.rb +1 -1
- data/spec/unit/resource/catalog_spec.rb +23 -97
- data/spec/unit/resource/resource_type.json +34 -0
- data/spec/unit/resource/status_spec.rb +56 -0
- data/spec/unit/resource/type_collection_spec.rb +6 -6
- data/spec/unit/resource/type_spec.rb +25 -5
- data/spec/unit/resource_spec.rb +68 -24
- data/spec/unit/run_spec.rb +16 -0
- data/spec/unit/scheduler/scheduler_spec.rb +14 -27
- data/spec/unit/semver_spec.rb +5 -0
- data/spec/unit/settings/enum_setting_spec.rb +27 -0
- data/spec/unit/settings_spec.rb +53 -44
- data/spec/unit/ssl/certificate_authority_spec.rb +155 -19
- data/spec/unit/transaction/additional_resource_generator_spec.rb +419 -0
- data/spec/unit/transaction/event_manager_spec.rb +2 -2
- data/spec/unit/transaction/event_spec.rb +57 -0
- data/spec/unit/transaction/report_spec.rb +66 -0
- data/spec/unit/transaction/resource_harness_spec.rb +27 -20
- data/spec/unit/transaction_spec.rb +182 -390
- data/spec/unit/type/augeas_spec.rb +3 -3
- data/spec/unit/type/component_spec.rb +0 -9
- data/spec/unit/type/computer_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +2 -2
- data/spec/unit/type/exec_spec.rb +4 -2
- data/spec/unit/type/file/content_spec.rb +11 -0
- data/spec/unit/type/file/group_spec.rb +1 -1
- data/spec/unit/type/file_spec.rb +16 -8
- data/spec/unit/type/mount_spec.rb +445 -259
- data/spec/unit/type/package_spec.rb +4 -4
- data/spec/unit/type/resources_spec.rb +30 -1
- data/spec/unit/type/user_spec.rb +26 -3
- data/spec/unit/type/yumrepo_spec.rb +7 -27
- data/spec/unit/type/zone_spec.rb +4 -1
- data/spec/unit/type_spec.rb +66 -33
- data/spec/unit/util/backups_spec.rb +3 -3
- data/spec/unit/util/http_proxy_spec.rb +83 -0
- data/spec/unit/util/log_spec.rb +79 -8
- data/spec/unit/util/metric_spec.rb +12 -0
- data/spec/unit/util/monkey_patches_spec.rb +6 -0
- data/spec/unit/util/network_device/config_spec.rb +26 -64
- data/spec/unit/util/pidlock_spec.rb +4 -1
- data/spec/unit/util/tagging_spec.rb +5 -9
- data/spec/unit/util/warnings_spec.rb +1 -1
- data/spec/unit/util/watched_file_spec.rb +52 -0
- data/spec/unit/util/watcher/periodic_watcher_spec.rb +52 -0
- data/spec/unit/util/watcher_spec.rb +56 -0
- data/spec/unit/util_spec.rb +16 -0
- metadata +2767 -2576
- data/ext/debian/puppet.manpages +0 -32
- data/ext/osx/PackageInfo.plist +0 -36
- data/ext/osx/createpackage.sh +0 -187
- data/ext/redhat/rundir-perms.patch +0 -28
- data/lib/puppet/external/base64.rb +0 -19
- data/lib/puppet/util/graph.rb +0 -27
- data/lib/puppet/util/loadedfile.rb +0 -61
- data/lib/puppet/util/log_paths.rb +0 -22
- data/lib/puppet/util/subclass_loader.rb +0 -78
- data/spec/monkey_patches/publicize_methods.rb +0 -11
- data/spec/unit/util/loadedfile_spec.rb +0 -71
@@ -147,7 +147,7 @@ describe Puppet::Transaction::EventManager do
|
|
147
147
|
|
148
148
|
describe "when processing events for a given resource" do
|
149
149
|
before do
|
150
|
-
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
|
150
|
+
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, nil, nil)
|
151
151
|
@manager = Puppet::Transaction::EventManager.new(@transaction)
|
152
152
|
@manager.stubs(:queue_events)
|
153
153
|
|
@@ -271,7 +271,7 @@ describe Puppet::Transaction::EventManager do
|
|
271
271
|
|
272
272
|
describe "when queueing then processing events for a given resource" do
|
273
273
|
before do
|
274
|
-
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
|
274
|
+
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, nil, nil)
|
275
275
|
@manager = Puppet::Transaction::EventManager.new(@transaction)
|
276
276
|
|
277
277
|
@resource = Puppet::Type.type(:file).new :path => make_absolute("/my/file")
|
@@ -140,4 +140,61 @@ describe Puppet::Transaction::Event do
|
|
140
140
|
event.to_yaml_properties.should =~ Puppet::Transaction::Event::YAML_ATTRIBUTES
|
141
141
|
end
|
142
142
|
end
|
143
|
+
|
144
|
+
it "should round trip through pson" do
|
145
|
+
resource = Puppet::Type.type(:file).new(:title => make_absolute("/tmp/foo"))
|
146
|
+
event = Puppet::Transaction::Event.new(
|
147
|
+
:source_description => "/my/param",
|
148
|
+
:resource => resource,
|
149
|
+
:file => "/foo.rb",
|
150
|
+
:line => 27,
|
151
|
+
:tags => %w{one two},
|
152
|
+
:desired_value => 7,
|
153
|
+
:historical_value => 'Brazil',
|
154
|
+
:message => "Help I'm trapped in a spec test",
|
155
|
+
:name => :mode_changed,
|
156
|
+
:previous_value => 6,
|
157
|
+
:property => :mode,
|
158
|
+
:status => 'success')
|
159
|
+
|
160
|
+
tripped = Puppet::Transaction::Event.from_pson(PSON.parse(event.to_pson))
|
161
|
+
|
162
|
+
tripped.audited.should == event.audited
|
163
|
+
tripped.property.should == event.property
|
164
|
+
tripped.previous_value.should == event.previous_value
|
165
|
+
tripped.desired_value.should == event.desired_value
|
166
|
+
tripped.historical_value.should == event.historical_value
|
167
|
+
tripped.message.should == event.message
|
168
|
+
tripped.name.should == event.name
|
169
|
+
tripped.status.should == event.status
|
170
|
+
tripped.time.should == event.time
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should round trip an event for an inspect report through pson" do
|
174
|
+
resource = Puppet::Type.type(:file).new(:title => make_absolute("/tmp/foo"))
|
175
|
+
event = Puppet::Transaction::Event.new(
|
176
|
+
:audited => true,
|
177
|
+
:source_description => "/my/param",
|
178
|
+
:resource => resource,
|
179
|
+
:file => "/foo.rb",
|
180
|
+
:line => 27,
|
181
|
+
:tags => %w{one two},
|
182
|
+
:message => "Help I'm trapped in a spec test",
|
183
|
+
:previous_value => 6,
|
184
|
+
:property => :mode,
|
185
|
+
:status => 'success')
|
186
|
+
|
187
|
+
tripped = Puppet::Transaction::Event.from_pson(PSON.parse(event.to_pson))
|
188
|
+
|
189
|
+
tripped.desired_value.should be_nil
|
190
|
+
tripped.historical_value.should be_nil
|
191
|
+
tripped.name.should be_nil
|
192
|
+
|
193
|
+
tripped.audited.should == event.audited
|
194
|
+
tripped.property.should == event.property
|
195
|
+
tripped.previous_value.should == event.previous_value
|
196
|
+
tripped.message.should == event.message
|
197
|
+
tripped.status.should == event.status
|
198
|
+
tripped.time.should == event.time
|
199
|
+
end
|
143
200
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
+
require 'puppet'
|
4
5
|
require 'puppet/transaction/report'
|
5
6
|
|
6
7
|
describe Puppet::Transaction::Report do
|
@@ -32,12 +33,22 @@ describe Puppet::Transaction::Report do
|
|
32
33
|
Puppet::Transaction::Report.new("inspect", "some configuration version", "some environment").configuration_version.should == "some configuration version"
|
33
34
|
end
|
34
35
|
|
36
|
+
it "should take a 'transaction_uuid' as an argument" do
|
37
|
+
Puppet::Transaction::Report.new("inspect", "some configuration version", "some environment", "some transaction uuid").transaction_uuid.should == "some transaction uuid"
|
38
|
+
end
|
39
|
+
|
35
40
|
it "should be able to set configuration_version" do
|
36
41
|
report = Puppet::Transaction::Report.new("inspect")
|
37
42
|
report.configuration_version = "some version"
|
38
43
|
report.configuration_version.should == "some version"
|
39
44
|
end
|
40
45
|
|
46
|
+
it "should be able to set transaction_uuid" do
|
47
|
+
report = Puppet::Transaction::Report.new("inspect")
|
48
|
+
report.transaction_uuid = "some transaction uuid"
|
49
|
+
report.transaction_uuid.should == "some transaction uuid"
|
50
|
+
end
|
51
|
+
|
41
52
|
it "should take 'environment' as an argument" do
|
42
53
|
Puppet::Transaction::Report.new("inspect", "some configuration version", "some environment").environment.should == "some environment"
|
43
54
|
end
|
@@ -82,6 +93,18 @@ describe Puppet::Transaction::Report do
|
|
82
93
|
end
|
83
94
|
end
|
84
95
|
|
96
|
+
describe "#as_logging_destination" do
|
97
|
+
it "makes the report collect logs during the block " do
|
98
|
+
log_string = 'Hello test report!'
|
99
|
+
report = Puppet::Transaction::Report.new('test')
|
100
|
+
report.as_logging_destination do
|
101
|
+
Puppet.err(log_string)
|
102
|
+
end
|
103
|
+
|
104
|
+
expect(report.logs.collect(&:message)).to include(log_string)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
85
108
|
describe "when accepting resource statuses" do
|
86
109
|
before do
|
87
110
|
@report = Puppet::Transaction::Report.new("apply")
|
@@ -351,4 +374,47 @@ describe Puppet::Transaction::Report do
|
|
351
374
|
report.to_yaml_properties.should_not include('@external_times')
|
352
375
|
end
|
353
376
|
end
|
377
|
+
|
378
|
+
it "can make a round trip through pson" do
|
379
|
+
status = Puppet::Resource::Status.new(Puppet::Type.type(:notify).new(:title => "a resource"))
|
380
|
+
status.changed = true
|
381
|
+
|
382
|
+
report = Puppet::Transaction::Report.new('testy', 1357986, 'test_environment', "df34516e-4050-402d-a166-05b03b940749")
|
383
|
+
report << Puppet::Util::Log.new(:level => :warning, :message => "log message")
|
384
|
+
report.add_times("timing", 4)
|
385
|
+
report.add_resource_status(status)
|
386
|
+
report.finalize_report
|
387
|
+
|
388
|
+
tripped = Puppet::Transaction::Report.convert_from(:pson, report.render(:pson))
|
389
|
+
|
390
|
+
tripped.host.should == report.host
|
391
|
+
tripped.time.should == report.time
|
392
|
+
tripped.configuration_version.should == report.configuration_version
|
393
|
+
tripped.transaction_uuid.should == report.transaction_uuid
|
394
|
+
tripped.report_format.should == report.report_format
|
395
|
+
tripped.puppet_version.should == report.puppet_version
|
396
|
+
tripped.kind.should == report.kind
|
397
|
+
tripped.status.should == report.status
|
398
|
+
tripped.environment.should == report.environment
|
399
|
+
|
400
|
+
logs_as_strings(tripped).should == logs_as_strings(report)
|
401
|
+
metrics_as_hashes(tripped).should == metrics_as_hashes(report)
|
402
|
+
resource_statuses_as_hashes(tripped).should == resource_statuses_as_hashes(report)
|
403
|
+
end
|
404
|
+
|
405
|
+
def logs_as_strings(report)
|
406
|
+
report.logs.map(&:to_report)
|
407
|
+
end
|
408
|
+
|
409
|
+
def metrics_as_hashes(report)
|
410
|
+
Hash[*report.metrics.collect do |name, m|
|
411
|
+
[name, { :name => m.name, :label => m.label, :value => m.value }]
|
412
|
+
end.flatten]
|
413
|
+
end
|
414
|
+
|
415
|
+
def resource_statuses_as_hashes(report)
|
416
|
+
Hash[*report.resource_statuses.collect do |name, s|
|
417
|
+
[name, PSON.parse(s.to_pson)]
|
418
|
+
end.flatten]
|
419
|
+
end
|
354
420
|
end
|
@@ -11,13 +11,11 @@ describe Puppet::Transaction::ResourceHarness do
|
|
11
11
|
@mode_755 = Puppet.features.microsoft_windows? ? '644' : '755'
|
12
12
|
path = make_absolute("/my/file")
|
13
13
|
|
14
|
-
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
|
14
|
+
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, nil, nil)
|
15
15
|
@resource = Puppet::Type.type(:file).new :path => path
|
16
16
|
@harness = Puppet::Transaction::ResourceHarness.new(@transaction)
|
17
17
|
@current_state = Puppet::Resource.new(:file, path)
|
18
18
|
@resource.stubs(:retrieve).returns @current_state
|
19
|
-
@status = Puppet::Resource::Status.new(@resource)
|
20
|
-
Puppet::Resource::Status.stubs(:new).returns @status
|
21
19
|
end
|
22
20
|
|
23
21
|
it "should accept a transaction at initialization" do
|
@@ -31,28 +29,38 @@ describe Puppet::Transaction::ResourceHarness do
|
|
31
29
|
end
|
32
30
|
|
33
31
|
describe "when evaluating a resource" do
|
34
|
-
it "
|
35
|
-
@harness.evaluate(@resource)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should fail if no status can be created" do
|
39
|
-
Puppet::Resource::Status.expects(:new).raises ArgumentError
|
32
|
+
it "produces a resource state that describes what happened with the resource" do
|
33
|
+
status = @harness.evaluate(@resource)
|
40
34
|
|
41
|
-
|
35
|
+
status.resource.should == @resource.ref
|
36
|
+
status.should_not be_failed
|
37
|
+
status.events.should be_empty
|
42
38
|
end
|
43
39
|
|
44
|
-
it "
|
40
|
+
it "retrieves the current state of the resource" do
|
45
41
|
@resource.expects(:retrieve).returns @current_state
|
42
|
+
|
46
43
|
@harness.evaluate(@resource)
|
47
44
|
end
|
48
45
|
|
49
|
-
it "
|
50
|
-
|
51
|
-
@
|
46
|
+
it "produces a failure status for the resource when an error occurs" do
|
47
|
+
the_message = "retrieve failed in testing"
|
48
|
+
@resource.expects(:retrieve).raises(ArgumentError.new(the_message))
|
49
|
+
|
50
|
+
status = @harness.evaluate(@resource)
|
51
|
+
|
52
|
+
status.should be_failed
|
53
|
+
events_to_hash(status.events).collect do |event|
|
54
|
+
{ :@status => event[:@status], :@message => event[:@message] }
|
55
|
+
end.should == [{ :@status => "failure", :@message => the_message }]
|
52
56
|
end
|
53
57
|
|
54
|
-
it "
|
55
|
-
|
58
|
+
it "records the time it took to evaluate the resource" do
|
59
|
+
before = Time.now
|
60
|
+
status = @harness.evaluate(@resource)
|
61
|
+
after = Time.now
|
62
|
+
|
63
|
+
status.evaluation_time.should be <= after - before
|
56
64
|
end
|
57
65
|
end
|
58
66
|
|
@@ -470,17 +478,16 @@ describe Puppet::Transaction::ResourceHarness do
|
|
470
478
|
before do
|
471
479
|
@catalog = Puppet::Resource::Catalog.new
|
472
480
|
@resource.catalog = @catalog
|
473
|
-
@status = Puppet::Resource::Status.new(@resource)
|
474
481
|
end
|
475
482
|
|
476
483
|
it "should return true if 'ignoreschedules' is set" do
|
477
484
|
Puppet[:ignoreschedules] = true
|
478
485
|
@resource[:schedule] = "meh"
|
479
|
-
@harness.should be_scheduled(@
|
486
|
+
@harness.should be_scheduled(@resource)
|
480
487
|
end
|
481
488
|
|
482
489
|
it "should return true if the resource has no schedule set" do
|
483
|
-
@harness.should be_scheduled(@
|
490
|
+
@harness.should be_scheduled(@resource)
|
484
491
|
end
|
485
492
|
|
486
493
|
it "should return the result of matching the schedule with the cached 'checked' time if a schedule is set" do
|
@@ -493,7 +500,7 @@ describe Puppet::Transaction::ResourceHarness do
|
|
493
500
|
|
494
501
|
sched.expects(:match?).with(t.to_i).returns "feh"
|
495
502
|
|
496
|
-
@harness.scheduled?(@
|
503
|
+
@harness.scheduled?(@resource).should == "feh"
|
497
504
|
end
|
498
505
|
end
|
499
506
|
|
@@ -1,50 +1,37 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'spec_helper'
|
3
|
+
require 'matchers/include_in_order'
|
4
|
+
require 'puppet_spec/compiler'
|
3
5
|
|
4
6
|
require 'puppet/transaction'
|
5
7
|
require 'fileutils'
|
6
8
|
|
7
|
-
def without_warnings
|
8
|
-
flag = $VERBOSE
|
9
|
-
$VERBOSE = nil
|
10
|
-
yield
|
11
|
-
$VERBOSE = flag
|
12
|
-
end
|
13
|
-
|
14
9
|
describe Puppet::Transaction do
|
15
10
|
include PuppetSpec::Files
|
11
|
+
include PuppetSpec::Compiler
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
def catalog_with_resource(resource)
|
14
|
+
catalog = Puppet::Resource::Catalog.new
|
15
|
+
catalog.add_resource(resource)
|
16
|
+
catalog
|
20
17
|
end
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@transaction.events.should == %w{my events}
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should delegate adding times to its report" do
|
29
|
-
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
|
30
|
-
@transaction.report.expects(:add_times).with(:foo, 10)
|
31
|
-
@transaction.report.expects(:add_times).with(:bar, 20)
|
32
|
-
|
33
|
-
@transaction.add_times :foo => 10, :bar => 20
|
19
|
+
def transaction_with_resource(resource)
|
20
|
+
transaction = Puppet::Transaction.new(catalog_with_resource(resource), nil, Puppet::Graph::RandomPrioritizer.new)
|
21
|
+
transaction
|
34
22
|
end
|
35
23
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@transaction.add_resource_status(status)
|
40
|
-
@transaction.resource_status(resource).should equal(status)
|
24
|
+
before do
|
25
|
+
@basepath = make_absolute("/what/ever")
|
26
|
+
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, nil, Puppet::Graph::RandomPrioritizer.new)
|
41
27
|
end
|
42
28
|
|
43
29
|
it "should be able to look resource status up by resource reference" do
|
44
30
|
resource = Puppet::Type.type(:notify).new :title => "foobar"
|
45
|
-
|
46
|
-
|
47
|
-
|
31
|
+
transaction = transaction_with_resource(resource)
|
32
|
+
transaction.evaluate
|
33
|
+
|
34
|
+
transaction.resource_status(resource.to_s).should be_changed
|
48
35
|
end
|
49
36
|
|
50
37
|
# This will basically only ever be used during testing.
|
@@ -55,86 +42,72 @@ describe Puppet::Transaction do
|
|
55
42
|
|
56
43
|
it "should add provided resource statuses to its report" do
|
57
44
|
resource = Puppet::Type.type(:notify).new :title => "foobar"
|
58
|
-
|
59
|
-
|
60
|
-
@transaction.report.resource_statuses[resource.to_s].should equal(status)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should consider a resource to be failed if a status instance exists for that resource and indicates it is failed" do
|
64
|
-
resource = Puppet::Type.type(:notify).new :name => "yayness"
|
65
|
-
status = Puppet::Resource::Status.new(resource)
|
66
|
-
status.failed = "some message"
|
67
|
-
@transaction.add_resource_status(status)
|
68
|
-
@transaction.should be_failed(resource)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should not consider a resource to be failed if a status instance exists for that resource but indicates it is not failed" do
|
72
|
-
resource = Puppet::Type.type(:notify).new :name => "yayness"
|
73
|
-
status = Puppet::Resource::Status.new(resource)
|
74
|
-
@transaction.add_resource_status(status)
|
75
|
-
@transaction.should_not be_failed(resource)
|
76
|
-
end
|
45
|
+
transaction = transaction_with_resource(resource)
|
46
|
+
transaction.evaluate
|
77
47
|
|
78
|
-
|
79
|
-
resource
|
80
|
-
status = Puppet::Resource::Status.new(resource)
|
81
|
-
status.failed = "some message"
|
82
|
-
@transaction.add_resource_status(status)
|
83
|
-
@transaction.should be_any_failed
|
48
|
+
status = transaction.resource_status(resource)
|
49
|
+
transaction.report.resource_statuses[resource.to_s].should equal(status)
|
84
50
|
end
|
85
51
|
|
86
52
|
it "should not consider there to be failed resources if no statuses are marked failed" do
|
87
|
-
resource = Puppet::Type.type(:notify).new :
|
88
|
-
|
89
|
-
|
90
|
-
|
53
|
+
resource = Puppet::Type.type(:notify).new :title => "foobar"
|
54
|
+
transaction = transaction_with_resource(resource)
|
55
|
+
transaction.evaluate
|
56
|
+
|
57
|
+
transaction.should_not be_any_failed
|
91
58
|
end
|
92
59
|
|
93
60
|
it "should use the provided report object" do
|
94
61
|
report = Puppet::Transaction::Report.new("apply")
|
95
|
-
|
62
|
+
transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, report, nil)
|
96
63
|
|
97
|
-
|
64
|
+
transaction.report.should == report
|
98
65
|
end
|
99
66
|
|
100
67
|
it "should create a report if none is provided" do
|
101
|
-
|
68
|
+
transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, nil, nil)
|
102
69
|
|
103
|
-
|
70
|
+
transaction.report.should be_kind_of Puppet::Transaction::Report
|
104
71
|
end
|
105
72
|
|
106
73
|
describe "when initializing" do
|
107
74
|
it "should create an event manager" do
|
108
|
-
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
|
75
|
+
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, nil, nil)
|
109
76
|
@transaction.event_manager.should be_instance_of(Puppet::Transaction::EventManager)
|
110
77
|
@transaction.event_manager.transaction.should equal(@transaction)
|
111
78
|
end
|
112
79
|
|
113
80
|
it "should create a resource harness" do
|
114
|
-
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
|
81
|
+
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new, nil, nil)
|
115
82
|
@transaction.resource_harness.should be_instance_of(Puppet::Transaction::ResourceHarness)
|
116
83
|
@transaction.resource_harness.transaction.should equal(@transaction)
|
117
84
|
end
|
85
|
+
|
86
|
+
it "should set retrieval time on the report" do
|
87
|
+
catalog = Puppet::Resource::Catalog.new
|
88
|
+
report = Puppet::Transaction::Report.new("apply")
|
89
|
+
catalog.retrieval_duration = 5
|
90
|
+
|
91
|
+
report.expects(:add_times).with(:config_retrieval, 5)
|
92
|
+
|
93
|
+
transaction = Puppet::Transaction.new(catalog, report, nil)
|
94
|
+
end
|
118
95
|
end
|
119
96
|
|
120
97
|
describe "when evaluating a resource" do
|
121
98
|
before do
|
122
|
-
@
|
123
|
-
@transaction.stubs(:skip?).returns false
|
124
|
-
|
99
|
+
@catalog = Puppet::Resource::Catalog.new
|
125
100
|
@resource = Puppet::Type.type(:file).new :path => @basepath
|
126
|
-
|
101
|
+
@catalog.add_resource(@resource)
|
127
102
|
|
128
|
-
|
129
|
-
@transaction.
|
130
|
-
|
131
|
-
@transaction.eval_resource(@resource)
|
103
|
+
@transaction = Puppet::Transaction.new(@catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
104
|
+
@transaction.stubs(:skip?).returns false
|
132
105
|
end
|
133
106
|
|
134
107
|
it "should process events" do
|
135
108
|
@transaction.event_manager.expects(:process_events).with(@resource)
|
136
109
|
|
137
|
-
@transaction.
|
110
|
+
@transaction.evaluate
|
138
111
|
end
|
139
112
|
|
140
113
|
describe "and the resource should be skipped" do
|
@@ -143,7 +116,7 @@ describe Puppet::Transaction do
|
|
143
116
|
end
|
144
117
|
|
145
118
|
it "should mark the resource's status as skipped" do
|
146
|
-
@transaction.
|
119
|
+
@transaction.evaluate
|
147
120
|
@transaction.resource_status(@resource).should be_skipped
|
148
121
|
end
|
149
122
|
end
|
@@ -151,149 +124,44 @@ describe Puppet::Transaction do
|
|
151
124
|
|
152
125
|
describe "when applying a resource" do
|
153
126
|
before do
|
127
|
+
@catalog = Puppet::Resource::Catalog.new
|
154
128
|
@resource = Puppet::Type.type(:file).new :path => @basepath
|
129
|
+
@catalog.add_resource(@resource)
|
155
130
|
@status = Puppet::Resource::Status.new(@resource)
|
156
131
|
|
157
|
-
@transaction = Puppet::Transaction.new(Puppet::
|
132
|
+
@transaction = Puppet::Transaction.new(@catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
158
133
|
@transaction.event_manager.stubs(:queue_events)
|
159
|
-
@transaction.resource_harness.stubs(:evaluate).returns(@status)
|
160
134
|
end
|
161
135
|
|
162
136
|
it "should use its resource harness to apply the resource" do
|
163
137
|
@transaction.resource_harness.expects(:evaluate).with(@resource)
|
164
|
-
@transaction.
|
138
|
+
@transaction.evaluate
|
165
139
|
end
|
166
140
|
|
167
141
|
it "should add the resulting resource status to its status list" do
|
168
|
-
@transaction.
|
142
|
+
@transaction.resource_harness.stubs(:evaluate).returns(@status)
|
143
|
+
@transaction.evaluate
|
169
144
|
@transaction.resource_status(@resource).should be_instance_of(Puppet::Resource::Status)
|
170
145
|
end
|
171
146
|
|
172
147
|
it "should queue any events added to the resource status" do
|
148
|
+
@transaction.resource_harness.stubs(:evaluate).returns(@status)
|
173
149
|
@status.expects(:events).returns %w{a b}
|
174
150
|
@transaction.event_manager.expects(:queue_events).with(@resource, ["a", "b"])
|
175
|
-
@transaction.
|
151
|
+
@transaction.evaluate
|
176
152
|
end
|
177
153
|
|
178
154
|
it "should log and skip any resources that cannot be applied" do
|
179
|
-
@
|
180
|
-
@
|
181
|
-
@transaction.
|
182
|
-
@transaction.report.resource_statuses[@resource.to_s].should be_nil
|
155
|
+
@resource.expects(:properties).raises ArgumentError
|
156
|
+
@transaction.evaluate
|
157
|
+
@transaction.report.resource_statuses[@resource.to_s].should be_failed
|
183
158
|
end
|
184
|
-
end
|
185
159
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
let(:graph) { @transaction.relationship_graph }
|
160
|
+
it "should report any_failed if any resources failed" do
|
161
|
+
@resource.expects(:properties).raises ArgumentError
|
162
|
+
@transaction.evaluate
|
190
163
|
|
191
|
-
|
192
|
-
graph.vertices.find {|v| v.type == type and v.title == title}
|
193
|
-
end
|
194
|
-
|
195
|
-
before :each do
|
196
|
-
@filenames = []
|
197
|
-
|
198
|
-
'a'.upto('c') do |x|
|
199
|
-
@filenames << File.join(path,x)
|
200
|
-
|
201
|
-
'a'.upto('c') do |y|
|
202
|
-
@filenames << File.join(path,x,y)
|
203
|
-
FileUtils.mkdir_p(File.join(path,x,y))
|
204
|
-
|
205
|
-
'a'.upto('c') do |z|
|
206
|
-
@filenames << File.join(path,x,y,z)
|
207
|
-
FileUtils.touch(File.join(path,x,y,z))
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
@transaction.catalog.add_resource(resource)
|
213
|
-
end
|
214
|
-
|
215
|
-
it "should add the generated resources to the catalog" do
|
216
|
-
@transaction.eval_generate(resource)
|
217
|
-
|
218
|
-
@filenames.each do |file|
|
219
|
-
@transaction.catalog.resource(:file, file).must be_a(Puppet::Type.type(:file))
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
it "should add a sentinel whit for the resource" do
|
224
|
-
@transaction.eval_generate(resource)
|
225
|
-
|
226
|
-
find_vertex(:whit, "completed_#{path}").must be_a(Puppet::Type.type(:whit))
|
227
|
-
end
|
228
|
-
|
229
|
-
it "should replace dependencies on the resource with dependencies on the sentinel" do
|
230
|
-
dependent = Puppet::Type.type(:notify).new(:name => "hello", :require => resource)
|
231
|
-
|
232
|
-
@transaction.catalog.add_resource(dependent)
|
233
|
-
|
234
|
-
res = find_vertex(resource.type, resource.title)
|
235
|
-
generated = find_vertex(dependent.type, dependent.title)
|
236
|
-
|
237
|
-
graph.should be_edge(res, generated)
|
238
|
-
|
239
|
-
@transaction.eval_generate(resource)
|
240
|
-
|
241
|
-
sentinel = find_vertex(:whit, "completed_#{path}")
|
242
|
-
|
243
|
-
graph.should be_edge(sentinel, generated)
|
244
|
-
graph.should_not be_edge(res, generated)
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should add an edge from the nearest ancestor to the generated resource" do
|
248
|
-
@transaction.eval_generate(resource)
|
249
|
-
|
250
|
-
@filenames.each do |file|
|
251
|
-
v = find_vertex(:file, file)
|
252
|
-
p = find_vertex(:file, File.dirname(file))
|
253
|
-
|
254
|
-
graph.should be_edge(p, v)
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
it "should add an edge from each generated resource to the sentinel" do
|
259
|
-
@transaction.eval_generate(resource)
|
260
|
-
|
261
|
-
sentinel = find_vertex(:whit, "completed_#{path}")
|
262
|
-
@filenames.each do |file|
|
263
|
-
v = find_vertex(:file, file)
|
264
|
-
|
265
|
-
graph.should be_edge(v, sentinel)
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should add an edge from the resource to the sentinel" do
|
270
|
-
@transaction.eval_generate(resource)
|
271
|
-
|
272
|
-
res = find_vertex(:file, path)
|
273
|
-
sentinel = find_vertex(:whit, "completed_#{path}")
|
274
|
-
|
275
|
-
graph.should be_edge(res, sentinel)
|
276
|
-
end
|
277
|
-
|
278
|
-
it "should return false if an error occured when generating resources" do
|
279
|
-
resource.stubs(:eval_generate).raises(Puppet::Error)
|
280
|
-
|
281
|
-
@transaction.eval_generate(resource).should == false
|
282
|
-
end
|
283
|
-
|
284
|
-
it "should return true if resources were generated" do
|
285
|
-
@transaction.eval_generate(resource).should == true
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should not add a sentinel if no resources are generated" do
|
289
|
-
path2 = tmpfile('empty')
|
290
|
-
other_file = Puppet::Type.type(:file).new(:path => path2)
|
291
|
-
|
292
|
-
@transaction.catalog.add_resource(other_file)
|
293
|
-
|
294
|
-
@transaction.eval_generate(other_file).should == false
|
295
|
-
|
296
|
-
find_vertex(:whit, "completed_#{path2}").should be_nil
|
164
|
+
expect(@transaction).to be_any_failed
|
297
165
|
end
|
298
166
|
end
|
299
167
|
|
@@ -343,41 +211,7 @@ describe Puppet::Transaction do
|
|
343
211
|
end
|
344
212
|
end
|
345
213
|
|
346
|
-
describe "#finish" do
|
347
|
-
let(:graph) { @transaction.relationship_graph }
|
348
|
-
let(:path) { tmpdir('eval_generate') }
|
349
|
-
let(:resource) { Puppet::Type.type(:file).new(:path => path, :recurse => true) }
|
350
|
-
|
351
|
-
before :each do
|
352
|
-
@transaction.catalog.add_resource(resource)
|
353
|
-
end
|
354
|
-
|
355
|
-
it "should unblock the resource's dependents and queue them if ready" do
|
356
|
-
dependent = Puppet::Type.type(:file).new(:path => tmpfile('dependent'), :require => resource)
|
357
|
-
more_dependent = Puppet::Type.type(:file).new(:path => tmpfile('more_dependent'), :require => [resource, dependent])
|
358
|
-
@transaction.catalog.add_resource(dependent, more_dependent)
|
359
|
-
|
360
|
-
graph.finish(resource)
|
361
|
-
|
362
|
-
graph.blockers[dependent].should == 0
|
363
|
-
graph.blockers[more_dependent].should == 1
|
364
|
-
|
365
|
-
key = graph.unguessable_deterministic_key[dependent]
|
366
|
-
|
367
|
-
graph.ready[key].must == dependent
|
368
|
-
|
369
|
-
graph.ready.should_not be_has_key(graph.unguessable_deterministic_key[more_dependent])
|
370
|
-
end
|
371
|
-
|
372
|
-
it "should mark the resource as done" do
|
373
|
-
graph.finish(resource)
|
374
|
-
|
375
|
-
graph.done[resource].should == true
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
214
|
describe "when traversing" do
|
380
|
-
let(:graph) { @transaction.relationship_graph }
|
381
215
|
let(:path) { tmpdir('eval_generate') }
|
382
216
|
let(:resource) { Puppet::Type.type(:file).new(:path => path, :recurse => true) }
|
383
217
|
|
@@ -385,26 +219,11 @@ describe Puppet::Transaction do
|
|
385
219
|
@transaction.catalog.add_resource(resource)
|
386
220
|
end
|
387
221
|
|
388
|
-
it "should clear blockers if resources are added" do
|
389
|
-
graph.blockers['foo'] = 3
|
390
|
-
graph.blockers['bar'] = 4
|
391
|
-
|
392
|
-
graph.ready[graph.unguessable_deterministic_key[resource]] = resource
|
393
|
-
|
394
|
-
@transaction.expects(:eval_generate).with(resource).returns true
|
395
|
-
|
396
|
-
graph.traverse {}
|
397
|
-
|
398
|
-
graph.blockers.should be_empty
|
399
|
-
end
|
400
|
-
|
401
222
|
it "should yield the resource even if eval_generate is called" do
|
402
|
-
|
403
|
-
|
404
|
-
@transaction.expects(:eval_generate).with(resource).returns true
|
223
|
+
Puppet::Transaction::AdditionalResourceGenerator.any_instance.expects(:eval_generate).with(resource).returns true
|
405
224
|
|
406
225
|
yielded = false
|
407
|
-
|
226
|
+
@transaction.evaluate do |res|
|
408
227
|
yielded = true if res == resource
|
409
228
|
end
|
410
229
|
|
@@ -414,89 +233,31 @@ describe Puppet::Transaction do
|
|
414
233
|
it "should prefetch the provider if necessary" do
|
415
234
|
@transaction.expects(:prefetch_if_necessary).with(resource)
|
416
235
|
|
417
|
-
|
418
|
-
end
|
419
|
-
|
420
|
-
it "should not clear blockers if resources aren't added" do
|
421
|
-
graph.blockers['foo'] = 3
|
422
|
-
graph.blockers['bar'] = 4
|
423
|
-
|
424
|
-
graph.ready[graph.unguessable_deterministic_key[resource]] = resource
|
425
|
-
|
426
|
-
@transaction.expects(:eval_generate).with(resource).returns false
|
427
|
-
|
428
|
-
graph.traverse {}
|
429
|
-
|
430
|
-
graph.blockers.should == {'foo' => 3, 'bar' => 4, resource => 0}
|
431
|
-
end
|
432
|
-
|
433
|
-
it "should unblock all dependents of the resource" do
|
434
|
-
dependent = Puppet::Type.type(:notify).new(:name => "hello", :require => resource)
|
435
|
-
dependent2 = Puppet::Type.type(:notify).new(:name => "goodbye", :require => resource)
|
436
|
-
|
437
|
-
@transaction.catalog.add_resource(dependent, dependent2)
|
438
|
-
|
439
|
-
# We enqueue them here just so we can check their blockers. This is done
|
440
|
-
# again in traverse.
|
441
|
-
graph.enqueue_roots
|
442
|
-
|
443
|
-
graph.blockers[dependent].should == 1
|
444
|
-
graph.blockers[dependent2].should == 1
|
445
|
-
|
446
|
-
graph.ready[graph.unguessable_deterministic_key[resource]] = resource
|
447
|
-
|
448
|
-
graph.traverse {}
|
449
|
-
|
450
|
-
graph.blockers[dependent].should == 0
|
451
|
-
graph.blockers[dependent2].should == 0
|
236
|
+
@transaction.evaluate {}
|
452
237
|
end
|
453
238
|
|
454
|
-
it "
|
239
|
+
it "traverses independent resources before dependent resources" do
|
455
240
|
dependent = Puppet::Type.type(:notify).new(:name => "hello", :require => resource)
|
456
|
-
|
457
|
-
|
458
|
-
@transaction.catalog.add_resource(dependent, dependent2)
|
459
|
-
|
460
|
-
graph.enqueue_roots
|
461
|
-
|
462
|
-
graph.blockers[dependent].should == 1
|
463
|
-
graph.blockers[dependent2].should == 1
|
464
|
-
|
465
|
-
graph.ready[graph.unguessable_deterministic_key[resource]] = resource
|
241
|
+
@transaction.catalog.add_resource(dependent)
|
466
242
|
|
467
243
|
seen = []
|
468
|
-
|
469
|
-
graph.traverse do |res|
|
244
|
+
@transaction.evaluate do |res|
|
470
245
|
seen << res
|
471
246
|
end
|
472
247
|
|
473
|
-
seen.
|
248
|
+
expect(seen).to include_in_order(resource, dependent)
|
474
249
|
end
|
475
250
|
|
476
|
-
it "
|
477
|
-
|
478
|
-
|
479
|
-
graph.traverse {}
|
251
|
+
it "traverses completely independent resources in the order they appear in the catalog" do
|
252
|
+
independent = Puppet::Type.type(:notify).new(:name => "hello", :require => resource)
|
253
|
+
@transaction.catalog.add_resource(independent)
|
480
254
|
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
it "should not evaluate the resource if it's not suitable" do
|
485
|
-
resource.stubs(:suitable?).returns false
|
486
|
-
|
487
|
-
graph.traverse do |resource|
|
488
|
-
raise "evaluated a resource"
|
255
|
+
seen = []
|
256
|
+
@transaction.evaluate do |res|
|
257
|
+
seen << res
|
489
258
|
end
|
490
|
-
end
|
491
|
-
|
492
|
-
it "should defer an unsuitable resource unless it can't go on" do
|
493
|
-
other = Puppet::Type.type(:notify).new(:name => "hello")
|
494
|
-
@transaction.catalog.add_resource(other)
|
495
|
-
|
496
|
-
# Show that we check once, then get the resource back and check again
|
497
|
-
resource.expects(:suitable?).twice.returns(false).then.returns(true)
|
498
259
|
|
499
|
-
|
260
|
+
expect(seen).to include_in_order(resource, independent)
|
500
261
|
end
|
501
262
|
|
502
263
|
it "should fail unsuitable resources and go on if it gets blocked" do
|
@@ -506,7 +267,7 @@ describe Puppet::Transaction do
|
|
506
267
|
resource.stubs(:suitable?).returns false
|
507
268
|
|
508
269
|
evaluated = []
|
509
|
-
|
270
|
+
@transaction.evaluate do |res|
|
510
271
|
evaluated << res
|
511
272
|
end
|
512
273
|
|
@@ -518,7 +279,7 @@ describe Puppet::Transaction do
|
|
518
279
|
|
519
280
|
describe "when generating resources before traversal" do
|
520
281
|
let(:catalog) { Puppet::Resource::Catalog.new }
|
521
|
-
let(:transaction) { Puppet::Transaction.new(catalog) }
|
282
|
+
let(:transaction) { Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new) }
|
522
283
|
let(:generator) { Puppet::Type.type(:notify).new :title => "generator" }
|
523
284
|
let(:generated) do
|
524
285
|
%w[a b c].map { |name| Puppet::Type.type(:notify).new(:name => name) }
|
@@ -532,30 +293,19 @@ describe Puppet::Transaction do
|
|
532
293
|
it "should call 'generate' on all created resources" do
|
533
294
|
generated.each { |res| res.expects(:generate) }
|
534
295
|
|
535
|
-
transaction.
|
296
|
+
transaction.evaluate
|
536
297
|
end
|
537
298
|
|
538
299
|
it "should finish all resources" do
|
539
300
|
generated.each { |res| res.expects(:finish) }
|
540
301
|
|
541
|
-
transaction.
|
542
|
-
end
|
543
|
-
|
544
|
-
it "should skip generated resources that conflict with existing resources" do
|
545
|
-
duplicate = generated.first
|
546
|
-
catalog.add_resource(duplicate)
|
547
|
-
|
548
|
-
duplicate.expects(:finish).never
|
549
|
-
|
550
|
-
duplicate.expects(:info).with { |msg| msg =~ /Duplicate generated resource/ }
|
551
|
-
|
552
|
-
transaction.add_dynamically_generated_resources
|
302
|
+
transaction.evaluate
|
553
303
|
end
|
554
304
|
|
555
305
|
it "should copy all tags to the newly generated resources" do
|
556
306
|
generator.tag('one', 'two')
|
557
307
|
|
558
|
-
transaction.
|
308
|
+
transaction.evaluate
|
559
309
|
|
560
310
|
generated.each do |res|
|
561
311
|
res.must be_tagged(generator.tags)
|
@@ -568,7 +318,7 @@ describe Puppet::Transaction do
|
|
568
318
|
@resource = Puppet::Type.type(:notify).new :name => "foo"
|
569
319
|
@catalog = Puppet::Resource::Catalog.new
|
570
320
|
@resource.catalog = @catalog
|
571
|
-
@transaction = Puppet::Transaction.new(@catalog)
|
321
|
+
@transaction = Puppet::Transaction.new(@catalog, nil, nil)
|
572
322
|
end
|
573
323
|
|
574
324
|
it "should skip resource with missing tags" do
|
@@ -592,22 +342,39 @@ describe Puppet::Transaction do
|
|
592
342
|
end
|
593
343
|
|
594
344
|
it "should skip device only resouce on normal host" do
|
345
|
+
@resource.stubs(:appliable_to_host?).returns false
|
595
346
|
@resource.stubs(:appliable_to_device?).returns true
|
596
347
|
@transaction.for_network_device = false
|
597
348
|
@transaction.should be_skip(@resource)
|
598
349
|
end
|
599
350
|
|
600
351
|
it "should not skip device only resouce on remote device" do
|
352
|
+
@resource.stubs(:appliable_to_host?).returns false
|
601
353
|
@resource.stubs(:appliable_to_device?).returns true
|
602
354
|
@transaction.for_network_device = true
|
603
355
|
@transaction.should_not be_skip(@resource)
|
604
356
|
end
|
605
357
|
|
606
358
|
it "should skip host resouce on device" do
|
359
|
+
@resource.stubs(:appliable_to_host?).returns true
|
607
360
|
@resource.stubs(:appliable_to_device?).returns false
|
608
361
|
@transaction.for_network_device = true
|
609
362
|
@transaction.should be_skip(@resource)
|
610
363
|
end
|
364
|
+
|
365
|
+
it "should not skip resouce available on both device and host when on device" do
|
366
|
+
@resource.stubs(:appliable_to_host?).returns true
|
367
|
+
@resource.stubs(:appliable_to_device?).returns true
|
368
|
+
@transaction.for_network_device = true
|
369
|
+
@transaction.should_not be_skip(@resource)
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should not skip resouce available on both device and host when on host" do
|
373
|
+
@resource.stubs(:appliable_to_host?).returns true
|
374
|
+
@resource.stubs(:appliable_to_device?).returns true
|
375
|
+
@transaction.for_network_device = false
|
376
|
+
@transaction.should_not be_skip(@resource)
|
377
|
+
end
|
611
378
|
end
|
612
379
|
|
613
380
|
describe "when determining if tags are missing" do
|
@@ -615,7 +382,7 @@ describe Puppet::Transaction do
|
|
615
382
|
@resource = Puppet::Type.type(:notify).new :name => "foo"
|
616
383
|
@catalog = Puppet::Resource::Catalog.new
|
617
384
|
@resource.catalog = @catalog
|
618
|
-
@transaction = Puppet::Transaction.new(@catalog)
|
385
|
+
@transaction = Puppet::Transaction.new(@catalog, nil, nil)
|
619
386
|
|
620
387
|
@transaction.stubs(:ignore_tags?).returns false
|
621
388
|
end
|
@@ -646,27 +413,28 @@ describe Puppet::Transaction do
|
|
646
413
|
before :each do
|
647
414
|
@resource = Puppet::Type.type(:notify).new :name => "foo"
|
648
415
|
@catalog = Puppet::Resource::Catalog.new
|
649
|
-
@
|
650
|
-
@transaction = Puppet::Transaction.new(@catalog)
|
416
|
+
@catalog.add_resource(@resource)
|
417
|
+
@transaction = Puppet::Transaction.new(@catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
651
418
|
end
|
652
419
|
|
653
420
|
it "should always schedule resources if 'ignoreschedules' is set" do
|
654
421
|
@transaction.ignoreschedules = true
|
655
422
|
@transaction.resource_harness.expects(:scheduled?).never
|
656
423
|
|
657
|
-
@transaction.
|
424
|
+
@transaction.evaluate
|
425
|
+
@transaction.resource_status(@resource).should be_changed
|
658
426
|
end
|
659
427
|
|
660
428
|
it "should let the resource harness determine whether the resource should be scheduled" do
|
661
|
-
@transaction.resource_harness.expects(:scheduled?).with(@
|
429
|
+
@transaction.resource_harness.expects(:scheduled?).with(@resource).returns "feh"
|
662
430
|
|
663
|
-
@transaction.
|
431
|
+
@transaction.evaluate
|
664
432
|
end
|
665
433
|
end
|
666
434
|
|
667
435
|
describe "when prefetching" do
|
668
436
|
let(:catalog) { Puppet::Resource::Catalog.new }
|
669
|
-
let(:transaction) { Puppet::Transaction.new(catalog) }
|
437
|
+
let(:transaction) { Puppet::Transaction.new(catalog, nil, nil) }
|
670
438
|
let(:resource) { Puppet::Type.type(:sshkey).new :title => "foo", :name => "bar", :type => :dsa, :key => "eh", :provider => :parsed }
|
671
439
|
let(:resource2) { Puppet::Type.type(:package).new :title => "blah", :provider => "apt" }
|
672
440
|
|
@@ -675,30 +443,6 @@ describe Puppet::Transaction do
|
|
675
443
|
catalog.add_resource resource2
|
676
444
|
end
|
677
445
|
|
678
|
-
|
679
|
-
describe "#resources_by_provider" do
|
680
|
-
it "should fetch resources by their type and provider" do
|
681
|
-
transaction.resources_by_provider(:sshkey, :parsed).should == {
|
682
|
-
resource.name => resource,
|
683
|
-
}
|
684
|
-
|
685
|
-
transaction.resources_by_provider(:package, :apt).should == {
|
686
|
-
resource2.name => resource2,
|
687
|
-
}
|
688
|
-
end
|
689
|
-
|
690
|
-
it "should omit resources whose types don't use providers" do
|
691
|
-
# faking the sshkey type not to have a provider
|
692
|
-
resource.class.stubs(:attrclass).returns nil
|
693
|
-
|
694
|
-
transaction.resources_by_provider(:sshkey, :parsed).should == {}
|
695
|
-
end
|
696
|
-
|
697
|
-
it "should return empty hash for providers with no resources" do
|
698
|
-
transaction.resources_by_provider(:package, :yum).should == {}
|
699
|
-
end
|
700
|
-
end
|
701
|
-
|
702
446
|
it "should match resources by name, not title" do
|
703
447
|
resource.provider.class.expects(:prefetch).with("bar" => resource)
|
704
448
|
|
@@ -734,37 +478,25 @@ describe Puppet::Transaction do
|
|
734
478
|
end
|
735
479
|
end
|
736
480
|
|
737
|
-
it "should return all resources for which the resource status indicates the resource has changed when determinig changed resources" do
|
738
|
-
@catalog = Puppet::Resource::Catalog.new
|
739
|
-
@transaction = Puppet::Transaction.new(@catalog)
|
740
|
-
names = []
|
741
|
-
2.times do |i|
|
742
|
-
name = File.join(@basepath, "file#{i}")
|
743
|
-
resource = Puppet::Type.type(:file).new :path => name
|
744
|
-
names << resource.to_s
|
745
|
-
@catalog.add_resource resource
|
746
|
-
@transaction.add_resource_status Puppet::Resource::Status.new(resource)
|
747
|
-
end
|
748
|
-
|
749
|
-
@transaction.resource_status(names[0]).changed = true
|
750
|
-
|
751
|
-
@transaction.changed?.should == [@catalog.resource(names[0])]
|
752
|
-
end
|
753
|
-
|
754
481
|
describe 'when checking application run state' do
|
755
482
|
before do
|
756
|
-
without_warnings { Puppet::Application = Class.new(Puppet::Application) }
|
757
483
|
@catalog = Puppet::Resource::Catalog.new
|
758
|
-
@transaction = Puppet::Transaction.new(@catalog)
|
484
|
+
@transaction = Puppet::Transaction.new(@catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
759
485
|
end
|
760
486
|
|
761
|
-
|
762
|
-
|
763
|
-
|
487
|
+
context "when stop is requested" do
|
488
|
+
before :each do
|
489
|
+
Puppet::Application.stubs(:stop_requested?).returns(true)
|
490
|
+
end
|
764
491
|
|
765
|
-
|
766
|
-
|
767
|
-
|
492
|
+
it 'should return true for :stop_processing?' do
|
493
|
+
@transaction.should be_stop_processing
|
494
|
+
end
|
495
|
+
|
496
|
+
it 'always evaluates non-host_config catalogs' do
|
497
|
+
@catalog.host_config = false
|
498
|
+
@transaction.should_not be_stop_processing
|
499
|
+
end
|
768
500
|
end
|
769
501
|
|
770
502
|
it 'should return false for :stop_processing? if Puppet::Application.stop_requested? is false' do
|
@@ -792,12 +524,72 @@ describe Puppet::Transaction do
|
|
792
524
|
end
|
793
525
|
end
|
794
526
|
end
|
527
|
+
|
528
|
+
it "errors with a dependency cycle for a resource that requires itself" do
|
529
|
+
expect do
|
530
|
+
apply_compiled_manifest(<<-MANIFEST)
|
531
|
+
notify { cycle: require => Notify[cycle] }
|
532
|
+
MANIFEST
|
533
|
+
end.to raise_error(Puppet::Error, /Found 1 dependency cycle:.*\(Notify\[cycle\] => Notify\[cycle\]\)/m)
|
534
|
+
end
|
535
|
+
|
536
|
+
it "errors with a dependency cycle for a self-requiring resource also required by another resource" do
|
537
|
+
expect do
|
538
|
+
apply_compiled_manifest(<<-MANIFEST)
|
539
|
+
notify { cycle: require => Notify[cycle] }
|
540
|
+
notify { other: require => Notify[cycle] }
|
541
|
+
MANIFEST
|
542
|
+
end.to raise_error(Puppet::Error, /Found 1 dependency cycle:.*\(Notify\[cycle\] => Notify\[cycle\]\)/m)
|
543
|
+
end
|
544
|
+
|
545
|
+
it "errors with a dependency cycle for a resource that requires itself and another resource" do
|
546
|
+
expect do
|
547
|
+
apply_compiled_manifest(<<-MANIFEST)
|
548
|
+
notify { cycle:
|
549
|
+
require => [Notify[other], Notify[cycle]]
|
550
|
+
}
|
551
|
+
notify { other: }
|
552
|
+
MANIFEST
|
553
|
+
end.to raise_error(Puppet::Error, /Found 1 dependency cycle:.*\(Notify\[cycle\] => Notify\[cycle\]\)/m)
|
554
|
+
end
|
555
|
+
|
556
|
+
it "errors with a dependency cycle for a resource that is later modified to require itself" do
|
557
|
+
expect do
|
558
|
+
apply_compiled_manifest(<<-MANIFEST)
|
559
|
+
notify { cycle: }
|
560
|
+
Notify <| title == 'cycle' |> {
|
561
|
+
require => Notify[cycle]
|
562
|
+
}
|
563
|
+
MANIFEST
|
564
|
+
end.to raise_error(Puppet::Error, /Found 1 dependency cycle:.*\(Notify\[cycle\] => Notify\[cycle\]\)/m)
|
565
|
+
end
|
566
|
+
|
567
|
+
it "reports a changed resource with a successful run" do
|
568
|
+
transaction = apply_compiled_manifest("notify { one: }")
|
569
|
+
|
570
|
+
transaction.report.status.should == 'changed'
|
571
|
+
transaction.report.resource_statuses['Notify[one]'].should be_changed
|
572
|
+
end
|
573
|
+
|
574
|
+
describe "when interrupted" do
|
575
|
+
it "marks unprocessed resources as skipped" do
|
576
|
+
Puppet::Application.stop!
|
577
|
+
|
578
|
+
transaction = apply_compiled_manifest(<<-MANIFEST)
|
579
|
+
notify { a: } ->
|
580
|
+
notify { b: }
|
581
|
+
MANIFEST
|
582
|
+
|
583
|
+
transaction.report.resource_statuses['Notify[a]'].should be_skipped
|
584
|
+
transaction.report.resource_statuses['Notify[b]'].should be_skipped
|
585
|
+
end
|
586
|
+
end
|
795
587
|
end
|
796
588
|
|
797
589
|
describe Puppet::Transaction, " when determining tags" do
|
798
590
|
before do
|
799
591
|
@config = Puppet::Resource::Catalog.new
|
800
|
-
@transaction = Puppet::Transaction.new(@config)
|
592
|
+
@transaction = Puppet::Transaction.new(@config, nil, nil)
|
801
593
|
end
|
802
594
|
|
803
595
|
it "should default to the tags specified in the :tags setting" do
|