Imported puppetlabs-vcsrepo

This commit is contained in:
Ciaby 2014-07-16 13:58:34 -05:00
parent 0938a13fe6
commit 18d9aa4a23
152 changed files with 9191 additions and 0 deletions

99
modules/vcsrepo/CHANGELOG Normal file
View file

@ -0,0 +1,99 @@
2014-07-14 - Supported Release 1.1.0
Summary:
This release adds a Perforce provider* and corrects the git provider behavior
when using `ensure => latest`.
*(Only git provider is currently supported.)
Features:
- New Perforce provider
Bugfixes:
- (MODULES-660) Fix behavior with `ensure => latest` and detached HEAD
- Spec test fixes
2014-06-30 - Supported Release 1.0.2
Summary:
This supported release adds SLES 11 to the list of compatible OSs and
documentation updates for support.
2014-06-17 - Supported Release 1.0.1
Summary:
This release is the first supported release of vcsrepo. The readme has been
greatly improved.
Features:
- Updated and expanded readme to follow readme template
Fixes:
- Remove SLES from compatability metadata
- Unpin rspec development dependencies
- Update acceptance level testing
2014-06-04 - Version 1.0.0
Summary:
This release focuses on a number of bugfixes, and also has some
new features for Bzr and Git.
Features:
- Bzr:
- Call set_ownership
- Git:
- Add ability for shallow clones
- Use -a and desired for HARD resets
- Use rev-parse to get tag canonical revision
Fixes:
- HG:
- Only add ssh options when it's talking to the network
- Git:
- Fix for issue with detached HEAD
- force => true will now destroy and recreate repo
- Actually use the remote parameter
- Use origin/master instead of origin/HEAD when on master
- SVN:
- Fix svnlook behavior with plain directories
2013-11-13 - Version 0.2.0
Summary:
This release mainly focuses on a number of bugfixes, which should
significantly improve the reliability of Git and SVN. Thanks to
our many contributors for all of these fixes!
Features:
- Git:
- Add autorequire for Package['git']
- HG:
- Allow user and identity properties.
- Bzr:
- "ensure => latest" support.
- SVN:
- Added configuration parameter.
- Add support for master svn repositories.
- CVS:
- Allow for setting the CVS_RSH environment variable.
Fixes:
- Handle Puppet::Util[::Execution].withenv for 2.x and 3.x properly.
- Change path_empty? to not do full directory listing.
- Overhaul spec tests to work with rspec2.
- Git:
- Improve Git SSH usage documentation.
- Add ssh session timeouts to prevent network issues from blocking runs.
- Fix git provider checkout of a remote ref on an existing repo.
- Allow unlimited submodules (thanks to --recursive).
- Use git checkout --force instead of short -f everywhere.
- Update git provider to handle checking out into an existing (empty) dir.
- SVN:
- Handle force property. for svn.
- Adds support for changing upstream repo url.
- Check that the URL of the WC matches the URL from the manifest.
- Changed from using "update" to "switch".
- Handle revision update without source switch.
- Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'.
- CVS:
- Documented the "module" attribute.

View file

