adding fake driver

This commit is contained in:
2013-07-25 16:14:38 -04:00
parent 266b0722f1
commit 5a69517c0b
24 changed files with 1740 additions and 1230 deletions

View File

@@ -1 +1 @@
95b6de96-61ef-4e5a-be3f-94376f3c2dce
d996d7ab-63be-42e1-bfe7-9b4057251598

View File

@@ -1 +1 @@
00a9efde-6e58-48d9-a88f-9dca39ab7655
4048e90a-240a-4146-8ac7-729aa0e0b530

View File

@@ -1 +1 @@
ad9a456c-c5dc-432f-a3b1-a3e464e5e9d1
2adeff38-b5e2-468e-a3c7-e74fae8e02ab

121
Vagrantfile vendored
View File

@@ -1,60 +1,61 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "Centos64Puppet"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box"
#config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20130427.box"
config.vm.define :puppet do |puppet_config|
puppet_config.vm.hostname = "puppet.vagrant.info"
puppet_config.vm.network :private_network, ip: "192.168.33.10" #eth1 MGMT
end
config.vm.define :controller do |controller_config|
controller_config.vm.hostname = "controller.vagrant.info"
controller_config.vm.network :private_network, ip: "192.168.33.11" #eth1 MGMT
controller_config.vm.network :private_network, ip: "10.10.1.11" #eth2 VM Traffic
controller_config.vm.network :private_network, ip: "10.10.2.11" #eth3 floating
controller_config.vm.network :forwarded_port, guest: 80, host: 8080
controller_config.vm.provision :shell, :inline => "ip link set mtu 1546 dev eth2"
controller_config.vm.provider "virtualbox" do |controller_vbox|
controller_vbox.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"] # eth3
controller_vbox.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"] # eth3
end
end
config.vm.define :compute1 do |compute1_config|
compute1_config.vm.hostname = "compute1.vagrant.info"
compute1_config.vm.network :private_network, ip: "192.168.33.12" #eth1 MGMT
compute1_config.vm.network :private_network, ip: "10.10.1.12" #eth2 VM Traffic
compute1_config.vm.provision :shell, :inline => "ip link set mtu 1546 dev eth2"
compute1_config.vm.provision :shell, :inline => "ip link set eth2 promisc on"
compute1_config.vm.provider "virtualbox" do |compute1_vbox|
compute1_vbox.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"] # eth2
compute1_vbox.customize ["modifyvm", :id, "--cpus", 4]
compute1_vbox.customize ["modifyvm", :id, "--memory", 2048]
end
end
config.vm.provider "virtualbox" do |vbox|
vbox.gui = false
end
config.vm.provision :puppet do |puppet|
puppet.module_path = "modules"
puppet.manifest_file = "site.pp"
puppet.options = "--verbose --debug"
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "Centos64Puppet"
config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box"
#config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20130427.box"
config.vm.define :puppet do |puppet_config|
puppet_config.vm.hostname = "puppet.vagrant.info"
puppet_config.vm.network :private_network, ip: "192.168.33.10" #eth1 MGMT
end
config.vm.define :controller do |controller_config|
controller_config.vm.hostname = "controller.vagrant.info"
controller_config.vm.network :private_network, ip: "192.168.33.11" #eth1 MGMT
controller_config.vm.network :private_network, ip: "10.10.1.11" #eth2 VM Traffic
controller_config.vm.network :private_network, ip: "10.10.2.11" #eth3 floating
controller_config.vm.network :forwarded_port, guest: 80, host: 8080
controller_config.vm.provision :shell, :inline => "ip link set mtu 1546 dev eth2"
controller_config.vm.provider "virtualbox" do |controller_vbox|
controller_vbox.customize ["modifyvm", :id, "--nicpromisc4", "allow-all", "--nictype4", "Am79C973"] # eth4
controller_vbox.customize ["modifyvm", :id, "--nicpromisc3", "allow-all", "--nictype3", "Am79C973"] # eth3
end
end
config.vm.define :compute1 do |compute1_config|
compute1_config.vm.hostname = "compute1.vagrant.info"
compute1_config.vm.network :private_network, ip: "192.168.33.12" #eth1 MGMT
compute1_config.vm.network :private_network, ip: "10.10.1.12" #eth2 VM Traffic
#compute1_config.vm.provision :shell, :inline => "ip link set mtu 1546 dev eth2"
#compute1_config.vm.provision :shell, :inline => "ip link set eth2 promisc on"
compute1_config.vm.provider "virtualbox" do |compute1_vbox|
compute1_vbox.customize ["modifyvm", :id, "--nicpromisc2", "allow-all", "--nictype2", "Am79C973"] # eth2
compute1_vbox.customize ["modifyvm", :id, "--nicpromisc3", "allow-all", "--nictype3", "Am79C973"] # eth3
compute1_vbox.customize ["modifyvm", :id, "--cpus", 4]
compute1_vbox.customize ["modifyvm", :id, "--memory", 2048]
end
end
config.vm.provider "virtualbox" do |vbox|
vbox.gui = false
end
config.vm.provision :puppet do |puppet|
puppet.module_path = "modules"
puppet.manifest_file = "site.pp"
puppet.options = "--verbose --debug"
end
end

503
manifests/fake.py Normal file
View File

