Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add functional test * Add helper functions * Add unit tests
- Loading branch information
Showing
6 changed files
with
253 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# import mock | ||
import unit_tests.utils as ut_utils | ||
import zaza.utilities.ceph as ceph_utils | ||
|
||
|
||
class TestCephUtils(ut_utils.BaseTestCase): | ||
|
||
def setUp(self): | ||
super(TestCephUtils, self).setUp() | ||
|
||
def test_get_ceph_osd_id_cmd(self): | ||
osd_id = 1 | ||
expected = ("`initctl list | grep 'ceph-osd ' | " | ||
"awk 'NR=={} {{ print $2 }}' | " | ||
"grep -o '[0-9]*'`".format(osd_id + 1)) | ||
actual = ceph_utils.get_ceph_osd_id_cmd(osd_id) | ||
self.assertEqual(expected, actual) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Module containing Ceph related utilities.""" | ||
|
||
|
||
def get_ceph_osd_id_cmd(osd_id): | ||
"""Get ceph OSD command. | ||
Produce a shell command that will return a ceph-osd id. | ||
:returns: Command for ceph OSD. | ||
:rtype: string | ||
""" | ||
return ("`initctl list | grep 'ceph-osd ' | " | ||
"awk 'NR=={} {{ print $2 }}' | " | ||
"grep -o '[0-9]*'`".format(osd_id + 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters