summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-05-30 16:57:33 +0200
committerJan Pokorný <jpokorny@redhat.com>2014-05-30 17:06:51 +0200
commitef00d0758a854f04d908159f9616bc71a579ae0c (patch)
tree882b9d747c5cf543478ed5d63bd793548e2f447a /tests
parent10853c31a948a9a77053f05f91cdf8f5ea8da846 (diff)
downloadclufter-ef00d0758a854f04d908159f9616bc71a579ae0c.tar.gz
clufter-ef00d0758a854f04d908159f9616bc71a579ae0c.tar.xz
clufter-ef00d0758a854f04d908159f9616bc71a579ae0c.zip
tests: check validation harness using now fixed corosync.rng
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/coro_fail.xml110
-rw-r--r--tests/coro_ok.xml110
-rw-r--r--tests/format.py94
3 files changed, 284 insertions, 30 deletions
diff --git a/tests/coro_fail.xml b/tests/coro_fail.xml
new file mode 100644
index 0000000..36fa657
--- /dev/null
+++ b/tests/coro_fail.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0"?>
+
+<!--
+ Please read the corosync.xml.5 and corosync.conf.5 manual page
+-->
+
+<corosync>
+
+<!--
+ totem tag configures behavior of totem and interfaces.
+
+ crypto_cipher and crypto_hash:
+ Used for mutual node authentication. If you choose to
+ enable this, then do remember to create a shared
+ secret with "corosync-keygen".
+ enabling crypto_cipher, requires also enabling of crypto_hash.
+-->
+<totem version="2" crypto_cypher="none" crypto_hash="none">
+ <!--
+ interface tag to define at least one interface to communicate
+ over. If you define more than one interface stanza, you must
+ also set rrp_mode.
+
+ Main parameters:
+ ringnumber:
+ Rings must be consecutively numbered, starting at 0.
+
+ bindnetaddr:
+ This is normally the *network* address of the
+ interface to bind to. This ensures that you can use
+ identical instances of this configuration file
+ across all your cluster nodes, without having to
+ modify this option.
+
+ However, if you have multiple physical network
+ interfaces configured for the same subnet, then the
+ network address alone is not sufficient to identify
+ the interface Corosync should bind to. In that case,
+ configure the *host* address of the interface
+ instead: bindnetaddr="192.168.1.1"
+
+ mcastaddr:
+ When selecting a multicast address, consider RFC
+ 2365 (which, among other things, specifies that
+ 239.255.x.x addresses are left to the discretion of
+ the network administrator). Do not reuse multicast
+ addresses across multiple Corosync clusters sharing
+ the same network.
+
+ mcastport:
+ Corosync uses the port you specify here for UDP
+ messaging, and also the immediately preceding
+ port. Thus if you set this to 5405, Corosync send
+ messages over UDP ports 5405 and 5404.
+
+ ttl:
+ Time-to-live for cluster communication packets. The
+ number of hops (routers) that this ring will allow
+ itself to pass. Note that multicast routing must be
+ specifically enabled on most network routers.
+ -->
+
+ <interface ringnumber="0" bindnetaddr="192.168.1.0" mcastaddr="239.255.1.1"
+ mcastport="5405" ttl="1" />
+</totem>
+
+<!--
+ Logging tag for defining various logging options
+
+ Main parameters:
+ fileline:
+ Log the source file and line where messages are being
+ generated. When in doubt, leave off. Potentially useful for
+ debugging.
+
+ to_stderr:
+ Log to standard error. When in doubt, set to no. Useful when
+ running in the foreground (when invoking "corosync -f")
+
+ to_logfile:
+ logfile:
+ Log to a log file. When set to "no", the "logfile" option
+ must not be set.
+
+ to_syslog:
+ Log to the system log daemon. When in doubt, set to yes.
+
+ debug:
+ Log debug messages (very verbose). When in doubt, leave off.
+
+ timestamp:
+ Log messages with time stamps. When in doubt, set to on
+ (unless you are only logging to syslog, where double
+ timestamps can be annoying).
+
+-->
+
+<logging fileline="off" to_stderr="no" to_logfile="yes"
+ logfile="/var/log/cluster/corosync.log" to_syslog="yes" debug="off"
+ timestamp="on">
+
+ <!--
+ Logger susys tag is used to overwrite default settings for given
+ subsys if needed.
+ -->
+
+ <logger_subsys subsys="QUORUM" debug="off" />
+</logging>
+
+</corosync>
diff --git a/tests/coro_ok.xml b/tests/coro_ok.xml
new file mode 100644
index 0000000..f8812e2
--- /dev/null
+++ b/tests/coro_ok.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0"?>
+
+<!--
+ Please read the corosync.xml.5 and corosync.conf.5 manual page
+-->
+
+<corosync>
+
+<!--
+ totem tag configures behavior of totem and interfaces.
+
+ crypto_cipher and crypto_hash:
+ Used for mutual node authentication. If you choose to
+ enable this, then do remember to create a shared
+ secret with "corosync-keygen".
+ enabling crypto_cipher, requires also enabling of crypto_hash.
+-->
+<totem version="2" crypto_cipher="none" crypto_hash="none">
+ <!--
+ interface tag to define at least one interface to communicate
+ over. If you define more than one interface stanza, you must
+ also set rrp_mode.
+
+ Main parameters:
+ ringnumber:
+ Rings must be consecutively numbered, starting at 0.
+
+ bindnetaddr:
+ This is normally the *network* address of the
+ interface to bind to. This ensures that you can use
+ identical instances of this configuration file
+ across all your cluster nodes, without having to
+ modify this option.
+
+ However, if you have multiple physical network
+ interfaces configured for the same subnet, then the
+ network address alone is not sufficient to identify
+ the interface Corosync should bind to. In that case,
+ configure the *host* address of the interface
+ instead: bindnetaddr="192.168.1.1"
+
+ mcastaddr:
+ When selecting a multicast address, consider RFC
+ 2365 (which, among other things, specifies that
+ 239.255.x.x addresses are left to the discretion of
+ the network administrator). Do not reuse multicast
+ addresses across multiple Corosync clusters sharing
+ the same network.
+
+ mcastport:
+ Corosync uses the port you specify here for UDP
+ messaging, and also the immediately preceding
+ port. Thus if you set this to 5405, Corosync send
+ messages over UDP ports 5405 and 5404.
+
+ ttl:
+ Time-to-live for cluster communication packets. The
+ number of hops (routers) that this ring will allow
+ itself to pass. Note that multicast routing must be
+ specifically enabled on most network routers.
+ -->
+
+ <interface ringnumber="0" bindnetaddr="192.168.1.0" mcastaddr="239.255.1.1"
+ mcastport="5405" ttl="1" />
+</totem>
+
+<!--
+ Logging tag for defining various logging options
+
+ Main parameters:
+ fileline:
+ Log the source file and line where messages are being
+ generated. When in doubt, leave off. Potentially useful for
+ debugging.
+
+ to_stderr:
+ Log to standard error. When in doubt, set to no. Useful when
+ running in the foreground (when invoking "corosync -f")
+
+ to_logfile:
+ logfile:
+ Log to a log file. When set to "no", the "logfile" option
+ must not be set.
+
+ to_syslog:
+ Log to the system log daemon. When in doubt, set to yes.
+
+ debug:
+ Log debug messages (very verbose). When in doubt, leave off.
+
+ timestamp:
+ Log messages with time stamps. When in doubt, set to on
+ (unless you are only logging to syslog, where double
+ timestamps can be annoying).
+
+-->
+
+<logging fileline="off" to_stderr="no" to_logfile="yes"
+ logfile="/var/log/cluster/corosync.log" to_syslog="yes" debug="off"
+ timestamp="on">
+
+ <!--
+ Logger susys tag is used to overwrite default settings for given
+ subsys if needed.
+ -->
+
+ <logger_subsys subsys="QUORUM" debug="off" />
+</logging>
+
+</corosync>
diff --git a/tests/format.py b/tests/format.py
index f651f6c..3a18cab 100644
--- a/tests/format.py
+++ b/tests/format.py
@@ -6,54 +6,88 @@
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
import unittest
+from lxml import etree
from os.path import dirname, join
#from pprint import pprint
import _bootstrap # known W402, required
+from clufter.format import FormatError
from clufter.formats.ccs import ccs
+from clufter.formats.coro import coroxml_needle
-WALK_DIR = join(dirname(__file__), 'XMLFormat-walk')
-RESULT_WALK_FULL = {
- 'cluster': ('cluster-full', {
- 'clusternodes': ('clusternodes-full', {
- 'clusternode': ('clusternode-full', {
- })
- }),
- 'cman': ('cman-full', {
- }),
- 'dlm': ('dlm-full', {
- }),
- 'rm': ('rm-full', {
- 'failoverdomains': ('failoverdomains-full', {
- 'failoverdomain': ('failoverdomain-full', {
+class XMLFormatWalkTestCase(unittest.TestCase):
+ walk_dir = join(dirname(__file__), 'XMLFormat-walk')
+ result_walk_full = {
+ 'cluster': ('cluster-full', {
+ 'clusternodes': ('clusternodes-full', {
+ 'clusternode': ('clusternode-full', {
})
}),
- 'service': ('service-full', {
+ 'cman': ('cman-full', {
+ }),
+ 'dlm': ('dlm-full', {
+ }),
+ 'rm': ('rm-full', {
+ 'failoverdomains': ('failoverdomains-full', {
+ 'failoverdomain': ('failoverdomain-full', {
+ })
+ }),
+ 'service': ('service-full', {
+ })
})
})
- })
-}
-
-RESULT_WALK_SPARSE = {
- 'failoverdomain': ('failoverdomain-sparse', {
- }),
- 'heuristic': ('heuristic-sparse', {
- })
-}
-
+ }
+ result_walk_sparse = {
+ 'failoverdomain': ('failoverdomain-sparse', {
+ }),
+ 'heuristic': ('heuristic-sparse', {
+ })
+ }
-class XMLFormatWalkTestCase(unittest.TestCase):
def testWalkFull(self):
- r = ccs.walk_schema(WALK_DIR, 'full')
+ r = ccs.walk_schema(self.walk_dir, 'full')
#pprint(r, width=8) # --> expected
- self.assertTrue(r == RESULT_WALK_FULL)
+ self.assertTrue(r == self.result_walk_full)
def testWalkSparse(self):
- r = ccs.walk_schema(WALK_DIR, 'sparse')
+ r = ccs.walk_schema(self.walk_dir, 'sparse')
#pprint(r, width=8) # --> expected
- self.assertTrue(r == RESULT_WALK_SPARSE)
+ self.assertTrue(r == self.result_walk_sparse)
+
+
+class XMLValidationTestCase(unittest.TestCase):
+ coro_input_ok = join(dirname(__file__), 'coro_ok.xml')
+ coro_input_fail = join(dirname(__file__), 'coro_fail.xml')
+
+ def testRngImplicitValidationOk(self):
+ try:
+ et = coroxml_needle('file', self.coro_input_ok)('etree')
+ except Exception:
+ raise
+ self.assertTrue(False)
+
+ def testRngImplicitValidationFail(self):
+ try:
+ et = coroxml_needle('file', self.coro_input_fail)('etree')
+ except FormatError as e:
+ self.assertTrue('Validation' in str(e))
+ pass
+ else:
+ self.assertTrue(False)
+
+ def testRngExplicitValidationOk(self):
+ et, entries = coroxml_needle.etree_validator(
+ etree.parse(self.coro_input_ok)
+ )
+ self.assertFalse(entries)
+
+ def testRngExplicitValidationFail(self):
+ et, entries = coroxml_needle.etree_validator(
+ etree.parse(self.coro_input_fail)
+ )
+ self.assertTrue(entries)
if __name__ == '__main__':