Initial Vagrant testing support, using the Chef provider with Chef Zero.

The Vagrant box is the default 12.04 and 13.04 provided by Opscode's Bento
project. It uses the Vagrant plugins vagrant-berkshelf, vagrant-cachier,
vagrant-chef-zero and vagrant-omnibus. Unfortunately Chef Zero does not
understand .rb files yet, so we're using the recipes directly in the run
list. This also means that searching by roles is broken so this needs to be
fixed ASAP.

Change-Id: I5fe8b175f15c4a21c16de46bc05ec6a0c27cfdaa
This commit is contained in:
Matt Ray 2013-09-21 13:38:33 -05:00
parent c32f2a1445
commit 7e32b4747e
7 changed files with 299 additions and 99 deletions

2
.gitignore vendored
View File

@ -11,5 +11,7 @@
.bundle
.berkshelf
.vagabond
.vagrant
berks.json
.kitchen
.zero-knife.rb

View File

@ -1,7 +1,7 @@
site :opscode
cookbook 'apache2', '1.6.2'
cookbook 'apt', '1.9.2'
cookbook 'apt', '2.1.1'
cookbook 'aws', '0.101.0'
cookbook 'build-essential', '1.4.0'
cookbook 'database', '~> 1.4.0'
@ -9,19 +9,20 @@ cookbook 'erlang', '1.3.0'
cookbook 'memcached'
cookbook 'mysql', '3.0.0'
cookbook 'openssl', '1.0.2'
cookbook 'packages', '0.1.0'
cookbook 'postgresql', '3.0.0'
cookbook 'rabbitmq', '~> 2.1.0'
cookbook 'xfs', '1.1.0'
cookbook 'yum', '2.2.2'
cookbook 'openstack-block-storage', github: "stackforge/cookbook-openstack-block-storage"
cookbook 'openstack-common', github: "stackforge/cookbook-openstack-common"
cookbook 'openstack-block-storage', github: 'stackforge/cookbook-openstack-block-storage'
cookbook 'openstack-common', github: 'stackforge/cookbook-openstack-common'
cookbook 'openstack-compute', github: 'stackforge/cookbook-openstack-compute'
cookbook 'openstack-dashboard', github: 'stackforge/cookbook-openstack-dashboard'
cookbook 'openstack-identity', github: 'stackforge/cookbook-openstack-identity'
cookbook 'openstack-image', github: 'stackforge/cookbook-openstack-image'
cookbook 'openstack-metering', github: 'stackforge/cookbook-openstack-metering'
cookbook 'openstack-network', github: 'stackforge/cookbook-openstack-network'
cookbook 'openstack-object-storage', github: "stackforge/cookbook-openstack-object-storage"
cookbook 'openstack-object-storage', github: 'stackforge/cookbook-openstack-object-storage'
cookbook 'openstack-ops-database', github: 'stackforge/cookbook-openstack-ops-database'
cookbook 'openstack-ops-messaging', github: 'stackforge/cookbook-openstack-ops-messaging'

View File

