| Age | Commit message (Collapse) | Author | Files | Lines |
|
In mocha >= 0.11.0, unstubbing a method is done by defining a method that
calls the original method. Somehow this indirection causes issues when
Thread::new is stubbed, and the new thread does not have proper access to
local variables. This patch fixes this from both ends, by not stubbing
Thread::new and not using local variables in the test that was failing.
|
|
Many tests set stubs or expectations on configuration values. This is
unnecessary, as settings are reset before each test. Because creating a stub
stubs out the entire value method on settings, stubbing any individual setting
interferes with retrieving any other setting. This makes for weird errors and
fragile tests. This commit changes most cases to just set each setting
directly.
Expectations on settings were often used to verify that a setting is used.
This is not a good way of testing this, since it checks that the value is
accessed but not that it is actually used correctly. Most expecations on
settings are better expressed by changing the setting and then verifying a
returned value.
|
|
|
|
Without this patch some spec files are using `ruby -S rspec` and others
are using `rspec`.
We should standardize on a single form of the interpreter used for spec
files.
`ruby -S rspec` is the best choice because it correctly informs editors
such as Vim with Syntastic that the file is a Ruby file rather than an
Rspec file.
|
|
|
|
When autoloading classes/defines, the typeloader constructs a set of
possible locations for the class, based on its name. Effectively, it
will look in the canonical locations corresponding to each namespace in
the fully-qualified name. So for each namespace, it will ask the
environment for a Puppet::Module instance for that module, to ask it
which of the module's potentially manifests match the class it's looking
for. To answer that request, the environment instantiates a
Puppet::Module.
This amounts to potentially thousands of Puppet::Module instances being
created, because it does this many times (based on nesting of the class
name) per include/autoload/import. When Puppet::Module instances are
created, they parse and load their metadata.json file, in part to
validate their use. This implies that each compilation results in
metadata.json being parsed thousands of times, which is extremely slow
(and obviously provides no actual benefit).
Fortunately, the environment object already keeps a list of
Puppet::Module instances for every module in its modulepath. The fix
applied here is simply to change the environment such that it provides
modules by looking them up in its cached list, resulting in up to an
order of magnitude improvement in compilation time.
|
|
* 2.7.x:
(maint) Remove unnecessary step from puppet module build help
(#13659) Convert fact values to string when searching database
(#13649) Restrict module name matching
(#13643) Make the use of FileUtils.rm_rf secure
(#13642) Move search notice message
(#13639) Don't send errors directly to stderr
(#13638) Add SemVer#pre function
(#3581) Stop forking around: Add fork helper method
(#13397) fix gem provider ensure=>latest bug
(#12101) Make Puppet::Util::absolute_path? usable in autoloader
(#12101) Add shared context for specs to imitate windows or posix
Conflicts:
lib/puppet/util.rb
spec/unit/util_spec.rb
|
|
* 2.7.x:
(#9167) Do not send email when nothing changes
[#13686] Fix directoryservices ShadowHashData code
Fixup tests to work on CentOS 5
fix bug in Util#symbolizehash!
(#13567) Fix create_resources name parameter bug
(#13636) Update Module Face copyright date
(#13737) Swap build_tree and format_tree method names
(#9167) Do not send email when nothing changes
Add Module Tool
Make core changes needed for the puppet module tool
(#13367) Patch SemVer to permit ranges including pre-release components.
Monkey patch FileUtils.mv in Ruby 1.8.5
(#1076) Show warning if an empty group is specified
Maint: Remove unused mock objects in user spec
Maint: Use real objects in user spec
Maint: Add a real provider class to user spec
Maint: Remove unused variable in user spec
Conflicts:
lib/puppet/util/monkey_patches.rb
spec/unit/type/resources_spec.rb
spec/unit/type/user_spec.rb
|
|
Before this patch the regex used to match valid module names in
`Puppet::Node::Environment#modules_by_path` matches invalid module
names.
This patch replaces the current regex pattern with one more accurate.
This patch also includes updated specs to cover this change in behavior.
|
|
This includes changes to portions of the Puppet code base that have some
use by other parts of Puppet than the module tool, but are necessary for
the module tool work.
|
|
* 2.7.x: (63 commits)
Maint: Fix bad copy and paste
(#12725) Fix puppet agent --listen on Windows
(#11740) Wait on the handle from the PROCESS_INFORMATION structure
(#12564) Stub CHILDSTATUS in all test cases, not just failure cases.
Updating CHANGELOG and lib/puppet.rb for 2.7.11
(#12412) Mark symbolic file modes test as pending on Windows
Symbolic file mode test fixes when no mode change happens.
Fix spec ordering failure on environment
Updating CHANGELOG and lib/puppet.rb for 2.7.11
Disable specs that use replace_file on Windows
Disable replace_file on Windows
Remove unnecessary fallbacks in change_{user,group}
Document uid/gid-related methods in Puppet::Util
Copy owner/group in replace_file
(#12463) eliminate `secure_open` in favour of `replace_file`
(#12460) use `replace_file` for the .k5login file
(#12462) user_role_add: use `replace_file` for /etc/shadow
(#12463) add secure `replace_file` to Puppet::Util
(#12459) drop supplementary groups when permanently dropping UID
(#12458) default to users primary group, not root, in `asuser`
...
Conflicts:
lib/puppet/application/queue.rb
lib/puppet/provider/package/openbsd.rb
lib/puppet/util.rb
spec/unit/network/http/webrick_spec.rb
spec/unit/util_spec.rb
test/lib/puppettest/servertest.rb
|
|
The module_requirements method was sorting the requirements, but only as
it went along, not for the entire list of requirements that got put in
the data structure. This caused intermittent test failures since
sometimes the results would come out in a different order than the
specs asserted.
This moves the sort to happen *after* the data is all in.
|
|
Windows has a bigger list of reserved characters that can't be used in
directory names than Linux does, so a spec failed that tried to create
an invalid module dir actually created an invalid Windows dir.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
The following reserved characters:
< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
The main point of the failing spec was to show the restrictions on module
directory names, which is /^[-\w]+$/, so I'm just going to use an '=' in the
spec since Windows doesn't reserve that.
|
|
Before this patch module requirements do not include version numbers.
Since modules with the same name, but different version numbers, can be
installed at the same time -- in different parts of the modulepath,
there is no way to tell which module has the dependency.
This patch fixes this issue by changing the data structure that
represents module requirements from a two item Array to a Hash with
three keys: name, version, and version_requirement.
This patch includes updated spec tests related to this change.
|
|
Being able to figure out what other modules depend on a module is useful
for resolving contraints when installing and preventing uninstalls of
modules that are still required. And being able to tell if a module has
local changes is useful to prevent accidentally losing those changes
when upgrading or uninstalling a module.
|
|
There are still deprecated stubs for execpipe, execfail, and execute in Puppet::Util for backwards compatibility. rspecs are all passing, but would still like to go through and check for deprecation warnings that were triggered by this changeset (and fix them, obviously).
get spec tests running against Puppet::Util -> Util::Execution refactor
|
|
|
|
There's already a modules method on environments that returns your
modules, but only the first one in the module path. For example, if you
have a modulepath with multiple directories, and a module is in both
directories, you only ever info back about the module in the first
directory in the modulepath. For the `module list` command we need to
show details about all the modules split up by path.
|
|
For the `module list` command we want to be able to tell about all the
modules in multiple directories of an environment's modulepath.
Currently, if we have a module with the same name in two different
directories of the modulepath it's impossible to get information on it
since Puppet::Module.new takes a name and environment will always
assume the path for the module is in the first directory of the
environment's modulepath.
This change allows the module's path to be passed in so that you can
instantiate a Puppet::Module for any module location.
|
|
A test environment was being setup repeatedly so I just moved it into a
let block. I also used real modulepaths on the environments instead of
stubbing the value since it's shorter and easier to read.
|
|
These specs were creating environments when they didn't need to, and not
testing what the description said. The test to show that a string was
accepted passed an environment object.
|
|
These methods aren't available until Ruby 1.8.6 (Dir.mktmpdir) and Ruby 1.8.7
(Object#tap).
Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 61df3f7c39d74b82e37f48c3519293406036e1e9)
|
|
The environment validates its modulepath and manifestdir settings, but
it uses Dir.getwd to convert a relative path into an absolute path. The
problem is that on Windows, Dir.getwd returns a path with backslashes.
(Interestingly this only happens when puppet is loaded, not in irb for
example.) And since we do not yet support backslashes in Windows paths
or UNC paths, the directory is not included in the environment.
For the time being, I am using File.expand_path to normalize the path.
It has the side-effect of converting backslashes to forward slashes.
This is sufficient to work around backslashes in Dir.getwd. In the near
future, I will be refactoring how paths are split, validated, tested,
etc, and I have a REMIND in place to fix the environment.
But as a result of this change it exposed a bug in our rdoc parser
dealing with the finding the root of a path. The parser assumed that the
root was '/', but caused an infinite loop when passed a Windows path.
I added a test for this case, which is only run on Windows, because on
Unix File.dirname("C:/") == '.'.
After all of that, I had to disable one of the rdoc spec tests, because
it attempted to reproduce a specific bug, which caused rdoc to try to
create a directory of the form: C:/.../files/C:/.... Of course, this
fails because ':' is not a valid filename character on Windows.
Paired-with: Nick Lewis <nick@puppetlabs.com>
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 9279d0954eb20d75e18a666fd572b5492e157608)
|
|
We have removed every usage of cached_attr in which the attribute needs to be
manually expired. Thus, the only meaningful behavior provided by
Puppet::Util::Cacher is expiration based on TTLs. This commit reworks the
cacher to only support that behavior.
Rather than accepting an options hash, of which :ttl is the only available
option, cached_attr now requires a second argument, which is the TTL.
TTLs are now used to compute expirations, which are stored and used for
expiring values. Previously, we stored a timestamp and used it and the TTL to
determine whether the attribute was expired. This had the potentially
undesirable side effect that the lifetime of a cached attribute could be
extended after its insertion by modifying the TTL setting for the cache. Now,
the lifetime of an attribute is determined when it is set, and is thereafter
immutable, aside from deliberately re-setting the expiration for that
particular attribute.
Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit d198fedf65e472b384666fc9ae3bef487852068a)
Conflicts:
spec/integration/node/facts_spec.rb
spec/unit/node_spec.rb
|
|
Absolute paths on Unix, e.g. /foo/bar, are not absolute on Windows,
which breaks many test cases. This commit adds a method to
PuppetSpec::Files.make_absolute that makes the path absolute in
test cases.
On Unix (Puppet.features.posix?) it is a no-op. On Windows,
(Puppet.features.microsoft_windows?) the drive from the current
working directory is prepended.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 462a95e3d077b1915a919399b846068816c84583)
Conflicts:
spec/unit/parser/functions/extlookup_spec.rb
|
|
The environment validates its modulepath and manifestdir settings, but
it uses Dir.getwd to convert a relative path into an absolute path. The
problem is that on Windows, Dir.getwd returns a path with backslashes.
(Interestingly this only happens when puppet is loaded, not in irb for
example.) And since we do not yet support backslashes in Windows paths
or UNC paths, the directory is not included in the environment.
For the time being, I am using File.expand_path to normalize the path.
It has the side-effect of converting backslashes to forward slashes.
This is sufficient to work around backslashes in Dir.getwd. In the near
future, I will be refactoring how paths are split, validated, tested,
etc, and I have a REMIND in place to fix the environment.
But as a result of this change it exposed a bug in our rdoc parser
dealing with the finding the root of a path. The parser assumed that the
root was '/', but caused an infinite loop when passed a Windows path.
I added a test for this case, which is only run on Windows, because on
Unix File.dirname("C:/") == '.'.
After all of that, I had to disable one of the rdoc spec tests, because
it attempted to reproduce a specific bug, which caused rdoc to try to
create a directory of the form: C:/.../files/C:/.... Of course, this
fails because ':' is not a valid filename character on Windows.
Paired-with: Nick Lewis <nick@puppetlabs.com>
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
|
|
These methods aren't available until Ruby 1.8.6 (Dir.mktmpdir) and Ruby 1.8.7
(Object#tap).
Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
|
|
We have removed every usage of cached_attr in which the attribute needs to be
manually expired. Thus, the only meaningful behavior provided by
Puppet::Util::Cacher is expiration based on TTLs. This commit reworks the
cacher to only support that behavior.
Rather than accepting an options hash, of which :ttl is the only available
option, cached_attr now requires a second argument, which is the TTL.
TTLs are now used to compute expirations, which are stored and used for
expiring values. Previously, we stored a timestamp and used it and the TTL to
determine whether the attribute was expired. This had the potentially
undesirable side effect that the lifetime of a cached attribute could be
extended after its insertion by modifying the TTL setting for the cache. Now,
the lifetime of an attribute is determined when it is set, and is thereafter
immutable, aside from deliberately re-setting the expiration for that
particular attribute.
Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
|
|
Absolute paths on Unix, e.g. /foo/bar, are not absolute on Windows,
which breaks many test cases. This commit adds a method to
PuppetSpec::Files.make_absolute that makes the path absolute in
test cases.
On Unix (Puppet.features.posix?) it is a no-op. On Windows,
(Puppet.features.microsoft_windows?) the drive from the current
working directory is prepended.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
|
|
We were failing if any values were nil, and values
were often nil, at least in testing.
We now only include non-nil values, and we handle nil
values just fine.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
|
|
This reverts commit 07a7a68a25eb9b21189751c27f90f972224ea533.
The JSON patch series has caused problems with the inventory service,
and further discussion is needed to decide how to serialize objects to
PSON with regards to future compatibility.
Conflicts:
spec/unit/node/facts_spec.rb
Paired-with:Matt Robinson <matt@puppetlabs.com>
|
|
There were two times being used, and the previous fix only fixed one of them.
Reviewed-By: Jacob Helwig
|
|
This was breaking in other timezones because it was comparing to a string
literal representation of a time, which really varies between timezones.
|
|
These make the JSON tests much easier to read and
write. They're the first custom matchers that I can
find, so they're breaking a bit of new ground,
but the JSON tests were pretty hard to read
and there was a lot of duplication, so it seemed
worth it.
Note that for some reason they're not working on
Facts - it seems to get immediately turned into
a full instance by the JSON parsing subsystem,
and I've no idea why.
Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
|
|
They were currently failing if any values were nil,
which happened a lot.
We also prefer not to include nil values, since it muddies
the json unnecessarily.
Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
|
|
This reverts commit 24a277c5e805ce16e0b86e17e6cb2fbe1945ae07.
Despite not needing --ignoreimport as an option anymore, it's still used
internally and has to stay.
|
|
This was only used with --parseonly, which is gone.
Paired-With: Jesse Wolfe
|
|
We now use a shebang of: #!/usr/bin/env rspec
This enables the direct execution of spec tests again, which was lost earlier
during the transition to more directly using the rspec2 runtime environment.
|
|
rspec2 automatically sets a bunch of load-path stuff we were by hand, so we
can just stop. As a side-effect we can now avoid a whole pile of stupid things
to try and include the spec_helper.rb file...
...and then we can stop protecting spec_helper from evaluating twice, since we
now require it with a consistent name. Yay.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
|
|
* 2.6.x:
(maint) Indentation fixes
(#6490) Add plugin initialization callback system to core
Fix #4339 - Locally save the last report to $lastrunreport
Fix #4339 - Save a last run report summary to $statedir/last_run_summary.yaml
Fixed #3127 - removed legacy debug code
Fixed #3127 - Fixed gem selection regex
(#5437) Invalidate cached TypeCollection when there was an error parsing
(#6937) Adjust formatting of recurse's desc
(#6937) Document the recurse parameter of File type.
(#6893) Document the cron type in the case of specials.
(#5670) Don't trigger refresh from a failed resource
Fixed #6554 - Missing $haveftool if/else conditional in install.rb breaking Ruby 1.9
Conflicts (Manually resolved):
lib/puppet/application/agent.rb
lib/puppet/application/apply.rb
lib/puppet/configurer.rb
lib/puppet/resource/type_collection.rb
lib/puppet/type/file.rb
spec/integration/configurer_spec.rb
spec/unit/application/agent_spec.rb
spec/unit/application/apply_spec.rb
spec/unit/configurer_spec.rb
spec/unit/indirector/report/yaml_spec.rb
spec/unit/resource/type_collection_spec.rb
Paired-with: Nick Lewis
|
|
The caching of the TypeCollection in Puppet::Node::Environment would cause
parse errors to occur (and be reported) only once and never again, until
the file had changed on disk. This would also cause empty catalogs to be
sent down to the agents further hiding the problem.
Now, when a file fails to parse, it will be re-parsed every time on every
following compilation, causing the parse error to be reported every time,
and preventing sending down empty catalogs to agents.
Paired-with: Nick Lewis <nick@puppetlabs.com>
|
|
The watch_file mechanism would refuse to monitor paths to files that
didn't exist. This patch makes it possible to watch a file that hasn't
been created yet, so when it is created, you manifests will get
reparsed.
Paired-With: Max Martin <max@puppetlabs.com>
Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
|
|
Time.parse(...) will yield a string in the local timezone. So when
this spec was run in a non -0700 timezone, it was failing, because
it was comparing a string in local time to a string in -0700. This
fixes it to compare to the local string representation of the time.
|
|
Previously, facts could be fetched via the REST API in PSON, but came
back as the to_s representation of a Ruby object, rather than as
proper PSON data. This patch adds to_pson and from_pson to facts, so
they can be properly used with PSON.
|
|
Doing a require to a relative path can cause files to be required more
than once when they're required from different relative paths. If you
expand the path fully, this won't happen. Ruby 1.9 also requires that
you use expand_path when doing these requires.
Paired-with: Jesse Wolfe
|
|
This change replaces calls to <model object>.save with calls to <model
class>.indirection.save(<model object>). This makes the use of the
indirector explicit rather than implicit so that it will be easier to
search for all indirector call sites using grep. This is an
intermediate refactor on the way towards allowing indirector calls to
be explicitly routed to multiple termini.
This patch affects tests only; the next patch will make the
corresponding change to the code.
|
|
Replaced uses of the find, search, destroy, and expire methods on
model classes with direct calls to the indirection objects. This
change affects tests only.
|
|
Time.parse(...) will yield a string in the local timezone. So when
this spec was run in a non -0700 timezone, it was failing, because
it was comparing a string in local time to a string in -0700. This
fixes it to compare to the local string representation of the time.
|
|
Previously, facts could be fetched via the REST API in PSON, but came
back as the to_s representation of a Ruby object, rather than as
proper PSON data. This patch adds to_pson and from_pson to facts, so
they can be properly used with PSON.
|
|
a.k.a. "make_taller_trees"
|