diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2015-12-17 20:09:25 +0100 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2015-12-17 23:39:17 +0100 |
commit | aba27fe8159fdbb5907c41f317b8066222ffc18d (patch) | |
tree | 6ba67aa15be8d6d9efc6863ccbfbe292b2dc0a82 | |
parent | b8a01c4bcf3ceeb34f590db4c50c0ec22a044692 (diff) | |
download | clufter-aba27fe8159fdbb5907c41f317b8066222ffc18d.tar.gz clufter-aba27fe8159fdbb5907c41f317b8066222ffc18d.tar.xz clufter-aba27fe8159fdbb5907c41f317b8066222ffc18d.zip |
tests/filters/ccsflat2cibprelude: fix (now) deployed resource tests
Note that there was a subtle, broken assumption behind how these tests
should work, but this was masked thanks to the result from XSLT always
being a standalone tree (not a set/forest) since the resources were
previously undeployed (passively defined in <resources> of cluster.conf
and not referenced from the active parts). After putting "activating"
the resources by putting them under <service> stanza, the XSLT results
were actually sets of element nodes and while only the first one was
exposed externally, mysterious kabooms around RNG validation emerged.
Proper fix is to rely on a single wrapping level of processing
(following the same rules of root element transformations, notably
this "single result tree only" one) that will make the result of the
actual level of XSLT under test be wrapped with <clufter:snippet>
that is then removed upon attachment to the parent level, which is
OK even if such result contained more trees modulo the wrapping.
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r-- | tests/filters/ccsflat2cibprelude.py | 226 |
1 files changed, 148 insertions, 78 deletions
diff --git a/tests/filters/ccsflat2cibprelude.py b/tests/filters/ccsflat2cibprelude.py index 09348af..7bba574 100644 --- a/tests/filters/ccsflat2cibprelude.py +++ b/tests/filters/ccsflat2cibprelude.py @@ -10,52 +10,82 @@ from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_com')) flt = 'ccsflat2cibprelude' +walk_transform = lambda walk: \ + { + 'cluster': ('''\ + <resources> + <clufter:descent at="rm"/> + </resources> +''', walk) + } + + class FiltersCcsFlat2CibPreludeTestCase(TeardownFilterTestCase): def testNfsClient(self): - flt_obj = rewrite_root(self.flt_mgr.filters[flt], 'cluster/rm') + flt_obj = rewrite_root(self.flt_mgr.filters[flt], 'cluster/rm', + walk_transform=walk_transform) in_fmt = flt_obj.in_format io_strings = ( ('''\ -<nfsclient name="test1" target="*" path="/srv/nfs/test1"/> + <nfsclient name="test1" target="*" path="/srv/nfs/test1"/> ''', '''\ -<primitive id="RESOURCE-nfsclient-test1" description="natively converted from nfsclient RA" class="ocf" provider="heartbeat" type="exportfs"> - <instance_attributes id="RESOURCE-nfsclient-test1-ATTRS"> - <nvpair id="RESOURCE-nfsclient-test1-ATTRS-clientspec" name="clientspec" value="*"/> - <nvpair id="RESOURCE-nfsclient-test1-ATTRS-directory" name="directory" value="/srv/nfs/test1"/> - <!-- NOTE: explicitly disabling `unlock_on_stop` parameter for `exportfs` resource so as to preserve original `nfsclient` resource behavior; you may want to enable it, though --> - <nvpair id="RESOURCE-nfsclient-test1-ATTRS-unlock_on_stop" name="unlock_on_stop" value="false"/> - </instance_attributes> - <meta_attributes id="RESOURCE-nfsclient-test1-META"> - <nvpair id="RESOURCE-nfsclient-test1-META-service" name="rgmanager-service" value="RESOURCES-"/> - <nvpair id="RESOURCE-nfsclient-test1-META-monitor" name="rgmanager-monitor" value="60s"/> - </meta_attributes> -</primitive> + <primitive id="RESOURCE-nfsclient-test1" description="natively converted from nfsclient RA" class="ocf" provider="heartbeat" type="exportfs"> + <instance_attributes id="RESOURCE-nfsclient-test1-ATTRS"> + <nvpair id="RESOURCE-nfsclient-test1-ATTRS-clientspec" name="clientspec" value="*"/> + <nvpair id="RESOURCE-nfsclient-test1-ATTRS-directory" name="directory" value="/srv/nfs/test1"/> + <!-- NOTE: explicitly disabling `unlock_on_stop` parameter for `exportfs` resource so as to preserve original `nfsclient` resource behavior; you may want to enable it, though --> + <nvpair id="RESOURCE-nfsclient-test1-ATTRS-unlock_on_stop" name="unlock_on_stop" value="false"/> + </instance_attributes> + <meta_attributes id="RESOURCE-nfsclient-test1-META"> + <nvpair id="RESOURCE-nfsclient-test1-META-service" name="rgmanager-service" value="SERVICE-foobar"/> + <nvpair id="RESOURCE-nfsclient-test1-META-monitor" name="rgmanager-monitor" value="60s"/> + </meta_attributes> + </primitive> '''), ('''\ -<nfsclient name="test2" target="*" path="/srv/nfs/test2" options="rw,async,no_root_squash"/> + <nfsclient name="test2" target="*" path="/srv/nfs/test2" options="rw,async,no_root_squash"/> ''', '''\ -<primitive id="RESOURCE-nfsclient-test2" description="natively converted from nfsclient RA" class="ocf" provider="heartbeat" type="exportfs"> - <instance_attributes id="RESOURCE-nfsclient-test2-ATTRS"> - <nvpair id="RESOURCE-nfsclient-test2-ATTRS-clientspec" name="clientspec" value="*"/> - <nvpair id="RESOURCE-nfsclient-test2-ATTRS-directory" name="directory" value="/srv/nfs/test2"/> - <nvpair id="RESOURCE-nfsclient-test2-ATTRS-options" name="options" value="rw,async,no_root_squash"/> - <!-- NOTE: explicitly disabling `unlock_on_stop` parameter for `exportfs` resource so as to preserve original `nfsclient` resource behavior; you may want to enable it, though --> - <nvpair id="RESOURCE-nfsclient-test2-ATTRS-unlock_on_stop" name="unlock_on_stop" value="false"/> - </instance_attributes> - <meta_attributes id="RESOURCE-nfsclient-test2-META"> - <nvpair id="RESOURCE-nfsclient-test2-META-service" name="rgmanager-service" value="RESOURCES-"/> - <nvpair id="RESOURCE-nfsclient-test2-META-monitor" name="rgmanager-monitor" value="60s"/> - </meta_attributes> -</primitive> + <primitive id="RESOURCE-nfsclient-test2" description="natively converted from nfsclient RA" class="ocf" provider="heartbeat" type="exportfs"> + <instance_attributes id="RESOURCE-nfsclient-test2-ATTRS"> + <nvpair id="RESOURCE-nfsclient-test2-ATTRS-clientspec" name="clientspec" value="*"/> + <nvpair id="RESOURCE-nfsclient-test2-ATTRS-directory" name="directory" value="/srv/nfs/test2"/> + <nvpair id="RESOURCE-nfsclient-test2-ATTRS-options" name="options" value="rw,async,no_root_squash"/> + <!-- NOTE: explicitly disabling `unlock_on_stop` parameter for `exportfs` resource so as to preserve original `nfsclient` resource behavior; you may want to enable it, though --> + <nvpair id="RESOURCE-nfsclient-test2-ATTRS-unlock_on_stop" name="unlock_on_stop" value="false"/> + </instance_attributes> + <meta_attributes id="RESOURCE-nfsclient-test2-META"> + <nvpair id="RESOURCE-nfsclient-test2-META-service" name="rgmanager-service" value="SERVICE-foobar"/> + <nvpair id="RESOURCE-nfsclient-test2-META-monitor" name="rgmanager-monitor" value="60s"/> + </meta_attributes> + </primitive> '''), ) for (in_str, out_str) in io_strings: in_str = '''\ -<rm> - <resources> +<cluster> + <rm> + <service name="foobar"> ''' + in_str + '''\ - </resources> -</rm> + </service> + </rm> +</cluster> +''' + out_str = '''\ +<resources> +''' + out_str + '''\ + <template id="SERVICE-foobar" class="ocf" provider="clufter" type="temporary-service"> + <meta_attributes id="SERVICE-foobar-META"> + <nvpair id="SERVICE-foobar-META-autostart" name="autostart" value="1"/> + <nvpair id="SERVICE-foobar-META-exclusive" name="exclusive" value="0"/> + <nvpair id="SERVICE-foobar-META-recovery" name="recovery" value=""/> + <nvpair id="SERVICE-foobar-META-depend" name="depend" value=""/> + <nvpair id="SERVICE-foobar-META-depend_mode" name="depend_mode" value=""/> + <nvpair id="SERVICE-foobar-META-max_restarts" name="max_restarts" value=""/> + <nvpair id="SERVICE-foobar-META-restart_expire_time" name="restart_expire_time" value=""/> + <nvpair id="SERVICE-foobar-META-priority" name="priority" value=""/> + </meta_attributes> + </template> +</resources> ''' in_obj = in_fmt('bytestring', in_str) out_obj = flt_obj(in_obj) @@ -63,48 +93,68 @@ class FiltersCcsFlat2CibPreludeTestCase(TeardownFilterTestCase): self.assertEquals(out_obj.BYTESTRING(), out_str) def testSapDatabase(self): - flt_obj = rewrite_root(self.flt_mgr.filters[flt], 'cluster/rm') + flt_obj = rewrite_root(self.flt_mgr.filters[flt], 'cluster/rm', + walk_transform=walk_transform) in_fmt = flt_obj.in_format io_strings = ( ('''\ <SAPDatabase SID="SAP1" DBTYPE="ORA" NETSERVICENAME="LISTENER_SAP1" DIR_EXECUTABLE="/dbpath/SAP1"/> ''', '''\ -<primitive id="RESOURCE-SAPDatabase-SAP1" description="natively converted from SAPDatabase RA" class="ocf" provider="heartbeat" type="SAPDatabase"> - <instance_attributes id="RESOURCE-SAPDatabase-SAP1-ATTRS"> - <nvpair id="RESOURCE-SAPDatabase-SAP1-ATTRS-SID" name="SID" value="SAP1"/> - <nvpair id="RESOURCE-SAPDatabase-SAP1-ATTRS-DBTYPE" name="DBTYPE" value="ORA"/> - <nvpair id="RESOURCE-SAPDatabase-SAP1-ATTRS-NETSERVICENAME" name="NETSERVICENAME" value="LISTENER_SAP1"/> - </instance_attributes> - <meta_attributes id="RESOURCE-SAPDatabase-SAP1-META"> - <nvpair id="RESOURCE-SAPDatabase-SAP1-META-service" name="rgmanager-service" value="RESOURCES-"/> - <nvpair id="RESOURCE-SAPDatabase-SAP1-META-monitor" name="rgmanager-monitor" value="60s"/> - </meta_attributes> -</primitive> + <primitive id="RESOURCE-SAPDatabase-SAP1" description="natively converted from SAPDatabase RA" class="ocf" provider="heartbeat" type="SAPDatabase"> + <instance_attributes id="RESOURCE-SAPDatabase-SAP1-ATTRS"> + <nvpair id="RESOURCE-SAPDatabase-SAP1-ATTRS-SID" name="SID" value="SAP1"/> + <nvpair id="RESOURCE-SAPDatabase-SAP1-ATTRS-DBTYPE" name="DBTYPE" value="ORA"/> + <nvpair id="RESOURCE-SAPDatabase-SAP1-ATTRS-NETSERVICENAME" name="NETSERVICENAME" value="LISTENER_SAP1"/> + </instance_attributes> + <meta_attributes id="RESOURCE-SAPDatabase-SAP1-META"> + <nvpair id="RESOURCE-SAPDatabase-SAP1-META-service" name="rgmanager-service" value="SERVICE-foobar"/> + <nvpair id="RESOURCE-SAPDatabase-SAP1-META-monitor" name="rgmanager-monitor" value="60s"/> + </meta_attributes> + </primitive> '''), ('''\ -<SAPDatabase SID="GT1" AUTOMATIC_RECOVER="TRUE" DBTYPE="ORA" DIR_EXECUTABLE="/sapmnt/GT1/exe" STRICT_MONITORING="FALSE"/> + <SAPDatabase SID="GT1" AUTOMATIC_RECOVER="TRUE" DBTYPE="ORA" DIR_EXECUTABLE="/sapmnt/GT1/exe" STRICT_MONITORING="FALSE"/> ''', '''\ -<primitive id="RESOURCE-SAPDatabase-GT1" description="natively converted from SAPDatabase RA" class="ocf" provider="heartbeat" type="SAPDatabase"> - <instance_attributes id="RESOURCE-SAPDatabase-GT1-ATTRS"> - <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-SID" name="SID" value="GT1"/> - <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-DBTYPE" name="DBTYPE" value="ORA"/> - <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-STRICT_MONITORING" name="STRICT_MONITORING" value="FALSE"/> - <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-AUTOMATIC_RECOVER" name="AUTOMATIC_RECOVER" value="TRUE"/> - </instance_attributes> - <meta_attributes id="RESOURCE-SAPDatabase-GT1-META"> - <nvpair id="RESOURCE-SAPDatabase-GT1-META-service" name="rgmanager-service" value="RESOURCES-"/> - <nvpair id="RESOURCE-SAPDatabase-GT1-META-monitor" name="rgmanager-monitor" value="60s"/> - </meta_attributes> -</primitive> + <primitive id="RESOURCE-SAPDatabase-GT1" description="natively converted from SAPDatabase RA" class="ocf" provider="heartbeat" type="SAPDatabase"> + <instance_attributes id="RESOURCE-SAPDatabase-GT1-ATTRS"> + <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-SID" name="SID" value="GT1"/> + <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-DBTYPE" name="DBTYPE" value="ORA"/> + <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-STRICT_MONITORING" name="STRICT_MONITORING" value="FALSE"/> + <nvpair id="RESOURCE-SAPDatabase-GT1-ATTRS-AUTOMATIC_RECOVER" name="AUTOMATIC_RECOVER" value="TRUE"/> + </instance_attributes> + <meta_attributes id="RESOURCE-SAPDatabase-GT1-META"> + <nvpair id="RESOURCE-SAPDatabase-GT1-META-service" name="rgmanager-service" value="SERVICE-foobar"/> + <nvpair id="RESOURCE-SAPDatabase-GT1-META-monitor" name="rgmanager-monitor" value="60s"/> + </meta_attributes> + </primitive> '''), ) for (in_str, out_str) in io_strings: in_str = '''\ -<rm> - <resources> +<cluster> + <rm> + <service name="foobar"> ''' + in_str + '''\ - </resources> -</rm> + </service> + </rm> +</cluster> +''' + out_str = '''\ +<resources> +''' + out_str + '''\ + <template id="SERVICE-foobar" class="ocf" provider="clufter" type="temporary-service"> + <meta_attributes id="SERVICE-foobar-META"> + <nvpair id="SERVICE-foobar-META-autostart" name="autostart" value="1"/> + <nvpair id="SERVICE-foobar-META-exclusive" name="exclusive" value="0"/> + <nvpair id="SERVICE-foobar-META-recovery" name="recovery" value=""/> + <nvpair id="SERVICE-foobar-META-depend" name="depend" value=""/> + <nvpair id="SERVICE-foobar-META-depend_mode" name="depend_mode" value=""/> + <nvpair id="SERVICE-foobar-META-max_restarts" name="max_restarts" value=""/> + <nvpair id="SERVICE-foobar-META-restart_expire_time" name="restart_expire_time" value=""/> + <nvpair id="SERVICE-foobar-META-priority" name="priority" value=""/> + </meta_attributes> + </template> +</resources> ''' in_obj = in_fmt('bytestring', in_str) out_obj = flt_obj(in_obj) @@ -112,32 +162,52 @@ class FiltersCcsFlat2CibPreludeTestCase(TeardownFilterTestCase): self.assertEquals(out_obj.BYTESTRING(), out_str) def testSapInstance(self): - flt_obj = rewrite_root(self.flt_mgr.filters[flt], 'cluster/rm') + flt_obj = rewrite_root(self.flt_mgr.filters[flt], 'cluster/rm', + walk_transform=walk_transform) in_fmt = flt_obj.in_format io_strings = ( ('''\ -<SAPInstance AUTOMATIC_RECOVER="TRUE" DIR_EXECUTABLE="/sapmnt/GT1/exe" InstanceName="GT1_foobar"/> + <SAPInstance AUTOMATIC_RECOVER="TRUE" DIR_EXECUTABLE="/sapmnt/GT1/exe" InstanceName="GT1_foobar"/> ''', '''\ -<primitive id="RESOURCE-SAPInstance-GT1_foobar" description="natively converted from SAPInstance RA" class="ocf" provider="heartbeat" type="SAPInstance"> - <instance_attributes id="RESOURCE-SAPInstance-GT1_foobar-ATTRS"> - <nvpair id="RESOURCE-SAPInstance-GT1_foobar-ATTRS-InstanceName" name="InstanceName" value="GT1_foobar"/> - <nvpair id="RESOURCE-SAPInstance-GT1_foobar-ATTRS-DIR_EXECUTABLE" name="DIR_EXECUTABLE" value="/sapmnt/GT1/exe"/> - <nvpair id="RESOURCE-SAPInstance-GT1_foobar-ATTRS-AUTOMATIC_RECOVER" name="AUTOMATIC_RECOVER" value="TRUE"/> - </instance_attributes> - <meta_attributes id="RESOURCE-SAPInstance-GT1_foobar-META"> - <nvpair id="RESOURCE-SAPInstance-GT1_foobar-META-service" name="rgmanager-service" value="RESOURCES-"/> - <nvpair id="RESOURCE-SAPInstance-GT1_foobar-META-monitor" name="rgmanager-monitor" value="60s"/> - </meta_attributes> -</primitive> + <primitive id="RESOURCE-SAPInstance-GT1_foobar" description="natively converted from SAPInstance RA" class="ocf" provider="heartbeat" type="SAPInstance"> + <instance_attributes id="RESOURCE-SAPInstance-GT1_foobar-ATTRS"> + <nvpair id="RESOURCE-SAPInstance-GT1_foobar-ATTRS-InstanceName" name="InstanceName" value="GT1_foobar"/> + <nvpair id="RESOURCE-SAPInstance-GT1_foobar-ATTRS-DIR_EXECUTABLE" name="DIR_EXECUTABLE" value="/sapmnt/GT1/exe"/> + <nvpair id="RESOURCE-SAPInstance-GT1_foobar-ATTRS-AUTOMATIC_RECOVER" name="AUTOMATIC_RECOVER" value="TRUE"/> + </instance_attributes> + <meta_attributes id="RESOURCE-SAPInstance-GT1_foobar-META"> + <nvpair id="RESOURCE-SAPInstance-GT1_foobar-META-service" name="rgmanager-service" value="SERVICE-foobar"/> + <nvpair id="RESOURCE-SAPInstance-GT1_foobar-META-monitor" name="rgmanager-monitor" value="60s"/> + </meta_attributes> + </primitive> '''), ) for (in_str, out_str) in io_strings: in_str = '''\ -<rm> - <resources> +<cluster> + <rm> + <service name="foobar"> ''' + in_str + '''\ - </resources> -</rm> + </service> + </rm> +</cluster> +''' + out_str = '''\ +<resources> +''' + out_str + '''\ + <template id="SERVICE-foobar" class="ocf" provider="clufter" type="temporary-service"> + <meta_attributes id="SERVICE-foobar-META"> + <nvpair id="SERVICE-foobar-META-autostart" name="autostart" value="1"/> + <nvpair id="SERVICE-foobar-META-exclusive" name="exclusive" value="0"/> + <nvpair id="SERVICE-foobar-META-recovery" name="recovery" value=""/> + <nvpair id="SERVICE-foobar-META-depend" name="depend" value=""/> + <nvpair id="SERVICE-foobar-META-depend_mode" name="depend_mode" value=""/> + <nvpair id="SERVICE-foobar-META-max_restarts" name="max_restarts" value=""/> + <nvpair id="SERVICE-foobar-META-restart_expire_time" name="restart_expire_time" value=""/> + <nvpair id="SERVICE-foobar-META-priority" name="priority" value=""/> + </meta_attributes> + </template> +</resources> ''' in_obj = in_fmt('bytestring', in_str) out_obj = flt_obj(in_obj) |