@ -4,7 +4,7 @@
"locked_version": "1.6.2"
},
"apt": {
"locked_version": "1.9.2"
"locked_version": "2.1.1"
},
"aws": {
"locked_version": "0.101.0"
@ -19,7 +19,7 @@
"locked_version": "1.3.0"
},
"memcached": {
"locked_version": "1.4.0"
"locked_version": "1.5.0"
},
"mysql": {
"locked_version": "3.0.0"
@ -27,6 +27,9 @@
"openssl": {
"locked_version": "1.0.2"
},
"packages": {
"locked_version": "0.1.0"
},
"postgresql": {
"locked_version": "3.0.0"
},
@ -40,9 +43,9 @@
"locked_version": "2.2.2"
},
"openstack-block-storage": {
"locked_version": "7.0.0",
"locked_version": "7.0.2",
"git": "git://github.com/stackforge/cookbook-openstack-block-storage.git",
"ref": "fe9e955de111fef2c0e9f60d2d8be3a0101e79e8"
"ref": "af20b1e5219e8b66c83c1af6275ea54aeb293d34"
},
"openstack-common": {
"locked_version": "0.4.3",
@ -52,22 +55,22 @@
"openstack-compute": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-compute.git",
"ref": "09f7cb177734c7d9e0ba6a15bda7bdafc4214d33"
"ref": "2dd5a554dee644621551417906dec098c1f7f70f"
},
"openstack-dashboard": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-dashboard.git",
"ref": "1051d4a6f2960ca59793789039a263f763e31464"
"ref": "89009e26a415137b808140b59d6915f6e97b39e3"
},
"openstack-identity": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-identity.git",
"ref": "b881af26095cfa869a6970067c49597a0ee63586"
"ref": "e0cf42e1019d1998f447520fcd1a97e4bbd2a01c"
},
"openstack-image": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-image.git",
"ref": "637c04412e600b10147ff1c1853d99b75f46840e"
"ref": "722a973a09ef7c2d58ac010cd0659ca48a81c266"
},
"openstack-metering": {
"locked_version": "7.0.4",
@ -77,17 +80,17 @@
"openstack-network": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-network.git",
"ref": "b4bfd38efede48d4405364322a7dd84f936b21c1"
"ref": "45954b707295a1a1de0b5abc7fafd4d9bd8741c8"
},
"openstack-object-storage": {
"locked_version": "1.0.16",
"locked_version": "1.1.0",
"git": "git://github.com/stackforge/cookbook-openstack-object-storage.git",
"ref": "fe10aaeeb99d555b5929bb0767688373dafd220c"
"ref": "54b7e7719af5edff343971d570bdfd2e8f162720"
},
"openstack-ops-database": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-ops-database.git",
"ref": "28619c1357a826dae4a74d6ac3f14c7fdef5a740"
"ref": "cf8e48039bef2a6ff3a8215cd5a79d8193d6cefd"
},
"openstack-ops-messaging": {
"locked_version": "7.0.0",
@ -100,12 +103,12 @@
"selinux": {
"locked_version": "0.5.6"
},
"sysctl": {
"locked_version": "0.3.3"
},
"python": {
"locked_version": "1.4.0"
},
"sysctl": {
"locked_version": "0.3.3"
},
"statsd": {
"locked_version": "0.0.1"
},

View File

@ -72,87 +72,9 @@ http://github.com/stackforge/cookbook-openstack-object-storage/
There is further documentation in the [OpenStack Object Storage cookbook README](http://github.com/stackforge/cookbook-openstack-object-storage/).
## Testing
# Testing #
We use Vagabond to do integration testing. The Vagabondfile in the root
directory of the Chef repo contains the definitions of the nodes that
are used during integration testing.
To set up Vagabond, do this:
bundle exec vagabond init
When prompted, answer "N" to not overwrite the existing Vagabondfile, and then
answer "n" for all templates you don't want to use and "y" for the rest.
When running integration tests, Vagabond starts up a set of LXC containers
to represent the actual hardware nodes used in a deployment, including the
Chef server itself. The nodes we use in integration testing are the
following:
* `server` -- A hardcoded LXC instance name that contains a Chef 11 server
that is loaded up with the Berkshelf cookbooks, the role definitions,
and environment definitions defined in this Chef repo
* `ops` -- An LXC instance that gets all the ops-related recipes and applications
installed in it, including databases, message queues, logging, etc
* `compute-worker` -- An LXC instance that acts as a compute worker
* `controller` -- An LXC instance that contains all the OpenStack control software
### Vagabond Local Chef Server
To start the local Chef 11 server LXC instance using Vagabond:
bundle exec vagabond server up
The above will automatically upload the roles and environment
definitions in this Chef repo along with all of the cookbooks
in the Berkshelf.
To re-upload all of the cookbooks in the Berkshelf, simply do:
bundle exec vagabond server upload_cookbooks
To re-upload the roles or environment files:
bundle exec vagabond server upload_roles
bundle exec vagabond server upload_environments
Remember that the above will install the **current** Berkshelf. Remember to
run:
bundle exec berks update
before you do the `vagabond server upload_cookbooks` command.
### Test Nodes
To start any of the LXC instances that represent the different ops, controller
and worker nodes in an OpenStack environment, do:
bundle exec vagabond up <NODE>
If you make changes to cookbooks and issue a `vagabond server upload_cookbooks` or
role/environment definitions, you will want to re-provision the node, which basically
ensures the node is up and runs chef-client on it:
bundle exec vagabond provision <NODE>
To destroy a node:
bundle exec vagabond destroy <NODE>
To entirely rebuild a node from scratch:
bundle exec vagabond rebuild <NODE>
When a node is up, you can SSH into that node to run tests or investigate logs, etc:
bundle exec vagabond ssh <NODE>
To see the status of all the nodes that Vagabond is managing, including the IP addresses
that the containers are bound to:
bundle exec vagabond status
Please refer to the [TESTING.md](TESTING.md) for instructions for testing the repository and cookbooks with Vagrant or Vagabond.
# License and Author #

101
TESTING.md Normal file
View File

@ -0,0 +1,101 @@
# Testing with Vagrant #
The allinone-compute role may be tested with Vagrant, currently with Ubuntu 12.04 and 13.04. You need the following prerequisites:
1. You must have Vagrant 1.2.1 or later installed.
2. You must have a "sane" Ruby 1.9.3 environment.
3. You must have the following Vagrant plugins:
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-cachier
vagrant plugin install vagrant-chef-zero
vagrant plugin install vagrant-omnibus
To test with Ubuntu 12.04, run:
vagrant up ubuntu1204
To test with Ubuntu 13.04, run:
vagrant up ubuntu1304
# Testing with Vagabond #
We use Vagabond to do integration testing. The Vagabondfile in the root
directory of the Chef repo contains the definitions of the nodes that
are used during integration testing.
To set up Vagabond, do this:
bundle exec vagabond init
When prompted, answer "N" to not overwrite the existing Vagabondfile, and then
answer "n" for all templates you don't want to use and "y" for the rest.
When running integration tests, Vagabond starts up a set of LXC containers
to represent the actual hardware nodes used in a deployment, including the
Chef server itself. The nodes we use in integration testing are the
following:
* `server` -- A hardcoded LXC instance name that contains a Chef 11 server
that is loaded up with the Berkshelf cookbooks, the role definitions,
and environment definitions defined in this Chef repo
* `ops` -- An LXC instance that gets all the ops-related recipes and applications
installed in it, including databases, message queues, logging, etc
* `compute-worker` -- An LXC instance that acts as a compute worker
* `controller` -- An LXC instance that contains all the OpenStack control software
### Vagabond Local Chef Server
To start the local Chef 11 server LXC instance using Vagabond:
bundle exec vagabond server up
The above will automatically upload the roles and environment
definitions in this Chef repo along with all of the cookbooks
in the Berkshelf.
To re-upload all of the cookbooks in the Berkshelf, simply do:
bundle exec vagabond server upload_cookbooks
To re-upload the roles or environment files:
bundle exec vagabond server upload_roles
bundle exec vagabond server upload_environments
Remember that the above will install the **current** Berkshelf. Remember to
run:
bundle exec berks update
before you do the `vagabond server upload_cookbooks` command.
### Test Nodes
To start any of the LXC instances that represent the different ops, controller
and worker nodes in an OpenStack environment, do:
bundle exec vagabond up <NODE>
If you make changes to cookbooks and issue a `vagabond server upload_cookbooks` or
role/environment definitions, you will want to re-provision the node, which basically
ensures the node is up and runs chef-client on it:
bundle exec vagabond provision <NODE>
To destroy a node:
bundle exec vagabond destroy <NODE>
To entirely rebuild a node from scratch:
bundle exec vagabond rebuild <NODE>
When a node is up, you can SSH into that node to run tests or investigate logs, etc:
bundle exec vagabond ssh <NODE>
To see the status of all the nodes that Vagabond is managing, including the IP addresses
that the containers are bound to:
bundle exec vagabond status

100
Vagrantfile vendored Normal file
View File

@ -0,0 +1,100 @@
Vagrant.require_plugin "vagrant-berkshelf"
Vagrant.require_plugin "vagrant-cachier"
Vagrant.require_plugin "vagrant-chef-zero"
Vagrant.require_plugin "vagrant-omnibus"
Vagrant.configure("2") do |config|
# Berkshelf plugin configuration
config.berkshelf.enabled = true
# Cachier plugin configuration
config.cache.auto_detect = true
# Chef-Zero plugin configuration
config.chef_zero.enabled = true
config.chef_zero.chef_repo_path = "."
# Omnibus plugin configuration
config.omnibus.chef_version = :latest
# OpenStack-related settings
config.vm.network "private_network", ip: "33.33.33.60"
config.vm.network "private_network", ip: "192.168.100.60"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cpus", 2]
vb.customize ["modifyvm", :id, "--memory", 1024]
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
end
# Chef Zero doesn't do .rb files yet, so we expand out the allinone to the recipes
roleallinone = [
# "role[os-base]",
"recipe[openstack-common]",
"recipe[openstack-common::logging]",
# "role[os-ops-database]",
"recipe[openstack-ops-database::server]",
"recipe[openstack-ops-database::openstack-db]",
# "role[os-ops-messaging]",
"recipe[openstack-ops-messaging::server]",
# "role[os-identity]",
"recipe[openstack-identity::server]",
"recipe[openstack-identity::registration]",
# "role[os-image]",
"recipe[openstack-image::identity_registration]",
"recipe[openstack-image::registry]",
"recipe[openstack-image::api]",
# "role[os-network]",
"recipe[openstack-network::common]",
# "role[os-compute-setup]",
"recipe[openstack-compute::nova-setup]",
"recipe[openstack-compute::identity-registration]",
# "role[os-compute-conductor]",
"recipe[openstack-compute::conductor]",
# "role[os-compute-scheduler]",
"recipe[openstack-compute::scheduler]",
# "role[os-compute-api]",
"recipe[openstack-compute::api-ec2]",
"recipe[openstack-compute::api-os-compute]",
"recipe[openstack-compute::api-metadata]",
"recipe[openstack-compute::identity_registration]",
# "role[os-block-storage]",
"recipe[openstack-block-storage::api]",
"recipe[openstack-block-storage::scheduler]",
"recipe[openstack-block-storage::volume]",
"recipe[openstack-block-storage::identity_registration]",
# "role[os-compute-cert]",
"recipe[openstack-compute::nova-cert]",
# "role[os-compute-vncproxy]",
"recipe[openstack-compute::vncproxy]",
# "role[os-dashboard]",
"recipe[openstack-dashboard::server]",
# "role[os-compute-worker]"
"recipe[openstack-compute::compute]"
]
# Ubuntu 12.04 Config
config.vm.define :ubuntu1204 do |ubuntu1204|
ubuntu1204.vm.hostname = "ubuntu1204"
ubuntu1204.vm.box = "opscode-ubuntu-12.04"
ubuntu1204.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"
ubuntu1204.vm.provision :chef_client do |chef|
chef.environment = "vagrant"
chef.run_list = [ "recipe[apt]", "recipe[packages]", roleallinone ]
end
end
# Ubuntu 13.04 Config
config.vm.define :ubuntu1304 do |ubuntu1304|
ubuntu1304.vm.hostname = "ubuntu1304"
ubuntu1304.vm.box = "opscode-ubuntu-13.04"
ubuntu1304.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box"
ubuntu1304.vm.provision :chef_client do |chef|
chef.environment = "vagrant"
chef.run_list = [ "recipe[apt]", "recipe[packages]", roleallinone ]
end
end
end

71
environments/vagrant.json Normal file
View File

@ -0,0 +1,71 @@
{
"name": "vagrant",
"description": "Environment used in testing with Vagrant the upstream cookbooks and reference Chef repository. Defines the network and database settings to use with OpenStack. The networks will be used in the libraries provided by the osops-utils cookbook. This example is for FlatDHCP with 2 physical networks.",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
"packages": [
"avahi-daemon",
"libxslt1-dev",
"libxml2-dev"
],
"mysql": {
"allow_remote_root": true,
"root_network_acl": "%"
},
"openstack": {
"developer_mode": true,
"identity": {
"bind_interface": "lo"
},
"image": {
"image_upload": false,
"upload_images": ["cirros"],
"upload_image": {
"cirros": "https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img"
},
"identity_service_chef_role": "allinone-compute"
},
"block-storage": {
"keystone_service_chef_role": "allinone-compute"
},
"dashboard": {
"keystone_service_chef_role": "allinone-compute"
},
"network": {
"rabbit_server_chef_role": "allinone-compute"
},
"compute": {
"identity_service_chef_role": "allinone-compute",
"network": {
"fixed_range": "192.168.100.0/24",
"public_interface": "eth2"
},
"config": {
"ram_allocation_ratio": 5.0
},
"libvirt": {
"virt_type": "qemu"
},
"networks": [
{
"label": "public",
"ipv4_cidr": "192.168.100.0/24",
"num_networks": "1",
"network_size": "255",
"bridge": "br100",
"bridge_dev": "eth2",
"dns1": "8.8.8.8",
"dns2": "8.8.4.4"
}
]
}
}
}
}