~openstack-charmers-next/charms/wily/odl-controller/trunk

« back to all changes in this revision

Viewing changes to unit_tests/test_odl_controller_hooks.py

  • Committer: Gerrit Code Review
  • Author(s): Jenkins
  • Date: 2016-03-18 16:10:08 UTC
  • mfrom: (21.1.1 trunk)
  • Revision ID: review@openstack.org-20160318161008-grzlrlzei667shdd
Merge "Add support for Ubuntu Xenial"

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    'service_start',
22
22
    'shutil',
23
23
    'write_mvn_config',
 
24
    'init_is_systemd',
 
25
    'service',
24
26
]
25
27
 
26
28
 
34
36
        self.install_url = 'http://10.10.10.10/distribution-karaf.tgz'
35
37
        self.test_config.set('install-url', self.install_url)
36
38
        self.test_config.set('profile', 'default')
 
39
        self.init_is_systemd.return_value = False
37
40
 
38
41
    def _call_hook(self, hookname):
39
42
        hooks.hooks.execute([
68
71
        self.shutil.copy.assert_called_with('files/odl-controller.conf',
69
72
                                            '/etc/init')
70
73
 
 
74
    @patch('os.symlink')
 
75
    @patch('os.path.exists')
 
76
    @patch('os.listdir')
 
77
    def test_install_hook_systemd(self, mock_listdir,
 
78
                                  mock_path_exists, mock_symlink):
 
79
        self.init_is_systemd.return_value = True
 
80
        mock_listdir.return_value = ['random-file', 'distribution-karaf.tgz']
 
81
        mock_path_exists.return_value = False
 
82
        self._call_hook('install')
 
83
        self.apt_install.assert_called_with([
 
84
            "default-jre-headless", "python-jinja2"],
 
85
            fatal=True
 
86
        )
 
87
        mock_symlink.assert_called_with('distribution-karaf.tgz',
 
88
                                        '/opt/opendaylight-karaf')
 
89
        self.adduser.assert_called_with("opendaylight", system_user=True)
 
90
        self.mkdir.assert_has_calls([
 
91
            call('/home/opendaylight', owner="opendaylight",
 
92
                 group="opendaylight", perms=0755),
 
93
            call('/var/log/opendaylight', owner="opendaylight",
 
94
                 group="opendaylight", perms=0755)
 
95
        ])
 
96
        self.check_call.assert_called_with([
 
97
            "chown", "-R", "opendaylight:opendaylight",
 
98
            "/opt/distribution-karaf.tgz"
 
99
        ])
 
100
        self.write_mvn_config.assert_called_with()
 
101
        self.service_start.assert_called_with('odl-controller')
 
102
        self.shutil.copy.assert_called_with('files/odl-controller.service',
 
103
                                            '/lib/systemd/system')
 
104
        self.service.assert_called_with('enable', 'odl-controller')
 
105
 
71
106
    def test_ovsdb_manager_joined_hook(self):
72
107
        self._call_hook('ovsdb-manager-relation-joined')
73
108
        self.relation_set.assert_called_with(port=6640, protocol="tcp")