summaryrefslogtreecommitdiff
path: root/spec/lib/puppet_spec
AgeCommit message (Collapse)AuthorFilesLines
2014-10-02(maint) Remove duplicate file handling codeAndrew Parker1-0/+1
The tests had their own way of creating files and directories for testing. All of these different ways of creating files and directories already existed in PuppetSpec::Files. This unifies them.
2014-09-08(PUP-3162) Prevent $environment interpolation in directory environmentsJosh Partlow1-0/+5
There are a few settings for which interpolation of $environment does not make sense when using directory environments. * default_manifest -> defines either the relative path to manifests within a directory environment, or an absolute path to manifests to be used by all directory environments. It is currently a configuration error to set $environment within default_manifest. * basemodulepath -> conceptually, this is intended for supplemental modules required for all environments, and should not vary by environment. * environmentpath -> this is the base path defining what directory environments can be found. Interpolating $environment within it makes no sense. Additionally, both environmentpath and basemodulepath are required by the environment loaders during initialization. They will interpolate relative to a specified environment if you interogate config, but in a running master instance, will have interpolated to the default environment regardless of the current environment being processed for a catalog, for instance. A last case, irregardless of type of environment, is the pathological case of attempting to interpolate $environment within environment. This, unsurprisingly, causes a stack overflow. This patch adjusts the Puppet::Settings interpolation code so that $environment is not interpolated within any of these four settings when using directory environments (so, when the environmentpath has been set).* So assuming a confdir=/etc/puppet, basemodulepath=$confdir/modules/$environment will be interpolated as '/etc/puppet/modules/$environment' and a warning will be logged. *Currently setting $environment in default_manifest will error out when puppet loads as a setting validation error, and this behavior will never be reached.
2014-08-27(maint) Make PuppetSpec::Language emit more helpful stack tracesHenrik Lindberg1-0/+17
This change was required to be able to see anything relevant regarding where a problem originated. The fix is to patch the stacktrace for failed expectencies. While not ideal there is very little that can be done with Rspec 2 to fix this except reimplementing the support for produces and fails to be matchers. (Rspec 3 has composable matchers that may make this simpler). A ticket has been logged about further improvements to the two support functions (produces, and fails).
2014-08-18(maint) Express language tests in puppet languageAndrew Parker1-14/+31
This changes the tests of the puppet language, which should become part of the language specification's example and test suite, to be entirely expressed in the puppet language. This removes any dependency on ruby! Well, any dependency on ruby for specifying the language tests.
2014-08-18(maint) Extract language specification toolsAndrew Parker2-0/+42
The resource_expressions_spec contained a useful way of writing language specification tests. This extracts those out so that they can be reused in other places.
2014-08-01(PUP-501) Check virtual and exported resourcesAndrew Parker1-1/+2
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-17(PUP-2882) Fix single available upgradeBrandon High1-0/+3
Prior to this commit `puppet module upgrade` would fail with an error message about not being able to satisfy the upgrade when there is only one published release of the module. This commit changes the error message to say that there is no version to upgrade to. This should reduce some user confusion.
2014-07-02Merge pull request #2756 from ffrank/ticket/master/PUP-1177-sshkey-mode-600Adrien Thebo1-0/+10
(PUP-1177) make sure ssh_known_hosts is not created with mode 0600
2014-06-25Merge pull request #2754 from ffrank/maint/compiler-spec-catch-resource-errorsAndrew Parker1-1/+11
(maint) spec: allow expectations of resources from compiled manifests
2014-06-11(maint) move the file mode tests to the files spec moduleFelix Frank1-0/+10
It is helpful to have a simple helper method to match desired file modes from spec tests.
2014-06-09(maint) spec: allow expectations of resources from compiled manifestsFelix Frank1-1/+11
Add logic to the PuppetSpec::Compiler.apply_compiled_manifest method so that a spec test can supply a block that processes the single resources that comprise that catalog that was compiled before it is run in a transaction. As a proof of concept and general helper, add a apply_with_error_checks method, that adds an expectation to never send an :err signal to each resource. This makes spectest debugging much easier, because without expectations, the transaction will just finish and the only reported error will be that the end result is not as expected. When the expectation is added to each resource, rspec will display all resource error messages as failed expectations.
2014-06-03(PUP-2622) Use non-zero exit codes for unknown subcommands.Peter Huene1-32/+51
Previously, if users execute 'puppet foo', an error message is displayed about unknown subcommand 'foo', but puppet still exits with a zero exit code indicating success. Additionally, if users execute 'puppet --option <valid_subcommand>', puppet silently ignores the option, prints a message, and exits with a zero exit code. As a result, a user accidentally transposed a valid option for a subcommand with the subcommand itself in an automated context and puppet did not report a failure. This commit fixes both conditions by exiting with 1 from the nil and unknown subcommands where appropriate. It also prints error messages using the same colorized output we use for usual puppet errors.
2014-05-28Merge branch 'pr/2492'Andrew Parker1-0/+8
* pr/2492: (PUP-1381) Add link to explanation of message (PUP-1381) make file_setting spec test more robust (PUP-1381) issue warnings to current users of cron purging maint: relax spec test of resources
2014-04-26maint: relax spec test of resourcesFelix Frank1-0/+8
The resource_spec performs some comparisons by using the equal_attributes_of matcher. This is mostly correct, but considers some instance variables that are of no consequence to the resource, e.g. @rstype. As a result, internal changes to Puppet::Resource that may lead to this attribute not being set in a resource that is generated from YAML would break this expectation: expected Foo::Bar[xyzzy]{:name=>"xyzzy", :one=>"test", :two=>"other"} to equal attributes of Foo::Bar[xyzzy]{:name=>"xyzzy", :one=>"test", :two=>"other"} This is not only difficult to debug, it first and foremost misses the intention of the example, which is only concerned with RAL attributes, not "internal" instance variables.
2014-04-21Merge remote-tracking branch 'upstream/master' into PE-3182Pieter van de Bruggen1-0/+18
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-18(PUP-2093) Migrate all PMT code to use JSON.Pieter van de Bruggen1-1/+3
Prior to this commit, there were scattered bits throughout the PMT code that still lived under the tyranny of PSON. Since we've now officially adopted a dependency on the JSON gem everywhere, our code should run free and flourish in the new world, where JSON processing is handled through a less ridiculously named constant – this change fully realizes that new world for the PMT.
2014-04-05(maint) Add dir_containing(name, hash) to spec helpersHenrik Lindberg1-0/+18
This makes it easy to mock a directory structure by giving it a hash, where non hash entries are content, and hashes are directories.
2014-04-04(PUP-2093) Migrate PMT to /v3 API.Pieter van de Bruggen2-0/+187
Prior to this commit, the PMT managed all communication with the Forge via the (now legacy) /v1 API. That API has been deprecated (primarily due to scalability concerns), which is less of an issue since it was never officially a public API. This commit migrates all communication to the Forge to the new /v3 API, which is expected to be launched as our official public API "soon". This commit also integrates a standalone dependency resolver, as the /v3 API contains no implicit dependency resolution (as the /v1 API did); consequently, large portions of the PMT code have been changed, and others have become unreachable. This commit also changes the default host that the PMT communicates with, from https://forge.puppetlabs.com to https://forgeapi.puppetlabs.com (the natural URL for the Forge API service). Since the tool now expects to communicate with a completely different service, it will be unable to communicate with services that do not implement the same /v3 API.
2014-02-25(PUP-1707) StringIO#set_encoding doesn't exist in ruby 1.8Josh Cooper1-1/+1
Only call the method if the object responds to it.
2014-02-25(PUP-1707) Ensure ERB generated help content is UTF-8 encodedJosh Cooper1-0/+1
Previously, `env LANG=C bundle exec puppet man module` could not output non US-ASCII characters correctly due to two issues. First, puppet uses ERB generate the help output. Since the templates did not include a magic encoding comment[1], ERB would set the string encoding of the content it generated to `Encoding.default_external`, which in the case of LANG=C and ruby 1.9 is US-ASCII. When generating ERB help output for the `module` application, the resulting byte stream would be correctly UTF-8 encoded, but `String#encoding` would report US-ASCII. So later when we tried to perform a regex against it, we'd get the `invalid byte sequence in US-ASCII` error. The second issue was that HavePrintedMatcher redirects stdout and stderr to an instance of StringIO, whose default encoding was `Encoding.default_external`. When we try to apply the regexp to what was written to stdout, it would again fail, because the string was UTF-8 encoded, but reported itself to be US-ASCII. This commit sets the ERB magic encoding comment, and sets the StringIO encoding to 'UTF-8'. A test can override this behavior if desired within the `expect { ... }.to have_printed` block. [1] https://github.com/ruby/ruby/blob/v1_9_3_484/lib/erb.rb#L63-L68
2014-02-20(PUP-1707) Ensure puppet man works for all applicationsJosh Cooper1-0/+4
Adds a spec test that ensures `puppet man <app>` exits with 0 and does not emit the 'undefined method' error reported in PUP-1707.
2014-01-29(PUP-1118) Stop using Environment.newAndrew Parker1-1/+1
Instead of creating environments directly, we need to go through the configured environment loaders, otherwise environments can't come from other places.
2013-12-20(PUP-1133) Windows tests write config to tempEthan J. Brown1-0/+1
- Previously tests were writing to the shared %ALLUSERSPROFILE%\PuppetLabs\puppet directory, and would blow up if this directory did not exist - Because this directory was shared from one run to the next, failing tests could be masked by data generated / used by a locally installed Puppet - The stubbing of FileSystem::File.exist? to return true was causing some tests to treat files like c:\dev\null\foo to attempt to be loaded, which would cause these tests to fail in isolation, but not when run within the suite - Had to change some doc specs under Ruby 1.9 / OSX to verify a value instead of asserting a method was called, to prevent a stack overflow - In some unit tests, the process of reading / writing settings caused issues with test loading, so Puppet.settings.use has been stubbed
2013-12-05(maint) Cleanup Scope impl from unused methods & test specific codeHenrik Lindberg1-0/+14
This removes several unused methods and attributes from Puppet::Parser::Scope. The only places in code using them where tests. It also removes some "convenience"/"proxy" methods used by only the Collector (better for it to do this on its own than cluttering the Scope implementation) Also refactors creating scopes for the purpose of running tests by moving that logic from Scope to PuppetSpec::Scope that should be included in examples to use the no(now renamed) method Useless and tests that test that scope behaves the wrong ! way removed. (It is always illegal to set match data variables from anything but a match, but this functionality was tested by spec tests). It was then much clearer how match scope and local scope should work. Now a LocalScope always have a nested MatchScope that is transparent until a match is set, or a nested MatchScope is created for an inner scope. This enables rewriting the evaluator logic to not leak match scopes where there is a sequence of matches at top level in a define or class body.
2013-11-13(Maint) Make tmp directory more safelyKylo Ginsberg1-21/+13
Because the temp directory is not immediately created with the discovered name, there might be a race condition between tests running on the same machine.
2013-09-30(Maint) Create spec coverage for parser faceAndrew Parker1-0/+7
The parser face had no spec test coverage. This creates some coverage around the code. This coverage replaces what is currently being done in an acceptance test.
2013-09-27(#22652) Add be_one_of matcher (copped from pcarlisle)Kylo Ginsberg1-0/+10
2013-09-09(#8040) Test order of application for contained classesPatrick Carlisle1-0/+6
This also includes some minor refactoring of the contain function.
2013-08-16(#22205) Chose a Prioritizer based on Puppet[:ordering]Andrew Parker1-5/+9
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-08-13(#18508) Ensure that no two resources have the same priorityAndrew Parker1-0/+1
The underlying red-black tree that is used as the priority queue for tracking what resources to evaluate will only allow a single value per key. This means that when generated resources are added they need to get unique priority keys. However there could be an arbitrary number of these resources added in between existing resources. This commit provides a Puppet::Graph::Key that behaves like the numbering scheme of an outline so that priorities can be arbitrarily nested and the nested priorities are between the priorities at the outer level. The integration tests for the file type caught this error. It only showed up when 2 unique, new resources are generated.
2013-08-09(#18508) Ensure resource ordering in interesting casesAndrew Parker1-2/+9
From the the accepted proposal for this functionality some of the example cases have been captured as test cases.
2013-08-03(#16856) Add w.i.p on BinderConfigHenrik Lindberg1-0/+3
2013-08-03(#16856) Adds Hiera2 bindings with backends for YAML and JSONThomas Hallgren1-0/+13
This commit contains the initial work on the Hiear2 bindings producer. It is W.I.P. at this point as some concepts still remains to be fully designed. In particular, this commit only contains whats needed in order to read bindings from one module. The code that finds and then combines modules is not included.
2013-06-18Merge branch 'stable'Matthaus Owens1-0/+8
Conflicts: spec/unit/file_serving/metadata_spec.rb
2013-06-11(#14652) Add check for self-dependency cyclesAndrew Parker1-0/+12
With some changes that were made to how the graph is processed, puppet 2.7.0 lost the ability to detect dependency cycles where a resource requires itself. Instead of erroring, the resource ended up being silently ignored. This restores the behavior that existed in 2.6 where this was considered a cyclic dependency. The erroneous code had considered any single vertex, strongly connected component to not be a cycle. This was done because by definition any single vertex is a strongly connected component, no matter what edges are involved. By always excluding those vertices, the case of a self-referencing vertex was not handled. This adds a check for a single vertex SCC that is adjacent to itself in order to find dependency cycles of a single resource. Paired-with: Josh Cooper <josh@puppetlabs.com>
2013-06-03(#20584) Only deserialize expected objects from YAMLPatrick Carlisle1-0/+8
Puppet no longer allows the base YAML library to deserialize arbitrary objects. By using the safe_yaml package, we deserialize only primitive data structures. The remainder of the deserialization process is now unified between YAML and PSON. This code will explicitly create only the expected objects from the primitive data types. As a side effect of this change the code for REST indirections now allows specialized deserialization routines per method. The save method now returns nil by default, and is only overridden in a couple of cases where Puppet was using the return value to preserve previous behavior.
2013-04-25(maint) Make sqlite3 use an in-memory DB for specsJeff McCune1-1/+1
Without this patch the spec tests are configuring sqlite in a manner that writes the database to a file named ':memory'. This is a problem because filesystem databases are slower than in-memory databases and the tests are not cleaning up this file after completing. The change in 60e78b2d36f23877dc7b50e72578ad123d62c1f0 caused this change in behavior, likely by accident, because the database connection string was ':memory:' and the patch changed the string to ':memory' likely because this looks like a Ruby symbol. This patch addresses the problem by restoring the original connection string of ':memory:'
2013-04-11(Maint) Ensure that activerecord tests are isolatedAndrew Parker1-5/+2
The activerecord based tests would setup activerecord and rails in a manner that included stubbing. This made some things behave as you might want, but caused some manner of getting them to behave the wrong way. By removing the stubbing, the test cases all work from a clean database. Another issue occured when one of the tests assumed that no other code that used its indirection had been run prior to it. The test itself was very questionable and ended up breaking when the tests were run in a particular order. The test in question tried to assert that the code would setup activerecord when it was initialized. Since all of the other tests relied on this, and that particular behavior did not appear to be important to the external contract of the class, the test has been removed.
2013-01-24Revert "Merge branch 'new-ruby-dsl-by-mlen'"Patrick Carlisle2-40/+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 Lenik2-0/+40
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-14(#16189) Make --run_mode a global option and not a settingHenrik Lindberg1-1/+0
In #16189 the problem is described as config print and --configprint disagree. That problem was caused by the option --mode RUNMODE defined in FaceBase not having any effect thus making 'user' be the only runmode available to any Face. Rather than implementing another way of modifying the run_mode (as attempted in FaceBase), this commit makes the previously 'read-only' global setting --run_mode settable from the command line and promotes it from being a setting to a special case around the loading of settings. In order to make this global run_mode the default, the Application class now picks up the default from Settings (where run_mode is handled), and thus the default becomes either the runmode set from the command line, or 'user' which Settings has a fallback (default default). Applications (such as Master) can still set run_mode as part of application initialization - it works as before. Unused/non working code relating to this is removed. Documentation referring to --mode updated.
2012-08-31Merge remote-tracking branch 'upstream/2.7.x' into 3.xJosh Cooper1-3/+3
* upstream/2.7.x: (#16208): Correct spec test to match new failed parameter message Maint: Fix inconsistent expect-should usage Maint: Fix leaked tempfile handle Conflicts: spec/unit/util_spec.rb
2012-08-31Maint: Fix leaked tempfile handleJosh Cooper1-3/+3
This test failed on Windows because we were creating a tempfile, but not closing the underlying file descriptor. So later attempts to cleanup fail on Windows (unlike POSIX). This commit modifies the `.tmpfile` and `#tmpfile` methods on the PuppetSpec::Files module to accept an optional directory in which to create the temp file.
2012-07-12Merge branch '2.7.x' into 3.0rcPatrick Carlisle1-1/+2
* 2.7.x: (26 commits) Extract host validation in store report processor Use cross-platform absolute paths in file_serving tests (#15221) Create /etc/puppet/modules directory for puppet module tool (Maint:) Fix bad doc strings for two settings ("wether") Try again to avoid circular dependency in file indirections Remove useless tests for Envelope Clear deprecation warnings between tests Avoid circular requirement in FileMetadata indirection (Maint) Document common Windows issues Update CHANGELOG lib/puppet.rb conf/redhat/puppet.spec for 2.7.18 Maint: Note in docs that the file type's "replace" attribute defaults to true Reject directory traversal in store report processor Tighten permissions on classfile, resourcefile, lastrunfile, and lastrunreport. Use "inspect" when listing certificates Don't allow the creation of SSL objects with invalid certnames Validate CSR CN and provided certname before signing Add specs for selector terminuses of file_{content,metadata} Fix whitespace inside parentheses Use head method to determine if file is in file bucket Always use the local file_bucket on master ... Conflicts: CHANGELOG conf/redhat/puppet.spec lib/puppet.rb lib/puppet/application/master.rb lib/puppet/defaults.rb lib/puppet/file_serving/terminus_selector.rb lib/puppet/reports/store.rb lib/puppet/test/test_helper.rb spec/integration/file_serving/content_spec.rb spec/integration/file_serving/metadata_spec.rb spec/shared_behaviours/file_serving.rb spec/unit/file_serving/terminus_selector_spec.rb spec/unit/network/handler/ca_spec.rb test/ral/manager/attributes.rb
2012-07-12Use cross-platform absolute paths in file_serving testsPatrick Carlisle1-1/+2
The file_serving tests were failing on windows because they used unix style paths. This makes them absolute on both posix and windows.
2012-07-05Refactor module to require path and environment argsPatrick Carlisle1-1/+1
2012-07-03Use in memory sqlite database for unit testsPatrick Carlisle1-4/+6
2012-07-02(maint) Add trailing newlines to all filesJeff McCune1-1/+1
2012-06-28Use in memory sqlite database for unit testsPatrick Carlisle1-3/+5
2012-05-11Rewrite `have_printed` matcher to be more robust.Daniel Pittman1-17/+27
The DSL for matchers doesn't actually work terribly well with the `have_printed` matcher - rewrite it to a class to be a little smoother. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>