@@ -0,0 +1,503 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Copyright (c) 2010 Citrix Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
A fake (in-memory) hypervisor+api.
Allows nova testing w/o a hypervisor. This module also documents the
semantics of real hypervisor connections.
"""
from oslo.config import cfg
import os
from nova.compute import power_state
from nova.compute import task_states
from nova import db
from nova import exception
from nova.openstack.common import log as logging
from nova.virt import driver
from nova.virt import virtapi
from nova.virt import images
CONF = cfg.CONF
CONF.import_opt('host', 'nova.netconf')
LOG = logging.getLogger(__name__)
_FAKE_NODES = None
def set_nodes(nodes):
"""Sets FakeDriver's node.list.
It has effect on the following methods:
get_available_nodes()
get_available_resource
get_host_stats()
To restore the change, call restore_nodes()
"""
global _FAKE_NODES
_FAKE_NODES = nodes
def restore_nodes():
"""Resets FakeDriver's node list modified by set_nodes().
Usually called from tearDown().
"""
global _FAKE_NODES
_FAKE_NODES = [CONF.host]
class FakeInstance(object):
def __init__(self, name, state):
self.name = name
self.state = state
def __getitem__(self, key):
return getattr(self, key)
class FakeDriver(driver.ComputeDriver):
capabilities = {
"has_imagecache": True,
"supports_recreate": True,
}
"""Fake hypervisor driver."""
def __init__(self, virtapi, read_only=False):
super(FakeDriver, self).__init__(virtapi)
self.instances = {}
self.host_status_base = {
'host_name-description': 'Fake Host',
'host_hostname': CONF.host,
'host_memory_total': 8000000000,
'host_memory_overhead': 10000000,
'host_memory_free': 7900000000,
'host_memory_free_computed': 7900000000,
'host_other_config': {},
'host_ip_address': '192.168.1.109',
'host_cpu_info': {},
'disk_available': 500000000000,
'disk_total': 600000000000,
'disk_used': 100000000000,
'host_uuid': 'cedb9b39-9388-41df-8891-c5c9a0c0fe5f',
'host_name_label': 'fake-host',
'hypervisor_hostname': CONF.host,
}
self._mounts = {}
self._interfaces = {}
if not _FAKE_NODES:
set_nodes([CONF.host])
def init_host(self, host):
return
def list_instances(self):
return self.instances.keys()
def plug_vifs(self, instance, network_info):
"""Plug VIFs into networks."""
pass
def unplug_vifs(self, instance, network_info):
"""Unplug VIFs from networks."""
pass
def spawn(self, context, instance, image_meta, injected_files,
admin_password, network_info=None, block_device_info=None):
name = instance['name']
state = power_state.RUNNING
fake_instance = FakeInstance(name, state)
self.instances[name] = fake_instance
if 'image_ref' in instance:
image_href = instance['image_ref']
if 'user_id' in instance:
user_id = instance['user_id']
if 'project_id' in instance:
project_id = instance['user_id']
size = instance['root_gb']
path = "%s%s%s" % (CONF.instances_path, '/_base/',image_href)
#LOG.warning("Fake DriverMSG: image_meta type = %s" % type(image_meta))
#LOG.warning("Fake DriverMSG: image_meta = %s" % image_meta)
#LOG.warning("Fake DriverMSG: instance type = %s" % type(instance))
#LOG.warning("Fake DriverMSG: instance = %s" % instance)
cmd = "qemu-img', 'create', '-f', 'raw %s %s" % (path, size)
LOG.warning("Fake Driver: base instances_path = %s" % path)
os.system(cmd)
#images.fetch_to_raw(context, image_href, path, user_id, project_id)
images.fetch(context, image_href, path, user_id, project_id)
def live_snapshot(self, context, instance, name, update_task_state):
if instance['name'] not in self.instances:
raise exception.InstanceNotRunning(instance_id=instance['uuid'])
update_task_state(task_state=task_states.IMAGE_UPLOADING)
def snapshot(self, context, instance, name, update_task_state):
if instance['name'] not in self.instances:
raise exception.InstanceNotRunning(instance_id=instance['uuid'])
update_task_state(task_state=task_states.IMAGE_UPLOADING)
def reboot(self, context, instance, network_info, reboot_type,
block_device_info=None, bad_volumes_callback=None):
pass
@staticmethod
def get_host_ip_addr():
return '192.168.0.1'
def set_admin_password(self, instance, new_pass):
pass
def inject_file(self, instance, b64_path, b64_contents):
pass
def resume_state_on_host_boot(self, context, instance, network_info,
block_device_info=None):
pass
def rescue(self, context, instance, network_info, image_meta,
rescue_password):
pass
def unrescue(self, instance, network_info):
pass
def poll_rebooting_instances(self, timeout, instances):
pass
def migrate_disk_and_power_off(self, context, instance, dest,
instance_type, network_info,
block_device_info=None):
pass
def finish_revert_migration(self, instance, network_info,
block_device_info=None, power_on=True):
pass
def post_live_migration_at_destination(self, context, instance,
network_info,
block_migration=False,
block_device_info=None):
pass
def power_off(self, instance):
pass
def power_on(self, context, instance, network_info, block_device_info):
pass
def soft_delete(self, instance):
pass
def restore(self, instance):
pass
def pause(self, instance):
pass
def unpause(self, instance):
pass
def suspend(self, instance):
pass
def resume(self, instance, network_info, block_device_info=None):
pass
def destroy(self, instance, network_info, block_device_info=None,
destroy_disks=True):
key = instance['name']
if key in self.instances:
del self.instances[key]
else:
LOG.warning(_("Key '%(key)s' not in instances '%(inst)s'") %
{'key': key,
'inst': self.instances}, instance=instance)
def attach_volume(self, connection_info, instance, mountpoint):
"""Attach the disk to the instance at mountpoint using info."""
instance_name = instance['name']
if instance_name not in self._mounts:
self._mounts[instance_name] = {}
self._mounts[instance_name][mountpoint] = connection_info
return True
def detach_volume(self, connection_info, instance, mountpoint):
"""Detach the disk attached to the instance."""
try:
del self._mounts[instance['name']][mountpoint]
except KeyError:
pass
return True
def attach_interface(self, instance, image_meta, network_info):
for (network, mapping) in network_info:
if mapping['vif_uuid'] in self._interfaces:
raise exception.InterfaceAttachFailed('duplicate')
self._interfaces[mapping['vif_uuid']] = mapping
def detach_interface(self, instance, network_info):
for (network, mapping) in network_info:
try:
del self._interfaces[mapping['vif_uuid']]
except KeyError:
raise exception.InterfaceDetachFailed('not attached')
def get_info(self, instance):
if instance['name'] not in self.instances:
raise exception.InstanceNotFound(instance_id=instance['name'])
i = self.instances[instance['name']]
return {'state': i.state,
'max_mem': 0,
'mem': 0,
'num_cpu': 2,
'cpu_time': 0}
def get_diagnostics(self, instance_name):
return {'cpu0_time': 17300000000,
'memory': 524288,
'vda_errors': -1,
'vda_read': 262144,
'vda_read_req': 112,
'vda_write': 5778432,
'vda_write_req': 488,
'vnet1_rx': 2070139,
'vnet1_rx_drop': 0,
'vnet1_rx_errors': 0,
'vnet1_rx_packets': 26701,
'vnet1_tx': 140208,
'vnet1_tx_drop': 0,
'vnet1_tx_errors': 0,
'vnet1_tx_packets': 662,
}
def get_all_bw_counters(self, instances):
"""Return bandwidth usage counters for each interface on each
running VM.
"""
bw = []
return bw
def get_all_volume_usage(self, context, compute_host_bdms):
"""Return usage info for volumes attached to vms on
a given host.
"""
volusage = []
return volusage
def block_stats(self, instance_name, disk_id):
return [0L, 0L, 0L, 0L, None]
def interface_stats(self, instance_name, iface_id):
return [0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]
def get_console_output(self, instance):
return 'FAKE CONSOLE OUTPUT\nANOTHER\nLAST LINE'
def get_vnc_console(self, instance):
return {'internal_access_path': 'FAKE',
'host': 'fakevncconsole.com',
'port': 6969}
def get_spice_console(self, instance):
return {'internal_access_path': 'FAKE',
'host': 'fakespiceconsole.com',
'port': 6969,
'tlsPort': 6970}
def get_console_pool_info(self, console_type):
return {'address': '127.0.0.1',
'username': 'fakeuser',
'password': 'fakepassword'}
def refresh_security_group_rules(self, security_group_id):
return True
def refresh_security_group_members(self, security_group_id):
return True
def refresh_instance_security_rules(self, instance):
return True
def refresh_provider_fw_rules(self):
pass
def get_available_resource(self, nodename):
"""Updates compute manager resource info on ComputeNode table.
Since we don't have a real hypervisor, pretend we have lots of
disk and ram.
"""
if nodename not in _FAKE_NODES:
return {}
dic = {'vcpus': 1,
'memory_mb': 8192,
'local_gb': 1028,
'vcpus_used': 0,
'memory_mb_used': 0,
'local_gb_used': 0,
'hypervisor_type': 'fake',
'hypervisor_version': '1.0',
'hypervisor_hostname': nodename,
'cpu_info': '?'}
return dic
def ensure_filtering_rules_for_instance(self, instance_ref, network_info):
"""This method is supported only by libvirt."""
raise NotImplementedError('This method is supported only by libvirt.')
def get_instance_disk_info(self, instance_name):
return
def live_migration(self, context, instance_ref, dest,
post_method, recover_method, block_migration=False,
migrate_data=None):
return
def check_can_live_migrate_destination_cleanup(self, ctxt,
dest_check_data):
return
def check_can_live_migrate_destination(self, ctxt, instance_ref,
src_compute_info, dst_compute_info,
block_migration=False,
disk_over_commit=False):
return {}
def check_can_live_migrate_source(self, ctxt, instance_ref,
dest_check_data):
return
def finish_migration(self, context, migration, instance, disk_info,
network_info, image_meta, resize_instance,
block_device_info=None, power_on=True):
return
def confirm_migration(self, migration, instance, network_info):
return
def pre_live_migration(self, context, instance_ref, block_device_info,
network_info, disk, migrate_data=None):
return
def unfilter_instance(self, instance_ref, network_info):
"""This method is supported only by libvirt."""
raise NotImplementedError('This method is supported only by libvirt.')
def test_remove_vm(self, instance_name):
"""Removes the named VM, as if it crashed. For testing."""
self.instances.pop(instance_name)
def get_host_stats(self, refresh=False):
"""Return fake Host Status of ram, disk, network."""
stats = []
for nodename in _FAKE_NODES:
host_status = self.host_status_base.copy()
host_status['hypervisor_hostname'] = nodename
host_status['host_hostname'] = nodename
host_status['host_name_label'] = nodename
stats.append(host_status)
if len(stats) == 0:
raise exception.NovaException("FakeDriver has no node")
elif len(stats) == 1:
return stats[0]
else:
return stats
def host_power_action(self, host, action):
"""Reboots, shuts down or powers up the host."""
return action
def host_maintenance_mode(self, host, mode):
"""Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation.
"""
if not mode:
return 'off_maintenance'
return 'on_maintenance'
def set_host_enabled(self, host, enabled):
"""Sets the specified host's ability to accept new instances."""
if enabled:
return 'enabled'
return 'disabled'
def get_disk_available_least(self):
pass
def get_volume_connector(self, instance):
return {'ip': '127.0.0.1', 'initiator': 'fake', 'host': 'fakehost'}
def get_available_nodes(self):
return _FAKE_NODES
def instance_on_disk(self, instance):
return False
def list_instance_uuids(self):
return []
def legacy_nwinfo(self):
return True
class FakeVirtAPI(virtapi.VirtAPI):
def instance_update(self, context, instance_uuid, updates):
return db.instance_update_and_get_original(context,
instance_uuid,
updates)
def aggregate_get_by_host(self, context, host, key=None):
return db.aggregate_get_by_host(context, host, key=key)
def aggregate_metadata_add(self, context, aggregate, metadata,
set_delete=False):
return db.aggregate_metadata_add(context, aggregate['id'], metadata,
set_delete=set_delete)
def aggregate_metadata_delete(self, context, aggregate, key):
return db.aggregate_metadata_delete(context, aggregate['id'], key)
def security_group_get_by_instance(self, context, instance):
return db.security_group_get_by_instance(context, instance['uuid'])
def security_group_rule_get_by_security_group(self, context,
security_group):
return db.security_group_rule_get_by_security_group(
context, security_group['id'])
def provider_fw_rule_get_all(self, context):
return db.provider_fw_rule_get_all(context)
def agent_build_get_by_triple(self, context, hypervisor, os, architecture):
return db.agent_build_get_by_triple(context,
hypervisor, os, architecture)
def instance_type_get(self, context, instance_type_id):
return db.instance_type_get(context, instance_type_id)

