]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph_key: fix after rebase
authorSébastien Han <seb@redhat.com>
Tue, 27 Nov 2018 08:59:07 +0000 (09:59 +0100)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Tue, 27 Nov 2018 16:47:40 +0000 (16:47 +0000)
Fix the tests

Signed-off-by: Sébastien Han <seb@redhat.com>
library/ceph_key.py
library/test_ceph_key.py

index f25275e5c9c6881b9f7bb006b31b5bad118a334d..9b42a06b73157fb884d4465ad2dae4171d29b512 100644 (file)
@@ -590,7 +590,7 @@ def run_module():
                 module.exit_json(**result)
 
         rc, cmd, out, err = exec_commands(module, create_key(
-            module, result, cluster, name, secret, caps, import_key, dest, container_image))  # noqa E501
+            module, result, cluster, name, secret, caps, import_key, file_path, container_image))  # noqa E501
 
         file_args = module.load_file_common_arguments(module.params)
         file_args['path'] = file_path
index 7a2a7c9ca12977fec97fa935c025b9fe7297d367..7a99bb32124bf3852e378f845f7ffaa4a6a362d0 100644 (file)
@@ -1,8 +1,10 @@
 import json
 import os
 from . import ceph_key
+import mock
 
 
+@mock.patch.dict(os.environ, {'CEPH_CONTAINER_BINARY': 'docker'})
 class TestCephKeyModule(object):
 
     def test_generate_secret(self):
@@ -120,7 +122,7 @@ class TestCephKeyModule(object):
             'allow rwx',
         ]
         result = ceph_key.generate_ceph_authtool_cmd(
-            fake_cluster, fake_name, fake_secret, fake_caps, fake_dest)  # noqa E501
+            fake_cluster, fake_name, fake_secret, fake_caps, fake_file_destination)  # noqa E501
         assert result == expected_command_list
 
     def test_generate_ceph_authtool_cmd_container(self):
@@ -157,7 +159,7 @@ class TestCephKeyModule(object):
                                  'osd',
                                  'allow rwx']
         result = ceph_key.generate_ceph_authtool_cmd(
-            fake_cluster, fake_name, fake_secret, fake_caps, fake_dest, fake_container_image)  # noqa E501
+            fake_cluster, fake_name, fake_secret, fake_caps, fake_file_destination, fake_container_image)  # noqa E501
         assert result == expected_command_list
 
     def test_create_key_non_container(self):
@@ -181,7 +183,7 @@ class TestCephKeyModule(object):
                 'import', '-i', fake_file_destination],
         ]
         result = ceph_key.create_key(fake_module, fake_result, fake_cluster,
-                                     fake_name, fake_secret, fake_caps, fake_import_key, fake_dest)  # noqa E501
+                                     fake_name, fake_secret, fake_caps, fake_import_key, fake_file_destination)  # noqa E501
         assert result == expected_command_list
 
     def test_create_key_container(self):
@@ -230,7 +232,7 @@ class TestCephKeyModule(object):
             '-i', fake_file_destination]
         ]
         result = ceph_key.create_key(fake_module, fake_result, fake_cluster, fake_name,  # noqa E501
-                                     fake_secret, fake_caps, fake_import_key, fake_dest, fake_container_image)  # noqa E501
+                                     fake_secret, fake_caps, fake_import_key, fake_file_destination, fake_container_image)  # noqa E501
         assert result == expected_command_list
 
     def test_create_key_non_container_no_import(self):
@@ -264,7 +266,7 @@ class TestCephKeyModule(object):
             'allow rwx', ]
         ]
         result = ceph_key.create_key(fake_module, fake_result, fake_cluster,
-                                     fake_name, fake_secret, fake_caps, fake_import_key, fake_dest)  # noqa E501
+                                     fake_name, fake_secret, fake_caps, fake_import_key, fake_file_destination)  # noqa E501
         assert result == expected_command_list
 
     def test_create_key_container_no_import(self):
@@ -305,7 +307,7 @@ class TestCephKeyModule(object):
                                  'osd',
                                  'allow rwx']]
         result = ceph_key.create_key(fake_module, fake_result, fake_cluster, fake_name,  # noqa E501
-                                     fake_secret, fake_caps, fake_import_key, fake_dest, fake_container_image)  # noqa E501
+                                     fake_secret, fake_caps, fake_import_key, fake_file_destination, fake_container_image)  # noqa E501
         assert result == expected_command_list
 
     def test_update_key_non_container(self):
@@ -436,16 +438,27 @@ class TestCephKeyModule(object):
     def test_get_key_container(self):
         fake_cluster = "fake"
         fake_name = "client.fake"
-        fake_containerized = "docker exec -ti ceph-mon"
+        fake_container_image = "docker.io/ceph/daemon:latest-luminous"
         fake_dest = "/fake/ceph"
         fake_file_destination = os.path.join(
             fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
-        expected_command_list = [
-            ['docker', 'exec', '-ti', 'ceph-mon', 'ceph', '-n', "client.admin", '-k', "/etc/ceph/fake.client.admin.keyring", '--cluster',  # noqa E501
-                fake_cluster, 'auth', 'get', fake_name, '-o', fake_file_destination],  # noqa E501
+        expected_command_list = [['docker',   # noqa E128
+                                 'run',
+                                 '--rm',
+                                 '--net=host',
+                                 '-v', '/etc/ceph:/etc/ceph:z',
+                                 '-v', '/var/lib/ceph/:/var/lib/ceph/:z',
+                                 '-v', '/var/log/ceph/:/var/log/ceph/:z',
+                                 '--entrypoint=ceph',
+                                 'docker.io/ceph/daemon:latest-luminous',
+                                 '-n', "client.admin",
+                                 '-k', "/etc/ceph/fake.client.admin.keyring",  # noqa E501
+                                 '--cluster', fake_cluster,
+                                 'auth', 'get',
+                                 fake_name, '-o', fake_file_destination],
         ]
         result = ceph_key.get_key(
-            fake_cluster, fake_name, fake_file_destination, fake_containerized)  # noqa E501
+            fake_cluster, fake_name, fake_file_destination, fake_container_image)  # noqa E501
         assert result == expected_command_list
 
     def test_get_key_non_container(self):