summaryrefslogtreecommitdiff
path: root/spec/unit/node
AgeCommit message (Collapse)AuthorFilesLines
2014-08-29(PUP-3069) Change restrict_environment_manifest nameJosh Partlow1-3/+3
After discussion with Nick Fagerlund and Henrik Lindberg, changing restrict_environment_manifest setting to disable_per_environment_manifest to more clearly reflect what the setting does.
2014-08-29(PUP-3069) Halt compile if environment has manifest conflictJosh Partlow1-0/+54
Henrik brought up that with the new restrict_environment_manifest setting set true, authors of modules in a particular environment may be surprised by a manifest they have specified in their environment.conf not being pulled in, leading to bad behavior when a catalog is executed. Although this is logged on the master, compilation delivery and catalog execution is not prevented. This commit will raise an exception on the master prior to catalog compilation if it detect's a conflict between manifest settings in the requested environment.
2014-05-30(PUP-2692) Correctly implement environment equalityAndrew Parker1-0/+36
This fixes environment equality to make it work as a hash key. It also adds tests around this functionality.
2014-04-21Merge remote-tracking branch 'upstream/master' into PE-3182Pieter van de Bruggen1-1/+1
Conflicts: spec/unit/face/module/install_spec.rb spec/unit/face/module/list_spec.rb spec/unit/face/module/uninstall_spec.rb spec/unit/module_tool/applications/installer_spec.rb spec/unit/module_tool/applications/uninstaller_spec.rb spec/unit/module_tool_spec.rb
2014-04-09Merge remote-tracking branch 'upstream/stable'Andrew Parker1-1/+1
* upstream/stable: (PUP-2158) Unlist configured environment (PUP-2158) Test dynamic environments with an empty environmentpath (PUP-2158) Fix integration apply application spec (PUP-2129) Fix issues with false interpolation start (no-such-method) (PUP-2158) Report 404 for missing environment (PUP-2158) Default a missing manifest to no_manifest (PUP-2158) Hide dir envs behind a feature flag Conflicts: lib/puppet/node/environment.rb spec/unit/environments_spec.rb
2014-04-07(PUP-2093) Support hyphenated module names as dependencies.Pieter van de Bruggen1-1/+1
In master, hyphenated module names are supported (effectively) everywhere except as the name of a dependency. A previous commit in this branch attempted to alleviate that situation, but failed to adequately test the change and its implications, and potential failures existed. This change introduces a change to existing tests that triggers the offensive behavior both in master and in this branch, and refactors the implementation to apply the necessary transliteration in all required locations.
2014-04-07(PUP-2158) Default a missing manifest to no_manifestAndrew Parker1-1/+1
The tests were often creating environments that didn't need to have manifests. Since we didn't have a way of specifying that when they were written, we used '' to fill in the blank. This actually caused a large number of tests to try to find code to load in the PWD, which caused tests to break if a developer had parse errors in manifests being used for testing in the root directory of their puppet project. This changes the manifest to be optional and removes '' from those tests. The tests no longer fail if a bad manifest is in the PWD :D
2014-03-21(PUP-1596) Expand all paths when creating directory environmentsJosh Partlow1-2/+2
When reading EnvironmentConf settings, relative paths were prepended with the directory environment path. This commit ensures that we also expand the paths properly so that they are absolute on both Windows and Posix platforms.
2014-03-18(PUP-1596) Add config_version as an explicit env propertyJosh Partlow1-1/+26
Legacy environments could have config_version set in their puppet.conf stanza, just as any setting in an [env] stanza would shadow if that setting was looked up in the context of the environment. But the new directory environments are intended to explicitly include config_version as a setting (albeit an optional one). This change adds a config_version attribute to Puppet::Node::Environment, looking it up from settings if a new call is made, or taking it directly from a create call, which is what the Directory environments loader will do once environment.conf is parsed for directory environments.
2014-02-22(PUP-1735) Reimplement deprecated Puppet::Node::Environment.currentDominic Cleal1-0/+9
Puppet::Node::Environment.current is used in some external code, so reimplement it, linking to the context lookup for the current environment and issue a deprecation warning.
2014-02-21(PUP-1678) Puppet::Node::Environment.create expands manifest pathJosh Partlow1-2/+2
Modulepath was already being expanded; this ensures manifest is expanded as well and fixes some specs so that they will work on Windows too.
2014-02-14(PUP-751) Check for reparse once per compileAndrew Parker1-13/+5
Previously, whenever the known_resource_types (Puppet::Resource::TypeCollection) was retrieved from the environment it would check if there were any files that needed to be reparsed. If any files needed a reparse, then the entire TypeCollection was thrown away and redone. In most cases the reparse check did not need to touch the filesystem because the Puppet::Util::PeriodicWatcher would return a cached result until the filetimeout had expired. Unfortunately the check was done so often that the overhead of simply checking if enough time had passed caused it to take a considerable amount of time. This changes it so that the environment's known resource types are only recalculated if the new check_for_reparse method determines that it should. The new method is only called at the beginning of a compile and so the files will never be checked while a compilation is being executed. In my local benchmark runs (the many_modules benchmark) this resulted in a speedup from ~0.8 seconds to ~0.6 seconds.
2014-02-06(PUP-1574) Environment setting does not override apply/parser manifestJosh Partlow1-0/+22
Both `puppet apply` and `puppet parser validate` were relying on the legacy environment behavior to implicit draw in the setting of Puppet[:manifest]. But the new directory environments do not pay attention to Puppet[:manifest] and thus a call such as `puppet apply foo.pp --environment dir_env` would not apply foo.pp if dir_env was in the $environmentpath. This change explicitly creates a new environment based off the currently configured environment and overrides with the manifest this to be applied or validated.
2014-01-29(PUP-1118) Stop using Environment.newAndrew Parker1-22/+0
Instead of creating environments directly, we need to go through the configured environment loaders, otherwise environments can't come from other places.
2014-01-16(PUP-1118) Introduce "create" to make specific environmentsAndrew Parker1-36/+1
Environments are more than just a name, they are also a modulepath and a manifest. This commit makes a "create" method for setting up environments with specific modulepaths and manifests rather than relying on the Puppet Settings at the time that methods are called. In order to control environments for module installation they now take advantage of this in order to control the modulepath that things will be installed into.
2014-01-14(PUP-1118) Fetch the environment's manifest & modulepath at initAndrew Parker1-30/+53
After trying to get the manifest and modulepath during the initialization for an environment, it turned out that a lot of other things depended on a very specific load order. Some of those needed to change around, others needed to delay executing until later, after everything had been loaded and initialized (creation of the root environment was one of these). The reset of the Parser::Functions also moved so that it doesn't happen until settings have been initialized.
2014-01-14(PUP-1151) Consolidate JSON schema validationAndrew Parker1-12/+5
This adds a new matcher to the JSONMatchers to validate json against a given json-schema. All of the json schema validation now goes through this one matcher, which also handles skipping the checks on windows.
2014-01-06(PUP-716) Fix up FileSystem API change, tests indirector, parser, nodeHenrik Lindberg1-1/+1
2013-12-27(PUP-798) E4ParserAdapter watches files through EnvironmentJosh Partlow1-1/+17
Instead of passing known_resource_types, if present, pass the given environment, and provide a delegate method to watch_file on Environment. Clears up a few layers of type checking and does not require the adapter to know anything about known_resource_types for the purpose of watching files, but a valid environment must be passed.
2013-12-17Merge branch 'pr/2158'Josh Cooper1-1/+5
* pr/2158: (Maint) Fix deprecation message to point to the right alternative (#23373) Only parse section lines once (#23373) Restore 'all' functionality (Maint) Remove unused code (#23373) Don't apply all metadata (#23373) Use puppet config set in tests (#23373) Don't set metadata when it isn't supported (#23373) Check for minimal use of [main] (#23373) Reuse existing section headers (#23373) Add section control to the config print action (#23373) Pull apart settings into a few more classes (#23373) Provide a more structure config file parse (#23373) Have config parsing use IniFile's sections (#23373) Support selecting the section Closes GH-2158
2013-12-14(PUP-865) Add ability to parse a directory of manifestsHenrik Lindberg1-0/+2
This adds the ability to run a directory of manifests instead of just a single file. Simply assign a directory to Puppet[:manifest] via settings or from the command line. The files are parsed and combined in alphabetical order as if the files were to be concatenated into a single file. The support is in environment, and it is only support for the initial import. This also means that both current and future parser can be used (i.e. the support for this is not in the parser). Testing is done in integration/node/environment_spec.
2013-12-12(#23373) Pull apart settings into a few more classesAndrew Parker1-1/+5
The monolithic settings infrastructure is really hard to work with. In order to implement the functionality for puppet config print to reliably be able to print the value of any given section of the configuration I need to be able to split it apart from the very static structure that exists inside puppet. This takes a step in that direction by starting the process of extracting the lookup logic into smaller classes.
2013-11-08(#19447) Puppet::FileSystem::File.exist?Ethan J. Brown1-1/+1
- All previous File and FileTest calls to exist? or exists? go through the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-10-11(maint) Serialize timestamp in Puppet::Node::Fact using iso8601Patrick Carlisle1-2/+2
2013-10-08(maint) Rename validate_as_json to be specificPatrick Carlisle1-5/+1
This renames validate_as_json methods to be specific to the schema they are validating (since that's embedded in each definition) and inlines the implementations that didn't need to be abstracted.
2013-10-03Merge remote-tracking branch 'upstream/stable'Josh Cooper1-1/+1
* upstream/stable: (maint) Move constant outside shared_examples_for to avoid "already initialized" warning (maint) Windows failing spec fixes Conflicts: spec/unit/node/environment_spec.rb
2013-10-02(maint) Factor a duplicated constant up to spec_helperKylo Ginsberg1-2/+0
2013-10-02(maint) Remove constant and requires now provided in spec_helperKylo Ginsberg1-4/+0
2013-09-12(#22522) some formatting fixupsKylo Ginsberg1-1/+0
2013-09-12(#22522) validate node facts against facts schemaKylo Ginsberg1-1/+29
2013-09-06(maint) Windows failing spec fixesIristyle1-1/+1
- The usage of Dir.getwd in tests has been simplified to File.expand_path to properly handle mixed case CWD - util_spec.rb ensures 'FOO' Env var cleared before test starts - Windows SID checks should be performed as a regex match to properly handle all accounts starting with S-1-5-*, which denotes accounts with an identifier authority of SECURITY_NT_AUTHORITY instead of hardcoding S-1-5-32-544, the Administrators group
2013-08-20(#21201) Remove thread-safety codeAndrew Parker1-17/+3
Puppet does not support running in any threaded environments. The thread safety code that has been added has been, for the most part, haphazard and not a holistic solution to the threading problem. There are many areas that are not protected at all and others that were protected in incomplete ways. The extra code and logic only caused more complication in the codebase and is removed by this commit.
2013-08-20(Maint) Remove whitespace errorsAndrew Parker1-75/+75
A lot of blank lines had picked up extra spaces.
2013-08-07(#21839) Stringify the :_timestamp fact nameCharlie Sharpsteen1-2/+2
Change all instances of the `:_timestamp` fact to `_timestamp`. Symbols can be converted to strings during a round-trip through a simple terminus such as JSON. If the Fact is then updated using the symbol, there will be two names for the same data. After 5ac681f, in the 3.0 rc series, all varible names are explicitly stringified when added to compiler scopes. This means that facts named `:_timestamp` and `_timestamp` will end up mapping to the same scope variable which violates static single assignment.
2013-07-31(maint) Add test for GH-1783Adrien Thebo1-0/+5
2013-07-31(maint) refactor node local facts into describe blockAdrien Thebo1-16/+18
2013-06-04(maint) remove fact stringifying deprecation warningAdrien Thebo1-1/+0
Fact stringifying is on by default, but we're issuing a deprecation warning on stringified facts. Since it looks like we'll have to stringify facts for a while, this commit removes the deprecation warning. This is an update of GH-1658 that takes the comments into account.
2013-04-24(#4561) Support structured factsErik Dalén1-0/+45
Add the option stringify_facts which defaults to true. If it is turned on the current behaviour with turning facts into strings is kept. If it is false facts are sanitized and only converted to strings if they aren't booleans, numerics, arrays and hashes. It does this sanitizing in a nested manner for arrays and hashes.
2013-04-05(#11331) Make tests run for both current and future parser.Henrik Lindberg1-404/+420
Tests were hardwired to run for only future/eparser. Now all tests where parser is involved runs for both current/classic and future/eparser (except when testing methods; where parsing is only done in order to construct a call; it is the function that is tested, not the parsing). The collect method testing includes testing the various ways a call can be made to it, but this is the only place; this because it is more work to unwire all the others when the final style for lambdas gets picked.
2013-04-05(#11331) Refactor ParserFactory and PopsParserAdapterHenrik Lindberg1-1/+1
This separates the PopsParserAdapter from the ParserFactory and renames it to EParserAdapter.
2013-04-05(#11331) Change specs to use ParserFactory instead of (classic) Parser.Henrik Lindberg1-2/+3
2013-02-07Revert "Merge branch 'pull-1339' into 3.1.x"Adrien Thebo1-32/+0
This reverts commit 7bd6a908a82b0502558564d32a7fa604cee3c5a3, reversing changes made to 480379d1f61d88e732bd10d6773845a788351ed3. This commit seems to be the cause of acceptance test failures so I'm backing this out until we get that cleared up.
2013-02-05(#18187) Clear *root* environment when clearing cachesDominic Cleal1-0/+32
When changing settings or initializing Puppet via TestHelper, the Puppet::Node::Environment.clear method is called to delete the cached environment objects, as they may reference cached module paths based on old values of settings. The *root* environment is a special case, as it acts as the current environment when no other environment has been created and set yet. It can still have a module path based on current settings, so it too should be cleared along with other cached environments. Failure to reinitialize *root* causes failures when initializing Puppet via the TestHelper. The Puppet::MetaType::Manager class uses the current environment in calls to Puppet::Util::Autoload, which starts as the default *root* enviroment. The type loader is called a few times during TestHelper initialization and so if the module path is then changed (which triggers a .clear call), the *root* environment will contain paths based on old settings, so types won't load. Loading types based on the environment is new in 8173a6e6 (2.7.19). 3.x is unaffected as caching of module paths doesn't begin until app_defaults_initialized? changes to true.
2013-01-24Revert "Merge branch 'new-ruby-dsl-by-mlen'"Patrick Carlisle1-13/+0
This reverts commit 751efa9174adfe1bc0a5707855e6ba16ff2aed43, reversing changes made to 023cffdbb9b30945fbf4dcaded4f63428ce54ea7. Conflicts: lib/puppet/dsl/context.rb spec/unit/dsl/context_spec.rb
2012-11-27Add new Ruby DSL by Mateusz Lenik.Mateusz Lenik1-0/+13
This adds new Ruby DSL features by Mateusz Lenik. This was developed as a Google Summer of Code project. This commit contains all of the new Ruby DSL work in one single commit.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune2-2/+2
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-09-06(#16275) Don't set $environment as a local factPatrick Carlisle1-2/+2
The environment set by set_local_facts was not always correct. Since the node object should always have the correct environment now we should just use that.
2012-08-16(#15758) Remove fact downcasingHailee Kenney1-26/+0
Remove `downcasefact` and `downcase_if_necessary` as downcasing of facts is no longer supported.
2012-08-08Merge branch '2.7.x' into 3.xPatrick Carlisle1-7/+7
* 2.7.x: Add Puppet::Parser::Functions::clear for specs Clear Environment.current when calling Environment.clear Check that function loading worked correctly. Avoid stubbing Thread::new due to issues in newer mocha Rename specs to end in _spec.rb Don't require mocha in spec_helper Fix stubbing on nil in some specs (#14515) Tests fail with mocha 0.11.4 Conflicts: spec/unit/network/http/webrick_spec.rb spec/unit/parser/functions/require_spec.rb spec/unit/parser/functions/template_spec.rb
2012-08-08Clear Environment.current when calling Environment.clearPatrick Carlisle1-3/+3
This makes Puppet::Node::Environment::clear properly clear all the environment state. This reduces dependencies between tests due to leaked state. It also moves the call to clear to happen before each test. This avoids issues where tests set up stubs on settings, as the after block is called before stubs are removed.