]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-22118] tests: update osd disk tests for API change
authorAlfredo Deza <adeza@redhat.com>
Wed, 29 Nov 2017 12:10:16 +0000 (07:10 -0500)
committerAlfredo Deza <adeza@redhat.com>
Wed, 29 Nov 2017 13:52:32 +0000 (08:52 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
ceph_deploy/tests/parser/test_disk.py

index e2851add750199c38b8c4e663d8601a8203c7194..02c11ab8213a12f1b73601dfa765db6987d50cbc 100644 (file)
@@ -3,7 +3,7 @@ import pytest
 from ceph_deploy.cli import get_parser
 from ceph_deploy.tests.util import assert_too_few_arguments
 
-SUBCMDS_WITH_ARGS = ['list', 'prepare', 'activate', 'zap']
+SUBCMDS_WITH_ARGS = ['list', 'zap']
 
 
 class TestParserDisk(object):
@@ -43,98 +43,12 @@ class TestParserDisk(object):
 
     def test_disk_list_single_host(self):
         args = self.parser.parse_args('disk list host1'.split())
-        assert args.disk[0][0] == 'host1'
+        assert args.host[0] == 'host1'
 
     def test_disk_list_multi_host(self):
         hostnames = ['host1', 'host2', 'host3']
         args = self.parser.parse_args('disk list'.split() + hostnames)
-        # args.disk is a list of tuples, and tuple[0] is the hostname
-        hosts = [x[0] for x in args.disk]
-        assert hosts == hostnames
-
-    def test_disk_prepare_help(self, capsys):
-        with pytest.raises(SystemExit):
-            self.parser.parse_args('disk prepare --help'.split())
-        out, err = capsys.readouterr()
-        assert 'usage: ceph-deploy disk prepare' in out
-
-    def test_disk_prepare_zap_default_false(self):
-        args = self.parser.parse_args('disk prepare host1:sdb'.split())
-        assert args.zap_disk is False
-
-    def test_disk_prepare_zap_true(self):
-        args = self.parser.parse_args('disk prepare --zap-disk host1:sdb'.split())
-        assert args.zap_disk is True
-
-    def test_disk_prepare_fstype_default_xfs(self):
-        args = self.parser.parse_args('disk prepare host1:sdb'.split())
-        assert args.fs_type == "xfs"
-
-    def test_disk_prepare_fstype_btrfs(self):
-        args = self.parser.parse_args('disk prepare --fs-type btrfs host1:sdb'.split())
-        assert args.fs_type == "btrfs"
-
-    def test_disk_prepare_fstype_invalid(self, capsys):
-        with pytest.raises(SystemExit):
-            self.parser.parse_args('disk prepare --fs-type bork host1:sdb'.split())
-        out, err = capsys.readouterr()
-        assert 'invalid choice' in err
-
-    def test_disk_prepare_dmcrypt_default_false(self):
-        args = self.parser.parse_args('disk prepare host1:sdb'.split())
-        assert args.dmcrypt is False
-
-    def test_disk_prepare_dmcrypt_true(self):
-        args = self.parser.parse_args('disk prepare --dmcrypt host1:sdb'.split())
-        assert args.dmcrypt is True
-
-    def test_disk_prepare_dmcrypt_key_dir_default(self):
-        args = self.parser.parse_args('disk prepare host1:sdb'.split())
-        assert args.dmcrypt_key_dir == "/etc/ceph/dmcrypt-keys"
-
-    def test_disk_prepare_dmcrypt_key_dir_custom(self):
-        args = self.parser.parse_args('disk prepare --dmcrypt --dmcrypt-key-dir /tmp/keys host1:sdb'.split())
-        assert args.dmcrypt_key_dir == "/tmp/keys"
-
-    def test_disk_prepare_host_required(self, capsys):
-        with pytest.raises(SystemExit):
-            self.parser.parse_args('disk prepare'.split())
-        out, err = capsys.readouterr()
-        assert_too_few_arguments(err)
-
-    def test_disk_prepare_single_host(self):
-        args = self.parser.parse_args('disk prepare host1:sdb'.split())
-        assert args.disk[0][0] == 'host1'
-
-    def test_disk_prepare_multi_host(self):
-        hostnames = ['host1', 'host2', 'host3']
-        args = self.parser.parse_args('disk prepare'.split() + [x + ":sdb" for x in hostnames])
-        # args.disk is a list of tuples, and tuple[0] is the hostname
-        hosts = [x[0] for x in args.disk]
-        assert hosts == hostnames
-
-    def test_disk_activate_help(self, capsys):
-        with pytest.raises(SystemExit):
-            self.parser.parse_args('disk activate --help'.split())
-        out, err = capsys.readouterr()
-        assert 'usage: ceph-deploy disk activate' in out
-
-    def test_disk_activate_host_required(self, capsys):
-        with pytest.raises(SystemExit):
-            self.parser.parse_args('disk activate'.split())
-        out, err = capsys.readouterr()
-        assert_too_few_arguments(err)
-
-    def test_disk_activate_single_host(self):
-        args = self.parser.parse_args('disk activate host1:sdb1'.split())
-        assert args.disk[0][0] == 'host1'
-
-    def test_disk_activate_multi_host(self):
-        hostnames = ['host1', 'host2', 'host3']
-        args = self.parser.parse_args('disk activate'.split() + [x + ":sdb1" for x in hostnames])
-        # args.disk is a list of tuples, and tuple[0] is the hostname
-        hosts = [x[0] for x in args.disk]
-        assert hosts == hostnames
+        assert args.host == hostnames
 
     def test_disk_zap_help(self, capsys):
         with pytest.raises(SystemExit):
@@ -149,12 +63,12 @@ class TestParserDisk(object):
         assert_too_few_arguments(err)
 
     def test_disk_zap_single_host(self):
-        args = self.parser.parse_args('disk zap host1:sdb'.split())
-        assert args.disk[0][0] == 'host1'
+        args = self.parser.parse_args('disk zap host1 /dev/sdb'.split())
+        assert args.disk[0] == '/dev/sdb'
+        assert args.host == 'host1'
 
     def test_disk_zap_multi_host(self):
-        hostnames = ['host1', 'host2', 'host3']
-        args = self.parser.parse_args('disk zap'.split() + [x + ":sdb" for x in hostnames])
-        # args.disk is a list of tuples, and tuple[0] is the hostname
-        hosts = [x[0] for x in args.disk]
-        assert hosts == hostnames
+        host = 'host1'
+        disks = ['/dev/sda1', '/dev/sda2']
+        args = self.parser.parse_args(['disk', 'zap', host] + disks)
+        assert args.disk == disks