~charm-helpers/charm-helpers/devel

« back to all changes in this revision

Viewing changes to tests/contrib/openstack/test_os_contexts.py

  • Committer: Matt Bruzek
  • Date: 2014-07-03 17:32:51 UTC
  • mfrom: (177.1.2 charm-helpers.lp1337266)
  • Revision ID: matthew.bruzek@canonical.com-20140703173251-846xdknfjeux3uw4
[hoepm] Adding sections to context, added unit test coverage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
                - [glance-key2, value2]
214
214
"""
215
215
 
 
216
CINDER_SUB_CONFIG1 = """
 
217
cinder:
 
218
    /etc/cinder/cinder.conf:
 
219
        sections:
 
220
            cinder-1-section:
 
221
                - [key1, value1]
 
222
"""
 
223
 
 
224
CINDER_SUB_CONFIG2 = """
 
225
cinder:
 
226
    /etc/cinder/cinder.conf:
 
227
        sections:
 
228
            cinder-2-section:
 
229
                - [key2, value2]
 
230
        not-a-section:
 
231
            1234
 
232
"""
 
233
 
216
234
SUB_CONFIG_RELATION = {
217
235
    'nova-subordinate:0': {
218
236
        'nova-subordinate/0': {
231
249
            'private-address': 'foo_node1',
232
250
            'subordinate_configuration': 'ea8e09324jkadsfh',
233
251
        },
234
 
    }
 
252
    },
 
253
    'cinder-subordinate:0': {
 
254
        'cinder-subordinate/0': {
 
255
            'private-address': 'cinder_node1',
 
256
            'subordinate_configuration': json.dumps(yaml.load(CINDER_SUB_CONFIG1)),
 
257
        },
 
258
    },
 
259
    'cinder-subordinate:1': {
 
260
        'cinder-subordinate/1': {
 
261
            'private-address': 'cinder_node1',
 
262
            'subordinate_configuration': json.dumps(yaml.load(CINDER_SUB_CONFIG2)),
 
263
        },
 
264
    },
235
265
}
236
266
 
237
267
# Imported in contexts.py and needs patching in setUp()
1121
1151
            config_file='/etc/glance/glance.conf',
1122
1152
            interface='glance-subordinate',
1123
1153
        )
 
1154
        cinder_sub_ctxt = context.SubordinateConfigContext(
 
1155
            service='cinder',
 
1156
            config_file='/etc/cinder/cinder.conf',
 
1157
            interface='cinder-subordinate',
 
1158
        )
1124
1159
        foo_sub_ctxt = context.SubordinateConfigContext(
1125
1160
            service='foo',
1126
1161
            config_file='/etc/foo/foo.conf',
1142
1177
                    ['glance-key2', 'value2']]
1143
1178
            }}
1144
1179
        )
 
1180
        self.assertEquals(
 
1181
            cinder_sub_ctxt(),
 
1182
            {'sections': {
 
1183
                'cinder-1-section': [
 
1184
                    ['key1', 'value1']],
 
1185
                'cinder-2-section': [
 
1186
                    ['key2', 'value2']]
 
1187
             
 
1188
            }, 'not-a-section': 1234}
 
1189
        )
1145
1190
 
1146
1191
        # subrodinate supplies nothing for given config
1147
1192
        glance_sub_ctxt.config_file = '/etc/glance/glance-api-paste.ini'