@ -0,0 +1,234 @@
Checklist (and a short version for the impatient)
=================================================
* Commits:
- Make commits of logical units.
- Check for unnecessary whitespace with "git diff --check" before
committing.
- Commit using Unix line endings (check the settings around "crlf" in
git-config(1)).
- Do not check in commented out code or unneeded files.
- The first line of the commit message should be a short
description (50 characters is the soft limit, excluding ticket
number(s)), and should skip the full stop.
- Associate the issue in the message. The first line should include
the issue number in the form "(#XXXX) Rest of message".
- The body should provide a meaningful commit message, which:
- uses the imperative, present tense: "change", not "changed" or
"changes".
- includes motivation for the change, and contrasts its
implementation with the previous behavior.
- Make sure that you have tests for the bug you are fixing, or
feature you are adding.
- Make sure the test suites passes after your commit:
`bundle exec rspec spec/acceptance` More information on [testing](#Testing) below
- When introducing a new feature, make sure it is properly
documented in the README.md
* Submission:
* Pre-requisites:
- Sign the [Contributor License Agreement](https://cla.puppetlabs.com/)
- Make sure you have a [GitHub account](https://github.com/join)
- [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for.
* Preferred method:
- Fork the repository on GitHub.
- Push your changes to a topic branch in your fork of the
repository. (the format ticket/1234-short_description_of_change is
usually preferred for this project).
- Submit a pull request to the repository in the puppetlabs
organization.
The long version
================
1. Make separate commits for logically separate changes.
Please break your commits down into logically consistent units
which include new or changed tests relevant to the rest of the
change. The goal of doing this is to make the diff easier to
read for whoever is reviewing your code. In general, the easier
your diff is to read, the more likely someone will be happy to
review it and get it into the code base.
If you are going to refactor a piece of code, please do so as a
separate commit from your feature or bug fix changes.
We also really appreciate changes that include tests to make
sure the bug is not re-introduced, and that the feature is not
accidentally broken.
Describe the technical detail of the change(s). If your
description starts to get too long, that is a good sign that you
probably need to split up your commit into more finely grained
pieces.
Commits which plainly describe the things which help
reviewers check the patch and future developers understand the
code are much more likely to be merged in with a minimum of
bike-shedding or requested changes. Ideally, the commit message
would include information, and be in a form suitable for
inclusion in the release notes for the version of Puppet that
includes them.
Please also check that you are not introducing any trailing
whitespace or other "whitespace errors". You can do this by
running "git diff --check" on your changes before you commit.
2. Sign the Contributor License Agreement
Before we can accept your changes, we do need a signed Puppet
Labs Contributor License Agreement (CLA).
You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/)
If you have any questions about the CLA, please feel free to
contact Puppet Labs via email at cla-submissions@puppetlabs.com.
3. Sending your patches
To submit your changes via a GitHub pull request, we _highly_
recommend that you have them on a topic branch, instead of
directly on "master".
It makes things much easier to keep track of, especially if
you decide to work on another thing before your first change
is merged in.
GitHub has some pretty good
[general documentation](http://help.github.com/) on using
their site. They also have documentation on
[creating pull requests](http://help.github.com/send-pull-requests/).
In general, after pushing your topic branch up to your
repository on GitHub, you can switch to the branch in the
GitHub UI and click "Pull Request" towards the top of the page
in order to open a pull request.
4. Update the related GitHub issue.
If there is a GitHub issue associated with the change you
submitted, then you should update the ticket to include the
location of your branch, along with any other commentary you
may wish to make.
Testing
=======
Getting Started
---------------
Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby
package manager such as [bundler](http://bundler.io/) what Ruby packages,
or Gems, are required to build, develop, and test this software.
Please make sure you have [bundler installed](http://bundler.io/#getting-started)
on your system, then use it to install all dependencies needed for this project,
by running
```shell
% bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0)
Using builder (3.2.2)
-- 8><-- many more --><8 --
Using rspec-system-puppet (2.2.0)
Using serverspec (0.6.3)
Using rspec-system-serverspec (1.0.0)
Using bundler (1.3.5)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
```
NOTE some systems may require you to run this command with sudo.
If you already have those gems installed, make sure they are up-to-date:
```shell
% bundle update
```
With all dependencies in place and up-to-date we can now run the tests:
```shell
% rake spec
```
This will execute all the [rspec tests](http://rspec-puppet.com/) tests
under [spec/defines](./spec/defines), [spec/classes](./spec/classes),
and so on. rspec tests may have the same kind of dependencies as the
module they are testing. While the module defines in its [Modulefile](./Modulefile),
rspec tests define them in [.fixtures.yml](./fixtures.yml).
Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker)
tests. These tests spin up a virtual machine under
[VirtualBox](https://www.virtualbox.org/)) with, controlling it with
[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test
scenarios. In order to run these, you will need both of those tools
installed on your system.
You can run them by issuing the following command
```shell
% rake spec_clean
% rspec spec/acceptance
```
This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
and then run all the tests under [spec/acceptance](./spec/acceptance).
Writing Tests
-------------
XXX getting started writing tests.
If you have commit access to the repository
===========================================
Even if you have commit access to the repository, you will still need to
go through the process above, and have someone else review and merge
in your changes. The rule is that all changes must be reviewed by a
developer on the project (that did not write the code) to ensure that
all changes go through a code review process.
Having someone other than the author of the topic branch recorded as
performing the merge is the record that they performed the code
review.
Additional Resources
====================
* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help)
* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests)
* [Patchwork](https://patchwork.puppetlabs.com)
* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign)
* [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)

27
modules/vcsrepo/Gemfile Normal file
View file

@ -0,0 +1,27 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'serverspec', :require => false
gem 'puppet-lint', :require => false
gem 'beaker', :require => false
gem 'beaker-rspec', :require => false
gem 'pry', :require => false
gem 'simplecov', :require => false
end
if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion, :require => false
else
gem 'facter', :require => false
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
# vim:ft=ruby

17
modules/vcsrepo/LICENSE Normal file
View file

@ -0,0 +1,17 @@
Copyright (C) 2010-2012 Puppet Labs Inc.
Puppet Labs can be contacted at: info@puppetlabs.com
This program and entire repository is free software; you can
redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software
Foundation; either version 2 of the License, or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

View file

@ -0,0 +1,563 @@
#vcsrepo
[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo)
####Table of Contents
1. [Overview](#overview)
2. [Module Description - What the module does and why it is useful](#module-description)
3. [Setup - The basics of getting started with vcsrepo](#setup)
* [Beginning with vcsrepo](#beginning-with-vcsrepo)
4. [Usage - Configuration options and additional functionality](#usage)
* [Bazaar](#bazaar)
* [CVS](#cvs)
* [Git](#git)
* [Mercurial](#mercurial)
* [Perforce](#perforce)
* [Subversion](#subversion)
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
* [Type: vcsrepo](#type-vcsrepo)
* [Providers](#providers)
* [Features](#features)
* [Parameters](#parameters)
* [Features and Parameters by Provider](#features-and-parameters-by-provider)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
##Overview
The vcsrepo module allows you to use Puppet to easily deploy content from your version control system (VCS).
##Module Description
This module provides a single type with providers for each VCS, which can be used to describe:
* A working copy checked out from a (remote or local) source, at an
arbitrary revision
* A blank working copy not associated with a source (when it makes
sense for the VCS being used)
* A blank central repository (when the distinction makes sense for the VCS
being used)
##Setup
###Beginning with vcsrepo
To get started with the vcsrepo module, you must simply define the type `vcsrepo` with a path to your repository and the [type of VCS](#Usage) you're using in `provider` (in the below example, Git).
vcsrepo { "/path/to/repo":
ensure => present,
provider => git,
}
##Usage
The vcsrepo module works with the following VCSs:
* [Git (git)](#git)*
* [Bazaar (bzr)](#bazaar)
* [CVS (cvs)](#cvs)
* [Mercurial (hg)](#mercurial)
* [Perforce (p4)](#perforce)
* [Subversion (svn)](#subversion)
**Note:** Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
###Git
#####To create a blank repository
To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.
vcsrepo { "/path/to/repo":
ensure => present,
provider => git,
}
If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'.
vcsrepo { "/path/to/repo":
ensure => bare,
provider => git,
}
#####To clone/pull a repository
To get the current HEAD on the master branch,
vcsrepo { "/path/to/repo":
ensure => present,
provider => git,
source => "git://example.com/repo.git",
}
To get a specific revision or branch (can be a commit SHA, tag, or branch name),
**SHA**
vcsrepo { "/path/to/repo":
ensure => present,
provider => git,
source => 'git://example.com/repo.git',
revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
}
**Tag**
vcsrepo { "/path/to/repo":
ensure => present,
provider => git,
source => 'git://example.com/repo.git',
revision => '1.1.2rc1',
}
**Branch name**
vcsrepo { "/path/to/repo":
ensure => present,
provider => git,
source => 'git://example.com/repo.git',
revision => 'development',
}
To check out a branch as a specific user,
vcsrepo { "/path/to/repo":
ensure => present,
provider => git,
source => 'git://example.com/repo.git',
revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
user => 'someUser',
}
To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository),
vcsrepo { "/path/to/repo":
ensure => latest,
provider => git,
source => 'git://example.com/repo.git',
revision => 'master',
}
#####Sources that use SSH
When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys.
user => 'toto' # will use toto's $HOME/.ssh setup
#####Further Examples
For more examples using Git, see `examples/git/`.
###Bazaar
#####Create a blank repository
To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.
vcsrepo { "/path/to/repo":
ensure => present,
provider => bzr,
}
#####Branch from an existing repository
Provide the `source` location to branch from an existing repository.
vcsrepo { "/path/to/repo":
ensure => present,
provider => bzr,
source => 'lp:myproj',
}
For a specific revision, use `revision` with a valid revisionspec
(see `bzr help revisionspec` for more information on formatting a revision).
vcsrepo { "/path/to/repo":
ensure => present,
provider => bzr,
source => 'lp:myproj',
revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x',
}
#####Sources that use SSH
When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,'
you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
#####Further examples
For more examples using Bazaar, see `examples/bzr/`.
###CVS
#####To create a blank repository
To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.
vcsrepo { "/path/to/repo":
ensure => present,
provider => cvs,
}
#####To checkout/update from a repository
To get the current mainline,
vcsrepo { "/path/to/workspace":
ensure => present,
provider => cvs,
source => ":pserver:anonymous@example.com:/sources/myproj",
}
To get a specific module on the current mainline,
vcsrepo {"/vagrant/lockss-daemon-source":
ensure => present,
provider => cvs,
source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss",
module => "lockss-daemon",
}
You can use the `compression` parameter to set the GZIP compression levels for your repository history.
vcsrepo { "/path/to/workspace":
ensure => present,
provider => cvs,
compression => 3,
source => ":pserver:anonymous@example.com:/sources/myproj",
}
For a specific tag, use `revision`.
vcsrepo { "/path/to/workspace":
ensure => present,
provider => cvs,
compression => 3,
source => ":pserver:anonymous@example.com:/sources/myproj",
revision => "SOMETAG",
}
#####Sources that use SSH
When your source uses SSH, you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
#####Further examples
For for more examples using CVS, see `examples/cvs/`.
###Mercurial
#####To create a blank repository
To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.
vcsrepo { "/path/to/repo":
ensure => present,
provider => hg,
}
#####To clone/pull & update a repository
To get the default branch tip,
vcsrepo { "/path/to/repo":
ensure => present,
provider => hg,
source => "http://hg.example.com/myrepo",
}
For a specific changeset, use `revision`.
vcsrepo { "/path/to/repo":
ensure => present,
provider => hg,
source => "http://hg.example.com/myrepo",
revision => '21ea4598c962',
}
You can also set `revision` to a tag.
vcsrepo { "/path/to/repo":
ensure => present,
provider => hg,
source => "http://hg.example.com/myrepo",
revision => '1.1.2',
}
To check out as a specific user,
vcsrepo { "/path/to/repo":
ensure => present,
provider => hg,
source => "http://hg.example.com/myrepo",
user => 'user',
}
To specify an SSH identity key,
vcsrepo { "/path/to/repo":
ensure => present,
provider => hg,
source => "ssh://hg@hg.example.com/myrepo",
identity => "/home/user/.ssh/id_dsa,
}
To specify a username and password for HTTP Basic authentication,
vcsrepo { "/path/to/repo":
ensure => latest,
provider => hg,
source => 'http://hg.example.com/myrepo',
basic_auth_username => 'hgusername',
basic_auth_password => 'hgpassword',
}
#####Sources that use SSH
When your source uses SSH, such as 'ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
#####Further Examples
For more examples using Mercurial, see `examples/hg/`.
###Perforce
#####To create an empty Workspace
To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`. The
Environment variables P4PORT, P4USER, etc... are used to define the Perforce server
connection settings.
vcsrepo { "/path/to/repo":
ensure => present,
provider => p4
}
If no `P4CLIENT` environment name is provided a workspace generated name is calculated
based on the Digest of path and hostname. For example:
puppet-91bc00640c4e5a17787286acbe2c021c
A Perforce configuration file can be used by setting the `P4CONFIG` environment or
defining `p4config`. If a configuration is defined, then the environment variable for
`P4CLIENT` is replaced.
vcsrepo { "/path/to/repo":
ensure => present,
provider => p4,
p4config => '.p4config'
}
#####To create/update and sync a Perforce workspace
To sync a depot path to head, ensure `latest`:
vcsrepo { "/path/to/repo":
ensure => latest,
provider => p4,
source => '//depot/branch/...'
}
For a specific changelist, ensure `present` and specify a `revision`:
vcsrepo { "/path/to/repo":
ensure => present,
provider => p4,
source => '//depot/branch/...',
revision => '2341'
}
You can also set `revision` to a label:
vcsrepo { "/path/to/repo":
ensure => present,
provider => p4,
source => '//depot/branch/...',
revision => 'my_label'
}
#####To authenticate against the Perforce server
Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file.
For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`.
#####Further Examples
For examples you can run, see `examples/p4/`
###Subversion
#####To create a blank repository
To create a blank repository suitable for use as a central repository,
define `vcsrepo` without `source` or `revision`.
vcsrepo { "/path/to/repo":
ensure => present,
provider => svn,
}
#####To check out from a repository
Provide a `source` pointing to the branch/tag you want to check out from a repository.
vcsrepo { "/path/to/repo":
ensure => present,
provider => svn,
source => "svn://svnrepo/hello/branches/foo",
}
You can also provide a specific revision.
vcsrepo { "/path/to/repo":
ensure => present,
provider => svn,
source => "svn://svnrepo/hello/branches/foo",
revision => '1234',
}
#####Using a specific Subversion configuration directory
To use a specific configuration directory, provide a `configuration` parameter which should be a directory path on the local system where your svn configuration files are. Typically, it is '/path/to/.subversion'.
vcsrepo { "/path/to/repo":
ensure => present,
provider => svn,
source => "svn://svnrepo/hello/branches/foo",
configuration => "/path/to/.subversion",
}
#####Sources that use SSH
When your source uses SSH, such as 'svn+ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present.
####Further examples
For more examples using Subversion, see `examples/svn/`.
##Reference
###Type: vcsrepo
The vcsrepo module is slightly unusual in that it is simply a type and providers. Each provider abstracts a different VCS, and a series of features are available to each provider based on its specific needs.
####Providers
**Note**: Not all features are available with all providers.
* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.)
* `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.)
* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.)
* `dummy` -
* `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.)
* `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.)
* `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.)
####Features
**Note**: Not all features are available with all providers.
* `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.)
* `basic_auth` - The provider supports HTTP Basic Authentication. (Available with `svn`.)
* `configuration` - The provider supports setting the configuration path.(Available with `svn`.)
* `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.)
* `depth` - The provider can do shallow clones. (Available with `git`.)
* `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.)
* `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.)
* `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.)
* `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.)
* `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.)
* `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.)
* `user` - The provider can run as a different user. (Available with `git` and `hg`.)
* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.)
####Parameters
* `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.)
* `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.)
* `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.)
* `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.)
* `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.)
* `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.)
* `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'.
* `excludes` - Lists any files to be excluded from the repository.
* `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path.
* `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.)
* `group` - Determines the group/gid that owns the repository files.
* `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.)
* `module` - Specifies the repository module to manage. (Requires the `modules` feature.)
* `owner` - Specifies the user/uid that owns the repository files.
* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title.
* `provider` - Specifies the backend to use for this vcsrepo resource.
* `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.)
* `revision` - Sets the revision of the repository. Values can match /^\S+$/.
* `source` - Specifies the source URI for the repository.
* `user` - Specifies the user to run as for repository operations.
* `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration.
####Features and Parameters by Provider
#####`git`
**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`
**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`
#####`bzr`
**Features**: `reference_tracking`
**Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
#####`cvs`
**Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision`
**Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user`
#####`hg`
**Features**: `reference_tracking`, `ssh_identity`, `user`
**Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user`
#####`p4`
**Features**: `reference_tracking`, `filesystem_types`, `p4config`
**Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config`
#####`svn`
**Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`
**Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user`
##Limitations
Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
This module has been built on and tested against Puppet 2.7 and higher.
The module has been tested on:
RedHat Enterprise Linux 5/6
Debian 6/7
CentOS 5/6
Ubuntu 12.04
Gentoo
Arch Linux
FreeBSD
Testing on other platforms has been light and cannot be guaranteed.
##Development
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We cant access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
You can read the complete module contribution guide on the Puppet Labs wiki.

78
modules/vcsrepo/Rakefile Executable file
View file

@ -0,0 +1,78 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'rake'
desc "Run beaker-rspec and beaker tests"
task 'beaker:test:all',[:host,:type] => ["rake:beaker:rspec:test", "rake:beaker:test"] do |t,args|
end
desc "Run beaker-rspec tests"
task 'beaker:rspec:test',[:host,:type] => [:set_beaker_variables] do |t,args|
Rake::Task['beaker-rspec:test'].invoke(args)
end
desc "Run beaker tests"
task 'beaker:test',[:host,:type] => [:set_beaker_variables] do |t,args|
sh(build_beaker_command args)
end
desc "Run beaker rspec tasks against pe"
RSpec::Core::RakeTask.new('beaker-rspec:test',[:host,:type]=>:set_beaker_variables) do |t,args|
t.pattern = 'spec/acceptance'
t.rspec_opts = '--color'
t.verbose = true
end
desc "Run beaker and beaker-rspec tasks"
task 'beaker:test:pe',:host do |t,args|
args.with_defaults(:type=> 'pe')
Rake::Task['beaker:test'].invoke(args[:host],args[:type])
end
task 'beaker:test:git',:host do |t,args|
args.with_defaults({:type=> 'git'})
Rake::Task['beaker:test'].invoke(args[:host],args[:type])
end
task :set_beaker_variables do |t,args|
puts 'Setting environment variables for testing'
if args[:host]
ENV['BEAKER_set'] = args[:host]
puts "Host to test #{ENV['BEAKER_set']}"
end
ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false"
if ENV['BEAKER_setfile']
@hosts_config = ENV['BEAKER_setfile']
end
if File.exists?(check_args_for_keyfile(args.extras))
ENV['BEAKER_keyfile'] = check_args_for_keyfile(args.extras)
end
end
def build_beaker_command(args)
cmd = ["beaker"]
cmd << "--type #{args[:type]}" unless !args[:type]
if File.exists?("./.beaker-#{args[:type]}.cfg")
cmd << "--options-file ./.beaker-#{args[:type]}.cfg"
end
if File.exists?(@hosts_config)
cmd << "--hosts #{@hosts_config}"
end
if File.exists?('./spec/acceptance/beaker_helper.rb')
cmd << "--pre-suite ./spec/acceptance/beaker_helper.rb"
end
if File.exists?("./spec/acceptance/beaker")
cmd << "--tests ./spec/acceptance/beaker"
end
if File.exists?(check_args_for_keyfile(args.extras))
cmd << "--keyfile #{check_args_for_keyfile(args.extras)}"
end
cmd.join(" ")
end
def check_args_for_keyfile(extra_args)
keyfile = ''
extra_args.each do |a|
keyfile = a unless (`ssh-keygen -l -f #{a}`.gsub(/\n/,"").match(/is not a .*key file/))
end
return keyfile
end

View file

@ -0,0 +1,153 @@
{
"CHANGELOG": "096c1cd172db26b2737ca9ec481b1fd8",
"CONTRIBUTING.md": "d911815dd7d0d90b90bb35382a6e3298",
"Gemfile": "31d67830f694c2af4c709d46c513bbc7",
"LICENSE": "b8d96fef1f55096f9d39326408122136",
"README.markdown": "6c4dfd269d90c7c3fdf9c981ec5d8b2e",
"Rakefile": "7839f13265f552486585d607c71446a9",
"examples/bzr/branch.pp": "05c66419324a576b9b28df876673580d",
"examples/bzr/init_repo.pp": "fadd2321866ffb0aacff698d2dc1f0ca",
"examples/cvs/local.pp": "7fbde03a5c71edf168267ae42d0bbcbc",
"examples/cvs/remote.pp": "491f18f752752bec6133a88de242c44d",
"examples/git/bare_init.pp": "7cf56abffdf99f379153166f18f961f8",
"examples/git/clone.pp": "0e3181990c095efee1498ccfca5897fb",
"examples/git/working_copy_init.pp": "99d92d9957e78a0c03f9cbed989c79ca",
"examples/hg/clone.pp": "c92bbd704a4c2da55fff5f45955ce6d1",
"examples/hg/clone_basic_auth.pp": "62442bb1f978732a712a712f66f9adde",
"examples/hg/init_repo.pp": "bf5fa0ab48a2f5a1ccb63768d961413d",
"examples/p4/create_client.pp": "7610dfb4bec055baf1029ada6864d12a",
"examples/p4/delete_client.pp": "c3955cdad40b56b02462318c62919e96",
"examples/p4/latest_client.pp": "f93b1cf3875411a826e4a45d73783208",
"examples/p4/sync_client.pp": "347aba005639148ddc757305eefc6fb2",
"examples/svn/checkout.pp": "9ef7a8fbd3a763fa3894efa864047023",
"examples/svn/server.pp": "94b26f6e50d5e411b33b1ded1bc2138a",
"lib/puppet/provider/vcsrepo/bzr.rb": "9304caa8c45685d741248fb167c47842",
"lib/puppet/provider/vcsrepo/cvs.rb": "2e25c861174fcad6be452290c0bbdd0b",
"lib/puppet/provider/vcsrepo/dummy.rb": "2f8159468d6ecc8087debde858a80dd6",
"lib/puppet/provider/vcsrepo/git.rb": "d9533ddd532d224ba3c9e5721ff5c120",
"lib/puppet/provider/vcsrepo/hg.rb": "dfedc09887b98c4df2b1000d860a4b8a",
"lib/puppet/provider/vcsrepo/p4.rb": "d32f72c9c86442a8e23904fe067a8861",
"lib/puppet/provider/vcsrepo/svn.rb": "da00dfb4a67fd01d4756e6497d5ed7f1",
"lib/puppet/provider/vcsrepo.rb": "dbd72590771291f1db23a41ac048ed9d",
"lib/puppet/type/vcsrepo.rb": "0427f46f99137cea53a45d19f2c918f0",
"metadata.json": "8b1546fe6b0a75a241b34d7964ce49cb",
"spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_http.rb": "eaa8419eff123dd15e1485d2462a7ba6",
"spec/acceptance/beaker/git/basic_auth/basic_auth_checkout_https.rb": "b7cb6c4c1852302ff2b37838548d4f22",
"spec/acceptance/beaker/git/basic_auth/negative/basic_auth_checkout_git.rb": "c2319ac03e26887ad4487ea3b582bbcb",
"spec/acceptance/beaker/git/branch_checkout/branch_checkout_file.rb": "a90df84a864354f445b5fe449ab88e1a",
"spec/acceptance/beaker/git/branch_checkout/branch_checkout_file_path.rb": "3f08ea8dfa28e4183e8eae53cea738d8",
"spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb": "4281e7577a042387f7b6126627c5cf8e",
"spec/acceptance/beaker/git/branch_checkout/branch_checkout_http.rb": "f93372914141c2c7955a2f7ebae217ff",
"spec/acceptance/beaker/git/branch_checkout/branch_checkout_https.rb": "aef3ebf1d6178de6c279cb87d7f55df1",
"spec/acceptance/beaker/git/branch_checkout/branch_checkout_scp.rb": "71ea6210e1539ea08c50d09323f772e8",
"spec/acceptance/beaker/git/branch_checkout/branch_checkout_ssh.rb": "fdba3d8a380030fa21272c12ad688e0b",
"spec/acceptance/beaker/git/branch_checkout/negative/branch_checkout_not_exists.rb": "4a4039969737bd25133a5534f0a1bc3a",
"spec/acceptance/beaker/git/clone/clone_file.rb": "c78e7e176f86e5ee6e24e4fcf8bc319f",
"spec/acceptance/beaker/git/clone/clone_file_path.rb": "1f599d4780927d61c9f814cbad8b46db",
"spec/acceptance/beaker/git/clone/clone_git.rb": "6273e28d6bc5a677c664b5ee82c04c65",
"spec/acceptance/beaker/git/clone/clone_http.rb": "5c8c16aeb9dea9d7ebfc53f67538242a",
"spec/acceptance/beaker/git/clone/clone_https.rb": "f4f78dea68b6200dcb2c51d22fc05fcb",
"spec/acceptance/beaker/git/clone/clone_over_different_exiting_repo_with_force.rb": "d8ae7f754060108776e425c0ea135d85",
"spec/acceptance/beaker/git/clone/clone_repo_with_excludes_in_repo.rb": "5b04f4cb8dfd08bab991c5291d5cd92b",
"spec/acceptance/beaker/git/clone/clone_repo_with_excludes_not_in_repo.rb": "229cf2cc88a97a5ccaa519d2f53ecd01",
"spec/acceptance/beaker/git/clone/clone_scp.rb": "58cdf39fcd490b20f2a74e1b4dd8f26e",
"spec/acceptance/beaker/git/clone/clone_ssh.rb": "23801f8fd433361ceb90871168d84a80",
"spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb": "affaed3538af18fe619b0672ee43337f",
"spec/acceptance/beaker/git/clone/negative/clone_repo_with_exec_excludes.rb": "0427368f2a3f740fdd34fee934f53a8a",
"spec/acceptance/beaker/git/compression/compression_0_checkout.rb": "5236bd53cdd40dca7af1fe126f5f36f7",
"spec/acceptance/beaker/git/compression/compression_1_checkout.rb": "8ec157b00fed76cfc491780024995578",
"spec/acceptance/beaker/git/compression/compression_2_checkout.rb": "6c282b8e167e63ae1726f3045b7f99f6",
"spec/acceptance/beaker/git/compression/compression_3_checkout.rb": "43d97bcc3cd3a48e8c73d20e71c324bb",
"spec/acceptance/beaker/git/compression/compression_4_checkout.rb": "96a8cba3585d0dd2c20acae67dbded29",
"spec/acceptance/beaker/git/compression/compression_5_checkout.rb": "21f944494b0f7dc2a902dddc2fbd445e",
"spec/acceptance/beaker/git/compression/compression_6_checkout.rb": "5462705b42e95be9e5ee7e5af3c7c0c0",
"spec/acceptance/beaker/git/compression/negative/compression_7_checkout.rb": "ea61e9642d9f03c44f060914e784ad87",
"spec/acceptance/beaker/git/compression/negative/compression_alpha_checkout.rb": "5f02f2a55386a53ea8919d010a12e390",
"spec/acceptance/beaker/git/compression/negative/compression_eval_checkout.rb": "168f9801155a478e948827d74dfcfaad",
"spec/acceptance/beaker/git/compression/negative/compression_exec_checkout.rb": "57ec765fd1af56c4349f9244ef285cc7",
"spec/acceptance/beaker/git/compression/negative/compression_negative_checkout.rb": "5c90e119f86e6d53713e20d86ae4a71d",
"spec/acceptance/beaker/git/create/create_bare_repo_that_already_exists.rb": "6d91f95ae93f00b3aa0ea8dac1557eb4",
"spec/acceptance/beaker/git/create/create_repo_that_already_exists.rb": "3184a82fc03408b3fc8fd468f184d5f1",
"spec/acceptance/beaker/git/create/negative/create_bare_repo_specifying_revision.rb": "79a6b9d96c39cd68d5480fa543d336b1",
"spec/acceptance/beaker/git/group_checkout/group_checkout_file.rb": "f2e75ec350f2e10b187ec2c1725c5307",
"spec/acceptance/beaker/git/group_checkout/group_checkout_file_path.rb": "d8d70e543ce770dc1233f266f17df761",
"spec/acceptance/beaker/git/group_checkout/group_checkout_git.rb": "e8a44d9fb3a2a938b3ca72cc05301455",
"spec/acceptance/beaker/git/group_checkout/group_checkout_http.rb": "9b288fb24803120d31802e6ced58bdfb",
"spec/acceptance/beaker/git/group_checkout/group_checkout_https.rb": "f4b82e2207808939bf0af441773d0eb5",
"spec/acceptance/beaker/git/group_checkout/group_checkout_scp.rb": "f0c3159f4e4a4a6422b406688693200d",
"spec/acceptance/beaker/git/group_checkout/group_checkout_ssh.rb": "f081ac9386aacae08e502009d621666b",
"spec/acceptance/beaker/git/group_checkout/negative/group_checkout_file_non_existent_group.rb": "0b950310690d479607a18c72bd4e73fc",
"spec/acceptance/beaker/git/revision_checkout/negative/revision_checkout_not_exists.rb": "4a797b38219cfbc01025d8307c41cb70",
"spec/acceptance/beaker/git/revision_checkout/revision_checkout_file.rb": "c9e8dfad4c4d1b22d813eb918f679fd9",
"spec/acceptance/beaker/git/revision_checkout/revision_checkout_file_path.rb": "eb9feef20d2757dfa460e968b0923a79",
"spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb": "a4a90ce2433032509947893340f786c0",
"spec/acceptance/beaker/git/revision_checkout/revision_checkout_http.rb": "fb0a32d1c5f350e3dad9494f411ac0bf",
"spec/acceptance/beaker/git/revision_checkout/revision_checkout_https.rb": "8530db58c5a1692d609d074f543b6b89",
"spec/acceptance/beaker/git/revision_checkout/revision_checkout_scp.rb": "df666f26828a100784f15a62e0c61c82",
"spec/acceptance/beaker/git/revision_checkout/revision_checkout_ssh.rb": "4adca01a2eb1668c7896876b6f32baf1",
"spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_exec_depth.rb": "ff73d9c33f9a3f07ffb4ce176534af0d",
"spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_file_path.rb": "09ea9d79a74210a982c2e6854208a7b8",
"spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_http.rb": "8a3ab8bae36e8bde4f160e1fb2191912",
"spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_negative_depth.rb": "de8a77d5932965a835654524aea483f3",
"spec/acceptance/beaker/git/shallow_clone/negative/shallow_clone_overflow_depth.rb": "22e9b16579fe60030eee2b132d413b01",
"spec/acceptance/beaker/git/shallow_clone/shallow_clone_file.rb": "8b9636398a48b0c22e10cd40e7fdb8e2",
"spec/acceptance/beaker/git/shallow_clone/shallow_clone_git.rb": "c67049334bb0ef008d825f9eb6f47d92",
"spec/acceptance/beaker/git/shallow_clone/shallow_clone_https.rb": "647f5d426b7f42e1b24addf74aa4fc17",
"spec/acceptance/beaker/git/shallow_clone/shallow_clone_scp.rb": "9b95f36fea77397f8b4de154590b39c7",
"spec/acceptance/beaker/git/shallow_clone/shallow_clone_ssh.rb": "9b8e07b2555399d905d7a9eb14e62a2a",
"spec/acceptance/beaker/git/shallow_clone/shallow_clone_zero_depth.rb": "4cb6ced685b73b9aa21a7d2379918be8",
"spec/acceptance/beaker/git/tag_checkout/negative/tag_checkout_not_exists.rb": "4e0a1e818ef2293264cdfdd297f7d6dd",
"spec/acceptance/beaker/git/tag_checkout/tag_checkout_file.rb": "700ffaaf392ebb4088e462fb56828cad",
"spec/acceptance/beaker/git/tag_checkout/tag_checkout_file_path.rb": "208a30a54bd6bb8ae97d5e93fab03dc9",
"spec/acceptance/beaker/git/tag_checkout/tag_checkout_git.rb": "63d5b3f6311a2cc599c2aab6eba8b2bd",
"spec/acceptance/beaker/git/tag_checkout/tag_checkout_http.rb": "227c1314a2505bfb2b0c06d5ebfd23c3",
"spec/acceptance/beaker/git/tag_checkout/tag_checkout_https.rb": "933d84a7d785beae101da3a0d0cea644",
"spec/acceptance/beaker/git/tag_checkout/tag_checkout_scp.rb": "cc4c4ca339c528a7ee4462b5fa65eb4e",
"spec/acceptance/beaker/git/tag_checkout/tag_checkout_ssh.rb": "b07af48689c609df8adc1d4c9716405c",
"spec/acceptance/beaker/git/user_checkout/negative/user_checkout_file_non_existent_user.rb": "fad8e56f14d27105604f1f047bebcdf3",
"spec/acceptance/beaker/git/user_checkout/user_checkout_file.rb": "a083b3b630bda231b0af38af2f63b3c1",
"spec/acceptance/beaker/git/user_checkout/user_checkout_file_path.rb": "7a2825c0c8847521e5ab5b5867287ce2",
"spec/acceptance/beaker/git/user_checkout/user_checkout_git.rb": "4e987c30e9904722ab832c7d9f44ca44",
"spec/acceptance/beaker/git/user_checkout/user_checkout_http.rb": "f441c4c1e5ab019f068abacf6792b5cb",
"spec/acceptance/beaker/git/user_checkout/user_checkout_https.rb": "a24d41af6331bdb7108bf5211b8aa9f7",
"spec/acceptance/beaker/git/user_checkout/user_checkout_scp.rb": "ea2719ca08404d568570f2c3f6a049dc",
"spec/acceptance/beaker/git/user_checkout/user_checkout_ssh.rb": "6da26ed472baadce407ecfab47cadc0c",
"spec/acceptance/beaker_helper.rb": "400892d8f5c6b65846221cca26c15627",
"spec/acceptance/clone_repo_spec.rb": "ec196a06c31c32a28ab8103e75990124",
"spec/acceptance/create_repo_spec.rb": "22de10bdf7718238928ae2ebc4cb2fa2",
"spec/acceptance/files/create_git_repo.sh": "7cf4087d6e850d439364826566e506ea",
"spec/acceptance/files/server.crt": "927f2f7f5862adb086c9f0022b885e71",
"spec/acceptance/files/server.key": "7c946c812b5b0d1bc60b470ffb61ee8d",
"spec/acceptance/modules_660_spec.rb": "8082e3f15301f4d26e8b4f82f57b1da2",
"spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151",
"spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b",
"spec/acceptance/nodesets/centos-64-x64.yml": "092dd2c588a9f87fa1fb12997c0723ef",
"spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af",
"spec/acceptance/nodesets/debian-607-x64.yml": "466d9ea1ed6b5557085aa8dcefd0d92d",
"spec/acceptance/nodesets/debian-73-x64.yml": "f6aac3ef7cb49d15781d68ab2ff8b03d",
"spec/acceptance/nodesets/default.yml": "092dd2c588a9f87fa1fb12997c0723ef",
"spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297",
"spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269",
"spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "5f0aed10098ac5b78e4217bb27c7aaf0",
"spec/acceptance/remove_repo_spec.rb": "d0e6ad1de613f52df6fdf8eaa93c9b24",
"spec/acceptance/remove_repo_spec_noop.rb": "e33baab5e49bdc3b247a47952c562c6f",
"spec/fixtures/bzr_version_info.txt": "5edb13429faf2f0b9964b4326ef49a65",
"spec/fixtures/git_branch_a.txt": "2371229e7c1706c5ab8f90f0cd57230f",
"spec/fixtures/git_branch_feature_bar.txt": "70903a4dc56f7300fbaa54c295b52c4f",
"spec/fixtures/git_branch_none.txt": "acaa61de6a7f0f5ca39b763799dcb9a6",
"spec/fixtures/hg_parents.txt": "efc28a1bd3f1ce7fb4481f76feed3f6e",
"spec/fixtures/hg_tags.txt": "8383048b15adb3d58a92ea0c8b887537",
"spec/fixtures/svn_info.txt": "978db25720a098e5de48388fe600c062",
"spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c",
"spec/spec_helper.rb": "ce4d39194e1b8486de8ec25f639f6762",
"spec/spec_helper_acceptance.rb": "9189fe27dd422e66b2bad3adc68e0170",
"spec/support/filesystem_helpers.rb": "eb2a8eb3769865004c84e971ccb1396c",
"spec/support/fixture_helpers.rb": "61781d99ea201e9da6d23c64a25cc285",
"spec/unit/puppet/provider/vcsrepo/bzr_spec.rb": "320b5be01c84f3424ac99729e42b4562",
"spec/unit/puppet/provider/vcsrepo/cvs_spec.rb": "24f760cb53be365ca185cd196c03743a",
"spec/unit/puppet/provider/vcsrepo/git_spec.rb": "f0f3d94f678ba38cdbdec5dc01a76004",
"spec/unit/puppet/provider/vcsrepo/hg_spec.rb": "f87f8996e19aa07dee270af713ef4509",
"spec/unit/puppet/provider/vcsrepo/p4_spec.rb": "f6d91dcb82b1a9d8baa26e3fc6ecebab",
"spec/unit/puppet/provider/vcsrepo/svn_spec.rb": "957328714f6df1e90b663514615f460e",
"spec/unit/puppet/type/README.markdown": "de26a7643813abd6c2e7e28071b1ef94"
}

View file

@ -0,0 +1,6 @@
vcsrepo { '/tmp/vcstest-bzr-branch':
ensure => present,
provider => bzr,
source => 'lp:do',
revision => '1312',
}

View file

@ -0,0 +1,4 @@
vcsrepo { '/tmp/vcstest-bzr-init':
ensure => present,
provider => bzr,
}

View file

@ -0,0 +1,11 @@
vcsrepo { '/tmp/vcstest-cvs-repo':
ensure => present,
provider => cvs,
}
vcsrepo { '/tmp/vcstest-cvs-workspace-local':
ensure => present,
provider => cvs,
source => '/tmp/vcstest-cvs-repo',
require => Vcsrepo['/tmp/vcstest-cvs-repo'],
}

View file

@ -0,0 +1,5 @@
vcsrepo { '/tmp/vcstest-cvs-workspace-remote':
ensure => present,
provider => cvs,
source => ':pserver:anonymous@cvs.sv.gnu.org:/sources/leetcvrt',
}

View file

@ -0,0 +1,4 @@
vcsrepo { '/tmp/vcstest-git-bare':
ensure => bare,
provider => git,
}

View file

@ -0,0 +1,5 @@
vcsrepo { '/tmp/vcstest-git-clone':
ensure => present,
provider => git,
source => 'git://github.com/bruce/rtex.git',
}

View file

@ -0,0 +1,4 @@
vcsrepo { '/tmp/vcstest-git-wc':
ensure => present,
provider => git,
}

View file

@ -0,0 +1,6 @@
vcsrepo { '/tmp/vcstest-hg-clone':
ensure => present,
provider => hg,
source => 'http://hg.basho.com/riak',
revision => 'riak-0.5.3',
}

View file

@ -0,0 +1,7 @@
vcsrepo { '/path/to/repo':
ensure => latest,
provider => 'hg',
source => 'http://hg.example.com/myrepo',
basic_auth_username => 'hgusername',
basic_auth_password => 'hgpassword',
}

View file

@ -0,0 +1,4 @@
vcsrepo { '/tmp/vcstest-hg-init':
ensure => present,
provider => hg,
}

View file

@ -0,0 +1,4 @@
vcsrepo { '/tmp/vcstest/p4_client_root':
ensure => present,
provider => 'p4',
}

View file

@ -0,0 +1,4 @@
vcsrepo { '/tmp/vcstest/p4_client_root':
ensure => absent,
provider => 'p4',
}

View file

@ -0,0 +1,5 @@
vcsrepo { '/tmp/vcstest/p4_client_root':
ensure => latest,
provider => 'p4',
source => '//depot/...',
}

View file

@ -0,0 +1,6 @@
vcsrepo { '/tmp/vcstest/p4_client_root':
ensure => present,
provider => 'p4',
source => '//depot/...',
revision => '30',
}

View file

@ -0,0 +1,5 @@
vcsrepo { '/tmp/vcstest-svn-checkout':
ensure => present,
provider => svn,
source => 'http://svn.edgewall.org/repos/babel/trunk',
}

View file

@ -0,0 +1,4 @@
vcsrepo { '/tmp/vcstest-svn-server':
ensure => present,
provider => svn,
}

View file

@ -0,0 +1,42 @@
require 'tmpdir'
require 'digest/md5'
require 'fileutils'
# Abstract
class Puppet::Provider::Vcsrepo < Puppet::Provider
private
def set_ownership
owner = @resource.value(:owner) || nil
group = @resource.value(:group) || nil
FileUtils.chown_R(owner, group, @resource.value(:path))
end
def path_exists?
File.directory?(@resource.value(:path))
end
def path_empty?
# Path is empty if the only entries are '.' and '..'
d = Dir.new(@resource.value(:path))
d.read # should return '.'
d.read # should return '..'
d.read.nil?
end
# Note: We don't rely on Dir.chdir's behavior of automatically returning the
# value of the last statement -- for easier stubbing.
def at_path(&block) #:nodoc:
value = nil
Dir.chdir(@resource.value(:path)) do
value = yield
end
value
end
def tempdir
@tempdir ||= File.join(Dir.tmpdir, 'vcsrepo-' + Digest::MD5.hexdigest(@resource.value(:path)))
end
end

View file

@ -0,0 +1,93 @@
require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo) do
desc "Supports Bazaar repositories"
commands :bzr => 'bzr'
has_features :reference_tracking
def create
if !@resource.value(:source)
create_repository(@resource.value(:path))
else
clone_repository(@resource.value(:revision))
end
end
def working_copy_exists?
File.directory?(File.join(@resource.value(:path), '.bzr'))
end
def exists?
working_copy_exists?
end
def destroy
FileUtils.rm_rf(@resource.value(:path))
end
def revision
at_path do
current_revid = bzr('version-info')[/^revision-id:\s+(\S+)/, 1]
desired = @resource.value(:revision)
begin
desired_revid = bzr('revision-info', desired).strip.split(/\s+/).last
rescue Puppet::ExecutionFailure
# Possible revid available during update (but definitely not current)
desired_revid = nil
end
if current_revid == desired_revid
desired
else
current_revid
end
end
end
def revision=(desired)
at_path do
begin
bzr('update', '-r', desired)
rescue Puppet::ExecutionFailure
bzr('update', '-r', desired, ':parent')
end
end
update_owner
end
def latest
at_path do
bzr('version-info', ':parent')[/^revision-id:\s+(\S+)/, 1]
end
end
def latest?
at_path do
return self.revision == self.latest
end
end
private
def create_repository(path)
bzr('init', path)
update_owner
end
def clone_repository(revision)
args = ['branch']
if revision
args.push('-r', revision)
end
args.push(@resource.value(:source),
@resource.value(:path))
bzr(*args)
update_owner
end
def update_owner
if @resource.value(:owner) or @resource.value(:group)
set_ownership
end
end
end

View file

@ -0,0 +1,137 @@
require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) do
desc "Supports CVS repositories/workspaces"
commands :cvs => 'cvs'
has_features :gzip_compression, :reference_tracking, :modules, :cvs_rsh
def create
if !@resource.value(:source)
create_repository(@resource.value(:path))
else
checkout_repository
end
update_owner
end
def exists?
if @resource.value(:source)
directory = File.join(@resource.value(:path), 'CVS')
else
directory = File.join(@resource.value(:path), 'CVSROOT')
end
File.directory?(directory)
end
def working_copy_exists?
File.directory?(File.join(@resource.value(:path), 'CVS'))
end
def destroy
FileUtils.rm_rf(@resource.value(:path))
end
def latest?
debug "Checking for updates because 'ensure => latest'"
at_path do
# We cannot use -P to prune empty dirs, otherwise
# CVS would report those as "missing", regardless
# if they have contents or updates.
is_current = (runcvs('-nq', 'update', '-d').strip == "")
if (!is_current) then debug "There are updates available on the checkout's current branch/tag." end
return is_current
end
end
def latest
# CVS does not have a conecpt like commit-IDs or change
# sets, so we can only have the current branch name (or the
# requested one, if that differs) as the "latest" revision.
should = @resource.value(:revision)
current = self.revision
return should != current ? should : current
end
def revision
if !@rev
if File.exist?(tag_file)
contents = File.read(tag_file).strip
# Note: Doesn't differentiate between N and T entries
@rev = contents[1..-1]
else
@rev = 'HEAD'
end
debug "Checkout is on branch/tag '#{@rev}'"
end
return @rev
end
def revision=(desired)
at_path do
runcvs('update', '-dr', desired, '.')
update_owner
@rev = desired
end
end
private
def tag_file
File.join(@resource.value(:path), 'CVS', 'Tag')
end
def checkout_repository
dirname, basename = File.split(@resource.value(:path))
Dir.chdir(dirname) do
args = ['-d', @resource.value(:source)]
if @resource.value(:compression)
args.push('-z', @resource.value(:compression))
end
args.push('checkout')
if @resource.value(:revision)
args.push('-r', @resource.value(:revision))
end
args.push('-d', basename, module_name)
runcvs(*args)
end
end
# When the source:
# * Starts with ':' (eg, :pserver:...)
def module_name
if (m = @resource.value(:module))
m
elsif (source = @resource.value(:source))
source[0, 1] == ':' ? File.basename(source) : '.'
end
end
def create_repository(path)
runcvs('-d', path, 'init')
end
def update_owner
if @resource.value(:owner) or @resource.value(:group)
set_ownership
end
end
def runcvs(*args)
if @resource.value(:cvs_rsh)
debug "Using CVS_RSH = " + @resource.value(:cvs_rsh)
e = { :CVS_RSH => @resource.value(:cvs_rsh) }
else
e = {}
end
# The location of withenv changed from Puppet 2.x to 3.x
withenv = Puppet::Util.method(:withenv) if Puppet::Util.respond_to?(:withenv)
withenv = Puppet::Util::Execution.method(:withenv) if Puppet::Util::Execution.respond_to?(:withenv)
fail("Cannot set custom environment #{e}") if e && !withenv
withenv.call e do
Puppet.debug cvs *args
end
end
end

View file

@ -0,0 +1,12 @@
require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:dummy, :parent => Puppet::Provider::Vcsrepo) do
desc "Dummy default provider"
defaultfor :vcsrepo => :dummy
def working_copy_exists?
providers = @resource.class.providers.map{|x| x.to_s}.sort.reject{|x| x == "dummy"}.join(", ") rescue "none"
raise("vcsrepo resource must have a provider, available: #{providers}")
end
end

View file

@ -0,0 +1,373 @@
require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) do
desc "Supports Git repositories"
##TODO modify the commands below so that the su - is included
commands :git => 'git'
optional_commands :su => 'su'
has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth
def create
if @resource.value(:revision) and @resource.value(:ensure) == :bare
fail("Cannot set a revision (#{@resource.value(:revision)}) on a bare repository")
end
if !@resource.value(:source)
init_repository(@resource.value(:path))
else
clone_repository(@resource.value(:source), @resource.value(:path))
if @resource.value(:revision)
checkout
end
if @resource.value(:ensure) != :bare
update_submodules
end
end
update_owner_and_excludes
end
def destroy
FileUtils.rm_rf(@resource.value(:path))
end
# Checks to see if the current revision is equal to the revision on the
# remote (whether on a branch, tag, or reference)
#
# @return [Boolean] Returns true if the repo is on the latest revision
def latest?
return revision == latest_revision
end
# Just gives the `should` value that we should be setting the repo to if
# latest? returns false
#
# @return [String] Returns the target sha/tag/branch
def latest
@resource.value(:revision)
end
# Get the current revision of the repo (tag/branch/sha)
#
# @return [String] Returns the branch/tag if the current sha matches the
# remote; otherwise returns the current sha.
def revision
#HEAD is the default, but lets just be explicit here.
get_revision('HEAD')
end
# Is passed the desired reference, whether a tag, rev, or branch. Should
# handle transitions from a rev/branch/tag to a rev/branch/tag. Detached
# heads should be treated like bare revisions.
#
# @param [String] desired The desired revision to which the repo should be
# set.
def revision=(desired)
#just checkout tags and shas; fetch has already happened so they should be updated.
checkout(desired)
#branches require more work.
if local_branch_revision?(desired)
#reset instead of pull to avoid merge conflicts. assuming remote is
#updated and authoritative.
#TODO might be worthwhile to have an allow_local_changes param to decide
#whether to reset or pull when we're ensuring latest.
at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") }
end
#TODO Would this ever reach here if it is bare?
if @resource.value(:ensure) != :bare
update_submodules
end
update_owner_and_excludes
end
def bare_exists?
bare_git_config_exists? && !working_copy_exists?
end
def working_copy_exists?
File.directory?(File.join(@resource.value(:path), '.git'))
end
def exists?
working_copy_exists? || bare_exists?
end
def update_remote_origin_url
current = git_with_identity('config', "remote.#{@resource.value(:remote)}.url")
unless @resource.value(:source).nil?
if current.nil? or current.strip != @resource.value(:source)
git_with_identity('config', "remote.#{@resource.value(:remote)}.url", @resource.value(:source))
end
end
end
def update_references
at_path do
update_remote_origin_url
git_with_identity('fetch', @resource.value(:remote))
git_with_identity('fetch', '--tags', @resource.value(:remote))
update_owner_and_excludes
end
end
private
# @!visibility private
def bare_git_config_exists?
File.exist?(File.join(@resource.value(:path), 'config'))
end
# @!visibility private
def clone_repository(source, path)
check_force
args = ['clone']
if @resource.value(:depth) and @resource.value(:depth).to_i > 0
args.push('--depth', @resource.value(:depth).to_s)
end
if @resource.value(:ensure) == :bare
args << '--bare'
end
if @resource.value(:remote) != 'origin'
args.push('--origin', @resource.value(:remote))
end
if !working_copy_exists?
args.push(source, path)
Dir.chdir("/") do
git_with_identity(*args)
end
else
notice "Repo has already been cloned"
end
end
# @!visibility private
def check_force
if path_exists? and not path_empty?
if @resource.value(:force)
notice "Removing %s to replace with vcsrepo." % @resource.value(:path)
destroy
else
raise Puppet::Error, "Could not create repository (non-repository at path)"
end
end
end
# @!visibility private
def init_repository(path)
check_force
if @resource.value(:ensure) == :bare && working_copy_exists?
convert_working_copy_to_bare
elsif @resource.value(:ensure) == :present && bare_exists?
convert_bare_to_working_copy
else
# normal init
FileUtils.mkdir(@resource.value(:path))
FileUtils.chown(@resource.value(:user), nil, @resource.value(:path)) if @resource.value(:user)
args = ['init']
if @resource.value(:ensure) == :bare
args << '--bare'
end
at_path do
git_with_identity(*args)
end
end
end
# Convert working copy to bare
#
# Moves:
# <path>/.git
# to:
# <path>/
# @!visibility private
def convert_working_copy_to_bare
notice "Converting working copy repository to bare repository"
FileUtils.mv(File.join(@resource.value(:path), '.git'), tempdir)
FileUtils.rm_rf(@resource.value(:path))
FileUtils.mv(tempdir, @resource.value(:path))
end
# Convert bare to working copy
#
# Moves:
# <path>/
# to:
# <path>/.git
# @!visibility private
def convert_bare_to_working_copy
notice "Converting bare repository to working copy repository"
FileUtils.mv(@resource.value(:path), tempdir)
FileUtils.mkdir(@resource.value(:path))
FileUtils.mv(tempdir, File.join(@resource.value(:path), '.git'))
if commits_in?(File.join(@resource.value(:path), '.git'))
reset('HEAD')
git_with_identity('checkout', '--force')
update_owner_and_excludes
end
end
# @!visibility private
def commits_in?(dot_git)
Dir.glob(File.join(dot_git, 'objects/info/*'), File::FNM_DOTMATCH) do |e|
return true unless %w(. ..).include?(File::basename(e))
end
false
end
# Will checkout a rev/branch/tag using the locally cached versions. Does not
# handle upstream branch changes
# @!visibility private
def checkout(revision = @resource.value(:revision))
if !local_branch_revision? && remote_branch_revision?
#non-locally existant branches (perhaps switching to a branch that has never been checked out)
at_path { git_with_identity('checkout', '--force', '-b', revision, '--track', "#{@resource.value(:remote)}/#{revision}") }
else
#tags, locally existant branches (perhaps outdated), and shas
at_path { git_with_identity('checkout', '--force', revision) }
end
end
# @!visibility private
def reset(desired)
at_path do
git_with_identity('reset', '--hard', desired)
end
end
# @!visibility private
def update_submodules
at_path do
git_with_identity('submodule', 'update', '--init', '--recursive')
end
end
# Determins if the branch exists at the upstream but has not yet been locally committed
# @!visibility private
def remote_branch_revision?(revision = @resource.value(:revision))
# git < 1.6 returns '#{@resource.value(:remote)}/#{revision}'
# git 1.6+ returns 'remotes/#{@resource.value(:remote)}/#{revision}'
branch = at_path { branches.grep /(remotes\/)?#{@resource.value(:remote)}\/#{revision}/ }
branch unless branch.empty?
end
# Determins if the branch is already cached locally
# @!visibility private
def local_branch_revision?(revision = @resource.value(:revision))
at_path { branches.include?(revision) }
end
# @!visibility private
def tag_revision?(revision = @resource.value(:revision))
at_path { tags.include?(revision) }
end
# @!visibility private
def branches
at_path { git_with_identity('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip }
end
# @!visibility private
def on_branch?
at_path {
matches = git_with_identity('branch', '-a').match /\*\s+(.*)/
matches[1] unless matches[1].match /(\(detached from|\(no branch)/
}
end
# @!visibility private
def tags
at_path { git_with_identity('tag', '-l') }.split(/\n/).map { |line| line.strip }
end
# @!visibility private
def set_excludes
at_path { open('.git/info/exclude', 'w') { |f| @resource.value(:excludes).each { |ex| f.write(ex + "\n") }}}
end
# Finds the latest revision or sha of the current branch if on a branch, or
# of HEAD otherwise.
# @note Calls create which can forcibly destroy and re-clone the repo if
# force => true
# @see get_revision
#
# @!visibility private
# @return [String] Returns the output of get_revision
def latest_revision
#TODO Why is create called here anyway?
create if @resource.value(:force) && working_copy_exists?
create if !working_copy_exists?
if branch = on_branch?
return get_revision("#{@resource.value(:remote)}/#{branch}")
else
return get_revision
end
end
# Returns the current revision given if the revision is a tag or branch and
# matches the current sha. If the current sha does not match the sha of a tag
# or branch, then it will just return the sha (ie, is not in sync)
#
# @!visibility private
#
# @param [String] rev The revision of which to check if it is current
# @return [String] Returns the tag/branch of the current repo if it's up to
# date; otherwise returns the sha of the requested revision.
def get_revision(rev = 'HEAD')
update_references
current = at_path { git_with_identity('rev-parse', rev).strip }
if @resource.value(:revision)
if tag_revision?
# git-rev-parse will give you the hash of the tag object itself rather
# than the commit it points to by default. Using tag^0 will return the
# actual commit.
canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:revision)}^0").strip }
elsif local_branch_revision?
canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).strip }
elsif remote_branch_revision?
canonical = at_path { git_with_identity('rev-parse', "#{@resource.value(:remote)}/#{@resource.value(:revision)}").strip }
else
#look for a sha (could match invalid shas)
canonical = at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).strip }
end
fail("#{@resource.value(:revision)} is not a local or remote ref") if canonical.nil? or canonical.empty?
current = @resource.value(:revision) if current == canonical
end
return current
end
# @!visibility private
def update_owner_and_excludes
if @resource.value(:owner) or @resource.value(:group)
set_ownership
end
if @resource.value(:excludes)
set_excludes
end
end
# @!visibility private
def git_with_identity(*args)
if @resource.value(:identity)
Tempfile.open('git-helper') do |f|
f.puts '#!/bin/sh'
f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -oConnectTimeout=120 -i #{@resource.value(:identity)} $*"
f.close
FileUtils.chmod(0755, f.path)
env_save = ENV['GIT_SSH']
ENV['GIT_SSH'] = f.path
ret = git(*args)
ENV['GIT_SSH'] = env_save
return ret
end
elsif @resource.value(:user) and @resource.value(:user) != Facter['id'].value
su(@resource.value(:user), '-c', "git #{args.join(' ')}" )
else
git(*args)
end
end
end

View file

@ -0,0 +1,131 @@
require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) do
desc "Supports Mercurial repositories"
commands :hg => 'hg'
optional_commands :su => 'su'
has_features :reference_tracking, :ssh_identity, :user, :basic_auth
def create
if !@resource.value(:source)
create_repository(@resource.value(:path))
else
clone_repository(@resource.value(:revision))
end
update_owner
end
def working_copy_exists?
File.directory?(File.join(@resource.value(:path), '.hg'))
end
def exists?
working_copy_exists?
end
def destroy
FileUtils.rm_rf(@resource.value(:path))
end
def latest?
at_path do
return self.revision == self.latest
end
end
def latest
at_path do
begin
hg_wrapper('incoming', '--branch', '.', '--newest-first', '--limit', '1', { :remote => true })[/^changeset:\s+(?:-?\d+):(\S+)/m, 1]
rescue Puppet::ExecutionFailure
# If there are no new changesets, return the current nodeid
self.revision
end
end
end
def revision
at_path do
current = hg_wrapper('parents')[/^changeset:\s+(?:-?\d+):(\S+)/m, 1]
desired = @resource.value(:revision)
if desired
# Return the tag name if it maps to the current nodeid
mapped = hg_wrapper('tags')[/^#{Regexp.quote(desired)}\s+\d+:(\S+)/m, 1]
if current == mapped
desired
else
current
end
else
current
end
end
end
def revision=(desired)
at_path do
begin
hg_wrapper('pull', { :remote => true })
rescue
end
begin
hg_wrapper('merge')
rescue Puppet::ExecutionFailure
# If there's nothing to merge, just skip
end
hg_wrapper('update', '--clean', '-r', desired)
end
update_owner
end
private
def create_repository(path)
hg_wrapper('init', path)
end
def clone_repository(revision)
args = ['clone']
if revision
args.push('-u', revision)
end
args.push(@resource.value(:source),
@resource.value(:path))
args.push({ :remote => true })
hg_wrapper(*args)
end
def update_owner
if @resource.value(:owner) or @resource.value(:group)
set_ownership
end
end
def hg_wrapper(*args)
options = { :remote => false }
if args.length > 0 and args[-1].is_a? Hash
options.merge!(args.pop)
end
if @resource.value(:basic_auth_username) && @resource.value(:basic_auth_password)
args += [
"--config", "\"auth.x.prefix=#{@resource.value(:source)}\"",
"--config", "\"auth.x.username=#{@resource.value(:basic_auth_username)}\"",
"--config", "\"auth.x.password=#{@resource.value(:basic_auth_password)}\"",
"--config", "\"auth.x.schemes=http https\""
]
end
if options[:remote] and @resource.value(:identity)
args += ["--ssh", "ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -i #{@resource.value(:identity)}"]
end
if @resource.value(:user) and @resource.value(:user) != Facter['id'].value
args.map! { |a| if a =~ /\s/ then "'#{a}'" else a end } # Adds quotes to arguments with whitespaces.
su(@resource.value(:user), '-c', "hg #{args.join(' ')}")
else
hg(*args)
end
end
end

View file

@ -0,0 +1,278 @@
require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) do
desc "Supports Perforce depots"
has_features :filesystem_types, :reference_tracking, :p4config
def create
# create or update client
create_client(client_name)
# if source provided, sync client
source = @resource.value(:source)
if source
revision = @resource.value(:revision)
sync_client(source, revision)
end
update_owner
end
def working_copy_exists?
# Check if the server is there, or raise error
p4(['info'], {:marshal => false})
# Check if workspace is setup
args = ['where']
args.push(@resource.value(:path) + "...")
hash = p4(args, {:raise => false})
return (hash['code'] != "error")
end
def exists?
working_copy_exists?
end
def destroy
args = ['client']
args.push('-d', '-f')
args.push(client_name)
p4(args)
FileUtils.rm_rf(@resource.value(:path))
end
def latest?
rev = self.revision
if rev
(rev >= self.latest)
else
true
end
end
def latest
args = ['changes']
args.push('-m1', @resource.value(:source))
hash = p4(args)
return hash['change'].to_i
end
def revision
args = ['cstat']
args.push(@resource.value(:source))
hash = p4(args, {:marshal => false})
hash = marshal_cstat(hash)
revision = 0
if hash && hash['code'] != 'error'
hash['data'].each do |c|
if c['status'] == 'have'
change = c['change'].to_i
revision = change if change > revision
end
end
end
return revision
end
def revision=(desired)
sync_client(@resource.value(:source), desired)
update_owner
end
private
def update_owner
if @resource.value(:owner) or @resource.value(:group)
set_ownership
end
end
# Sync the client workspace files to head or specified revision.
# Params:
# +source+:: Depot path to sync
# +revision+:: Perforce change list to sync to (optional)
def sync_client(source, revision)
Puppet.debug "Syncing: #{source}"
args = ['sync']
if revision
args.push(source + "@#{revision}")
else
args.push(source)
end
p4(args)
end
# Returns the name of the Perforce client workspace
def client_name
p4config = @resource.value(:p4config)
# default (generated) client name
path = @resource.value(:path)
host = Facter.value('hostname')
default = "puppet-" + Digest::MD5.hexdigest(path + host)
# check config for client name
set_client = nil
if p4config && File.file?(p4config)
open(p4config) do |f|
m = f.grep(/^P4CLIENT=/).pop
p = /^P4CLIENT=(.*)$/
set_client = p.match(m)[1] if m
end
end
return set_client || ENV['P4CLIENT'] || default
end
# Create (or update) a client workspace spec.
# If a client name is not provided then a hash based on the path is used.
# Params:
# +client+:: Name of client workspace
# +path+:: The Root location of the Perforce client workspace
def create_client(client)
Puppet.debug "Creating client: #{client}"
# fetch client spec
hash = parse_client(client)
hash['Root'] = @resource.value(:path)
hash['Description'] = "Generated by Puppet VCSrepo"
# check is source is a Stream
source = @resource.value(:source)
if source
parts = source.split(/\//)
if parts && parts.length >= 4
source = "//" + parts[2] + "/" + parts[3]
streams = p4(['streams', source], {:raise => false})
if streams['code'] == "stat"
hash['Stream'] = streams['Stream']
notice "Streams" + streams['Stream'].inspect
end
end
end
# save client spec
save_client(hash)
end
# Fetches a client workspace spec from Perforce and returns a hash map representation.
# Params:
# +client+:: name of the client workspace
def parse_client(client)
args = ['client']
args.push('-o', client)
hash = p4(args)
return hash
end
# Saves the client workspace spec from the given hash
# Params:
# +hash+:: hash map of client spec
def save_client(hash)
spec = String.new
view = "\nView:\n"
hash.keys.sort.each do |k|
v = hash[k]
next if( k == "code" )
if(k.to_s =~ /View/ )
view += "\t#{v}\n"
else
spec += "#{k.to_s}: #{v.to_s}\n"
end
end
spec += view
args = ['client']
args.push('-i')
p4(args, {:input => spec, :marshal => false})
end
# Sets Perforce Configuration environment.
# P4CLIENT generated, but overwitten if defined in config.
def config
p4config = @resource.value(:p4config)
cfg = Hash.new
cfg.store 'P4CONFIG', p4config if p4config
cfg.store 'P4CLIENT', client_name
return cfg
end
def p4(args, options = {})
# Merge custom options with defaults
opts = {
:raise => true, # Raise errors
:marshal => true, # Marshal output
}.merge(options)
cmd = ['p4']
cmd.push '-R' if opts[:marshal]
cmd.push args
cmd_str = cmd.respond_to?(:join) ? cmd.join(' ') : cmd
Puppet.debug "environment: #{config}"
Puppet.debug "command: #{cmd_str}"
hash = Hash.new
Open3.popen3(config, cmd_str) do |i, o, e, t|
# Send input stream if provided
if(opts[:input])
Puppet.debug "input:\n" + opts[:input]
i.write opts[:input]
i.close
end
if(opts[:marshal])
hash = Marshal.load(o)
else
hash['data'] = o.read
end
# Raise errors, Perforce or Exec
if(opts[:raise] && !e.eof && t.value != 0)
raise Puppet::Error, "\nP4: #{e.read}"
end
if(opts[:raise] && hash['code'] == 'error' && t.value != 0)
raise Puppet::Error, "\nP4: #{hash['data']}"
end
end
Puppet.debug "hash: #{hash}\n"
return hash
end
# helper method as cstat does not Marshal
def marshal_cstat(hash)
data = hash['data']
code = 'error'
list = Array.new
change = Hash.new
data.each_line do |l|
p = /^\.\.\. (.*) (.*)$/
m = p.match(l)
if m
change[m[1]] = m[2]
if m[1] == 'status'
code = 'stat'
list.push change
change = Hash.new
end
end
end
hash = Hash.new
hash.store 'code', code
hash.store 'data', list
return hash
end
end

View file

@ -0,0 +1,126 @@
require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) do
desc "Supports Subversion repositories"
commands :svn => 'svn',
:svnadmin => 'svnadmin',
:svnlook => 'svnlook'
has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration
def create
if !@resource.value(:source)
create_repository(@resource.value(:path))
else
checkout_repository(@resource.value(:source),
@resource.value(:path),
@resource.value(:revision))
end
update_owner
end
def working_copy_exists?
if File.directory?(@resource.value(:path))
# :path is an svn checkout
return true if File.directory?(File.join(@resource.value(:path), '.svn'))
if File.directory?(File.join(@resource.value(:path), 'format'))
# :path is an svn server
return true if svnlook('uuid', @resource.value(:path))
end
end
false
end
def exists?
working_copy_exists?
end
def destroy
FileUtils.rm_rf(@resource.value(:path))
end
def latest?
at_path do
(self.revision >= self.latest) and (@resource.value(:source) == self.sourceurl)
end
end
def buildargs
args = ['--non-interactive']
if @resource.value(:basic_auth_username) && @resource.value(:basic_auth_password)
args.push('--username', @resource.value(:basic_auth_username))
args.push('--password', @resource.value(:basic_auth_password))
args.push('--no-auth-cache')
end
if @resource.value(:force)
args.push('--force')
end
if @resource.value(:configuration)
args.push('--config-dir', @resource.value(:configuration))
end
args
end
def latest
args = buildargs.push('info', '-r', 'HEAD')
at_path do
svn(*args)[/^Revision:\s+(\d+)/m, 1]
end
end
def sourceurl
args = buildargs.push('info')
at_path do
svn(*args)[/^URL:\s+(\S+)/m, 1]
end
end
def revision
args = buildargs.push('info')
at_path do
svn(*args)[/^Revision:\s+(\d+)/m, 1]
end
end
def revision=(desired)
args = if @resource.value(:source)
buildargs.push('switch', '-r', desired, @resource.value(:source))
else
buildargs.push('update', '-r', desired)
end
at_path do
svn(*args)
end
update_owner
end
private
def checkout_repository(source, path, revision)
args = buildargs.push('checkout')
if revision
args.push('-r', revision)
end
args.push(source, path)
svn(*args)
end
def create_repository(path)
args = ['create']
if @resource.value(:fstype)
args.push('--fs-type', @resource.value(:fstype))
end
args << path
svnadmin(*args)
end
def update_owner
if @resource.value(:owner) or @resource.value(:group)
set_ownership
end
end
end

View file

@ -0,0 +1,221 @@
require 'pathname'
Puppet::Type.newtype(:vcsrepo) do
desc "A local version control repository"
feature :gzip_compression,
"The provider supports explicit GZip compression levels"
feature :basic_auth,
"The provider supports HTTP Basic Authentication"
feature :bare_repositories,
"The provider differentiates between bare repositories
and those with working copies",
:methods => [:bare_exists?, :working_copy_exists?]
feature :filesystem_types,
"The provider supports different filesystem types"
feature :reference_tracking,
"The provider supports tracking revision references that can change
over time (eg, some VCS tags and branch names)"
feature :ssh_identity,
"The provider supports a configurable SSH identity file"
feature :user,
"The provider can run as a different user"
feature :modules,
"The repository contains modules that can be chosen of"
feature :multiple_remotes,
"The repository tracks multiple remote repositories"
feature :configuration,
"The configuration directory to use"
feature :cvs_rsh,
"The provider understands the CVS_RSH environment variable"
feature :depth,
"The provider can do shallow clones"
feature :p4config,
"The provider understands Perforce Configuration"
ensurable do
attr_accessor :latest
def insync?(is)
@should ||= []
case should
when :present
return true unless [:absent, :purged, :held].include?(is)
when :latest
if is == :latest
return true
else
return false
end
when :bare
return is == :bare
end
end
newvalue :present do
notice "Creating repository from present"
provider.create
end
newvalue :bare, :required_features => [:bare_repositories] do
if !provider.exists?
provider.create
end
end
newvalue :absent do
provider.destroy
end
newvalue :latest, :required_features => [:reference_tracking] do
if provider.exists? && !@resource.value(:force)
if provider.respond_to?(:update_references)
provider.update_references
end
if provider.respond_to?(:latest?)
reference = provider.latest || provider.revision
else
reference = resource.value(:revision) || provider.revision
end
notice "Updating to latest '#{reference}' revision"
provider.revision = reference
else
notice "Creating repository from latest"
provider.create
end
end
def retrieve
prov = @resource.provider
if prov
if prov.working_copy_exists?
if @resource.value(:force)
if noop
notice "Noop Mode - Would have deleted repository and re-created from latest"
else
notice "Deleting current repository before recloning"
prov.destroy
notice "Create repository from latest"
prov.create
end
end
(@should.include?(:latest) && prov.latest?) ? :latest : :present
elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
:bare
else
:absent
end
else
raise Puppet::Error, "Could not find provider"
end
end
end
newparam :path do
desc "Absolute path to repository"
isnamevar
validate do |value|
path = Pathname.new(value)
unless path.absolute?
raise ArgumentError, "Path must be absolute: #{path}"
end
end
end
newparam :source do
desc "The source URI for the repository"
end
newparam :fstype, :required_features => [:filesystem_types] do
desc "Filesystem type"
end
newproperty :revision do
desc "The revision of the repository"
newvalue(/^\S+$/)
end
newparam :owner do
desc "The user/uid that owns the repository files"
end
newparam :group do
desc "The group/gid that owns the repository files"
end
newparam :user do
desc "The user to run for repository operations"
end
newparam :excludes do
desc "Files to be excluded from the repository"
end
newparam :force do
desc "Force repository creation, destroying any files on the path in the process."
newvalues(:true, :false)
defaultto false
end
newparam :compression, :required_features => [:gzip_compression] do
desc "Compression level"
validate do |amount|
unless Integer(amount).between?(0, 6)
raise ArgumentError, "Unsupported compression level: #{amount} (expected 0-6)"
end
end
end
newparam :basic_auth_username, :required_features => [:basic_auth] do
desc "HTTP Basic Auth username"
end
newparam :basic_auth_password, :required_features => [:basic_auth] do
desc "HTTP Basic Auth password"
end
newparam :identity, :required_features => [:ssh_identity] do
desc "SSH identity file"
end
newparam :module, :required_features => [:modules] do
desc "The repository module to manage"
end
newparam :remote, :required_features => [:multiple_remotes] do
desc "The remote repository to track"
defaultto "origin"
end
newparam :configuration, :required_features => [:configuration] do
desc "The configuration directory to use"
end
newparam :cvs_rsh, :required_features => [:cvs_rsh] do
desc "The value to be used for the CVS_RSH environment variable."
end
newparam :depth, :required_features => [:depth] do
desc "The value to be used to do a shallow clone."
end
newparam :p4config, :required_features => [:p4config] do
desc "The Perforce P4CONFIG environment."
end
autorequire(:package) do
['git', 'git-core']
end
end

View file

@ -0,0 +1,78 @@
{
"name": "puppetlabs-vcsrepo",
"version": "1.1.0",
"author": "Puppet Labs",
"summary": "Puppet module providing a type to manage repositories from various version control systems",
"license": "GPLv2",
"source": "https://github.com/puppetlabs/puppetlabs-vcsrepo",
"project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo",
"issues_url": "https://github.com/puppetlabs/puppetlabs-vcsrepo/issues",
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"5",
"6",
"7"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"11 SP1"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"10.04",
"12.04",
"14.04"
]
}
],
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 < 3.4.0"
},
{
"name": "puppet",
"version_requirement": "3.x"
}
],
"dependencies": [
]
}

View file

@ -0,0 +1,69 @@
test_name 'C3492 - checkout with basic auth (http protocol)'
skip_test 'HTTP not supported yet for basic auth using git. See FM-1331'
# Globals
repo_name = 'testrepo_checkout'
user = 'foo'
password = 'bar'
http_server_script = 'basic_auth_http_daemon.rb'
hosts.each do |host|
ruby = '/opt/puppet/bin/ruby' if host.is_pe? || 'ruby'
gem = '/opt/puppet/bin/gem' if host.is_pe? || 'gem'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start http server' do
script =<<-EOF
require 'sinatra'
set :bind, '0.0.0.0'
set :static, true
set :public_folder, '#{tmpdir}'
use Rack::Auth::Basic do |username, password|
username == '#{user}' && password == '#{password}'
end
EOF
create_remote_file(host, "#{tmpdir}/#{http_server_script}", script)
on(host, "#{gem} install sinatra")
on(host, "#{ruby} #{tmpdir}/#{http_server_script} &")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'checkout with puppet using basic auth' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "http://#{host}:4567/testrepo.git",
provider => git,
basic_auth_username => '#{user}',
basic_auth_password => '#{password}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,77 @@
test_name 'C3493 - checkout with basic auth (https protocol)'
skip_test 'waiting for CA trust solution'
# Globals
repo_name = 'testrepo_checkout'
user = 'foo'
password = 'bar'
http_server_script = 'basic_auth_https_daemon.rb'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start https server' do
script =<<-EOF
require 'webrick'
require 'webrick/https'
authenticate = Proc.new do |req, res|
WEBrick::HTTPAuth.basic_auth(req, res, '') do |user, password|
user == '#{user}' && password == '#{password}'
end
end
server = WEBrick::HTTPServer.new(
:Port => 8443,
:DocumentRoot => "#{tmpdir}",
:DocumentRootOptions=> {:HandlerCallback => authenticate},
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, "#{tmpdir}/#{http_server_script}", script)
on(host, "#{ruby} #{tmpdir}/#{http_server_script}")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} #{tmpdir}/#{http_server_script}' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'checkout with puppet using basic auth' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "http://#{host}:8443/testrepo.git",
provider => git,
basic_auth_username => '#{user}',
basic_auth_password => '#{password}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,53 @@
test_name 'C3494 - checkout with basic auth (git protocol)'
# Globals
repo_name = 'testrepo_checkout'
user = 'foo'
password = 'bar'
http_server_script = 'basic_auth_http_daemon.rb'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start git daemon' do
install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'pkill -9 git-daemon ; sleep 1')
end
step 'checkout with puppet using basic auth' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "git://#{host}/testrepo.git",
provider => git,
basic_auth_username => '#{user}',
basic_auth_password => '#{password}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout (silent error for basic auth using git protocol)" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,48 @@
test_name 'C3438 - checkout a branch (file protocol)'
# Globals
repo_name = 'testrepo_branch_checkout'
branch = 'a_branch'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout a branch with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
revision => '#{branch}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the #{branch} branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
end
end
end

View file

@ -0,0 +1,48 @@
test_name 'C3437 - checkout a branch (file path)'
# Globals
repo_name = 'testrepo_branch_checkout'
branch = 'a_branch'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout a branch with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "#{tmpdir}/testrepo.git",
provider => git,
revision => '#{branch}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the #{branch} branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
end
end
end

View file

@ -0,0 +1,53 @@
test_name 'C3436 - checkout a branch (git protocol)'
# Globals
repo_name = 'testrepo_branch_checkout'
branch = 'a_branch'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start git daemon' do
install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'pkill -9 git-daemon ; sleep 1')
end
step 'checkout a branch with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "git://#{host}/testrepo.git",
provider => git,
revision => '#{branch}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the #{branch} branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
end
end
end

View file

@ -0,0 +1,61 @@
test_name 'C3441 - checkout a branch (http protocol)'
# Globals
repo_name = 'testrepo_branch_checkout'
branch = 'a_branch'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start http server' do
http_daemon =<<-EOF
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
on(host, "#{ruby} /tmp/http_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'checkout a branch with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "http://#{host}:8000/testrepo.git",
provider => git,
revision => '#{branch}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the #{branch} branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
end
end
end

View file

@ -0,0 +1,68 @@
test_name 'C3442 - checkout a branch (https protocol)'
# Globals
repo_name = 'testrepo_branch_checkout'
branch = 'a_branch'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start https server' do
https_daemon =<<-EOF
require 'webrick'
require 'webrick/https'
server = WEBrick::HTTPServer.new(
:Port => 8443,
:DocumentRoot => "#{tmpdir}",
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
#on(host, "#{ruby} /tmp/https_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'checkout a branch with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "https://github.com/johnduarte/testrepo.git",
provider => git,
revision => '#{branch}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the #{branch} branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
end
end
end

View file

@ -0,0 +1,59 @@
test_name 'C3439 - checkout a branch (ssh protocol, scp syntax)'
# Globals
repo_name = 'testrepo_branch_checkout'
branch = 'a_branch'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'checkout a branch with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "root@#{host}:#{tmpdir}/testrepo.git",
provider => git,
revision => '#{branch}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the #{branch} branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
end
end
end

View file

@ -0,0 +1,59 @@
test_name 'C3440 - checkout a branch (ssh protocol)'
# Globals
repo_name = 'testrepo_branch_checkout'
branch = 'a_branch'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'checkout a branch with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
provider => git,
revision => '#{branch}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the #{branch} branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
end
end
end

View file

@ -0,0 +1,46 @@
test_name 'C3609 - checkout a branch that does not exist'
# Globals
repo_name = 'testrepo_branch_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout branch that does not exist with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
revision => 'non_existent_branch',
}
EOS
apply_manifest_on(host, pp, :expect_failures => true)
end
step 'verify that master branch is checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,46 @@
test_name 'C3427 - clone (file protocol)'
# Globals
repo_name = 'testrepo_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'clone with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the master branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,46 @@
test_name 'C3426 - clone (file path)'
# Globals
repo_name = 'testrepo_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'clone with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "#{tmpdir}/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the master branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,51 @@
test_name 'C3425 - clone (git protocol)'
# Globals
repo_name = 'testrepo_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start git daemon' do
install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'pkill -9 git-daemon ; sleep 1')
end
step 'clone with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "git://#{host}/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the master branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,59 @@
test_name 'C3430 - clone (http protocol)'
# Globals
repo_name = 'testrepo_clone'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start http server' do
http_daemon =<<-EOF
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
on(host, "#{ruby} /tmp/http_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'clone with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "http://#{host}:8000/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the master branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,66 @@
test_name 'C3431 - clone (https protocol)'
# Globals
repo_name = 'testrepo_clone'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start https server' do
https_daemon =<<-EOF
require 'webrick'
require 'webrick/https'
server = WEBrick::HTTPServer.new(
:Port => 8443,
:DocumentRoot => "#{tmpdir}",
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
#on(host, "#{ruby} /tmp/https_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'clone with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "https://github.com/johnduarte/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the master branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,49 @@
test_name 'C3511 - clone over an existing repo with force'
# Globals
repo_name = 'testrepo_already_exists'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
on(host, "mkdir #{tmpdir}/#{repo_name}")
on(host, "cd #{tmpdir}/#{repo_name} && git init")
on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'clone over existing repo with force using puppet' do
on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
@existing_sha = res.stdout
end
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
force => true,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify new repo has replaced old one' do
on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
fail_test('original repo not replaced by force') if res.stdout.include? "#{@existing_sha}"
end
end
end

View file

@ -0,0 +1,46 @@
test_name 'C3507 - clone repo with excludes in repo'
# Globals
repo_name = 'testrepo_with_excludes_in_repo'
exclude1 = 'file1.txt'
exclude2 ='file2.txt'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'clone repo with excludes in repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
excludes => [ '#{exclude1}', '#{exclude2}' ],
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify exludes are known to git' do
on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res|
fail_test('exclude not found') unless res.stdout.include? "#{exclude1}"
fail_test('exclude not found') unless res.stdout.include? "#{exclude2}"
end
end
end

View file

@ -0,0 +1,46 @@
test_name 'C3508 - clone repo with excludes not in repo'
# Globals
repo_name = 'testrepo_with_excludes_not_in_repo'
exclude1 = 'worh02o'
exclude2 ='ho398b'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'clone repo with excludes not in repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
excludes => [ '#{exclude1}', '#{exclude2}' ],
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify exludes are known to git' do
on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res|
fail_test('exclude not found') unless res.stdout.include? "#{exclude1}"
fail_test('exclude not found') unless res.stdout.include? "#{exclude2}"
end
end
end

View file

@ -0,0 +1,57 @@
test_name 'C3428 - clone (ssh protocol, scp syntax)'
# Globals
repo_name = 'testrepo_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'clone with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "root@#{host}:#{tmpdir}/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the master branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,57 @@
test_name 'C3429 - clone (ssh protocol)'
# Globals
repo_name = 'testrepo_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'clone with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is on the master branch" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('master not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,48 @@
test_name 'C3482 - clone over an existing repo'
# Globals
repo_name = 'testrepo_already_exists'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
on(host, "mkdir #{tmpdir}/#{repo_name}")
on(host, "cd #{tmpdir}/#{repo_name} && git init")
on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'clone over existing repo using puppet' do
on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
@existing_sha = res.stdout
end
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify original repo was not replaced' do
on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res|
fail_test('original repo was replaced without force') unless res.stdout.include? "#{@existing_sha}"
end
end
end

View file

@ -0,0 +1,45 @@
test_name 'C3509 - clone repo with excludes not in repo'
skip_test 'expectations not defined'
# Globals
repo_name = 'testrepo_with_excludes_not_in_repo'
exclude1 = "`exec \"rm -rf /tmp\"`"
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'clone repo with excludes not in repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
excludes => [ '#{exclude1}' ],
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify excludes are known to git' do
on(host, "cat #{tmpdir}/#{repo_name}/.git/info/exclude") do |res|
fail_test('exclude not found') unless res.stdout.include? "#{exclude1}"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3495 - checkout with compression 0'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 0 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 0,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3496 - checkout with compression 1'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 1 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3497 - checkout with compression 2'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 2 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 2,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3498 - checkout with compression 3'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 3 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 3,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3499 - checkout with compression 4'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 4 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 4,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3500 - checkout with compression 5'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 5 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 5,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3501 - checkout with compression 6'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 6 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 6,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3503 - checkout with compression 7'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 7 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 7,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3505 - checkout with compression alpha'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression alpha with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => abcde,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3504 - checkout with compression 10-5'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression 10-5 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => 10-5,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3506 - checkout with compression exec'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression exec with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => "exec 'rm -rf /tmp'",
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3502 - checkout with compression -1'
# Globals
repo_name = 'testrepo_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout with compression -1 with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
compression => -1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify git repo was checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
end
end

View file

@ -0,0 +1,40 @@
test_name 'C3472 - create bare repo that already exists'
# Globals
repo_name = 'testrepo_bare_repo_already_exists.git'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create bare repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
on(host, "mkdir #{tmpdir}/#{repo_name}")
on(host, "cd #{tmpdir}/#{repo_name} && git --bare init")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'create bare repo that already exists using puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => bare,
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify repo does not contain .git directory' do
on(host, "ls -al #{tmpdir}/#{repo_name}") do |res|
fail_test "found .git for #{repo_name}" if res.stdout.include? ".git"
end
end
end

View file

@ -0,0 +1,42 @@
test_name 'C3470 - create repo that already exists'
# Globals
repo_name = 'testrepo_already_exists'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
on(host, "cd #{tmpdir} && git clone file://#{tmpdir}/testrepo.git #{repo_name}")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'create repo that already exists using puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
provider => git,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify repo is on master branch' do
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
assert_match(/ref: refs\/heads\/master/, stdout, "Git checkout not on master on #{host}")
end
end
end

View file

@ -0,0 +1,38 @@
test_name 'C3473 - create bare repo specifying revision'
# Globals
repo_name = 'testrepo_bare.git'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'create bare repo specifying revision using puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => bare,
revision => master,
provider => git,
}
EOS
apply_manifest_on(host, pp, :expect_failures => true)
end
step 'verify repo does not contain .git directory' do
on(host, "ls -al #{tmpdir}") do |res|
fail_test "found repo for #{repo_name}" if res.stdout.include? repo_name
end
end
end

View file

@ -0,0 +1,53 @@
test_name 'C3487 - checkout as a group (file protocol)'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - create group' do
apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
step 'checkout as a group with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify git checkout is own by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,53 @@
test_name 'C3486 - checkout as a group (file path)'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - create group' do
apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
step 'checkout a group with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "#{tmpdir}/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify git checkout is own by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,58 @@
test_name 'C3485 - checkout as a group (git protocol)'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start git daemon' do
install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
end
step 'setup - create group' do
apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'pkill -9 git-daemon ; sleep 1')
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
step 'checkout a group with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "git://#{host}/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify git checkout is own by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,66 @@
test_name 'C3490 - checkout as a group (http protocol)'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start http server' do
http_daemon =<<-EOF
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
on(host, "#{ruby} /tmp/http_daemon.rb")
end
step 'setup - create group' do
apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
step 'checkout a group with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "http://#{host}:8000/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify git checkout is own by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,73 @@
test_name 'C3491 - checkout as a group (https protocol)'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start https server' do
https_daemon =<<-EOF
require 'webrick'
require 'webrick/https'
server = WEBrick::HTTPServer.new(
:Port => 8443,
:DocumentRoot => "#{tmpdir}",
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
#on(host, "#{ruby} /tmp/https_daemon.rb")
end
step 'setup - create group' do
apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
step 'checkout as a group with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "https://github.com/johnduarte/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify git checkout is own by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,64 @@
test_name 'C3488 - checkout as a group (ssh protocol, scp syntax)'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
step 'setup - create group' do
apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
step 'checkout as a group with puppet (scp syntax)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "root@#{host}:#{tmpdir}/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify git checkout is own by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,64 @@
test_name 'C3489 - checkout as a group (ssh protocol)'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
step 'setup - create group' do
apply_manifest_on(host, "group { '#{group}': ensure => present, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
step 'checkout as a group with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify git checkout is own by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') unless res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,51 @@
test_name 'C3484 - checkout as a group that is not on system'
# Globals
repo_name = 'testrepo_group_checkout'
group = 'mygroup'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - delete group' do
apply_manifest_on(host, "group { '#{group}': ensure => absent, }", :catch_failures => true)
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout as a group with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
group => '#{group}',
}
EOS
apply_manifest_on(host, pp, :expect_failures => true)
end
step "verify git checkout is NOT owned by group #{group}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "stat --format '%U:%G' #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('checkout not owned by group') if res.stdout.include? ":#{group}"
end
end
end

View file

@ -0,0 +1,46 @@
test_name 'C3614 - checkout a revision that does not exist'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout revision that does not exist with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
revision => '11111111111111111',
}
EOS
apply_manifest_on(host, pp, :expect_failures => true)
end
step 'verify that master revision is checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,53 @@
test_name 'C3452 - checkout a revision (file protocol)'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'get revision sha from repo' do
on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
@sha = res.stdout.chomp
end
end
step 'checkout a revision with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
revision => '#{@sha}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify repo is checked out to revision #{@sha}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "#{@sha}"
end
end
end

View file

@ -0,0 +1,53 @@
test_name 'C3451 - checkout a revision (file path)'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'get revision sha from repo' do
on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
@sha = res.stdout.chomp
end
end
step 'checkout a revision with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "#{tmpdir}/testrepo.git",
provider => git,
revision => '#{@sha}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify repo is checked out to revision #{@sha}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "#{@sha}"
end
end
end

View file

@ -0,0 +1,58 @@
test_name 'C3450 - checkout a revision (git protocol)'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start git daemon' do
install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'pkill -9 git-daemon ; sleep 1')
end
step 'get revision sha from repo' do
on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
@sha = res.stdout.chomp
end
end
step 'checkout a revision with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "git://#{host}/testrepo.git",
provider => git,
revision => '#{@sha}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is set to revision #{@sha}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "#{@sha}"
end
end
end

View file

@ -0,0 +1,66 @@
test_name 'C3455 - checkout a revision (http protocol)'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start http server' do
http_daemon =<<-EOF
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
on(host, "#{ruby} /tmp/http_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/http_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'get revision sha from repo' do
on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
@sha = res.stdout.chomp
end
end
step 'checkout a revision with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "http://#{host}:8000/testrepo.git",
provider => git,
revision => '#{@sha}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is set to revision #{@sha}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "#{@sha}"
end
end
end

View file

@ -0,0 +1,74 @@
test_name 'C3456 - checkout a revision (https protocol)'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start https server' do
https_daemon =<<-EOF
require 'webrick'
require 'webrick/https'
server = WEBrick::HTTPServer.new(
:Port => 8443,
:DocumentRoot => "#{tmpdir}",
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
#on(host, "#{ruby} /tmp/https_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, "ps ax | grep '#{ruby} /tmp/https_daemon.rb' | grep -v grep | awk '{print \"kill -9 \" $1}' | sh ; sleep 1")
end
step 'get revision sha from repo' do
on(host, "git clone https://github.com/johnduarte/testrepo.git #{tmpdir}/foo")
on(host, "git --git-dir=#{tmpdir}/foo/.git rev-list HEAD | tail -1") do |res|
@sha = res.stdout.chomp
end
end
step 'checkout a revision with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "https://github.com/johnduarte/testrepo.git",
provider => git,
revision => '#{@sha}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is set to revision #{@sha}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "#{@sha}"
end
end
end

View file

@ -0,0 +1,64 @@
test_name 'C3453 - checkout a revision (ssh protocol, scp syntax)'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'get revision sha from repo' do
on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
@sha = res.stdout.chomp
end
end
step 'checkout a revision with puppet (scp syntax)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "root@#{host}:#{tmpdir}/testrepo.git",
provider => git,
revision => '#{@sha}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is set to revision #{@sha}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "#{@sha}"
end
end
end

View file

@ -0,0 +1,64 @@
test_name 'C3454 - checkout a revision (ssh protocol)'
# Globals
repo_name = 'testrepo_revision_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'get revision sha from repo' do
on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
@sha = res.stdout.chomp
end
end
step 'checkout a revision with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
provider => git,
revision => '#{@sha}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout is set to revision #{@sha}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('revision not found') unless res.stdout.include? "#{@sha}"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3608 - shallow clone repo depth hostile input'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
depth => "exec 'rm -rf /tmp'",
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is NOT shallow' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') if res.stdout.include? "shallow"
end
end
end

View file

@ -0,0 +1,44 @@
test_name 'C3475 - shallow clone repo minimal depth = 1 (file path protocol)'
skip_test 'Not currently supported. See FM-1285'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'shallow clone repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "#{tmpdir}/testrepo.git",
provider => git,
depth => 1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'git does not support shallow clone via file path: verify checkout is NOT created' do
on(host, "ls #{tmpdir}") do |res|
fail_test('checkout found') if res.stdout.include? "#{repo_name}"
end
end
end

View file

@ -0,0 +1,55 @@
test_name 'C3479 - shallow clone repo minimal depth = 1 (http protocol)'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start http server' do
http_daemon =<<-EOF
require 'webrick'
server = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => "#{tmpdir}")
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/http_daemon.rb', http_daemon)
on(host, "#{ruby} /tmp/http_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'ps ax | grep "#{ruby} /tmp/http_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh ; sleep 1')
end
step 'shallow clone repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "http://#{host}:8000/testrepo.git",
provider => git,
depth => 1,
}
EOS
apply_manifest_on(host, pp, :expect_failures => true)
end
step 'git does not support shallow clone via HTTP: verify checkout is NOT created' do
on(host, "ls #{tmpdir}") do |res|
fail_test('checkout found') if res.stdout.include? "#{repo_name}"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3607 - shallow clone repo depth = -1'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
depth => -1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is NOT shallow' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') if res.stdout.include? "shallow"
end
end
end

