Skip to content

Commit

Permalink
Tests out all the different ways to mount cephfs
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Huf committed Jul 9, 2014
1 parent 88f1a5b commit 4412f63
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 0 deletions.
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ suites:
- { device: "/dev/sdd" }
run_list:
- recipe[ceph::all_in_one]
- recipe[ceph_test::cephfs]
1 change: 1 addition & 0 deletions Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ metadata

group :integration do
cookbook 'apt'
cookbook 'ceph_test', path: 'test/cookbooks/ceph_test'
end
13 changes: 13 additions & 0 deletions test/cookbooks/ceph_test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ceph_test CHANGELOG
===================

This file is used to list changes made in each version of the ceph_test cookbook.

0.1.0
-----
- [your_name] - Initial release of ceph_test

- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.

The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
68 changes: 68 additions & 0 deletions test/cookbooks/ceph_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
ceph_test Cookbook
==================
TODO: Enter the cookbook description here.

e.g.
This cookbook makes your favorite breakfast sandwich.

Requirements
------------
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.

e.g.
#### packages
- `toaster` - ceph_test needs toaster to brown your bagel.

Attributes
----------
TODO: List your cookbook attributes here.

e.g.
#### ceph_test::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['ceph_test']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>

Usage
-----
#### ceph_test::default
TODO: Write usage instructions for each cookbook.

e.g.
Just include `ceph_test` in your node's `run_list`:

```json
{
"name":"my_node",
"run_list": [
"recipe[ceph_test]"
]
}
```

Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.

e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github

License and Authors
-------------------
Authors: TODO: List authors
8 changes: 8 additions & 0 deletions test/cookbooks/ceph_test/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name 'ceph_test'
maintainer 'Kyle Bader'
maintainer_email 'kyle.bader@dreamhost.com'
license 'Apache 2.0'
description 'Installs/Configures ceph_test'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'ceph'
53 changes: 53 additions & 0 deletions test/cookbooks/ceph_test/recipes/cephfs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# Author:: Kyle Bader <kyle.bader@dreamhost.com>
# Cookbook Name:: ceph_test
# Recipe:: cephfs
#
# Copyright 2011, DreamHost Web Hosting
#
# 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.

requires_fuse =
case node['platform']
when 'debian'
node['platform_version'].to_f < 7.0
when 'ubuntu'
node['platform_version'].to_f < 12.04
when 'redhat'
node['platform_version'].to_f < 7.0
when 'fedora'
node['platform_version'].to_f < 17.0
else
true
end

ceph_cephfs '/ceph' do
use_fuse requires_fuse
action [:mount, :enable]
end
ceph_cephfs '/ceph.fuse' do
use_fuse true
action [:mount]
end
directory '/ceph/subdir'
file '/ceph/subdir/file' do
content "It works\n"
end

unless requires_fuse
ceph_cephfs '/subceph' do
use_fuse false
cephfs_subdir '/subdir'
action [:mount]
end
end
37 changes: 37 additions & 0 deletions test/integration/aio/bats/cephfs.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@test "/ceph is mounted" {
grep -q -E '^\S+\s+/ceph\s+' /proc/mounts
}
@test "/ceph.fuse is mounted" {
grep -q -E '^\S+\s+/ceph\.fuse\s+fuse' /proc/mounts
}

@test "/ceph is in fstab" {
grep -q -E '^\S+\s+/ceph\s+' /etc/fstab
}
@test "/ceph.fuse is NOT in fstab" {
grep -v -q -E '^\S+\s+/ceph.fuse\s+' /etc/fstab
}

@test "test file exists in /ceph" {
test -e /ceph/subdir/file
grep -q 'It works' /ceph/subdir/file
}
@test "test file exists in /ceph.fuse" {
test -e /ceph.fuse/subdir/file
grep -q 'It works' /ceph.fuse/subdir/file
}

# if we are using kernel cephfs
if grep -q -E '^\S+\s+/ceph\s+ceph' /proc/mounts; then
@test "/subceph is mounted" {
grep -q -E '^\S+\s+/subceph\s+ceph' /proc/mounts
}
@test "/subceph is NOT in fstab" {
grep -v -q -E '^\S+\s+/subceph\s+' /etc/fstab
}
@test "test file exists in /subceph" {
test -e /subceph/file
grep -q 'It works' /subceph/file
}
fi

0 comments on commit 4412f63

Please sign in to comment.