Age | Commit message (Collapse) | Author | Files | Lines |
|
This adds checks for the specification's assertions that virutal and
exported resources are not in the produced catalog, but are available
for later operations (realization) and reference (reading a parameter
value). This cannot check that the exported resources are made available
to catalog processors, since that is implementation dependent.
In order to check this the compile_to_catalog method needed to be
changed to filter out expoerted resources, just like the catalog
indirection does. This required a change to the create_resources test.
|
|
I believe most of these predated our clearing the settings before each
test in the central puppet/test/test_helper.rb. And since we then set
some base settings (such as :environment_timeout) in the test_helper,
the effect of a secondary clear in the test itself is to wipe out the
baseline setup test_helper just laid down.
In particular this is a problem with environment_timeout, as it leads to
tests which end up creating environments, getting them cached with the
default 180s timeout, which can leak to subsequent tests and create
unpleasant spec order issues.
|
|
This commit adds a check for the create_resources syntax error message.
If there is a syntax error, the error given by puppet master is unclear.
This commits adds a test to check that the error message is correct and
makes sense.
This only happens when the resources are auto imported, which is why I
use a fixture directory.
|
|
Currently, Puppet's `create_resources()` function only validates that
the number of arguments. However, the function expects a hash for the
second argument, and Puppet explodes with an unhelpful error if the
second argument is not a hash, or nil.
For example, if the second argument is a string, you'll receive
something along the lines of `undefined method `each' for "":String at
/etc/puppetlabs/puppet/manifests/site.pp:45`. This is less than helpful
for users.
This patch raises an argument error if the second argument is not a
hash, warning the user that it should be.
Also adds input validation for optional third argument of create_resources,
and added a test to match.
|
|
|
|
zaphod42/issue/master/21409-create_resources-differs-from-real-resource
(#21409) Ensure that create_resources acts the same as a resource decl
|
|
This ties the selection of the Puppet::Graph::Prioritizer to the
Puppet[:ordering] setting. In order to make it easier to ensure that all
of the uses of the prioritizer use the same one (because it needs to
track state) this also moves around the relationship of the catalog and
the transaction. Previously the catalog was responsible for converting
itself into a relationship graph. This now puts that responsibility on
the transaction, which much now be constructed with the desired
Prioritizer. The selection is still done in the catalog (because that is
where #apply lives, which is the public starting point of applying a
catalog).
Additionally this adds a random prioritizer.
|
|
The previous implementation of create_resources duplicated most of the
logic of Puppet::Parser::AST::Resource, but had variations which meant
that it didn't actually behave the same. This lead to the possibility
that what should have been equivalent statements in the language did not
always result in the same catalog. This re-implements create_resources
to construct the AST that is needed to create the requested resources
and evaluate the resulting structure. This should only be able to
differ from actual resource declarations in the language if the
constructed AST is wrong.
|
|
* dalen-function_arity:
(#15989) Tests for function arity
(#15989) Set arity on functions
(#15989) Allow setting arity on functions
|
|
Without this patch the create_resources function is unable to create
virtual or exported resources. This is a problem because the resources
created by create_resources are not a first class citizen with respect
to resources created from the Puppet DSL, or other means.
This patch fixes the problem by allowing the create resources function
to accept type names prefixed with @ or @@.
For example, the following puppet manifest works with this patch
applied.
create_resources('@file', {'/etc/foo' => {'ensure'=>'present'}})
realize(File['/etc/foo']
|
|
Set the arity on builtin functions.
|
|
* 2.7.x:
Use rspec 2.11 compatible block syntax
Conflicts:
spec/integration/faces/ca_spec.rb
spec/integration/network/server/mongrel_spec.rb
spec/unit/application_spec.rb
spec/unit/face/help_spec.rb
spec/unit/network/handler/fileserver_spec.rb
spec/unit/parser/functions/create_resources_spec.rb
spec/unit/provider/nameservice/directoryservice_spec.rb
spec/unit/type/file_spec.rb
spec/unit/type_spec.rb
|
|
In rspec 2.11, expectations on a block must take the form of expect...to or
lambda...should. Other combinations of those are no longer accepted. This
commit converts all mixed cases to use expect...to, as it seems to be the
preferred syntax now.
|
|
Now that the compiler is always required by the scope we can save a few
keystrokes by making the non-optional argument a regular value, not a name
prefixed option.
(...even if I love Objective-C as much as the next developer, having the same
text in every call just to name the argument doesn't make much sense in such
an internal context.)
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
|
|
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>
|
|
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.
|
|
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 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.
|
|
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>
|
|
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.
|
|
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>
|
|
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
|
|
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.
|