View file

@ -0,0 +1,45 @@
test_name 'C3606 - shallow clone repo depth overflow 64bit integer'
# Globals
repo_name = 'testrepo_shallow_clone'
pending_test("The overflow can't be handled on some git versions")
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'shallow clone repo with puppet (bad input ignored, full clone checkedout)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
depth => 18446744073709551616,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is NOT shallow' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') if res.stdout.include? "shallow"
end
end
end

View file

@ -0,0 +1,47 @@
test_name 'C3476 - shallow clone repo minimal depth = 1 (file protocol)'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'shallow clone repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
depth => 1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is shallow and of the correct depth' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') unless res.stdout.include? "shallow"
end
on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
end
end
end

View file

@ -0,0 +1,52 @@
test_name 'C3474 - shallow clone repo minimal depth = 1 (git protocol)'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start git daemon' do
install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'pkill -9 git-daemon ; sleep 1')
end
step 'shallow clone repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "git://#{host}/testrepo.git",
provider => git,
depth => 1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is shallow and of the correct depth' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') unless res.stdout.include? "shallow"
end
on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
end
end
end

View file

@ -0,0 +1,68 @@
test_name 'C3480 - shallow clone repo minimal depth = 1 (https protocol)'
skip_test 'Not currently supported. See FM-1286'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
ruby = (host.is_pe? && '/opt/puppet/bin/ruby') || 'ruby'
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - start https server' do
https_daemon =<<-EOF
require 'webrick'
require 'webrick/https'
server = WEBrick::HTTPServer.new(
:Port => 8443,
:DocumentRoot => "#{tmpdir}",
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => OpenSSL::X509::Certificate.new( File.open("#{tmpdir}/server.crt").read),
:SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open("#{tmpdir}/server.key").read),
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ])
WEBrick::Daemon.start
server.start
EOF
create_remote_file(host, '/tmp/https_daemon.rb', https_daemon)
#on(host, "#{ruby} /tmp/https_daemon.rb")
end
teardown do
on(host, "rm -fr #{tmpdir}")
on(host, 'ps ax | grep "#{ruby} /tmp/https_daemon.rb" | grep -v grep | awk \'{print "kill -9 " $1}\' | sh ; sleep 1')
end
step 'shallow clone repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "https://github.com/johnduarte/testrepo.git",
provider => git,
depth => 1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is shallow and of the correct depth' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') unless res.stdout.include? "shallow"
end
on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
end
end
end