View File

@@ -1,157 +1,163 @@
node puppet {
#ensure git is installed
package { 'puppetlabs-release-6-7':
provider => 'rpm',
ensure => installed,
source => "http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm";
'git':
ensure => 'present';
'puppet-server':
require => Package["puppetlabs-release-6-7"],
ensure => 'present';
'rubygem-rake':
ensure => 'present';
}
vcsrepo { '/etc/puppet/modules/openstack':
require => Package["puppet-server"],
ensure => latest,
provider => git,
source => 'https://sstent:farscape5@github.com/stratustech/puppet-openstack.git',
notify => File["/etc/puppet/modules/openstack"];
'/etc/puppet/manifests':
require => [Package["puppet-server"],File['/etc/puppet/manifests']],
ensure => latest,
provider => git,
source => 'https://sstent:farscape5@github.com/stratustech/POC_ALPHA.git';
'/etc/puppet/modules/rabbitmq':
require => Package["puppet-server"],
ensure => latest,
provider => git,
source => 'https://github.com/gergnz/puppetlabs-rabbitmq.git';
'/etc/puppet/modules/horizon':
require => Package["puppet-server"],
ensure => latest,
provider => git,
source => 'https://sstent:farscape5@github.com/stratustech/puppet-horizon.git';
}
file { "/etc/puppet/modules/openstack":
require => Package["puppet-server"],
ensure => "directory",
owner => "root",
group => "root",
mode => 755,
recurse => true,
notify => Exec["sudo rake modules:clone"];
"/etc/puppet/manifests":
require => Package["puppet-server"],
before => Vcsrepo['/etc/puppet/manifests'],
force => true,
backup => false,
ensure => "absent";
"/etc/puppet/autosign.conf":
require => Package["puppet-server"],
owner => "root",
group => "root",
mode => 0644,
content => "*";
}
exec {"sudo rake modules:clone":
require => [Package["rubygem-rake"],Vcsrepo['/etc/puppet/modules/horizon','/etc/puppet/modules/rabbitmq','/etc/puppet/manifests','/etc/puppet/modules/openstack']],
cwd => "/etc/puppet/modules/openstack",
path => ["/usr/local/bin","/bin","/usr/bin","/usr/local/sbin","/usr/sbin","/sbin","/home/vagrant/bin"];
}
service { "iptables":
ensure => "stopped",
enable => false;
"puppetmaster":
require => [File["/etc/puppet/autosign.conf"],Exec["sudo rake modules:clone"]],
ensure => "running",
enable => true;
}
host { 'controller.vagrant.info':
ip => '192.168.33.11',
host_aliases => 'controller';
'compute1.vagrant.info':
ip => '192.168.33.12',
host_aliases => 'compute1';
}
}
node controller {
#ensure git is installed
package { 'puppetlabs-release-6-7':
provider => 'rpm',
ensure => installed,
source => "http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm";
'puppet':
require => Package["puppetlabs-release-6-7"],
ensure => 'present';
}
service { "iptables":
ensure => "stopped",
enable => false;
"puppet":
require => Package["puppet"],
ensure => "running",
enable => true;
}
host { 'puppet.vagrant.info':
ip => '192.168.33.10',
host_aliases => 'puppet';
'compute1.vagrant.info':
ip => '192.168.33.12',
host_aliases => 'compute1';
}
}
node compute1 {
#ensure git is installed
package { 'puppetlabs-release-6-7':
provider => 'rpm',
ensure => installed,
source => "http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm";
'puppet':
require => Package["puppetlabs-release-6-7"],
ensure => 'present';
}
service { "puppet":
require => Package["puppet"],
ensure => "running",
enable => true;
}
host { 'puppet.vagrant.info':
ip => '192.168.33.10',
host_aliases => 'puppet';
'controller.vagrant.info':
ip => '192.168.33.11',
host_aliases => 'controller';
}
}
node puppet {
#ensure git is installed
package { 'puppetlabs-release-6-7':
provider => 'rpm',
ensure => installed,
source => "http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm";
'git':
ensure => 'present';
'puppet-server':
require => Package["puppetlabs-release-6-7"],
ensure => 'present';
'rubygem-rake':
ensure => 'present';
}
vcsrepo {
'/etc/puppet/modules/openstack':
require => Package["puppet-server"],
ensure => latest,
provider => git,
source => 'https://sstent:farscape5@github.com/stratustech/puppet-openstack.git',
notify => File["/etc/puppet/modules/openstack"];
'/etc/puppet/modules/stratus':
require => Package["puppet-server"],
ensure => latest,
provider => git,
source => 'https://sstent:farscape5@github.com/stratustech/POC_ALPHA_stratusmodule.git';
'/etc/puppet/manifests':
require => [Package["puppet-server"],File['/etc/puppet/manifests']],
ensure => latest,
provider => git,
source => 'https://sstent:farscape5@github.com/stratustech/POC_ALPHA_puppet_manifests.git';
'/etc/puppet/modules/rabbitmq':
require => Package["puppet-server"],
ensure => latest,
provider => git,
source => 'https://github.com/gergnz/puppetlabs-rabbitmq.git';
'/etc/puppet/modules/horizon':
require => Package["puppet-server"],
ensure => latest,
provider => git,
source => 'https://sstent:farscape5@github.com/stratustech/puppet-horizon.git';
}
file { "/etc/puppet/modules/openstack":
require => Package["puppet-server"],
ensure => "directory",
owner => "root",
group => "root",
mode => 755,
recurse => true,
notify => Exec["sudo rake modules:clone"];
"/etc/puppet/manifests":
require => Package["puppet-server"],
before => Vcsrepo['/etc/puppet/manifests'],
force => true,
backup => false,
ensure => "absent";
"/etc/puppet/autosign.conf":
require => Package["puppet-server"],
owner => "root",
group => "root",
mode => 0644,
content => "*";
}
exec {"sudo rake modules:clone":
require => [Package["rubygem-rake"],Vcsrepo['/etc/puppet/modules/horizon','/etc/puppet/modules/rabbitmq','/etc/puppet/manifests','/etc/puppet/modules/openstack']],
cwd => "/etc/puppet/modules/openstack",
path => ["/usr/local/bin","/bin","/usr/bin","/usr/local/sbin","/usr/sbin","/sbin","/home/vagrant/bin"];
}
service { "iptables":
ensure => "stopped",
enable => false;
"puppetmaster":
require => [File["/etc/puppet/autosign.conf"],Exec["sudo rake modules:clone"]],
ensure => "running",
enable => true;
}
host { 'controller.vagrant.info':
ip => '192.168.33.11',
host_aliases => 'controller';
'compute1.vagrant.info':
ip => '192.168.33.12',
host_aliases => 'compute1';
}
}
node controller {
#ensure git is installed
package { 'puppetlabs-release-6-7':
provider => 'rpm',
ensure => installed,
source => "http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm";
'puppet':
require => Package["puppetlabs-release-6-7"],
ensure => 'present';
}
service { "iptables":
ensure => "stopped",
enable => false;
"puppet":
require => Package["puppet"],
ensure => "running",
enable => true;
}
host { 'puppet.vagrant.info':
ip => '192.168.33.10',
host_aliases => 'puppet';
'compute1.vagrant.info':
ip => '192.168.33.12',
host_aliases => 'compute1';
}
}
node compute1 {
#ensure git is installed
package { 'puppetlabs-release-6-7':
provider => 'rpm',
ensure => installed,
source => "http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm";
'puppet':
require => Package["puppetlabs-release-6-7"],
ensure => 'present';
}
service { "puppet":
require => Package["puppet"],
ensure => "running",
enable => true;
}
host { 'puppet.vagrant.info':
ip => '192.168.33.10',
host_aliases => 'puppet';
'controller.vagrant.info':
ip => '192.168.33.11',
host_aliases => 'controller';
}
}

