Merge lp:~seyeongkim/charms/trusty/swift-storage/lp1375395 into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next

Proposed by Seyeong Kim
Status: Superseded
Proposed branch: lp:~seyeongkim/charms/trusty/swift-storage/lp1375395
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
Diff against target: 140 lines (+73/-7)
3 files modified
unit_tests/test_swift_storage_context.py (+13/-0)
unit_tests/test_swift_storage_relations.py (+45/-7)
unit_tests/test_swift_storage_utils.py (+15/-0)
To merge this branch: bzr merge lp:~seyeongkim/charms/trusty/swift-storage/lp1375395
Reviewer Review Type Date Requested Status
Edward Hope-Morley Needs Fixing
Review via email: mp+247789@code.launchpad.net

This proposal has been superseded by a proposal from 2015-02-25.

To post a comment you must log in.
Revision history for this message
Seyeong Kim (seyeongkim) wrote :

need an advice for this part

because of using - not _ on private-address, got error

#self.relation_set.assert_called_with(
# device='vdb', object_port=6000, account_port=6002,
# zone=1, container_port=6001, private-address='FE80:0000:0000:0000:0202:B3FF:FE1E:8329',
#)
# private-address : keyword can't be an expression

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Seyeong, you could try using a dict i.e.:

args = {'device': 'vdb', 'object_port': 6000, 'account_port': 6002,
        'zone': 1, 'container_port': 6001, 'private-address': 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329'}
self.relation_set.assert_called_with(**args)

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #1464 swift-storage-next for xtrusia mp247789
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/1464/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #1509 swift-storage-next for xtrusia mp247789
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
  unit_tests/test_swift_storage_utils.py:238:64: E231 missing whitespace after ':'
  make: *** [lint] Error 1

Full lint test output: http://paste.ubuntu.com/10033239/
Build: http://10.245.162.77:8080/job/charm_lint_check/1509/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #1628 swift-storage-next for xtrusia mp247789
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/1628/

59. By Seyeong Kim

fix lint error

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #1510 swift-storage-next for xtrusia mp247789
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/1510/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #1465 swift-storage-next for xtrusia mp247789
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/1465/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #1629 swift-storage-next for xtrusia mp247789
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/1629/

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Seyeong, thanks a lot for adding in new tests it is much appreciated! I have one inline question regarding one of your tests but apart from that this looks good.

Revision history for this message
Seyeong Kim (seyeongkim) :
Revision history for this message
Edward Hope-Morley (hopem) wrote :

See inline.

Revision history for this message
Edward Hope-Morley (hopem) :
review: Needs Fixing
60. By Seyeong Kim

fix with mock

61. By Seyeong Kim

sync rebase

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unit_tests/test_swift_storage_context.py'
2--- unit_tests/test_swift_storage_context.py 2014-10-06 21:45:39 +0000
3+++ unit_tests/test_swift_storage_context.py 2015-02-25 09:42:59 +0000
4@@ -11,6 +11,7 @@
5 'relation_get',
6 'relation_ids',
7 'unit_private_ip',
8+ 'get_ipv6_addr',
9 ]
10
11
12@@ -46,6 +47,18 @@
13 self.assertEquals({'local_ip': '10.0.0.5'}, ctxt())
14 self.assertTrue(ctxt.enable_rsyncd.called)
15
16+ def test_rsync_context_ipv6(self):
17+ self.test_config.set('prefer-ipv6', True)
18+ self.get_ipv6_addr.return_value = [
19+ 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329', ]
20+ ctxt = swift_context.RsyncContext()
21+ ctxt.enable_rsyncd = MagicMock()
22+ ctxt.enable_rsyncd.return_value = True
23+ self.assertEquals({
24+ 'local_ip': 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329'},
25+ ctxt())
26+ self.assertTrue(ctxt.enable_rsyncd.called)
27+
28 def test_rsync_enable_rsync(self):
29 with patch_open() as (_open, _file):
30 ctxt = swift_context.RsyncContext()
31
32=== modified file 'unit_tests/test_swift_storage_relations.py'
33--- unit_tests/test_swift_storage_relations.py 2015-01-09 10:21:49 +0000
34+++ unit_tests/test_swift_storage_relations.py 2015-02-25 09:42:59 +0000
35@@ -39,7 +39,8 @@
36 'setup_rsync',
37 'setup_storage',
38 'register_configs',
39- 'update_nrpe_config'
40+ 'update_nrpe_config',
41+ 'get_ipv6_addr',
42 ]
43
44
45@@ -82,19 +83,56 @@
46 self.assertTrue(self.do_openstack_upgrade.called)
47 self.assertTrue(self.CONFIGS.write_all.called)
48
49+ def test_config_changed_nrpe_master(self):
50+ self.openstack_upgrade_available.return_value = False
51+ self.relations_of_type.return_value = True
52+ with patch_open() as (_open, _file):
53+ _file.read.return_value = "foo"
54+ hooks.config_changed()
55+ self.assertTrue(self.CONFIGS.write_all.called)
56+ self.assertTrue(self.setup_rsync.called)
57+ self.assertTrue(self.update_nrpe_config.called)
58+
59+ @patch.object(hooks, 'assert_charm_supports_ipv6')
60+ def test_config_changed_ipv6(self, mock_assert_charm_supports_ipv6):
61+ self.test_config.set('prefer-ipv6', True)
62+ self.openstack_upgrade_available.return_value = False
63+ self.relations_of_type.return_value = False
64+ with patch_open() as (_open, _file):
65+ _file.read.return_value = "foo"
66+ hooks.config_changed()
67+ self.assertTrue(self.CONFIGS.write_all.called)
68+ self.assertTrue(self.setup_rsync.called)
69+
70 def test_upgrade_charm(self):
71- self.filter_installed_packages.return_value = ['python-psutil']
72+ self.filter_installed_packages.return_value = [
73+ 'python-psutil']
74 hooks.upgrade_charm()
75- self.apt_install.assert_called_with(['python-psutil'], fatal=True)
76+ self.apt_install.assert_called_with([
77+ 'python-psutil'], fatal=True)
78 self.assertTrue(self.update_nrpe_config.called)
79
80 def test_storage_joined_single_device(self):
81+ self.determine_block_devices.return_value = [
82+ '/dev/vdb']
83+ hooks.swift_storage_relation_joined()
84+ self.relation_set.assert_called_with(
85+ device='vdb', object_port=6000, account_port=6002,
86+ zone=1, container_port=6001
87+ )
88+
89+ def test_storage_joined_ipv6(self):
90 self.determine_block_devices.return_value = ['/dev/vdb']
91+ self.test_config.set('prefer-ipv6', True)
92+ self.get_ipv6_addr.return_value = [
93+ 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329', ]
94 hooks.swift_storage_relation_joined()
95- self.relation_set.assert_called_with(
96- device='vdb', object_port=6000, account_port=6002,
97- zone=1, container_port=6001
98- )
99+ args = {
100+ 'device': 'vdb', 'object_port': 6000,
101+ 'account_port': 6002, 'zone': 1, 'container_port': 6001,
102+ 'private-address': 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329',
103+ }
104+ self.relation_set.assert_called_with(**args)
105
106 def test_storage_joined_multi_device(self):
107 self.determine_block_devices.return_value = ['/dev/vdb', '/dev/vdc',
108
109=== modified file 'unit_tests/test_swift_storage_utils.py'
110--- unit_tests/test_swift_storage_utils.py 2015-01-09 10:21:49 +0000
111+++ unit_tests/test_swift_storage_utils.py 2015-02-25 09:42:59 +0000
112@@ -26,6 +26,7 @@
113 'unit_private_ip',
114 'service_restart',
115 '_save_script_rc',
116+ 'lsb_release',
117 ]
118
119
120@@ -223,6 +224,20 @@
121 swift_utils.save_script_rc()
122 self._save_script_rc.assert_called_with(**SCRIPT_RC_ENV)
123
124+ def test_assert_charm_not_supports_ipv6(self):
125+ self.lsb_release.return_value = {'DISTRIB_ID': 'Ubuntu',
126+ 'DISTRIB_RELEASE': '12.04',
127+ 'DISTRIB_CODENAME': 'precise',
128+ 'DISTRIB_DESCRIPTION': 'Ubuntu 12.04'}
129+ self.assertRaises(Exception, swift_utils.assert_charm_supports_ipv6)
130+
131+ def test_assert_charm_supports_ipv6(self):
132+ self.lsb_release.return_value = {'DISTRIB_ID': 'Ubuntu',
133+ 'DISTRIB_RELEASE': '14.04',
134+ 'DISTRIB_CODENAME': 'trusty',
135+ 'DISTRIB_DESCRIPTION': 'Ubuntu 14.04'}
136+ swift_utils.assert_charm_supports_ipv6()
137+
138 @patch('charmhelpers.contrib.openstack.templating.OSConfigRenderer')
139 def test_register_configs_pre_install(self, renderer):
140 self.get_os_codename_package.return_value = None

Subscribers

People subscribed via source and target branches