summaryrefslogtreecommitdiff
path: root/spec/unit/parser/functions/create_resources_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-08-01(PUP-501) Check virtual and exported resourcesAndrew Parker1-1/+1
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.
2014-07-24(maint) Remove unnecessary Puppet.settings.clear calls from specsJosh Partlow1-4/+0
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.
2014-06-12(PUP-1100) Create_resources syntax error message spec testJulien Pivotto1-0/+11
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.
2013-10-08(#22740) create_resources input validationZachary Alex Stern1-0/+8
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.
2013-09-03(maint) fix typo in comment and clean whitespaceKylo Ginsberg1-5/+5
2013-08-20Merge pull request #1766 from ↵Henrik Lindberg1-18/+6
zaphod42/issue/master/21409-create_resources-differs-from-real-resource (#21409) Ensure that create_resources acts the same as a resource decl
2013-08-16(#22205) Chose a Prioritizer based on Puppet[:ordering]Andrew Parker1-7/+3
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.
2013-07-13(#21409) Ensure that create_resources acts the same as a resource declAndrew Parker1-18/+6
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.
2012-11-07Merge branch 'dalen-function_arity'Jeff McCune1-1/+1
* dalen-function_arity: (#15989) Tests for function arity (#15989) Set arity on functions (#15989) Allow setting arity on functions
2012-10-25(#15081) Make virtual resources work with create_resourcesErik Dalén1-0/+11
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']
2012-10-05(#15989) Set arity on functionsErik Dalén1-1/+1
Set the arity on builtin functions.
2012-07-24Merge branch '2.7.x' into 3.xPatrick Carlisle1-6/+6
* 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
2012-07-23Use rspec 2.11 compatible block syntaxPatrick Carlisle1-6/+6
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.
2012-07-15Drop the hash prefix when passing compiler to scope.Daniel Pittman1-1/+1
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>
2012-07-15A scope always has a compiler.Daniel Pittman1-3/+3
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>
2012-07-11Merge commit 'ecc52ed' into 3.0rcPatrick Carlisle1-6/+6
* 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
2012-07-10Fix all trivial "should to must" errors in our tests.Daniel Pittman1-6/+6
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>
2012-04-16Fixed problems caused by 2.7.x mergeAndrew Parker1-1/+1
Several things had changed on master that caused the automatic merge to not catch problems.
2012-04-16Re-apply "Merge remote-tracking branch 'upstream/2.7.x'"Andrew Parker1-84/+116
This reverts commit 6d399e087372b77566dd3737d4b444aca2e61050.
2012-04-16Revert "Merge remote-tracking branch 'upstream/2.7.x'"Andrew Parker1-116/+84
This reverts commit 7a430815424e053d6e6c5925eef711ca5edd8373, reversing changes made to 32172d5d8de35f5cdbc31bce327b3567e078bb83.
2012-04-16Removed duplication of compiling a catalogAndrew Parker1-4/+2
Created a PuppetSpec::Compiler module for helping out testing things that want to compile some code to a catalog
2012-04-16Cleaner test for create_resources doing nothingAndrew Parker1-2/+3
Better expresses that a create_resources with an empty hash is the same as doing nothing in the catalog at all
2012-04-13Fixing problem caused by activerecordAndrew Parker1-84/+117
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.
2012-04-05(#13567) Fix create_resources name parameter bugReid Vandewiele1-0/+14
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.
2012-03-08Clean up the "foo" name in create_resources_spec.Daniel Pittman1-13/+16
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>
2011-12-07(#9768) Add a defaults argument to create_resourcesMatthias Pigulla1-2/+19
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>
2011-12-06(#6830) Fix create_resources spec for ruby 1.9Patrick Carlisle1-2/+2
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.
2011-05-17(#7507) Add ability to filter Ruby 1.9 spec failuresMatt Robinson1-2/+2
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>
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
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>
2011-04-06(5200) -- replace containers with sentinalsMarkus Roberts1-17/+19
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
2011-03-16(5909) Function to dyncamically generate resources.Dan Bode1-0/+135
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.