View File

@@ -1,180 +1,180 @@
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"
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?
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?
(@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
end
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"
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?
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?
(@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
end

View File

@@ -1,5 +1,5 @@
revision-id: menesis@pov.lt-20100309191856-4wmfqzc803fj300x
date: 2010-03-09 21:18:56 +0200
build-date: 2010-03-14 00:42:43 -0800
revno: 2634
branch-nick: mytest
revision-id: menesis@pov.lt-20100309191856-4wmfqzc803fj300x
date: 2010-03-09 21:18:56 +0200
build-date: 2010-03-14 00:42:43 -0800
revno: 2634
branch-nick: mytest

View File

@@ -1,14 +1,14 @@
feature/foo
feature/bar
feature/baz
feature/quux
only/local
* master
refactor/foo
origin/HEAD
origin/feature/foo
origin/feature/bar
origin/feature/baz
origin/feature/quux
origin/only/remote
origin/master
feature/foo
feature/bar
feature/baz
feature/quux
only/local
* master
refactor/foo
origin/HEAD
origin/feature/foo
origin/feature/bar
origin/feature/baz
origin/feature/quux
origin/only/remote
origin/master

View File

@@ -1,6 +1,6 @@
changeset: 3:34e6012c783a
parent: 2:21ea4598c962
parent: 1:9d0ff0028458
user: Test User <test.user@example.com>
date: Fri Aug 07 13:13:02 2009 -0400
summary: merge
changeset: 3:34e6012c783a
parent: 2:21ea4598c962
parent: 1:9d0ff0028458
user: Test User <test.user@example.com>
date: Fri Aug 07 13:13:02 2009 -0400
summary: merge

View File

@@ -1,18 +1,18 @@
tip 1019:bca3f20b249b
0.9.1 1017:76ce7cca95d8
0.9 1001:dbaa6f4ec585
0.8 839:65b66ac0fc83
0.7.1 702:e1357f00129f
0.7 561:7b2af3b4c968
0.6.3 486:e38077f4e4aa
0.6.2 405:07bb099b7b10
0.6.1 389:93750f3fbbe2
0.6 369:34e6012c783a
0.5.3 321:5ffa6ae7e699
0.5.2 318:fdc2c2e4cebe
0.5.1 315:33a5ea0cbe7a
0.5 313:47490716f4c9
0.4 240:47fa3a14cc63
0.3.1 132:bc231db18e1c
0.3 130:661615e510dd
0.2 81:f98d13b442f6
tip 1019:bca3f20b249b
0.9.1 1017:76ce7cca95d8
0.9 1001:dbaa6f4ec585
0.8 839:65b66ac0fc83
0.7.1 702:e1357f00129f
0.7 561:7b2af3b4c968
0.6.3 486:e38077f4e4aa
0.6.2 405:07bb099b7b10
0.6.1 389:93750f3fbbe2
0.6 369:34e6012c783a
0.5.3 321:5ffa6ae7e699
0.5.2 318:fdc2c2e4cebe
0.5.1 315:33a5ea0cbe7a
0.5 313:47490716f4c9
0.4 240:47fa3a14cc63
0.3.1 132:bc231db18e1c
0.3 130:661615e510dd
0.2 81:f98d13b442f6

View File

@@ -1,10 +1,10 @@
Path: .
URL: http://example.com/svn/trunk
Repository Root: http://example.com/svn
Repository UUID: 75246ace-e253-0410-96dd-a7613ca8dc81
Revision: 4
Node Kind: directory
Schedule: normal
Last Changed Author: jon
Last Changed Rev: 3
Last Changed Date: 2008-08-07 11:34:25 -0700 (Thu, 07 Aug 2008)
Path: .
URL: http://example.com/svn/trunk
Repository Root: http://example.com/svn
Repository UUID: 75246ace-e253-0410-96dd-a7613ca8dc81
Revision: 4
Node Kind: directory
Schedule: normal
Last Changed Author: jon
Last Changed Rev: 3
Last Changed Date: 2008-08-07 11:34:25 -0700 (Thu, 07 Aug 2008)

View File

@@ -1,6 +1,6 @@
--format
s
--colour
--loadby
mtime
--backtrace
--format
s
--colour
--loadby
mtime
--backtrace

View File

@@ -1,25 +1,25 @@
require 'pathname'
dir = Pathname.new(__FILE__).parent
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
require 'test/unit'
require 'mocha'
require 'puppet'
gem 'rspec', '>= 1.2.9'
require 'spec/autorun'
Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each do |support_file|
require support_file
end
Spec::Runner.configure do |config|
config.mock_with :mocha
config.include(FixtureHelpers)
config.include(FilesystemHelpers)
end
# We need this because the RAL uses 'should' as a method. This
# allows us the same behaviour but with a different method name.
class Object
alias :must :should
end
require 'pathname'
dir = Pathname.new(__FILE__).parent
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
require 'test/unit'
require 'mocha'
require 'puppet'
gem 'rspec', '>= 1.2.9'
require 'spec/autorun'
Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each do |support_file|
require support_file
end
Spec::Runner.configure do |config|
config.mock_with :mocha
config.include(FixtureHelpers)
config.include(FilesystemHelpers)
end
# We need this because the RAL uses 'should' as a method. This
# allows us the same behaviour but with a different method name.
class Object
alias :must :should
end

View File

@@ -1,18 +1,18 @@
module FilesystemHelpers
def expects_chdir(path = resource.value(:path))
Dir.expects(:chdir).with(path).at_least_once.yields
end
def expects_mkdir(path = resource.value(:path))
Dir.expects(:mkdir).with(path).at_least_once
end
def expects_rm_rf(path = resource.value(:path))
FileUtils.expects(:rm_rf).with(path)
end
def expects_directory?(returns = true, path = resource.value(:path))
File.expects(:directory?).with(path).returns(returns)
end
end
module FilesystemHelpers
def expects_chdir(path = resource.value(:path))
Dir.expects(:chdir).with(path).at_least_once.yields
end
def expects_mkdir(path = resource.value(:path))
Dir.expects(:mkdir).with(path).at_least_once
end
def expects_rm_rf(path = resource.value(:path))
FileUtils.expects(:rm_rf).with(path)
end
def expects_directory?(returns = true, path = resource.value(:path))
File.expects(:directory?).with(path).returns(returns)
end
end

View File

@@ -1,7 +1,7 @@
module FixtureHelpers
def fixture(name, ext = '.txt')
File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', name.to_s + ext))
end
end
module FixtureHelpers
def fixture(name, ext = '.txt')
File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', name.to_s + ext))
end
end

View File

@@ -1,80 +1,80 @@
class ProviderExampleGroup < Spec::Example::ExampleGroup
# Allow access to the current resource
attr_reader :resource
# Build up the values for the resource in this scope
before :each do
resource_hash = example_group_hierarchy.inject({}) do |memo, klass|
memo.merge(klass.options[:resource] || {})
end
full_hash = resource_hash.merge(:provider => described_class.name)
@resource = described_class.resource_type.new(full_hash)
end
# Build the provider
subject { described_class.new(@resource) }
# Allow access to it via +provider+
alias :provider :subject
# Generate a context for a provider operating on a resource with:
#
# call-seq:
#
# # A parameter/property set (when the value isn't important)
# resource_with :source do
# # ...
# end
#
# # A parameter/property set to a specific value
# resource_with :source => 'a-specific-value' do
# # ...
# end
#
# Note: Choose one or the other (mixing will create two separate contexts)
#
def self.resource_with(*params, &block)
params_with_values = params.last.is_a?(Hash) ? params.pop : {}
build_value_context(params_with_values, &block)
build_existence_context(*params, &block)
end
def self.build_existence_context(*params, &block) #:nodoc:
unless params.empty?
text = params.join(', ')
placeholders = params.inject({}) { |memo, key| memo.merge(key => 'an-unimportant-value') }
context("and with a #{text}", {:resource => placeholders}, &block)
end
end
def self.build_value_context(params = {}, &block) #:nodoc:
unless params.empty?
text = params.map { |k, v| "#{k} => #{v.inspect}" }.join(' and with ')
context("and with #{text}", {:resource => params}, &block)
end
end
# Generate a context for a provider operating on a resource without
# a given parameter/property.
#
# call-seq:
#
# resource_without :source do
# # ...
# end
#
def self.resource_without(field, &block)
context("and without a #{field}", &block)
end
end
Spec::Example::ExampleGroupFactory.register(:provider, ProviderExampleGroup)
# Outside wrapper to lookup a provider and start the spec using ProviderExampleGroup
def describe_provider(type_name, provider_name, options = {}, &block)
provider_class = Puppet::Type.type(type_name).provider(provider_name)
describe(provider_class, options.merge(:type => :provider), &block)
end
class ProviderExampleGroup < Spec::Example::ExampleGroup
# Allow access to the current resource
attr_reader :resource
# Build up the values for the resource in this scope
before :each do
resource_hash = example_group_hierarchy.inject({}) do |memo, klass|
memo.merge(klass.options[:resource] || {})
end
full_hash = resource_hash.merge(:provider => described_class.name)
@resource = described_class.resource_type.new(full_hash)
end
# Build the provider
subject { described_class.new(@resource) }
# Allow access to it via +provider+
alias :provider :subject
# Generate a context for a provider operating on a resource with:
#
# call-seq:
#
# # A parameter/property set (when the value isn't important)
# resource_with :source do
# # ...
# end
#
# # A parameter/property set to a specific value
# resource_with :source => 'a-specific-value' do
# # ...
# end
#
# Note: Choose one or the other (mixing will create two separate contexts)
#
def self.resource_with(*params, &block)
params_with_values = params.last.is_a?(Hash) ? params.pop : {}
build_value_context(params_with_values, &block)
build_existence_context(*params, &block)
end
def self.build_existence_context(*params, &block) #:nodoc:
unless params.empty?
text = params.join(', ')
placeholders = params.inject({}) { |memo, key| memo.merge(key => 'an-unimportant-value') }
context("and with a #{text}", {:resource => placeholders}, &block)
end
end
def self.build_value_context(params = {}, &block) #:nodoc:
unless params.empty?
text = params.map { |k, v| "#{k} => #{v.inspect}" }.join(' and with ')
context("and with #{text}", {:resource => params}, &block)
end
end
# Generate a context for a provider operating on a resource without
# a given parameter/property.
#
# call-seq:
#
# resource_without :source do
# # ...
# end
#
def self.resource_without(field, &block)
context("and without a #{field}", &block)
end
end
Spec::Example::ExampleGroupFactory.register(:provider, ProviderExampleGroup)
# Outside wrapper to lookup a provider and start the spec using ProviderExampleGroup
def describe_provider(type_name, provider_name, options = {}, &block)
provider_class = Puppet::Type.type(type_name).provider(provider_name)
describe(provider_class, options.merge(:type => :provider), &block)
end

View File

@@ -1,90 +1,90 @@
require 'spec_helper'
describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
resource_with :source do
resource_with :revision do
it "should execute 'bzr clone -r' with the revision" do
provider.expects(:bzr).with('branch', '-r', resource.value(:revision), resource.value(:source), resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'bzr clone' without a revision" do
provider.expects(:bzr).with('branch', resource.value(:source), resource.value(:path))
provider.create
end
end
end
resource_without :source do
it "should execute 'bzr init'" do
provider.expects(:bzr).with('init', resource.value(:path))
provider.create
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
it "should check for the directory" do
expects_directory?(true, File.join(resource.value(:path), '.bzr'))
provider.exists?
end
end
describe "checking the revision property" do
before do
expects_chdir
provider.expects(:bzr).with('version-info').returns(fixture(:bzr_version_info))
@current_revid = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'
end
context "when given a non-revid as the resource revision", :resource => {:revision => '2634'} do
context "when its revid is not different than the current revid" do
before do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("#{resource.value(:revision)} menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n")
end
it "should return the ref" do
provider.revision.should == resource.value(:revision)
end
end
context "when its revid is different than the current revid", :resource => {:revision => '2636'} do
it "should return the current revid" do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2635 foo\n")
provider.revision.should == @current_revid
end
end
end
context "when given a revid as the resource revision" do
context "when it is the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'} do
before do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n")
end
it "should return it" do
provider.revision.should == resource.value(:revision)
end
end
context "when it is not the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y'} do
it "should return the current revid" do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2636 foo\n")
provider.revision.should == @current_revid
end
end
end
end
describe "setting the revision property" do
it "should use 'bzr update -r' with the revision" do
expects_chdir
provider.expects(:bzr).with('update', '-r', 'somerev')
provider.revision = 'somerev'
end
end
end
require 'spec_helper'
describe_provider :vcsrepo, :bzr, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
resource_with :source do
resource_with :revision do
it "should execute 'bzr clone -r' with the revision" do
provider.expects(:bzr).with('branch', '-r', resource.value(:revision), resource.value(:source), resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'bzr clone' without a revision" do
provider.expects(:bzr).with('branch', resource.value(:source), resource.value(:path))
provider.create
end
end
end
resource_without :source do
it "should execute 'bzr init'" do
provider.expects(:bzr).with('init', resource.value(:path))
provider.create
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
it "should check for the directory" do
expects_directory?(true, File.join(resource.value(:path), '.bzr'))
provider.exists?
end
end
describe "checking the revision property" do
before do
expects_chdir
provider.expects(:bzr).with('version-info').returns(fixture(:bzr_version_info))
@current_revid = 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'
end
context "when given a non-revid as the resource revision", :resource => {:revision => '2634'} do
context "when its revid is not different than the current revid" do
before do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("#{resource.value(:revision)} menesis@pov.lt-20100309191856-4wmfqzc803fj300x\n")
end
it "should return the ref" do
provider.revision.should == resource.value(:revision)
end
end
context "when its revid is different than the current revid", :resource => {:revision => '2636'} do
it "should return the current revid" do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2635 foo\n")
provider.revision.should == @current_revid
end
end
end
context "when given a revid as the resource revision" do
context "when it is the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x'} do
before do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("1234 #{resource.value(:revision)}\n")
end
it "should return it" do
provider.revision.should == resource.value(:revision)
end
end
context "when it is not the same as the current revid", :resource => {:revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300y'} do
it "should return the current revid" do
provider.expects(:bzr).with('revision-info', resource.value(:revision)).returns("2636 foo\n")
provider.revision.should == @current_revid
end
end
end
end
describe "setting the revision property" do
it "should use 'bzr update -r' with the revision" do
expects_chdir
provider.expects(:bzr).with('update', '-r', 'somerev')
provider.revision = 'somerev'
end
end
end

View File

@@ -1,100 +1,100 @@
require 'spec_helper'
describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
context "with a source", :resource => {:source => ':ext:source@example.com:/foo/bar'} do
resource_with :revision do
it "should execute 'cvs checkout' and 'cvs update -r'" do
provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'vcsrepo', 'bar')
expects_chdir(File.dirname(resource.value(:path)))
#provider.expects(:cvs).with('update', '-r', resource.value(:revision), '.')
provider.create
end
end
resource_without :revision do
it "should just execute 'cvs checkout' without a revision" do
provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
provider.create
end
end
context "with a compression", :resource => {:compression => '3'} do
it "should just execute 'cvs checkout' without a revision" do
provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
provider.create
end
end
end
context "when a source is not given" do
it "should execute 'cvs init'" do
provider.expects(:cvs).with('-d', resource.value(:path), 'init')
provider.create
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
resource_with :source do
it "should check for the CVS directory" do
File.expects(:directory?).with(File.join(resource.value(:path), 'CVS'))
provider.exists?
end
end
resource_without :source do
it "should check for the CVSROOT directory" do
File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT'))
provider.exists?
end
end
end
describe "checking the revision property" do
before do
@tag_file = File.join(resource.value(:path), 'CVS', 'Tag')
end
context "when CVS/Tag exists" do
before do
@tag = 'TAG'
File.expects(:exist?).with(@tag_file).returns(true)
end
it "should read CVS/Tag" do
File.expects(:read).with(@tag_file).returns("T#{@tag}")
provider.revision.should == @tag
end
end
context "when CVS/Tag does not exist" do
before do
File.expects(:exist?).with(@tag_file).returns(false)
end
it "assumes HEAD" do
provider.revision.should == 'HEAD'
end
end
end
describe "when setting the revision property" do
before do
@tag = 'SOMETAG'
end
it "should use 'cvs update -dr'" do
expects_chdir
provider.expects(:cvs).with('update', '-dr', @tag, '.')
provider.revision = @tag
end
end
end
require 'spec_helper'
describe_provider :vcsrepo, :cvs, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
context "with a source", :resource => {:source => ':ext:source@example.com:/foo/bar'} do
resource_with :revision do
it "should execute 'cvs checkout' and 'cvs update -r'" do
provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-r', 'an-unimportant-value', '-d', 'vcsrepo', 'bar')
expects_chdir(File.dirname(resource.value(:path)))
#provider.expects(:cvs).with('update', '-r', resource.value(:revision), '.')
provider.create
end
end
resource_without :revision do
it "should just execute 'cvs checkout' without a revision" do
provider.expects(:cvs).with('-d', resource.value(:source), 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
provider.create
end
end
context "with a compression", :resource => {:compression => '3'} do
it "should just execute 'cvs checkout' without a revision" do
provider.expects(:cvs).with('-d', resource.value(:source), '-z', '3', 'checkout', '-d', File.basename(resource.value(:path)), File.basename(resource.value(:source)))
provider.create
end
end
end
context "when a source is not given" do
it "should execute 'cvs init'" do
provider.expects(:cvs).with('-d', resource.value(:path), 'init')
provider.create
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
resource_with :source do
it "should check for the CVS directory" do
File.expects(:directory?).with(File.join(resource.value(:path), 'CVS'))
provider.exists?
end
end
resource_without :source do
it "should check for the CVSROOT directory" do
File.expects(:directory?).with(File.join(resource.value(:path), 'CVSROOT'))
provider.exists?
end
end
end
describe "checking the revision property" do
before do
@tag_file = File.join(resource.value(:path), 'CVS', 'Tag')
end
context "when CVS/Tag exists" do
before do
@tag = 'TAG'
File.expects(:exist?).with(@tag_file).returns(true)
end
it "should read CVS/Tag" do
File.expects(:read).with(@tag_file).returns("T#{@tag}")
provider.revision.should == @tag
end
end
context "when CVS/Tag does not exist" do
before do
File.expects(:exist?).with(@tag_file).returns(false)
end
it "assumes HEAD" do
provider.revision.should == 'HEAD'
end
end
end
describe "when setting the revision property" do
before do
@tag = 'SOMETAG'
end
it "should use 'cvs update -dr'" do
expects_chdir
provider.expects(:cvs).with('update', '-dr', @tag, '.')
provider.revision = @tag
end
end
end

View File

@@ -1,17 +1,17 @@
require 'spec_helper'
describe_provider :vcsrepo, :dummy, :resource => {:path => '/tmp/vcsrepo'} do
context 'dummy' do
resource_with :source do
resource_with :ensure => :present do
context "with nothing doing", :resource => {:revision => 'foo'} do
it "should raise an exception" do
proc { provider.working_copy_exists? }.should raise_error(RuntimeError)
end
end
end
end
end
end
require 'spec_helper'
describe_provider :vcsrepo, :dummy, :resource => {:path => '/tmp/vcsrepo'} do
context 'dummy' do
resource_with :source do
resource_with :ensure => :present do
context "with nothing doing", :resource => {:revision => 'foo'} do
it "should raise an exception" do
proc { provider.working_copy_exists? }.should raise_error(RuntimeError)
end
end
end
end
end
end

View File

@@ -1,248 +1,248 @@
require 'spec_helper'
describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context 'creating' do
resource_with :source do
resource_with :ensure => :present do
context "with a revision that is a remote branch", :resource => {:revision => 'only/remote'} do
it "should execute 'git clone' and 'git checkout -b'" do
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
expects_chdir('/')
expects_chdir
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
end
context "with a revision that is not a remote branch", :resource => {:revision => 'a-commit-or-tag'} do
it "should execute 'git clone' and 'git reset --hard'" do
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
expects_chdir('/')
expects_chdir
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
end
resource_without :revision do
it "should execute 'git clone' and submodule commands" do
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
provider.expects(:update_submodules)
provider.create
end
end
end
resource_with :ensure => :bare do
resource_with :revision do
it "should just execute 'git clone --bare'" do
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'git clone --bare'" do
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
provider.create
end
end
end
end
context "when a source is not given" do
resource_with :ensure => :present do
context "when the path does not exist" do
it "should execute 'git init'" do
expects_mkdir
expects_chdir
expects_directory?(false)
provider.expects(:bare_exists?).returns(false)
provider.expects(:git).with('init')
provider.create
end
end
context "when the path is a bare repository" do
it "should convert it to a working copy" do
provider.expects(:bare_exists?).returns(true)
provider.expects(:convert_bare_to_working_copy)
provider.create
end
end
context "when the path is not a repository" do
it "should raise an exception" do
provider.expects(:path_exists?).returns(true)
proc { provider.create }.should raise_error(Puppet::Error)
end
end
end
resource_with :ensure => :bare do
context "when the path does not exist" do
it "should execute 'git init --bare'" do
expects_chdir
expects_mkdir
expects_directory?(false)
provider.expects(:working_copy_exists?).returns(false)
provider.expects(:git).with('init', '--bare')
provider.create
end
end
context "when the path is a working copy repository" do
it "should convert it to a bare repository" do
provider.expects(:working_copy_exists?).returns(true)
provider.expects(:convert_working_copy_to_bare)
provider.create
end
end
context "when the path is not a repository" do
it "should raise an exception" do
expects_directory?(true)
proc { provider.create }.should raise_error(Puppet::Error)
end
end
end
end
end
context 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
context "checking the revision property" do
resource_with :revision do
before do
expects_chdir
provider.expects(:git).with('rev-parse', 'HEAD').returns('currentsha')
end
context "when its SHA is not different than the current SHA" do
it "should return the ref" do
provider.expects(:git).with('config', 'remote.origin.url').returns('')
provider.expects(:git).with('fetch', 'origin') # FIXME
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == resource.value(:revision)
end
end
context "when its SHA is different than the current SHA" do
it "should return the current SHA" do
provider.expects(:git).with('config', 'remote.origin.url').returns('')
provider.expects(:git).with('fetch', 'origin') # FIXME
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('othersha')
provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == 'currentsha'
end
end
context "when the source is modified" do
resource_with :source => 'git://git@foo.com/bar.git' do
it "should update the origin url" do
provider.expects(:git).with('config', 'remote.origin.url').returns('old')
provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git')
provider.expects(:git).with('fetch', 'origin') # FIXME
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == resource.value(:revision)
end
end
end
end
end
context "setting the revision property" do
before do
expects_chdir
end
context "when it's an existing local branch", :resource => {:revision => 'feature/foo'} do
it "should use 'git fetch' and 'git reset'" do
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}")
provider.revision = resource.value(:revision)
end
end
context "when it's a remote branch", :resource => {:revision => 'only/remote'} do
it "should use 'git fetch' and 'git reset'" do
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}")
provider.revision = resource.value(:revision)
end
end
context "when it's a commit or tag", :resource => {:revision => 'a-commit-or-tag'} do
it "should use 'git fetch' and 'git reset'" do
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
provider.expects(:git).with('submodule', 'init')
provider.expects(:git).with('submodule', 'update')
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
provider.expects(:git).with('submodule', 'foreach', 'git', 'submodule', 'init')
provider.expects(:git).with('submodule', 'foreach', 'git', 'submodule', 'update')
provider.revision = resource.value(:revision)
end
end
end
context "updating references" do
it "should use 'git fetch --tags'" do
expects_chdir
provider.expects(:git).with('config', 'remote.origin.url').returns('')
provider.expects(:git).with('fetch', 'origin')
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.update_references
end
end
context "checking if revision" do
before do
expects_chdir
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
end
context "is a local branch" do
context "when it's listed in 'git branch -a'", :resource => {:revision => 'feature/foo'} do
it "should return true" do
provider.should be_local_branch_revision
end
end
context "when it's not listed in 'git branch -a'" , :resource => {:revision => 'feature/notexist'}do
it "should return false" do
provider.should_not be_local_branch_revision
end
end
end
context "is a remote branch" do
context "when it's listed in 'git branch -a' with an 'origin/' prefix", :resource => {:revision => 'only/remote'} do
it "should return true" do
provider.should be_remote_branch_revision
end
end
context "when it's not listed in 'git branch -a' with an 'origin/' prefix" , :resource => {:revision => 'only/local'}do
it "should return false" do
provider.should_not be_remote_branch_revision
end
end
end
end
end
require 'spec_helper'
describe_provider :vcsrepo, :git, :resource => {:path => '/tmp/vcsrepo'} do
context 'creating' do
resource_with :source do
resource_with :ensure => :present do
context "with a revision that is a remote branch", :resource => {:revision => 'only/remote'} do
it "should execute 'git clone' and 'git checkout -b'" do
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
expects_chdir('/')
expects_chdir
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
end
context "with a revision that is not a remote branch", :resource => {:revision => 'a-commit-or-tag'} do
it "should execute 'git clone' and 'git reset --hard'" do
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
expects_chdir('/')
expects_chdir
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
end
resource_without :revision do
it "should execute 'git clone' and submodule commands" do
provider.expects(:git).with('clone', resource.value(:source), resource.value(:path))
provider.expects(:update_submodules)
provider.create
end
end
end
resource_with :ensure => :bare do
resource_with :revision do
it "should just execute 'git clone --bare'" do
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'git clone --bare'" do
provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path))
provider.create
end
end
end
end
context "when a source is not given" do
resource_with :ensure => :present do
context "when the path does not exist" do
it "should execute 'git init'" do
expects_mkdir
expects_chdir
expects_directory?(false)
provider.expects(:bare_exists?).returns(false)
provider.expects(:git).with('init')
provider.create
end
end
context "when the path is a bare repository" do
it "should convert it to a working copy" do
provider.expects(:bare_exists?).returns(true)
provider.expects(:convert_bare_to_working_copy)
provider.create
end
end
context "when the path is not a repository" do
it "should raise an exception" do
provider.expects(:path_exists?).returns(true)
proc { provider.create }.should raise_error(Puppet::Error)
end
end
end
resource_with :ensure => :bare do
context "when the path does not exist" do
it "should execute 'git init --bare'" do
expects_chdir
expects_mkdir
expects_directory?(false)
provider.expects(:working_copy_exists?).returns(false)
provider.expects(:git).with('init', '--bare')
provider.create
end
end
context "when the path is a working copy repository" do
it "should convert it to a bare repository" do
provider.expects(:working_copy_exists?).returns(true)
provider.expects(:convert_working_copy_to_bare)
provider.create
end
end
context "when the path is not a repository" do
it "should raise an exception" do
expects_directory?(true)
proc { provider.create }.should raise_error(Puppet::Error)
end
end
end
end
end
context 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
context "checking the revision property" do
resource_with :revision do
before do
expects_chdir
provider.expects(:git).with('rev-parse', 'HEAD').returns('currentsha')
end
context "when its SHA is not different than the current SHA" do
it "should return the ref" do
provider.expects(:git).with('config', 'remote.origin.url').returns('')
provider.expects(:git).with('fetch', 'origin') # FIXME
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == resource.value(:revision)
end
end
context "when its SHA is different than the current SHA" do
it "should return the current SHA" do
provider.expects(:git).with('config', 'remote.origin.url').returns('')
provider.expects(:git).with('fetch', 'origin') # FIXME
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('othersha')
provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == 'currentsha'
end
end
context "when the source is modified" do
resource_with :source => 'git://git@foo.com/bar.git' do
it "should update the origin url" do
provider.expects(:git).with('config', 'remote.origin.url').returns('old')
provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git')
provider.expects(:git).with('fetch', 'origin') # FIXME
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
provider.expects(:git).with('tag', '-l').returns("Hello")
provider.revision.should == resource.value(:revision)
end
end
end
end
end
context "setting the revision property" do
before do
expects_chdir
end
context "when it's an existing local branch", :resource => {:revision => 'feature/foo'} do
it "should use 'git fetch' and 'git reset'" do
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}")
provider.revision = resource.value(:revision)
end
end
context "when it's a remote branch", :resource => {:revision => 'only/remote'} do
it "should use 'git fetch' and 'git reset'" do
provider.expects(:update_submodules)
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.expects(:git).with('branch', '-a').returns(resource.value(:revision))
provider.expects(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}")
provider.revision = resource.value(:revision)
end
end
context "when it's a commit or tag", :resource => {:revision => 'a-commit-or-tag'} do
it "should use 'git fetch' and 'git reset'" do
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
provider.expects(:git).with('submodule', 'init')
provider.expects(:git).with('submodule', 'update')
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
provider.expects(:git).with('submodule', 'foreach', 'git', 'submodule', 'init')
provider.expects(:git).with('submodule', 'foreach', 'git', 'submodule', 'update')
provider.revision = resource.value(:revision)
end
end
end
context "updating references" do
it "should use 'git fetch --tags'" do
expects_chdir
provider.expects(:git).with('config', 'remote.origin.url').returns('')
provider.expects(:git).with('fetch', 'origin')
provider.expects(:git).with('fetch', '--tags', 'origin')
provider.update_references
end
end
context "checking if revision" do
before do
expects_chdir
provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
end
context "is a local branch" do
context "when it's listed in 'git branch -a'", :resource => {:revision => 'feature/foo'} do
it "should return true" do
provider.should be_local_branch_revision
end
end
context "when it's not listed in 'git branch -a'" , :resource => {:revision => 'feature/notexist'}do
it "should return false" do
provider.should_not be_local_branch_revision
end
end
end
context "is a remote branch" do
context "when it's listed in 'git branch -a' with an 'origin/' prefix", :resource => {:revision => 'only/remote'} do
it "should return true" do
provider.should be_remote_branch_revision
end
end
context "when it's not listed in 'git branch -a' with an 'origin/' prefix" , :resource => {:revision => 'only/local'}do
it "should return false" do
provider.should_not be_remote_branch_revision
end
end
end
end
end

