Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
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.
|
|
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).
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
(PUP-1177) make sure ssh_known_hosts is not created with mode 0600
|
|
(maint) spec: allow expectations of resources from compiled manifests
|
|
It is helpful to have a simple helper method to match desired file modes
from spec tests.
|
|
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.
|
|
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.
|
|
* 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
|
|
* 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
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
This makes it easy to mock a directory structure by giving it
a hash, where non hash entries are content, and hashes are directories.
|
|
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.
|
|
Only call the method if the object responds to it.
|
|
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
|
|
Adds a spec test that ensures `puppet man <app>` exits with 0 and does
not emit the 'undefined method' error reported in PUP-1707.
|
|
Adds indirector terminii for catalog, report and node. These are a lot
faster to store than the PSON or YAML equivalents.
|
|
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.
|
|
Checking that catalogs have particular resources is useful. Let's make
it easier. This also adds parameter matching to the resource matcher.
|
|
Instead of creating environments directly, we need to go through the
configured environment loaders, otherwise environments can't come from
other places.
|
|
This changes the loader used by the code to list environments to be a
composition of the legacy environments and the new directory
environments.
|
|
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.
|
|
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.
|
|
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.
|
|
- 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
|
|
The output did not include':' for the "Got" tokens.
|
|
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).
|
|
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.
|
|
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.
|
|
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.
|
|
|
|
This also includes some minor refactoring of the contain function.
|
|
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'.
|
|
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 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.
|
|
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.
|
|
From the the accepted proposal for this functionality some of the
example cases have been captured as test cases.
|
|
|
|
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.
|
|
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.
|
|
Conflicts:
spec/unit/file_serving/metadata_spec.rb
|
|
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>
|
|
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.
|