Age | Commit message (Collapse) | Author | Files | Lines |
|
The scope object contained some internal code to substitute an external
environment when the compiler was not supplied. This was used only in
testing, not in any production capacity.
In light of that, we can eliminate the dynamic decision making inside the
scope and simply demand that a compiler instance (or a fake equivalent) is
always supplied.
This reduces the complexity of the code and makes clearer the object
relationships involved.
(The small cost is a lot of testing that depended on this had to change to use
a real compiler. Most of the change derives from that.)
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
* commit 'ecc52ed': (33 commits)
(#11868) Use `Installer` automation interface to query package state
Eliminate require calls at runtime.
Fix broken TransBucket transformation tests.
Fix broken ability to remove resources from the catalog.
Fix type check when transforming catalog.
Fix all trivial "should to must" errors in our tests.
Enforce "must not should" on Puppet::Type instances in tests.
Initialize resources strictly in backup specs
Refactor file backup specs
(maint) Add tags to .gitingore
Use in memory sqlite database for unit tests
(#14715) Use gtar with 'puppet module install' on Solaris
Stub pkginfo when installing in openbsd spec
(#14962) PMT doesn't support setting a relative modulepath
(#15078) Document USR2 log rotation signal
(#14909) Update createpackage.sh to resolve permissions issues
(maint) Add --test to puppet run
(maint) Add symlink stub to gentoo service provider spec
Add comment to upstart provider explaining exclusion of 'wait-for-state'
Upstart code cleanup, init provider improvement
...
Conflicts:
lib/puppet/face/module/install.rb
lib/puppet/network/handler/fileserver.rb
lib/puppet/parser/functions/fqdn_rand.rb
lib/puppet/parser/type_loader.rb
lib/puppet/ssl/base.rb
lib/puppet/util.rb
lib/puppet/util/autoload.rb
man/man8/puppetmasterd.8
spec/lib/puppet_spec/database.rb
spec/unit/face/module/install_spec.rb
spec/unit/other/transbucket_spec.rb
spec/unit/provider/augeas/augeas_spec.rb
spec/unit/util/backups_spec.rb
spec/unit/util_spec.rb
|
|
We had a bunch of places that used the wrong invocation to test something on a
resource instance, revealed by the previous change.
This fixes all the trivial instances - the places that are *correct* despite
not actually being tested for a long while.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
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.
|
|
The `generate` function has a fairly strict definition of what is and isn't
legal as a command name, in an effort to keep it reasonably sanitary.
On Windows this included `.`, `-`, and any alpha-numeric characters, but not
the `~` character. This blew up when faced with an "8.3" generated path -
something that we legitimately should accept since it can reduce problems
around spaces in path names.
This changes generate to accept that, and adds a specific test to verify that
it continues to work as expected.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
When this test was changed the path became relative on Windows, because it
doesn't have a drive letter. This fixes that with `make_absolute`.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Several things had changed on master that caused the automatic merge to
not catch problems.
|
|
This reverts commit 6d399e087372b77566dd3737d4b444aca2e61050.
|
|
This reverts commit 7a430815424e053d6e6c5925eef711ca5edd8373, reversing
changes made to 32172d5d8de35f5cdbc31bce327b3567e078bb83.
|
|
* upstream/2.7.x: (22 commits)
Removed duplication of compiling a catalog
Cleaner test for create_resources doing nothing
Fixing problem caused by activerecord
Put back require 'puppet' in Puppet::Util
(#13299) Fix error message when agent is disabled
Update puppet.spec for rpm packaging
Fixed old log test to match new autoflush behavior
Make sure the log file writable
Default autoflushing of log files to true
Created test that shows enc warning problem
(Maint) Fix order-dependent test failure
(Maint) Don't assume eventlog gem is installed on Windows
options[:ca_location] is a string not a symbol. Safer to pull Puppet::SSL::Host.ca_location since it is already set correctly.
(#13204) Don't ignore missing PATH.augnew files
(#13640) Only agents should use next_agent_run
Increased test coverage of scoping rules
Use more descriptive terms for the differing scopes
Make new scoping look through inherited scopes
Add tests for mixed inheritence/inclusion
Remove dynamic option for lookupvar
...
Conflicts:
lib/puppet/defaults.rb
lib/puppet/parser/scope.rb
spec/unit/parser/functions/create_resources_spec.rb
spec/unit/parser/scope_spec.rb
spec/unit/resource/type_spec.rb
test/util/log.rb
|
|
Created a PuppetSpec::Compiler module for helping out testing things
that want to compile some code to a catalog
|
|
Better expresses that a create_resources with an empty hash is the same
as doing nothing in the catalog at all
|
|
ActiveRecord installed a parent() method that seems to have wreaked
havoc on the inheritance traversing code in the variable lookup code.
This uses a new method that achieves the same end, but doesn't rely as
much on the duck typing (responds to :parent) of the resource.
In addition tests have been added for node inheritance to ensure that
that inheritance heirarchy is followed as we expect. Also tests that
tried to fake out things and now have incorrect assumptions have been
changed to make fewer assumptions about how the system works.
|
|
Previously, the posix regex for validating generate function commands
did not allow '+', however, this character appears in `Tempfile`s on
Mac.
This commit relaxes the regex to allow for '+' and adds a test for it.
The '-' character was already allowed.
Reviewed-by: Daniel Pittman <daniel@rimspace.net>
|
|
* 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
|
|
Ticket/2.7.x/12101 reapply autoload
|
|
* 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
|
|
eshamow/tickets/master/7801_include_should_accept_arrays
(#7801) Modify include function to accept arrays
|
|
When an array of classes is passed to the :include function, it
currently attempts to wrap the array in another array, and then pass the
entire array through as a single argument, causing an error. This
commit calls flatten against the array before sending it through,
following the pattern of :realize, and enabling arrays to be passed as
well as comma-separated or individual class values.
|
|
Previously, the create_resources function would inconsistently override
name parameters provided by the user, setting the name parameter equal
to the resource title. This commit modifies create_resources such that
when provided, user-supplied name parameters are used correctly and
consistently.
Add name parameter tests for create_resources.
|
|
In Ruby 1.9 the Test::Unit library was replaced by MiniTest. This changes
some "esoteric" parts of the code, sadly including the parts of the library we
depend on to confine certain tests to only some systems.
Instead of investing heavily in rebuilding that facility over the new MiniTest
library it makes sense to just check for and either destroy or port the old
tests to the new rspec harness.
This is our desired future - that only one test framework exist - and we might
as well take full advantage of this opportunity to clean up our legacy code.
It also drops tests that duplicate testing already present in the spec suite.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Now we have passing tests on Ruby 1.9, we can make all those tags go away and
enable the full suite. Now anything that fails should be treated like a real
failure, which is reasonable since this is a real and supported platform.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
The formatting in the spec file was very odd, with extraneous and random
whitespace around arguments, odd line breaks, and so forth.
It also used a whole pile of temporary variables that it didn't need to.
This cleans that up, without making any functional changes to the code.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
In Ruby 1.8 `"foo".map` would yield "foo" once, while in Ruby 1.9 it is not
defined as a method.
Various parts of our testing code stub other methods and return strings where
arrays of strings are appropriate; this historically worked because of that
1.8 shim, and no longer does.
The same is true of `String#each`, which fails in the same way.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Add "windows" and "posix" shared contexts to rspec. If you give :as_platform
=> :posix or :as_platform => :windows as argument to a describe block, it will
automatically stub the relevant facts and path behavior to imitate windows or
posix.
|
|
Conflicts:
spec/unit/parser/functions/create_resources_spec.rb
spec/unit/resource_spec.rb
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
Using a common meta-name like "foo" in testing runs a risk that global state
will lead down the path to things going wrong. In this case, it clashed
with a type created elsewhere that lingered...
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
This reverts commit edc544d73bc8f9f7de07de4b30e344d1f4db3178.
This doesn't work with rspec < 2.6.0 and it's breaking continuous integration.
|
|
Add "windows" and "posix" shared contexts to rspec. If you give :as_platform
=> :posix or :as_platform => :windows as argument to a describe block, it will
automatically stub the relevant facts and path behavior to imitate windows or
posix.
|
|
Conflicts:
acceptance/tests/ticket_3360_allow_duplicate_csr_with_option_set.rb
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
The generate function did not handle Windows style paths when
validating that it was fully qualified or that it only contained
alphanumerics, file separators, or dashes, as Windows paths can also
contain '\', as well as ':', but only when it is part of the drive
specifier.
|
|
|
|
Make it possible to supply defaults when calling create_resources using an
optional hash argument.
Signed-off-by: Andre Nathan <andre@digirati.com.br>
Signed-off-by: Patrick Carlisle <patrick@puppetlabs.com>
|
|
These tests broke because of changed behavior in Array#to_s, which exposed a
bug if add_class is passed an array instead of *args.
|
|
Several tests were broken due to pecularities of Windows
and Ruby on Windows:
* Ruby on windows does not differentiate between group and
other file permissions.
* All open file handles must be closed before the file can
be deleted
* Sometimes the current working directory (Dir.getwd) is
reported as C:/foo and other times as C:\\foo, which
confuses the spec tests.
* Ruby's sprintf formats floating point values differently
on Windows vs Unix. The Windows exponent has an extra
leading zero.
* Needed to stub execution of security command with the
SMF service provider.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 0e4ae653c0628cb0df9ccace98bca4bc7478fb7c)
|
|
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
|
|
Several tests were broken due to pecularities of Windows
and Ruby on Windows:
* Ruby on windows does not differentiate between group and
other file permissions.
* All open file handles must be closed before the file can
be deleted
* Sometimes the current working directory (Dir.getwd) is
reported as C:/foo and other times as C:\\foo, which
confuses the spec tests.
* Ruby's sprintf formats floating point values differently
on Windows vs Unix. The Windows exponent has an extra
leading zero.
* Needed to stub execution of security command with the
SMF service provider.
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>
|
|
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
|
|
The interface to scope is much clearer this way anyway,
but this is needed to integrate Puppet with Hiera[1].
It just provides hash-like behavior to Scope, which Hiera
and others can now easily rely on.
I also went through all of the code that used Scope#lookupvar
and Scope#setvar and changed it if possible, and at the same
time cleaned up a lot of tests that were unnecessarily stubbing
(and thus making it difficult to tell if I had actually broken
anything).
1 - https://github.com/ripienaar/hiera
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
|
|
By running:
rspec spec --tag ~@fails_on_ruby_1.9.2
We can now just run the specs that pass under Ruby 1.9. Obviously in
the long term we want to have all the specs passing, but until then we
need notification when we regress. From now on new code will be
required to pass under Ruby 1.9, and Jenkins will give us email
notification if it doesn't or if we break something that was already
working.
Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
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.
|
|
When we lookup a global variable / fact from code we should explicitly look
in the global scope.
|
|
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>
|
|
This commit removes the last remaining use of topsort (in SimpleGraph#splice!) by
fixing #5200 in a way that is compatible with graph fontiers. Instead of replacing
containers with many-to-many relationships, we now replace them with a pair of
sentinals (whits) that bracket them.
Thus a graph consisting of two containers, each containing ten resources, and a
dependency between the containers, which would have gone from 21 edges to 100
edges will instead have only 43, and a graph consisting of two containers (e.g.
stages) each containing a similar graph, which would have gone from 45 edges to
400 will only go to 95.
This change had minor consequences on many parts of the system and required lots
of small changes for consistancy, but the core of it is in Catelog#splice! (which
replaces SimpleGraph#splice!) and Transaction#eval_generate. Everything else is
just adjustments to the fact that some one-step edges are now two-step edges and
tests, event propagation, etc. need to reflect that.
Paired-with: Jesse Wolfe
|
|
into next
|
|
We historically had a state-dependency across tests in the parser function
support area; the first test caused the function to be loaded, and other tests
would then fail as a consequence of that.
We now autoload all functions at the top of each test suite, allowing us to
correctly and sensibly test on them as we should.
This theoretically prevents us from testing the autoloader implicitly in these
tests, but that should be tested independently.
Paired-With: Nick Lewis <nick@puppetlabs.com>
|
|
This function allows you to dynamically generate resources,
passing them as a hash to the create_resources function.
This was originally written to be used together with an ENC.
Resources can be programitally generated as yaml and passed to a class.
classes:
webserver::instances:
instances:
instance1:
foo: bar
instance2:
foo: blah
Then puppet code can consume the hash parameters and convert then into resources
class webserver::instances (
$instances = {}
) {
create_resources('webserver::instance', $instances)
}
Now I can dynamically determine how webserver instances are deployed to nodes
by updating the YAML files.
|
|
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
|
|
We found the gsub! in extlookup was actually modifying the value for
extlookup_precedence, so the next node to call it just got the
interpolated value from the first run.
We did two things in the code to prevent this:
1. We returned a dup of the ast string object so that modifying it
wouldn’t change puppet’s state. We didn’t do this for all possible
return values because we depend on using the original ast array object
to do array concatenation
2. We fixed extlookup to not do a destructive gsub
Reviewed by: Jesse Wolfe
|