View file

@ -0,0 +1,58 @@
test_name 'C3478 - shallow clone repo minimal depth = 1 (ssh protocol, scp syntax)'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'shallow clone repo with puppet (scp syntax)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "root@#{host}:#{tmpdir}/testrepo.git",
provider => git,
depth => 1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is shallow and of the correct depth' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') unless res.stdout.include? "shallow"
end
on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
end
end
end

View file

@ -0,0 +1,58 @@
test_name 'C3477 - shallow clone repo minimal depth = 1 (ssh protocol)'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
step 'setup - establish ssh keys' do
# create ssh keys
on(host, 'yes | ssh-keygen -q -t rsa -f /root/.ssh/id_rsa -N ""')
# copy public key to authorized_keys
on(host, 'cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys')
on(host, 'echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config')
on(host, 'chown -R root:root /root/.ssh')
end
teardown do
on(host, "rm -fr #{tmpdir}")
apply_manifest_on(host, "file{'/root/.ssh/id_rsa': ensure => absent, force => true }", :catch_failures => true)
apply_manifest_on(host, "file{'/root/.ssh/id_rsa.pub': ensure => absent, force => true }", :catch_failures => true)
end
step 'shallow clone repo with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "ssh://root@#{host}#{tmpdir}/testrepo.git",
provider => git,
depth => 1,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is shallow and of the correct depth' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow not found') unless res.stdout.include? "shallow"
end
on(host, "wc -l #{tmpdir}/#{repo_name}/.git/shallow") do |res|
fail_test('shallow not found') unless res.stdout.include? "1 #{tmpdir}/#{repo_name}/.git/shallow"
end
end
end