View File

@@ -1,104 +1,104 @@
require 'spec_helper'
describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
resource_with :source do
resource_with :revision do
it "should execute 'hg clone -u' with the revision" do
provider.expects(:hg).with('clone', '-u',
resource.value(:revision),
resource.value(:source),
resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'hg clone' without a revision" do
provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path))
provider.create
end
end
end
context "when a source is not given" do
it "should execute 'hg init'" do
provider.expects(:hg).with('init', resource.value(:path))
provider.create
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
it "should check for the directory" do
expects_directory?(true, File.join(resource.value(:path), '.hg'))
provider.exists?
end
end
describe "checking the revision property" do
before do
expects_chdir
end
context "when given a non-SHA as the resource revision" do
before do
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
end
context "when its SHA is not different than the current SHA", :resource => {:revision => '0.6'} do
it "should return the ref" do
provider.revision.should == '0.6'
end
end
context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do
it "should return the current SHA" do
provider.revision.should == '34e6012c783a'
end
end
end
context "when given a SHA as the resource revision" do
before do
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
end
context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do
it "should return it" do
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
provider.revision.should == resource.value(:revision)
end
end
context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do
it "should return the current SHA" do
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
provider.revision.should == '34e6012c783a'
end
end
end
end
describe "setting the revision property" do
before do
@revision = '6aa99e9b3ab1'
end
it "should use 'hg update ---clean -r'" do
expects_chdir
provider.expects(:hg).with('pull')
provider.expects(:hg).with('merge')
provider.expects(:hg).with('update', '--clean', '-r', @revision)
provider.revision = @revision
end
end
end
require 'spec_helper'
describe_provider :vcsrepo, :hg, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
resource_with :source do
resource_with :revision do
it "should execute 'hg clone -u' with the revision" do
provider.expects(:hg).with('clone', '-u',
resource.value(:revision),
resource.value(:source),
resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'hg clone' without a revision" do
provider.expects(:hg).with('clone', resource.value(:source), resource.value(:path))
provider.create
end
end
end
context "when a source is not given" do
it "should execute 'hg init'" do
provider.expects(:hg).with('init', resource.value(:path))
provider.create
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
it "should check for the directory" do
expects_directory?(true, File.join(resource.value(:path), '.hg'))
provider.exists?
end
end
describe "checking the revision property" do
before do
expects_chdir
end
context "when given a non-SHA as the resource revision" do
before do
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
end
context "when its SHA is not different than the current SHA", :resource => {:revision => '0.6'} do
it "should return the ref" do
provider.revision.should == '0.6'
end
end
context "when its SHA is different than the current SHA", :resource => {:revision => '0.5.3'} do
it "should return the current SHA" do
provider.revision.should == '34e6012c783a'
end
end
end
context "when given a SHA as the resource revision" do
before do
provider.expects(:hg).with('parents').returns(fixture(:hg_parents))
end
context "when it is the same as the current SHA", :resource => {:revision => '34e6012c783a'} do
it "should return it" do
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
provider.revision.should == resource.value(:revision)
end
end
context "when it is not the same as the current SHA", :resource => {:revision => 'not-the-same'} do
it "should return the current SHA" do
provider.expects(:hg).with('tags').returns(fixture(:hg_tags))
provider.revision.should == '34e6012c783a'
end
end
end
end
describe "setting the revision property" do
before do
@revision = '6aa99e9b3ab1'
end
it "should use 'hg update ---clean -r'" do
expects_chdir
provider.expects(:hg).with('pull')
provider.expects(:hg).with('merge')
provider.expects(:hg).with('update', '--clean', '-r', @revision)
provider.revision = @revision
end
end
end

View File

@@ -1,78 +1,78 @@
require 'spec_helper'
describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
resource_with :source do
resource_with :revision do
it "should execute 'svn checkout' with a revision" do
provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
resource.value(:revision),
resource.value(:source),
resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'svn checkout' without a revision" do
provider.expects(:svn).with('--non-interactive', 'checkout',
resource.value(:source),
resource.value(:path))
provider.create
end
end
end
resource_without :source do
resource_with :fstype do
it "should execute 'svnadmin create' with an '--fs-type' option" do
provider.expects(:svnadmin).with('create', '--fs-type',
resource.value(:fstype),
resource.value(:path))
provider.create
end
end
resource_without :fstype do
it "should execute 'svnadmin create' without an '--fs-type' option" do
provider.expects(:svnadmin).with('create', resource.value(:path))
provider.create
end
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
it "should check for the directory" do
expects_directory?(true, File.join(resource.value(:path), '.svn'))
provider.exists?
end
end
describe "checking the revision property" do
before do
provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
end
it "should use 'svn info'" do
expects_chdir
provider.revision.should == '3' # From 'Last Changed Rev', not 'Revision'
end
end
describe "setting the revision property" do
before do
@revision = '30'
end
it "should use 'svn update'" do
expects_chdir
provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
provider.revision = @revision
end
end
end
require 'spec_helper'
describe_provider :vcsrepo, :svn, :resource => {:path => '/tmp/vcsrepo'} do
describe 'creating' do
resource_with :source do
resource_with :revision do
it "should execute 'svn checkout' with a revision" do
provider.expects(:svn).with('--non-interactive', 'checkout', '-r',
resource.value(:revision),
resource.value(:source),
resource.value(:path))
provider.create
end
end
resource_without :revision do
it "should just execute 'svn checkout' without a revision" do
provider.expects(:svn).with('--non-interactive', 'checkout',
resource.value(:source),
resource.value(:path))
provider.create
end
end
end
resource_without :source do
resource_with :fstype do
it "should execute 'svnadmin create' with an '--fs-type' option" do
provider.expects(:svnadmin).with('create', '--fs-type',
resource.value(:fstype),
resource.value(:path))
provider.create
end
end
resource_without :fstype do
it "should execute 'svnadmin create' without an '--fs-type' option" do
provider.expects(:svnadmin).with('create', resource.value(:path))
provider.create
end
end
end
end
describe 'destroying' do
it "it should remove the directory" do
expects_rm_rf
provider.destroy
end
end
describe "checking existence" do
it "should check for the directory" do
expects_directory?(true, File.join(resource.value(:path), '.svn'))
provider.exists?
end
end
describe "checking the revision property" do
before do
provider.expects(:svn).with('--non-interactive', 'info').returns(fixture(:svn_info))
end
it "should use 'svn info'" do
expects_chdir
provider.revision.should == '3' # From 'Last Changed Rev', not 'Revision'
end
end
describe "setting the revision property" do
before do
@revision = '30'
end
it "should use 'svn update'" do
expects_chdir
provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision)
provider.revision = @revision
end
end
end

View File

@@ -1,4 +1,4 @@
Resource Type Specs
===================
Define specs for your resource types in this directory.
Resource Type Specs
===================
Define specs for your resource types in this directory.