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
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'matchers/include_in_order'
|
3
|
+
require 'puppet_spec/compiler'
|
4
|
+
require 'puppet/indirector/catalog/compiler'
|
5
|
+
|
6
|
+
describe "Transmission of the catalog to the agent" do
|
7
|
+
include PuppetSpec::Compiler
|
8
|
+
|
9
|
+
it "preserves the order in which the resources are added to the catalog" do
|
10
|
+
resources_in_declaration_order = ["Class[First]",
|
11
|
+
"Second[position]",
|
12
|
+
"Class[Third]",
|
13
|
+
"Fourth[position]"]
|
14
|
+
|
15
|
+
master_catalog, agent_catalog = master_and_agent_catalogs_for(<<-EOM)
|
16
|
+
define fourth() { }
|
17
|
+
class third { }
|
18
|
+
|
19
|
+
define second() {
|
20
|
+
fourth { "position": }
|
21
|
+
}
|
22
|
+
|
23
|
+
class first {
|
24
|
+
second { "position": }
|
25
|
+
class { "third": }
|
26
|
+
}
|
27
|
+
|
28
|
+
include first
|
29
|
+
EOM
|
30
|
+
|
31
|
+
expect(resources_in(master_catalog)).
|
32
|
+
to include_in_order(*resources_in_declaration_order)
|
33
|
+
expect(resources_in(agent_catalog)).
|
34
|
+
to include_in_order(*resources_in_declaration_order)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not contain unrealized, virtual resources" do
|
38
|
+
virtual_resources = ["Unrealized[unreal]", "Class[Unreal]"]
|
39
|
+
|
40
|
+
master_catalog, agent_catalog = master_and_agent_catalogs_for(<<-EOM)
|
41
|
+
class unreal { }
|
42
|
+
define unrealized() { }
|
43
|
+
|
44
|
+
class real {
|
45
|
+
@unrealized { "unreal": }
|
46
|
+
@class { "unreal": }
|
47
|
+
}
|
48
|
+
|
49
|
+
include real
|
50
|
+
EOM
|
51
|
+
|
52
|
+
expect(resources_in(master_catalog)).to_not include(*virtual_resources)
|
53
|
+
expect(resources_in(agent_catalog)).to_not include(*virtual_resources)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "does not contain unrealized, exported resources" do
|
57
|
+
exported_resources = ["Unrealized[unreal]", "Class[Unreal]"]
|
58
|
+
|
59
|
+
master_catalog, agent_catalog = master_and_agent_catalogs_for(<<-EOM)
|
60
|
+
class unreal { }
|
61
|
+
define unrealized() { }
|
62
|
+
|
63
|
+
class real {
|
64
|
+
@@unrealized { "unreal": }
|
65
|
+
@@class { "unreal": }
|
66
|
+
}
|
67
|
+
|
68
|
+
include real
|
69
|
+
EOM
|
70
|
+
|
71
|
+
expect(resources_in(master_catalog)).to_not include(*exported_resources)
|
72
|
+
expect(resources_in(agent_catalog)).to_not include(*exported_resources)
|
73
|
+
end
|
74
|
+
|
75
|
+
def master_and_agent_catalogs_for(manifest)
|
76
|
+
master_catalog = Puppet::Resource::Catalog::Compiler.new.filter(compile_to_catalog(manifest))
|
77
|
+
agent_catalog = Puppet::Resource::Catalog.convert_from(:pson, master_catalog.render(:pson))
|
78
|
+
|
79
|
+
[master_catalog, agent_catalog]
|
80
|
+
end
|
81
|
+
|
82
|
+
def resources_in(catalog)
|
83
|
+
catalog.resources.map(&:ref)
|
84
|
+
end
|
85
|
+
end
|
@@ -160,6 +160,17 @@ describe Puppet::Type.type(:cron).provider(:crontab), '(integration)', :unless =
|
|
160
160
|
run_in_catalog(resource)
|
161
161
|
expect_output('modify_entry')
|
162
162
|
end
|
163
|
+
it "should change a special schedule to numeric if requested" do
|
164
|
+
resource = Puppet::Type.type(:cron).new(
|
165
|
+
:name => 'My daily failure',
|
166
|
+
:special => 'absent',
|
167
|
+
:command => '/bin/false',
|
168
|
+
:target => crontab_user1,
|
169
|
+
:user => crontab_user1
|
170
|
+
)
|
171
|
+
run_in_catalog(resource)
|
172
|
+
expect_output('unspecialized')
|
173
|
+
end
|
163
174
|
it "should not try to move an entry from one file to another" do
|
164
175
|
# force the parsedfile provider to also parse user1's crontab
|
165
176
|
random_resource = Puppet::Type.type(:cron).new(
|
@@ -20,6 +20,7 @@ describe "mount provider (integration)", :unless => Puppet.features.microsoft_wi
|
|
20
20
|
@current_options = "local"
|
21
21
|
@current_device = "/dev/disk1s1"
|
22
22
|
Puppet::Type.type(:mount).defaultprovider.stubs(:default_target).returns(@fake_fstab)
|
23
|
+
Facter.stubs(:value).with(:kernel).returns('Darwin')
|
23
24
|
Facter.stubs(:value).with(:operatingsystem).returns('Darwin')
|
24
25
|
Facter.stubs(:value).with(:osfamily).returns('Darwin')
|
25
26
|
Puppet::Util::ExecutionStub.set do |command, options|
|
@@ -33,7 +33,7 @@ describe Puppet::Transaction do
|
|
33
33
|
|
34
34
|
resource.expects(:eval_generate).returns([child_resource])
|
35
35
|
|
36
|
-
transaction = Puppet::Transaction.new(catalog)
|
36
|
+
transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
37
37
|
|
38
38
|
resource.expects(:retrieve).raises "this is a failure"
|
39
39
|
resource.stubs(:err)
|
@@ -49,7 +49,7 @@ describe Puppet::Transaction do
|
|
49
49
|
resource.virtual = true
|
50
50
|
catalog.add_resource resource
|
51
51
|
|
52
|
-
transaction = Puppet::Transaction.new(catalog)
|
52
|
+
transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
53
53
|
|
54
54
|
resource.expects(:evaluate).never
|
55
55
|
|
@@ -74,7 +74,7 @@ describe Puppet::Transaction do
|
|
74
74
|
resource.virtual = true
|
75
75
|
catalog.add_resource resource
|
76
76
|
|
77
|
-
transaction = Puppet::Transaction.new(catalog)
|
77
|
+
transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
78
78
|
|
79
79
|
resource.expects(:evaluate).never
|
80
80
|
|
@@ -86,7 +86,7 @@ describe Puppet::Transaction do
|
|
86
86
|
resource = Puppet::Type.type(:interface).new :name => "FastEthernet 0/1"
|
87
87
|
catalog.add_resource resource
|
88
88
|
|
89
|
-
transaction = Puppet::Transaction.new(catalog)
|
89
|
+
transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
90
90
|
transaction.for_network_device = false
|
91
91
|
|
92
92
|
transaction.expects(:apply).never.with(resource, nil)
|
@@ -100,7 +100,7 @@ describe Puppet::Transaction do
|
|
100
100
|
resource = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar"), :backup => false
|
101
101
|
catalog.add_resource resource
|
102
102
|
|
103
|
-
transaction = Puppet::Transaction.new(catalog)
|
103
|
+
transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
104
104
|
transaction.for_network_device = true
|
105
105
|
|
106
106
|
transaction.expects(:apply).never.with(resource, nil)
|
@@ -114,7 +114,7 @@ describe Puppet::Transaction do
|
|
114
114
|
resource = Puppet::Type.type(:interface).new :name => "FastEthernet 0/1"
|
115
115
|
catalog.add_resource resource
|
116
116
|
|
117
|
-
transaction = Puppet::Transaction.new(catalog)
|
117
|
+
transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
118
118
|
transaction.for_network_device = true
|
119
119
|
|
120
120
|
transaction.expects(:apply).with(resource, nil)
|
@@ -128,7 +128,7 @@ describe Puppet::Transaction do
|
|
128
128
|
resource = Puppet::Type.type(:schedule).new :name => "test"
|
129
129
|
catalog.add_resource resource
|
130
130
|
|
131
|
-
transaction = Puppet::Transaction.new(catalog)
|
131
|
+
transaction = Puppet::Transaction.new(catalog, nil, Puppet::Graph::RandomPrioritizer.new)
|
132
132
|
transaction.for_network_device = true
|
133
133
|
|
134
134
|
transaction.expects(:apply).with(resource, nil)
|
@@ -341,6 +341,6 @@ describe Puppet::Transaction do
|
|
341
341
|
|
342
342
|
trans = catalog.apply
|
343
343
|
|
344
|
-
trans.resource_harness.should be_scheduled(
|
344
|
+
trans.resource_harness.should be_scheduled(resource)
|
345
345
|
end
|
346
346
|
end
|
@@ -454,7 +454,7 @@ describe Puppet::Type.type(:file) do
|
|
454
454
|
catalog.apply
|
455
455
|
|
456
456
|
File.readlink(link).should == dest2
|
457
|
-
|
457
|
+
File.exist?(bucket[:path]).should be_false
|
458
458
|
end
|
459
459
|
|
460
460
|
it "should backup directories to the local filesystem by copying the whole directory" do
|
@@ -10,23 +10,27 @@ describe Puppet::Settings do
|
|
10
10
|
{ :noop => {:default => false, :desc => "noop"} }
|
11
11
|
end
|
12
12
|
|
13
|
+
def define_settings(section, settings_hash)
|
14
|
+
settings.define_settings(section, minimal_default_settings.update(settings_hash))
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:settings) { Puppet::Settings.new }
|
18
|
+
|
13
19
|
it "should be able to make needed directories" do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
20
|
+
define_settings(:main,
|
21
|
+
:maindir => {
|
22
|
+
:default => tmpfile("main"),
|
23
|
+
:type => :directory,
|
24
|
+
:desc => "a",
|
25
|
+
}
|
21
26
|
)
|
22
27
|
settings.use(:main)
|
23
28
|
|
24
|
-
File.
|
29
|
+
expect(File.directory?(settings[:maindir])).to be_true
|
25
30
|
end
|
26
31
|
|
27
32
|
it "should make its directories with the correct modes" do
|
28
|
-
|
29
|
-
settings.define_settings :main, minimal_default_settings.update(
|
33
|
+
define_settings(:main,
|
30
34
|
:maindir => {
|
31
35
|
:default => tmpfile("main"),
|
32
36
|
:type => :directory,
|
@@ -37,6 +41,49 @@ describe Puppet::Settings do
|
|
37
41
|
|
38
42
|
settings.use(:main)
|
39
43
|
|
40
|
-
(File.stat(settings[:maindir]).mode & 007777).
|
44
|
+
expect(File.stat(settings[:maindir]).mode & 007777).to eq(Puppet.features.microsoft_windows? ? 0755 : 0750)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "reparses configuration if configuration file is touched", :if => !Puppet.features.microsoft_windows? do
|
48
|
+
config = tmpfile("config")
|
49
|
+
define_settings(:main,
|
50
|
+
:config => {
|
51
|
+
:type => :file,
|
52
|
+
:default => config,
|
53
|
+
:desc => "a"
|
54
|
+
},
|
55
|
+
:environment => {
|
56
|
+
:default => 'dingos',
|
57
|
+
:desc => 'test',
|
58
|
+
}
|
59
|
+
)
|
60
|
+
|
61
|
+
Puppet[:filetimeout] = '1s'
|
62
|
+
|
63
|
+
File.open(config, 'w') do |file|
|
64
|
+
file.puts <<-EOF
|
65
|
+
[main]
|
66
|
+
environment=toast
|
67
|
+
EOF
|
68
|
+
end
|
69
|
+
|
70
|
+
settings.initialize_global_settings
|
71
|
+
expect(settings[:environment]).to eq('toast')
|
72
|
+
|
73
|
+
# First reparse establishes WatchedFiles
|
74
|
+
settings.reparse_config_files
|
75
|
+
|
76
|
+
sleep 1
|
77
|
+
|
78
|
+
File.open(config, 'w') do |file|
|
79
|
+
file.puts <<-EOF
|
80
|
+
[main]
|
81
|
+
environment=bacon
|
82
|
+
EOF
|
83
|
+
end
|
84
|
+
|
85
|
+
# Second reparse if later than filetimeout, reparses if changed
|
86
|
+
settings.reparse_config_files
|
87
|
+
expect(settings[:environment]).to eq('bacon')
|
41
88
|
end
|
42
89
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec::Matchers.define :include_in_order do |*expected|
|
2
|
+
include RSpec::Matchers::Pretty
|
3
|
+
|
4
|
+
match do |actual|
|
5
|
+
elements = expected.dup
|
6
|
+
actual.each do |elt|
|
7
|
+
if elt == elements.first
|
8
|
+
elements.shift
|
9
|
+
end
|
10
|
+
end
|
11
|
+
elements.empty?
|
12
|
+
end
|
13
|
+
|
14
|
+
def failure_message_for_should
|
15
|
+
"expected #{@actual.inspect} to include#{expected_to_sentence} in order"
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure_message_for_should_not
|
19
|
+
"expected #{@actual.inspect} not to include#{expected_to_sentence} in order"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'matchers/include_in_order'
|
3
|
+
|
4
|
+
describe "Matching whether elements are included in order" do
|
5
|
+
context "an empty array" do
|
6
|
+
it "is included in an empty array" do
|
7
|
+
expect([]).to include_in_order()
|
8
|
+
end
|
9
|
+
|
10
|
+
it "is included in a non-empty array" do
|
11
|
+
expect([1]).to include_in_order()
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "[1,2,3] is included in [0,1,2,3,4]" do
|
16
|
+
expect([0,1,2,3,4]).to include_in_order(1,2,3)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "[2,1] is not included in order in [1,2]" do
|
20
|
+
expect([1,2]).not_to include_in_order(2,1)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "[2,4,6] is included in order in [1,2,3,4,5,6]" do
|
24
|
+
expect([1,2,3,4,5,6]).to include_in_order(2,4,6)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "overlapping ordered array is not included" do
|
28
|
+
expect([1,2,3]).not_to include_in_order(2,3,4)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module RelationshipGraphMatchers
|
2
|
+
class EnforceOrderWithEdge
|
3
|
+
def initialize(before, after)
|
4
|
+
@before = before
|
5
|
+
@after = after
|
6
|
+
end
|
7
|
+
|
8
|
+
def matches?(actual_graph)
|
9
|
+
@actual_graph = actual_graph
|
10
|
+
|
11
|
+
@reverse_edge = actual_graph.edge?(
|
12
|
+
vertex_called(actual_graph, @after),
|
13
|
+
vertex_called(actual_graph, @before))
|
14
|
+
|
15
|
+
@forward_edge = actual_graph.edge?(
|
16
|
+
vertex_called(actual_graph, @before),
|
17
|
+
vertex_called(actual_graph, @after))
|
18
|
+
|
19
|
+
@forward_edge && !@reverse_edge
|
20
|
+
end
|
21
|
+
|
22
|
+
def failure_message_for_should
|
23
|
+
"expect #{@actual_graph.to_dot_graph} to only contain an edge from #{@before} to #{@after} but #{[forward_failure_message, reverse_failure_message].compact.join(' and ')}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def forward_failure_message
|
27
|
+
if !@forward_edge
|
28
|
+
"did not contain an edge from #{@before} to #{@after}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def reverse_failure_message
|
33
|
+
if @reverse_edge
|
34
|
+
"contained an edge from #{@after} to #{@before}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def vertex_called(graph, name)
|
41
|
+
graph.vertices.find { |v| v.ref =~ /#{Regexp.escape(name)}/ }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def enforce_order_with_edge(before, after)
|
46
|
+
EnforceOrderWithEdge.new(before, after)
|
47
|
+
end
|
48
|
+
end
|
@@ -3,4 +3,28 @@ module PuppetSpec::Compiler
|
|
3
3
|
Puppet[:code] = string
|
4
4
|
Puppet::Parser::Compiler.compile(node)
|
5
5
|
end
|
6
|
+
|
7
|
+
def compile_to_ral(manifest)
|
8
|
+
catalog = compile_to_catalog(manifest)
|
9
|
+
ral = catalog.to_ral
|
10
|
+
ral.finalize
|
11
|
+
ral
|
12
|
+
end
|
13
|
+
|
14
|
+
def compile_to_relationship_graph(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new)
|
15
|
+
ral = compile_to_ral(manifest)
|
16
|
+
graph = Puppet::Graph::RelationshipGraph.new(prioritizer)
|
17
|
+
graph.populate_from(ral)
|
18
|
+
graph
|
19
|
+
end
|
20
|
+
|
21
|
+
def apply_compiled_manifest(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new)
|
22
|
+
transaction = Puppet::Transaction.new(compile_to_ral(manifest),
|
23
|
+
Puppet::Transaction::Report.new("apply"),
|
24
|
+
prioritizer)
|
25
|
+
transaction.evaluate
|
26
|
+
transaction.report.finalize_report
|
27
|
+
|
28
|
+
transaction
|
29
|
+
end
|
6
30
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module PuppetSpec::Pops
|
2
|
+
extend RSpec::Matchers::DSL
|
3
|
+
|
4
|
+
# Checks if an Acceptor has a specific issue in its list of diagnostics
|
5
|
+
matcher :have_issue do |expected|
|
6
|
+
match do |actual|
|
7
|
+
actual.diagnostics.index { |i| i.issue == expected } != nil
|
8
|
+
end
|
9
|
+
failure_message_for_should do |actual|
|
10
|
+
"expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to contain issue #{expected.issue_code}"
|
11
|
+
end
|
12
|
+
failure_message_for_should_not do |actual|
|
13
|
+
"expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to not contain issue #{expected.issue_code}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -33,7 +33,6 @@ require 'puppet_spec/fixtures'
|
|
33
33
|
require 'puppet_spec/matchers'
|
34
34
|
require 'puppet_spec/database'
|
35
35
|
require 'monkey_patches/alias_should_to_must'
|
36
|
-
require 'monkey_patches/publicize_methods'
|
37
36
|
require 'puppet/test/test_helper'
|
38
37
|
|
39
38
|
Pathname.glob("#{dir}/shared_contexts/*.rb") do |file|
|
@@ -11,18 +11,28 @@ describe Puppet::Application::Agent do
|
|
11
11
|
|
12
12
|
before :each do
|
13
13
|
@puppetd = Puppet::Application[:agent]
|
14
|
-
|
15
|
-
@daemon =
|
14
|
+
|
15
|
+
@daemon = Puppet::Daemon.new(nil)
|
16
|
+
@daemon.stubs(:daemonize)
|
17
|
+
@daemon.stubs(:start)
|
18
|
+
@daemon.stubs(:stop)
|
16
19
|
Puppet::Daemon.stubs(:new).returns(@daemon)
|
17
20
|
Puppet[:daemonize] = false
|
21
|
+
|
18
22
|
@agent = stub_everything 'agent'
|
19
23
|
Puppet::Agent.stubs(:new).returns(@agent)
|
24
|
+
|
20
25
|
@puppetd.preinit
|
21
26
|
Puppet::Util::Log.stubs(:newdestination)
|
22
27
|
|
28
|
+
@ssl_host = stub_everything 'ssl host'
|
29
|
+
Puppet::SSL::Host.stubs(:new).returns(@ssl_host)
|
30
|
+
|
23
31
|
Puppet::Node.indirection.stubs(:terminus_class=)
|
24
32
|
Puppet::Node.indirection.stubs(:cache_class=)
|
25
33
|
Puppet::Node::Facts.indirection.stubs(:terminus_class=)
|
34
|
+
|
35
|
+
$stderr.expects(:puts).never
|
26
36
|
end
|
27
37
|
|
28
38
|
it "should operate in agent run_mode" do
|
@@ -94,75 +104,80 @@ describe Puppet::Application::Agent do
|
|
94
104
|
@puppetd.command_line.stubs(:args).returns([])
|
95
105
|
end
|
96
106
|
|
97
|
-
[:
|
107
|
+
[:enable, :debug, :fqdn, :test, :verbose, :digest].each do |option|
|
98
108
|
it "should declare handle_#{option} method" do
|
99
109
|
@puppetd.should respond_to("handle_#{option}".to_sym)
|
100
110
|
end
|
101
111
|
|
102
112
|
it "should store argument value when calling handle_#{option}" do
|
103
|
-
@puppetd.options.expects(:[]=).with(option, 'arg')
|
104
113
|
@puppetd.send("handle_#{option}".to_sym, 'arg')
|
114
|
+
|
115
|
+
@puppetd.options[option].should == 'arg'
|
105
116
|
end
|
106
117
|
end
|
107
118
|
|
108
119
|
describe "when handling --disable" do
|
109
|
-
it "should declare handle_disable method" do
|
110
|
-
@puppetd.should respond_to(:handle_disable)
|
111
|
-
end
|
112
|
-
|
113
120
|
it "should set disable to true" do
|
114
|
-
@puppetd.options.stubs(:[]=)
|
115
|
-
@puppetd.options.expects(:[]=).with(:disable, true)
|
116
121
|
@puppetd.handle_disable('')
|
122
|
+
|
123
|
+
@puppetd.options[:disable].should == true
|
117
124
|
end
|
118
125
|
|
119
126
|
it "should store disable message" do
|
120
|
-
@puppetd.options.stubs(:[]=)
|
121
|
-
@puppetd.options.expects(:[]=).with(:disable_message, "message")
|
122
127
|
@puppetd.handle_disable('message')
|
128
|
+
|
129
|
+
@puppetd.options[:disable_message].should == 'message'
|
123
130
|
end
|
124
131
|
end
|
125
132
|
|
126
133
|
it "should set client to false with --no-client" do
|
127
134
|
@puppetd.handle_no_client(nil)
|
135
|
+
|
128
136
|
@puppetd.options[:client].should be_false
|
129
137
|
end
|
130
138
|
|
131
139
|
it "should set waitforcert to 0 with --onetime and if --waitforcert wasn't given" do
|
140
|
+
@agent.stubs(:run).returns(2)
|
132
141
|
Puppet[:onetime] = true
|
133
|
-
|
134
|
-
@
|
142
|
+
|
143
|
+
@ssl_host.expects(:wait_for_cert).with(0)
|
144
|
+
|
145
|
+
expect { execute_agent }.to exit_with 0
|
135
146
|
end
|
136
147
|
|
137
148
|
it "should use supplied waitforcert when --onetime is specified" do
|
149
|
+
@agent.stubs(:run).returns(2)
|
138
150
|
Puppet[:onetime] = true
|
139
151
|
@puppetd.handle_waitforcert(60)
|
140
|
-
|
141
|
-
@
|
152
|
+
|
153
|
+
@ssl_host.expects(:wait_for_cert).with(60)
|
154
|
+
|
155
|
+
expect { execute_agent }.to exit_with 0
|
142
156
|
end
|
143
157
|
|
144
158
|
it "should use a default value for waitforcert when --onetime and --waitforcert are not specified" do
|
145
|
-
|
146
|
-
|
159
|
+
@ssl_host.expects(:wait_for_cert).with(120)
|
160
|
+
|
161
|
+
execute_agent
|
147
162
|
end
|
148
163
|
|
149
164
|
it "should use the waitforcert setting when checking for a signed certificate" do
|
150
165
|
Puppet[:waitforcert] = 10
|
151
|
-
|
152
|
-
|
166
|
+
@ssl_host.expects(:wait_for_cert).with(10)
|
167
|
+
|
168
|
+
execute_agent
|
153
169
|
end
|
154
170
|
|
155
171
|
it "should set the log destination with --logdest" do
|
156
|
-
@puppetd.options.stubs(:[]=).with { |opt,val| opt == :setdest }
|
157
172
|
Puppet::Log.expects(:newdestination).with("console")
|
158
173
|
|
159
174
|
@puppetd.handle_logdest("console")
|
160
175
|
end
|
161
176
|
|
162
177
|
it "should put the setdest options to true" do
|
163
|
-
@puppetd.options.expects(:[]=).with(:setdest,true)
|
164
|
-
|
165
178
|
@puppetd.handle_logdest("console")
|
179
|
+
|
180
|
+
@puppetd.options[:setdest].should == true
|
166
181
|
end
|
167
182
|
|
168
183
|
it "should parse the log destination from the command line" do
|
@@ -174,50 +189,37 @@ describe Puppet::Application::Agent do
|
|
174
189
|
end
|
175
190
|
|
176
191
|
it "should store the waitforcert options with --waitforcert" do
|
177
|
-
@puppetd.options.expects(:[]=).with(:waitforcert,42)
|
178
|
-
|
179
192
|
@puppetd.handle_waitforcert("42")
|
180
|
-
end
|
181
193
|
|
182
|
-
|
183
|
-
@puppetd.handle_port("42")
|
184
|
-
@puppetd.args[:Port].should == "42"
|
194
|
+
@puppetd.options[:waitforcert].should == 42
|
185
195
|
end
|
186
|
-
|
187
196
|
end
|
188
197
|
|
189
198
|
describe "during setup" do
|
190
199
|
before :each do
|
191
|
-
@puppetd.options.stubs(:[])
|
192
200
|
Puppet.stubs(:info)
|
193
201
|
FileTest.stubs(:exists?).returns(true)
|
194
202
|
Puppet[:libdir] = "/dev/null/lib"
|
195
|
-
Puppet::SSL::Host.stubs(:ca_location=)
|
196
203
|
Puppet::Transaction::Report.indirection.stubs(:terminus_class=)
|
197
204
|
Puppet::Transaction::Report.indirection.stubs(:cache_class=)
|
198
205
|
Puppet::Resource::Catalog.indirection.stubs(:terminus_class=)
|
199
206
|
Puppet::Resource::Catalog.indirection.stubs(:cache_class=)
|
200
207
|
Puppet::Node::Facts.indirection.stubs(:terminus_class=)
|
201
|
-
@host = stub_everything 'host'
|
202
|
-
Puppet::SSL::Host.stubs(:new).returns(@host)
|
203
208
|
Puppet.stubs(:settraps)
|
204
209
|
end
|
205
210
|
|
206
211
|
describe "with --test" do
|
207
|
-
before :each do
|
208
|
-
#Puppet.settings.stubs(:handlearg)
|
209
|
-
@puppetd.options.stubs(:[]=)
|
210
|
-
end
|
211
|
-
|
212
212
|
it "should call setup_test" do
|
213
|
-
@puppetd.options
|
213
|
+
@puppetd.options[:test] = true
|
214
214
|
@puppetd.expects(:setup_test)
|
215
|
+
|
215
216
|
@puppetd.setup
|
216
217
|
end
|
217
218
|
|
218
219
|
it "should set options[:verbose] to true" do
|
219
|
-
@puppetd.options.expects(:[]=).with(:verbose,true)
|
220
220
|
@puppetd.setup_test
|
221
|
+
|
222
|
+
@puppetd.options[:verbose].should == true
|
221
223
|
end
|
222
224
|
it "should set options[:onetime] to true" do
|
223
225
|
Puppet[:onetime] = false
|
@@ -225,8 +227,9 @@ describe Puppet::Application::Agent do
|
|
225
227
|
Puppet[:onetime].should == true
|
226
228
|
end
|
227
229
|
it "should set options[:detailed_exitcodes] to true" do
|
228
|
-
@puppetd.options.expects(:[]=).with(:detailed_exitcodes,true)
|
229
230
|
@puppetd.setup_test
|
231
|
+
|
232
|
+
@puppetd.options[:detailed_exitcodes].should == true
|
230
233
|
end
|
231
234
|
end
|
232
235
|
|
@@ -241,29 +244,30 @@ describe Puppet::Application::Agent do
|
|
241
244
|
end
|
242
245
|
|
243
246
|
it "should set log level to debug if --debug was passed" do
|
244
|
-
@puppetd.options
|
247
|
+
@puppetd.options[:debug] = true
|
245
248
|
@puppetd.setup_logs
|
246
249
|
Puppet::Util::Log.level.should == :debug
|
247
250
|
end
|
248
251
|
|
249
252
|
it "should set log level to info if --verbose was passed" do
|
250
|
-
@puppetd.options
|
253
|
+
@puppetd.options[:verbose] = true
|
251
254
|
@puppetd.setup_logs
|
252
255
|
Puppet::Util::Log.level.should == :info
|
253
256
|
end
|
254
257
|
|
255
258
|
[:verbose, :debug].each do |level|
|
256
259
|
it "should set console as the log destination with level #{level}" do
|
257
|
-
@puppetd.options
|
260
|
+
@puppetd.options[level] = true
|
258
261
|
|
259
|
-
Puppet::Util::Log.expects(:newdestination).
|
262
|
+
Puppet::Util::Log.expects(:newdestination).at_least_once
|
263
|
+
Puppet::Util::Log.expects(:newdestination).with(:console).once
|
260
264
|
|
261
265
|
@puppetd.setup_logs
|
262
266
|
end
|
263
267
|
end
|
264
268
|
|
265
269
|
it "should set a default log destination if no --logdest" do
|
266
|
-
@puppetd.options
|
270
|
+
@puppetd.options[:setdest] = false
|
267
271
|
|
268
272
|
Puppet::Util::Log.expects(:setup_default)
|
269
273
|
|
@@ -275,7 +279,7 @@ describe Puppet::Application::Agent do
|
|
275
279
|
it "should print puppet config if asked to in Puppet config" do
|
276
280
|
Puppet[:configprint] = "pluginsync"
|
277
281
|
Puppet.settings.expects(:print_configs).returns true
|
278
|
-
expect {
|
282
|
+
expect { execute_agent }.to exit_with 0
|
279
283
|
end
|
280
284
|
|
281
285
|
it "should exit after printing puppet config if asked to in Puppet config" do
|
@@ -283,17 +287,7 @@ describe Puppet::Application::Agent do
|
|
283
287
|
Puppet[:modulepath] = path
|
284
288
|
Puppet[:configprint] = "modulepath"
|
285
289
|
Puppet::Settings.any_instance.expects(:puts).with(path)
|
286
|
-
expect {
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should set a central log destination with --centrallogs" do
|
290
|
-
@puppetd.options.stubs(:[]).with(:centrallogs).returns(true)
|
291
|
-
Puppet[:server] = "puppet.reductivelabs.com"
|
292
|
-
Puppet::Util::Log.stubs(:setup_default)
|
293
|
-
|
294
|
-
Puppet::Util::Log.expects(:newdestination).with("puppet.reductivelabs.com")
|
295
|
-
|
296
|
-
@puppetd.setup
|
290
|
+
expect { execute_agent }.to exit_with 0
|
297
291
|
end
|
298
292
|
|
299
293
|
it "should use :main, :puppetd, and :ssl" do
|
@@ -309,7 +303,7 @@ describe Puppet::Application::Agent do
|
|
309
303
|
end
|
310
304
|
|
311
305
|
it "should install a none ca location in fingerprint mode" do
|
312
|
-
@puppetd.options
|
306
|
+
@puppetd.options[:fingerprint] = true
|
313
307
|
Puppet::SSL::Host.expects(:ca_location=).with(:none)
|
314
308
|
|
315
309
|
@puppetd.setup
|
@@ -373,7 +367,7 @@ describe Puppet::Application::Agent do
|
|
373
367
|
|
374
368
|
[:enable, :disable].each do |action|
|
375
369
|
it "should delegate to enable_disable_client if we #{action} the agent" do
|
376
|
-
@puppetd.options
|
370
|
+
@puppetd.options[action] = true
|
377
371
|
@puppetd.expects(:enable_disable_client).with(@agent)
|
378
372
|
|
379
373
|
@puppetd.setup
|
@@ -383,41 +377,43 @@ describe Puppet::Application::Agent do
|
|
383
377
|
describe "when enabling or disabling agent" do
|
384
378
|
[:enable, :disable].each do |action|
|
385
379
|
it "should call client.#{action}" do
|
386
|
-
@puppetd.options
|
380
|
+
@puppetd.options[action] = true
|
387
381
|
@agent.expects(action)
|
388
|
-
expect {
|
382
|
+
expect { execute_agent }.to exit_with 0
|
389
383
|
end
|
390
384
|
end
|
391
385
|
|
392
386
|
it "should pass the disable message when disabling" do
|
393
|
-
@puppetd.options
|
394
|
-
@puppetd.options
|
387
|
+
@puppetd.options[:disable] = true
|
388
|
+
@puppetd.options[:disable_message] = "message"
|
395
389
|
@agent.expects(:disable).with("message")
|
396
|
-
|
390
|
+
|
391
|
+
expect { execute_agent }.to exit_with 0
|
397
392
|
end
|
398
393
|
|
399
394
|
it "should pass the default disable message when disabling without a message" do
|
400
|
-
@puppetd.options
|
401
|
-
@puppetd.options
|
395
|
+
@puppetd.options[:disable] = true
|
396
|
+
@puppetd.options[:disable_message] = nil
|
402
397
|
@agent.expects(:disable).with("reason not specified")
|
403
|
-
expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
|
404
|
-
end
|
405
398
|
|
406
|
-
|
407
|
-
expect { @puppetd.enable_disable_client(@agent) }.to exit_with 0
|
399
|
+
expect { execute_agent }.to exit_with 0
|
408
400
|
end
|
409
401
|
end
|
410
402
|
|
411
403
|
it "should inform the daemon about our agent if :client is set to 'true'" do
|
412
|
-
@puppetd.options
|
413
|
-
|
414
|
-
|
404
|
+
@puppetd.options[:client] = true
|
405
|
+
|
406
|
+
execute_agent
|
407
|
+
|
408
|
+
@daemon.agent.should == @agent
|
415
409
|
end
|
416
410
|
|
417
411
|
it "should not inform the daemon about our agent if :client is set to 'false'" do
|
418
412
|
@puppetd.options[:client] = false
|
419
|
-
|
420
|
-
|
413
|
+
|
414
|
+
execute_agent
|
415
|
+
|
416
|
+
@daemon.agent.should be_nil
|
421
417
|
end
|
422
418
|
|
423
419
|
it "should daemonize if needed" do
|
@@ -426,66 +422,72 @@ describe Puppet::Application::Agent do
|
|
426
422
|
|
427
423
|
@daemon.expects(:daemonize)
|
428
424
|
|
429
|
-
|
425
|
+
execute_agent
|
430
426
|
end
|
431
427
|
|
432
428
|
it "should wait for a certificate" do
|
433
|
-
@puppetd.options
|
434
|
-
@
|
429
|
+
@puppetd.options[:waitforcert] = 123
|
430
|
+
@ssl_host.expects(:wait_for_cert).with(123)
|
435
431
|
|
436
|
-
|
432
|
+
execute_agent
|
437
433
|
end
|
438
434
|
|
439
435
|
it "should not wait for a certificate in fingerprint mode" do
|
440
|
-
@puppetd.options
|
441
|
-
@puppetd.options
|
442
|
-
@
|
443
|
-
|
444
|
-
@puppetd.setup
|
445
|
-
end
|
436
|
+
@puppetd.options[:fingerprint] = true
|
437
|
+
@puppetd.options[:waitforcert] = 123
|
438
|
+
@puppetd.options[:digest] = 'MD5'
|
446
439
|
|
447
|
-
|
448
|
-
|
449
|
-
@
|
440
|
+
certificate = mock 'certificate'
|
441
|
+
certificate.stubs(:digest).with('MD5').returns('ABCDE')
|
442
|
+
@ssl_host.stubs(:certificate).returns(certificate)
|
450
443
|
|
451
|
-
@
|
444
|
+
@ssl_host.expects(:wait_for_cert).never
|
445
|
+
@puppetd.expects(:puts).with('ABCDE')
|
452
446
|
|
453
|
-
|
447
|
+
execute_agent
|
454
448
|
end
|
455
449
|
|
456
450
|
describe "when setting up listen" do
|
457
451
|
before :each do
|
458
452
|
FileTest.stubs(:exists?).with('auth').returns(true)
|
459
453
|
File.stubs(:exist?).returns(true)
|
460
|
-
@puppetd.options
|
454
|
+
@puppetd.options[:serve] = []
|
461
455
|
@server = stub_everything 'server'
|
462
456
|
Puppet::Network::Server.stubs(:new).returns(@server)
|
463
457
|
end
|
464
458
|
|
465
459
|
|
466
460
|
it "should exit if no authorization file" do
|
461
|
+
Puppet[:listen] = true
|
467
462
|
Puppet.stubs(:err)
|
468
463
|
FileTest.stubs(:exists?).with(Puppet[:rest_authconfig]).returns(false)
|
469
|
-
|
464
|
+
|
465
|
+
expect do
|
466
|
+
execute_agent
|
467
|
+
end.to exit_with 14
|
470
468
|
end
|
471
469
|
|
472
470
|
it "should use puppet default port" do
|
473
471
|
Puppet[:puppetport] = 32768
|
472
|
+
Puppet[:listen] = true
|
474
473
|
|
475
474
|
Puppet::Network::Server.expects(:new).with(anything, 32768)
|
476
475
|
|
477
|
-
|
476
|
+
execute_agent
|
478
477
|
end
|
479
|
-
|
478
|
+
|
480
479
|
it "should issue a warning that listen is deprecated" do
|
480
|
+
Puppet[:listen] = true
|
481
|
+
|
481
482
|
Puppet.expects(:warning).with() { |msg| msg =~ /kick is deprecated/ }
|
482
|
-
|
483
|
+
|
484
|
+
execute_agent
|
483
485
|
end
|
484
486
|
end
|
485
487
|
|
486
488
|
describe "when setting up for fingerprint" do
|
487
489
|
before(:each) do
|
488
|
-
@puppetd.options
|
490
|
+
@puppetd.options[:fingerprint] = true
|
489
491
|
end
|
490
492
|
|
491
493
|
it "should not setup as an agent" do
|
@@ -502,11 +504,6 @@ describe Puppet::Application::Agent do
|
|
502
504
|
@daemon.expects(:daemonize).never
|
503
505
|
@puppetd.setup
|
504
506
|
end
|
505
|
-
|
506
|
-
it "should setup our certificate host" do
|
507
|
-
@puppetd.expects(:setup_host)
|
508
|
-
@puppetd.setup
|
509
|
-
end
|
510
507
|
end
|
511
508
|
|
512
509
|
describe "when configuring agent for catalog run" do
|
@@ -526,114 +523,112 @@ describe Puppet::Application::Agent do
|
|
526
523
|
|
527
524
|
describe "when running" do
|
528
525
|
before :each do
|
529
|
-
@puppetd.
|
530
|
-
@puppetd.daemon = @daemon
|
531
|
-
@puppetd.options.stubs(:[]).with(:fingerprint).returns(false)
|
526
|
+
@puppetd.options[:fingerprint] = false
|
532
527
|
end
|
533
528
|
|
534
529
|
it "should dispatch to fingerprint if --fingerprint is used" do
|
535
|
-
@puppetd.options
|
530
|
+
@puppetd.options[:fingerprint] = true
|
536
531
|
|
537
532
|
@puppetd.stubs(:fingerprint)
|
538
|
-
|
533
|
+
|
534
|
+
execute_agent
|
539
535
|
end
|
540
536
|
|
541
537
|
it "should dispatch to onetime if --onetime is used" do
|
542
|
-
@puppetd.options
|
538
|
+
@puppetd.options[:onetime] = true
|
543
539
|
|
544
540
|
@puppetd.stubs(:onetime)
|
545
|
-
|
541
|
+
|
542
|
+
execute_agent
|
546
543
|
end
|
547
544
|
|
548
545
|
it "should dispatch to main if --onetime and --fingerprint are not used" do
|
549
|
-
@puppetd.options
|
546
|
+
@puppetd.options[:onetime] = false
|
550
547
|
|
551
548
|
@puppetd.stubs(:main)
|
552
|
-
|
549
|
+
|
550
|
+
execute_agent
|
553
551
|
end
|
554
552
|
|
555
553
|
describe "with --onetime" do
|
556
554
|
|
557
555
|
before :each do
|
558
556
|
@agent.stubs(:run).returns(:report)
|
559
|
-
|
560
|
-
@puppetd.options
|
557
|
+
Puppet[:onetime] = true
|
558
|
+
@puppetd.options[:client] = :client
|
559
|
+
@puppetd.options[:detailed_exitcodes] = false
|
561
560
|
Puppet.stubs(:newservice)
|
562
561
|
end
|
563
562
|
|
564
563
|
it "should exit if no defined --client" do
|
565
|
-
|
566
|
-
|
567
|
-
|
564
|
+
@puppetd.options[:client] = nil
|
565
|
+
|
566
|
+
Puppet.expects(:err).with('onetime is specified but there is no client')
|
567
|
+
|
568
|
+
expect { execute_agent }.to exit_with 43
|
568
569
|
end
|
569
570
|
|
570
571
|
it "should setup traps" do
|
571
572
|
@daemon.expects(:set_signal_traps)
|
572
|
-
|
573
|
+
|
574
|
+
expect { execute_agent }.to exit_with 0
|
573
575
|
end
|
574
576
|
|
575
577
|
it "should let the agent run" do
|
576
578
|
@agent.expects(:run).returns(:report)
|
577
|
-
expect { @puppetd.onetime }.to exit_with 0
|
578
|
-
end
|
579
579
|
|
580
|
-
|
581
|
-
expect { @puppetd.onetime }.to exit_with 0
|
580
|
+
expect { execute_agent }.to exit_with 0
|
582
581
|
end
|
583
582
|
|
584
583
|
it "should stop the daemon" do
|
585
584
|
@daemon.expects(:stop).with(:exit => false)
|
586
|
-
|
585
|
+
|
586
|
+
expect { execute_agent }.to exit_with 0
|
587
587
|
end
|
588
588
|
|
589
589
|
describe "and --detailed-exitcodes" do
|
590
590
|
before :each do
|
591
|
-
@puppetd.options
|
591
|
+
@puppetd.options[:detailed_exitcodes] = true
|
592
592
|
end
|
593
593
|
|
594
594
|
it "should exit with agent computed exit status" do
|
595
595
|
Puppet[:noop] = false
|
596
596
|
@agent.stubs(:run).returns(666)
|
597
597
|
|
598
|
-
expect {
|
598
|
+
expect { execute_agent }.to exit_with 666
|
599
599
|
end
|
600
600
|
|
601
601
|
it "should exit with the agent's exit status, even if --noop is set." do
|
602
602
|
Puppet[:noop] = true
|
603
603
|
@agent.stubs(:run).returns(666)
|
604
604
|
|
605
|
-
expect {
|
605
|
+
expect { execute_agent }.to exit_with 666
|
606
606
|
end
|
607
607
|
end
|
608
608
|
end
|
609
609
|
|
610
610
|
describe "with --fingerprint" do
|
611
611
|
before :each do
|
612
|
-
@cert =
|
613
|
-
@puppetd.options
|
614
|
-
@puppetd.options
|
615
|
-
@host = stub_everything 'host'
|
616
|
-
@puppetd.stubs(:host).returns(@host)
|
612
|
+
@cert = mock 'cert'
|
613
|
+
@puppetd.options[:fingerprint] = true
|
614
|
+
@puppetd.options[:digest] = :MD5
|
617
615
|
end
|
618
616
|
|
619
617
|
it "should fingerprint the certificate if it exists" do
|
620
|
-
@
|
621
|
-
@cert.
|
622
|
-
|
623
|
-
|
618
|
+
@ssl_host.stubs(:certificate).returns(@cert)
|
619
|
+
@cert.stubs(:digest).with('MD5').returns "fingerprint"
|
620
|
+
|
621
|
+
@puppetd.expects(:puts).with "fingerprint"
|
624
622
|
|
625
|
-
it "should fingerprint the certificate request if no certificate have been signed" do
|
626
|
-
@host.expects(:certificate).returns(nil)
|
627
|
-
@host.expects(:certificate_request).returns(@cert)
|
628
|
-
@cert.expects(:digest).with('MD5').returns "fingerprint"
|
629
623
|
@puppetd.fingerprint
|
630
624
|
end
|
631
625
|
|
632
|
-
it "should
|
633
|
-
@
|
634
|
-
@
|
626
|
+
it "should fingerprint the certificate request if no certificate have been signed" do
|
627
|
+
@ssl_host.stubs(:certificate).returns(nil)
|
628
|
+
@ssl_host.stubs(:certificate_request).returns(@cert)
|
629
|
+
@cert.stubs(:digest).with('MD5').returns "fingerprint"
|
635
630
|
|
636
|
-
@puppetd.expects(:puts).with "
|
631
|
+
@puppetd.expects(:puts).with "fingerprint"
|
637
632
|
|
638
633
|
@puppetd.fingerprint
|
639
634
|
end
|
@@ -642,14 +637,19 @@ describe Puppet::Application::Agent do
|
|
642
637
|
describe "without --onetime and --fingerprint" do
|
643
638
|
before :each do
|
644
639
|
Puppet.stubs(:notice)
|
645
|
-
@puppetd.options
|
640
|
+
@puppetd.options[:client] = nil
|
646
641
|
end
|
647
642
|
|
648
643
|
it "should start our daemon" do
|
649
644
|
@daemon.expects(:start)
|
650
645
|
|
651
|
-
|
646
|
+
execute_agent
|
652
647
|
end
|
653
648
|
end
|
654
649
|
end
|
650
|
+
|
651
|
+
def execute_agent
|
652
|
+
@puppetd.setup
|
653
|
+
@puppetd.run_command
|
654
|
+
end
|
655
655
|
end
|