~openstack-charmers-next/charms/trusty/cinder/trunk

« back to all changes in this revision

Viewing changes to unit_tests/test_cinder_utils.py

  • Committer: Gerrit Code Review
  • Author(s): Jenkins
  • Date: 2016-05-26 10:21:47 UTC
  • mfrom: (166.1.1 trunk)
  • Revision ID: review@openstack.org-20160526102147-r8vpyj0ij0cr73u3
Merge "Add systemd init support for deploy from source"

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
    'relation_set',
19
19
    'local_unit',
20
20
    # helpers.core.host
 
21
    'lsb_release',
21
22
    'mounts',
22
23
    'umount',
23
24
    'mkdir',
24
25
    'service_restart',
 
26
    # helpers.core.templating
 
27
    'render',
 
28
    # helpers.contrib.openstack.utils
 
29
    'git_generate_systemd_init_files',
 
30
    'git_src_dir',
 
31
    # helpers.contrib.python.packages
 
32
    'pip_install',
25
33
    # ceph utils
26
34
    # storage_utils
27
35
    'create_lvm_physical_volume',
48
56
    'service_stop',
49
57
    'service_start',
50
58
    # cinder
51
 
    'ceph_config_file'
 
59
    'ceph_config_file',
52
60
]
53
61
 
54
62
 
723
731
        self.assertEquals(write_file.call_args_list, expected)
724
732
 
725
733
    @patch.object(cinder_utils, 'services')
726
 
    @patch.object(cinder_utils, 'git_src_dir')
727
 
    @patch.object(cinder_utils, 'service_restart')
728
 
    @patch.object(cinder_utils, 'render')
729
 
    @patch.object(cinder_utils, 'pip_install')
730
734
    @patch('os.path.join')
731
735
    @patch('os.path.exists')
732
736
    @patch('shutil.copytree')
733
737
    @patch('shutil.rmtree')
734
 
    @patch('pwd.getpwnam')
735
 
    @patch('grp.getgrnam')
736
738
    @patch('os.chown')
737
739
    @patch('os.chmod')
738
740
    @patch('os.symlink')
739
 
    def test_git_post_install(self, symlink, chmod, chown, grp, pwd, rmtree,
740
 
                              copytree, exists, join, pip_install, render,
741
 
                              service_restart, git_src_dir, services):
 
741
    def test_git_post_install_upstart(self, symlink, chmod, chown, rmtree,
 
742
                                      copytree, exists, join, services):
742
743
        services.return_value = ['svc1']
743
744
        projects_yaml = openstack_origin_git
744
745
        join.return_value = 'joined-string'
 
746
        self.lsb_release.return_value = {'DISTRIB_RELEASE': '15.04'}
745
747
        cinder_utils.git_post_install(projects_yaml)
746
 
        pip_install('mysql-python', venv='joined-string')
 
748
        self.pip_install('mysql-python', venv='joined-string')
747
749
        expected = [
748
750
            call('joined-string', '/etc/cinder'),
749
751
        ]
821
823
                 cinder_volume_context, perms=0o644,
822
824
                 templates_dir='joined-string'),
823
825
        ]
824
 
        self.assertEquals(render.call_args_list, expected)
 
826
        self.assertEquals(self.render.call_args_list, expected)
825
827
        expected = [call('tgtd'), call('svc1')]
826
 
        self.assertEquals(service_restart.call_args_list, expected)
 
828
        self.assertEquals(self.service_restart.call_args_list, expected)
 
829
 
 
830
    @patch.object(cinder_utils, 'services')
 
831
    @patch('os.path.join')
 
832
    @patch('shutil.copytree')
 
833
    @patch('shutil.rmtree')
 
834
    @patch('pwd.getpwnam')
 
835
    @patch('grp.getgrnam')
 
836
    @patch('os.chown')
 
837
    @patch('os.chmod')
 
838
    @patch('os.symlink')
 
839
    def test_git_post_install_systemd(self, symlink, chmod, chown, grp, pwd,
 
840
                                      rmtree, copytree, join, services):
 
841
        projects_yaml = openstack_origin_git
 
842
        join.return_value = 'joined-string'
 
843
        self.lsb_release.return_value = {'DISTRIB_RELEASE': '15.10'}
 
844
        cinder_utils.git_post_install(projects_yaml)
 
845
 
 
846
        expected = [
 
847
            call('cinder.conf', '/etc/cinder/cinder.conf', {},
 
848
                 group='cinder', owner='cinder', perms=420),
 
849
            call('git/cinder_tgt.conf', '/etc/tgt/conf.d', {},
 
850
                 group='cinder', owner='cinder', perms=420),
 
851
            call('git/logging.conf', '/etc/cinder/logging.conf', {},
 
852
                 group='cinder', owner='cinder', perms=420),
 
853
            call('git/cinder_sudoers', '/etc/sudoers.d/cinder_sudoers', {},
 
854
                 group='root', owner='root', perms=288),
 
855
            call('git/cinder-api.init.in.template', 'joined-string',
 
856
                 {'daemon_path': 'joined-string'}, perms=420),
 
857
            call('git/cinder-backup.init.in.template', 'joined-string',
 
858
                 {'daemon_path': 'joined-string'}, perms=420),
 
859
            call('git/cinder-scheduler.init.in.template', 'joined-string',
 
860
                 {'daemon_path': 'joined-string'}, perms=420),
 
861
            call('git/cinder-volume.init.in.template', 'joined-string',
 
862
                 {'daemon_path': 'joined-string'}, perms=420),
 
863
        ]
 
864
        self.assertEquals(self.render.call_args_list, expected)
827
865
 
828
866
    @patch.object(cinder_utils, 'local_unit', lambda *args: 'unit/0')
829
867
    def test_check_db_initialised_by_self(self):