summaryrefslogtreecommitdiff
path: root/spec/lib
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 Parker3-0/+43
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-27Merge branch 'hlindberg-pup-2302_defaults-not-capitalized'Andrew Parker1-13/+45
* hlindberg-pup-2302_defaults-not-capitalized: (maint) Convert to using have_resource matcher (maint) Convert to compile_to_catalog (PUP-2302) Fix issue with Resource Defaults for qualified names
2014-04-27(maint) Convert to using have_resource matcherAndrew Parker1-13/+45
Using the have_resource matcher makes the tests a little shorter and more expressive. It also uses the common way of matching so that we can get better error reporting. It turns out that one of the tests was matching against the incorrect class name, so that is now fixed. This also extracts a be_resource matcher so that you can match against an individual resource independent of a catalog.
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-02-06(PUP-1588) Add msgpack indirector terminiiErik Dalén1-0/+6
Adds indirector terminii for catalog, report and node. These are a lot faster to store than the PSON or YAML equivalents.
2014-02-06(maint) Change name from from_pson to from_data_hashErik Dalén1-2/+6
This is because these methods are also used for deserialization from other formats than PSON. The method for serializing a object is called to_data_hash, so makes sense to call this from_data_hash.
2014-02-03(Maint) Extract re-usable resource matcherAndrew Parker1-0/+35
Checking that catalogs have particular resources is useful. Let's make it easier. This also adds parameter matching to the resource matcher.
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.
2014-01-23(PUP-1118) Load full environments from a directoryAndrew Parker2-2/+34
This changes the loader used by the code to list environments to be a composition of the legacy environments and the new directory environments.
2014-01-23(PUP-1118) List environments from a directoryAndrew Parker1-0/+27
This starts the process of creating a Puppet::Environments::Directory that will find environments from a particular directory. The directory has sub-directories, where each sub-directory name is the environment name.
2014-01-14(PUP-1151) Consolidate JSON schema validationAndrew Parker1-79/+135
This adds a new matcher to the JSONMatchers to validate json against a given json-schema. All of the json schema validation now goes through this one matcher, which also handles skipping the checks on windows.
2014-01-09(PUP-1151) Factor out v1 HTTP request processing into own request processor.Dan Lidral-Porter2-0/+13
The end goal is to have v1 and v2 API endpoints in their own processors, with the routes registered on a shared handler that performs client authentication and dispatch. This commit rips out the v1 endpoints to their own processor, but does not define anything about the handler including registration. v1-related behavorial tests have been moved from the handler spec to the v1 spec.
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) Improve output from match_tokens2.Henrik Lindberg1-1/+1
The output did not include':' for the "Got" tokens.
2013-12-05(perf) Add Lexer2 - a faster Lexer replacementHenrik Lindberg1-0/+74
The Lexer2 (not yet used by the parser) performs >3x faster on lexing of 10 lines of mixed code including simple expression interpolation than the original lexer (which does not keep track of detailed positions).
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-09-05(#8040) Add a function to specify containmentPatrick Carlisle1-0/+52
This adds the 'contain' function. When used inside of a class definition, it will create a containment relationship such that the current class contains the argument of 'contain'.
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-13(#18508) Extract class to control generating resourcesAndrew Parker1-0/+48
The logic for determining how to add generated resources into the catalog was tightly bound with the rest of the transaction code. This makes it hard to test the exact logic around that. By extracting a class it exposes that logic in a much more testable form.
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-07-29(#18508) Specify the order of resources in the catalogAndrew Parker2-0/+51
This adds a specification to the order in which resources appear in the catalog. They must appear in the order in which they are added to the catalog. In order to make this kind of assertion easier this commit also brings in Ramcrest.
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.