View file

@ -0,0 +1,43 @@
test_name 'C3404 - shallow clone repo depth = 0 non shallow'
# Globals
repo_name = 'testrepo_shallow_clone'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'shallow clone repo with puppet (zero depth means not shallow)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
depth => 0,
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify checkout is NOT shallow' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('shallow found') if res.stdout.include? "shallow"
end
end
end

View file

@ -0,0 +1,47 @@
test_name 'C3612 - checkout a tag that does not exist'
# Globals
repo_name = 'testrepo_tag_checkout'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout tag that does not exist with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
tag => '11111111111111111',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step 'verify that master tag is checked out' do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
fail_test('tag not found') unless res.stdout.include? "ref: refs/heads/master"
end
end
end

View file

@ -0,0 +1,48 @@
test_name 'C3445 - checkout a tag (file protocol)'
# Globals
repo_name = 'testrepo_tag_checkout'
tag = '0.0.2'
hosts.each do |host|
tmpdir = host.tmpdir('vcsrepo')
step 'setup - create repo' do
git_pkg = 'git'
if host['platform'] =~ /ubuntu-10/
git_pkg = 'git-core'
end
install_package(host, git_pkg)
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
on(host, "cd #{tmpdir} && ./create_git_repo.sh")
end
teardown do
on(host, "rm -fr #{tmpdir}")
end
step 'checkout a tag with puppet' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/#{repo_name}":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
revision => '#{tag}',
}
EOS
apply_manifest_on(host, pp, :catch_failures => true)
apply_manifest_on(host, pp, :catch_changes => true)
end
step "verify checkout out tag is #{tag}" do
on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
fail_test('checkout not found') unless res.stdout.include? "HEAD"
end
on(host,"git --git-dir=#{tmpdir}/#{repo_name}/.git name-rev HEAD") do |res|
fail_test('tag not found') unless res.stdout.include? "#{tag}"
end
end
end

Some files were not shown because too many files have changed in this diff Show more