Hello community, here is the log from the commit of package crmsh for openSUSE:Factory checked in at 2013-12-30 09:49:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/crmsh (Old) and /work/SRC/openSUSE:Factory/.crmsh.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "crmsh" Changes: -------- --- /work/SRC/openSUSE:Factory/crmsh/crmsh.changes 2013-12-10 17:42:09.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.crmsh.new/crmsh.changes 2013-12-30 09:50:00.000000000 +0100 @@ -1,0 +2,18 @@ +Fri Dec 20 10:11:42 UTC 2013 - [email protected] + +- Medium: ui_report: Fix bug when calling hb_report in report sublevel +- Medium: ui_history: Fix bug when checking current sublevel in + history commands +- upstream cs: 809d4b774bd4 + +------------------------------------------------------------------- +Tue Dec 17 16:48:30 UTC 2013 - [email protected] + +- Medium: parse: Resource sets in location constraints (fate#315158) +- Medium: parse: Regular expressions in location constraints +- Dev: unittests: Run unit tests with regression builds +- Low: parse: Stricter parsing of resource names +- Low: utils: Look for crmd in config.path.crm_daemon_dir +- upstream cs: 0d3abc34b627 + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ crmsh.spec ++++++ --- /var/tmp/diff_new_pack.uGQQJ3/_old 2013-12-30 09:50:01.000000000 +0100 +++ /var/tmp/diff_new_pack.uGQQJ3/_new 2013-12-30 09:50:01.000000000 +0100 @@ -139,6 +139,13 @@ make %{_smp_mflags} docdir=%{crmsh_docdir} +%if 0%{?with_regression_tests} + if ! test/unittests/testrunner.py ; then + echo "Shell unit tests failed." + exit 1 + fi +%endif + %install make DESTDIR=%{buildroot} docdir=%{crmsh_docdir} install install -Dm0644 contrib/bash_completion.sh %{buildroot}%{_sysconfdir}/bash_completion.d/crm.sh @@ -149,20 +156,18 @@ %clean rm -rf %{buildroot} +# Run regression tests after installing the package +# NB: this is called twice by OBS, that's why we touch the file %if 0%{?with_regression_tests} - %post - -# NB: this is called twice by OBS, that's why we touch the file if [ ! -e /tmp/.crmsh_regression_tests_ran ]; then touch /tmp/.crmsh_regression_tests_ran - if ! /usr/share/crmsh/tests/regression.sh ; then + if ! %{_datadir}/%{name}/tests/regression.sh ; then echo "Shell tests failed." cat crmtestout/regression.out exit 1 fi fi - %endif %files ++++++ crmsh-cibadmin_can_patch.patch ++++++ --- /var/tmp/diff_new_pack.uGQQJ3/_old 2013-12-30 09:50:01.000000000 +0100 +++ /var/tmp/diff_new_pack.uGQQJ3/_new 2013-12-30 09:50:01.000000000 +0100 @@ -1,12 +1,23 @@ -diff -r 13a63558be20 modules/utils.py ---- a/modules/utils.py Fri Oct 25 16:57:25 2013 +0200 -+++ b/modules/utils.py Fri Oct 25 17:14:45 2013 +0200 -@@ -1008,7 +1008,7 @@ def is_pcmk_118(cib_f=None): +commit 043a73a179116619bff65c46e3f6ac693dd57d3f +Author: Kristoffer Grönlund <[email protected]> +Date: Thu Dec 12 15:06:21 2013 +0100 + + Medium: utils: Enable CIB patches for 1.1.10> + + Enable CIB patches on patched 1.1.10 systems. + +diff --git a/modules/utils.py b/modules/utils.py +index 624fcbf0d841..45277fb10003 100644 +--- a/modules/utils.py ++++ b/modules/utils.py +@@ -1097,8 +1097,8 @@ def cibadmin_features(): + def cibadmin_can_patch(): - # cibadmin -P doesn't handle comments, hopefully in v1.1.11 -- return False -+ return True - #return is_min_pcmk_ver("1.1.11") +- # cibadmin -P doesn't handle comments in <1.1.11 (unless patched) +- return is_min_pcmk_ver("1.1.11") ++ # cibadmin -P doesn't handle comments in <1.1.10 (unless patched) ++ return is_min_pcmk_ver("1.1.10") + # quote function from python module shlex.py in python 3.3 ++++++ crmsh.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/.hg_archival.txt new/crmsh/.hg_archival.txt --- old/crmsh/.hg_archival.txt 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/.hg_archival.txt 2013-12-20 11:02:10.000000000 +0100 @@ -1,5 +1,5 @@ repo: 13c3bd69e935090cd25213c474cafc3f01b5910b -node: 1a0e32427c4270d7be8cdf7300fae13fe5d581c2 +node: 809d4b774bd4d6d41fdb0f2720286153fc5db977 branch: default latesttag: 1.2.6-rc1 -latesttagdistance: 261 +latesttagdistance: 272 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/TODO new/crmsh/TODO --- old/crmsh/TODO 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/TODO 2013-12-20 11:02:10.000000000 +0100 @@ -18,10 +18,17 @@ - this feature needs very careful consideration -Misc +. CIB features -. Create a web page + - Rules in primitive attribute declarations - - there's already space at crmsh.nongnu.org + primitive dummy ocf:heartbeat:IPaddr2 \ + params 3: rule 0: #uname eq pcmk-1 nic=eth1 \ + params 2: rule 1: #uname eq pcmk-2 nic=eth2 \ + params 1: netmask=32 ip=127.0.0.1 nic=eth0 - - preferred to be based on asciidoc or similar + Adding parser support is easy. + + Difficulty is adding support for multiple sets of parameters + with different scores + (right now they are all aggregated) in cibconfig.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/crmsh-cibadmin_can_patch.patch new/crmsh/crmsh-cibadmin_can_patch.patch --- old/crmsh/crmsh-cibadmin_can_patch.patch 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/crmsh-cibadmin_can_patch.patch 2013-12-20 11:02:10.000000000 +0100 @@ -1,12 +1,23 @@ -diff -r 13a63558be20 modules/utils.py ---- a/modules/utils.py Fri Oct 25 16:57:25 2013 +0200 -+++ b/modules/utils.py Fri Oct 25 17:14:45 2013 +0200 -@@ -1008,7 +1008,7 @@ def is_pcmk_118(cib_f=None): +commit 043a73a179116619bff65c46e3f6ac693dd57d3f +Author: Kristoffer Grönlund <[email protected]> +Date: Thu Dec 12 15:06:21 2013 +0100 + + Medium: utils: Enable CIB patches for 1.1.10> + + Enable CIB patches on patched 1.1.10 systems. + +diff --git a/modules/utils.py b/modules/utils.py +index 624fcbf0d841..45277fb10003 100644 +--- a/modules/utils.py ++++ b/modules/utils.py +@@ -1097,8 +1097,8 @@ def cibadmin_features(): + def cibadmin_can_patch(): - # cibadmin -P doesn't handle comments, hopefully in v1.1.11 -- return False -+ return True - #return is_min_pcmk_ver("1.1.11") +- # cibadmin -P doesn't handle comments in <1.1.11 (unless patched) +- return is_min_pcmk_ver("1.1.11") ++ # cibadmin -P doesn't handle comments in <1.1.10 (unless patched) ++ return is_min_pcmk_ver("1.1.10") + # quote function from python module shlex.py in python 3.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/crmsh.spec new/crmsh/crmsh.spec --- old/crmsh/crmsh.spec 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/crmsh.spec 2013-12-20 11:02:10.000000000 +0100 @@ -141,6 +141,13 @@ make %{_smp_mflags} docdir=%{crmsh_docdir} +%if 0%{?with_regression_tests} + if ! test/unittests/testrunner.py ; then + echo "Shell unit tests failed." + exit 1 + fi +%endif + %install make DESTDIR=%{buildroot} docdir=%{crmsh_docdir} install install -Dm0644 contrib/bash_completion.sh %{buildroot}%{_sysconfdir}/bash_completion.d/crm.sh @@ -151,20 +158,18 @@ %clean rm -rf %{buildroot} +# Run regression tests after installing the package +# NB: this is called twice by OBS, that's why we touch the file %if 0%{?with_regression_tests} - %post - -# NB: this is called twice by OBS, that's why we touch the file if [ ! -e /tmp/.crmsh_regression_tests_ran ]; then touch /tmp/.crmsh_regression_tests_ran - if ! /usr/share/crmsh/tests/regression.sh ; then + if ! %{_datadir}/%{name}/tests/regression.sh ; then echo "Shell tests failed." cat crmtestout/regression.out exit 1 fi fi - %endif %files diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/cibconfig.py new/crmsh/modules/cibconfig.py --- old/crmsh/modules/cibconfig.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/cibconfig.py 2013-12-20 11:02:10.000000000 +0100 @@ -1072,6 +1072,8 @@ xml2 = self.cli2node(cli_text) if xml2 is None: return False + common_debug("a: %s" % etree.tostring(self.node)) + common_debug("b: %s" % etree.tostring(xml2)) rc = xml_cmp(self.node, xml2, show=True) return rc @@ -1605,7 +1607,18 @@ ''' def _repr_cli_head(self, format): - rsc = cli_display.rscref(self.node.get("rsc")) + rsc = None + if "rsc" in self.node.keys(): + rsc = self.node.get("rsc") + elif "rsc-pattern" in self.node.keys(): + rsc = '/%s/' % (self.node.get("rsc-pattern")) + if rsc is not None: + rsc = cli_display.rscref(rsc) + elif self.node.find("resource_set") is not None: + rsc = '{ %s }' % (' '.join(rsc_set_constraint(self.node, self.obj_type))) + else: + common_err("%s: unknown rsc_location format" % self.obj_id) + return None s = cli_display.keyword(self.obj_type) id = cli_display.id(self.obj_id) s = "%s %s %s" % (s, id, rsc) @@ -1631,18 +1644,23 @@ headnode = mkxmlsimple(head, oldnode, 'location') id_hint = headnode.get("id") oldrule = None + rule = None for e in cli_list[1:]: if e[0] in ("expression", "date_expression"): n = mkxmlnode(e, oldrule, id_hint) else: n = mkxmlnode(e, oldnode, id_hint) - if keyword_cmp(e[0], "rule"): + if e[0] in ("resource_set"): + headnode.append(n) + elif keyword_cmp(e[0], "rule"): add_missing_attr(n) rule = n headnode.append(n) oldrule = lookup_node(rule, oldnode, location_only=True) - else: + elif rule is not None: rule.append(n) + else: + headnode.append(n) remove_id_used_attributes(oldnode) return headnode @@ -1653,11 +1671,23 @@ if self.node is None: # eh? common_err("%s: no xml (strange)" % self.obj_id) return utils.get_check_rc() + rc = 0 uname = self.node.get("node") if uname and uname not in cib_factory.node_id_list(): common_warn("%s: referenced node %s does not exist" % (self.obj_id, uname)) - return 1 - rc = 0 + rc = 1 + pattern = self.node.get("rsc-pattern") + if pattern: + try: + re.compile(pattern) + except IndexError, e: + common_warn("%s: '%s' may not be a valid regular expression (%s)" % + (self.obj_id, pattern, e)) + rc = 1 + except re.error, e: + common_warn("%s: '%s' may not be a valid regular expression (%s)" % + (self.obj_id, pattern, e)) + rc = 1 for enode in self.node.xpath("rule/expression"): if enode.get("attribute") == "#uname": uname = enode.get("value") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/cibobjects.py new/crmsh/modules/cibobjects.py --- old/crmsh/modules/cibobjects.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/cibobjects.py 2013-12-20 11:02:10.000000000 +0100 @@ -211,6 +211,8 @@ def __init__(self): Constraint.__init__(self) self.resource = None + self.rsc_pattern = None + self.rsc_set = None self.score = None self.node = None self.role = None @@ -219,12 +221,16 @@ def _to_list(self): ret = None + rscpart = None if self.score and self.node: - ret = listfmt('[[location [[id %] [rsc %] % [node %] [role %]]]]', - self.id, self.resource, self.score, self.node, self.role) + ret = listfmt('[[location [[id %] [rsc %] [rsc-pattern %] % [node %] [role %]]]]', + self.id, self.resource, self.rsc_pattern, + self.score, self.node, self.role) else: - ret = listfmt('[[location [[id %] [rsc %]]]]', - self.id, self.resource) + self.rules + ret = listfmt('[[location [[id %] [rsc %] [rsc-pattern %]]]]', + self.id, self.resource, self.rsc_pattern) + self.rules + if self.rsc_set: + ret += self.rsc_set return ret diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/cliformat.py new/crmsh/modules/cliformat.py --- old/crmsh/modules/cliformat.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/cliformat.py 2013-12-20 11:02:10.000000000 +0100 @@ -260,8 +260,10 @@ col.append("]") elif not sequential: col.append(")") - if (sequential and require_all and obj_type != "rsc_ticket" and cnt <= 2) or \ - (obj_type == "rsc_ticket" and cnt <= 1): # a degenerate thingie + is_ticket = obj_type == 'rsc_ticket' + is_location = obj_type == 'location' + if not is_location and ((sequential and require_all and not is_ticket and cnt <= 2) or + (is_ticket and cnt <= 1)): # a degenerate thingie col.insert(0, "_rsc_set_") return col diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/config.py new/crmsh/modules/config.py --- old/crmsh/modules/config.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/config.py 2013-12-20 11:02:10.000000000 +0100 @@ -25,7 +25,7 @@ _SYSTEMWIDE = '/etc/crm/crmsh.conf' -_PERUSER = os.path.join(userdir.CONFIG_HOME, 'crm.conf') +_PERUSER = os.getenv("CRM_CONFIG_FILE") or os.path.join(userdir.CONFIG_HOME, 'crm.conf') # opt_ classes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/parse.py new/crmsh/modules/parse.py --- old/crmsh/modules/parse.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/parse.py 2013-12-20 11:02:10.000000000 +0100 @@ -43,7 +43,7 @@ _IDENT_RE = re.compile(r'([a-z0-9_#$-].*)$', re.IGNORECASE) _DISPATCH_RE = re.compile(r'[a-z0-9_]+$', re.IGNORECASE) _DESC_RE = re.compile(r'description=(.+)$', re.IGNORECASE) - _RESOURCE_RE = re.compile(r'([^=]+)$') + _RESOURCE_RE = re.compile(r'([a-z_#$][^=]*)$', re.IGNORECASE) _IDSPEC_RE = re.compile(r'(\$id-ref|\$id)=(.*)$', re.IGNORECASE) def can_parse(self): @@ -588,14 +588,33 @@ else: return ('score-attribute', score) + def match_until(self, end_token): + tokens = [] + while self.current_token() is not None and self.current_token() != end_token: + tokens.append(self.match_any()) + return tokens + def parse_location(self): """ - location <id> <rsc> <score>: <node> [role=<role>] - location <id> <rsc> [rule ...] + location <id> rsc <score>: <node> [role=<role>] + location <id> rsc [rule ...] + rsc :: /<rsc-pattern>/ + | { <rsc-set> } + | <rsc> """ out = Location() out.id = self.match_identifier() - out.resource = self.match_resource() + if self.try_match('^/(.+)/$'): + out.rsc_pattern = self.matched(1) + elif self.try_match('{'): + tokens = self.match_until('}') + self.match('}') + if not tokens: + self.err("Empty resource set") + parser = ResourceSet('role', tokens, self) + out.rsc_set = parser.parse() + else: + out.resource = self.match_resource() if self.try_match(self._SCORE_RE): out.score = self.validate_score(self.matched(1)) out.node = self.match_identifier() @@ -624,6 +643,12 @@ parse_collocation = parse_colocation def parse_order(self): + ''' + order <id> {kind|<score>}: <rsc>[:<action>] <rsc>[:<action>] ... + [symmetrical=<bool>] + + kind :: Mandatory | Optional | Serialize + ''' out = Order() out.id = self.match_identifier() if self.try_match('(%s)$' % ('|'.join(self.validation.rsc_order_kinds()))): @@ -637,6 +662,12 @@ return out def parse_rsc_ticket(self): + ''' + rsc_ticket <id> <ticket_id>: <rsc>[:<role>] [<rsc>[:<role>] ...] + [loss-policy=<loss_policy_action>] + + loss_policy_action :: stop | demote | fence | freeze + ''' out = RscTicket() out.id = self.match_identifier() self.match(self._SCORE_RE) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/ui_history.py new/crmsh/modules/ui_history.py --- old/crmsh/modules/ui_history.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/ui_history.py 2013-12-20 11:02:10.000000000 +0100 @@ -493,7 +493,7 @@ that depends on the current value of the TERM variable. ''' opt_l = [] - if not self._common_pe_render_check(context.get_command_name(), opt_l, *args): + if not self._common_pe_render_check(context, opt_l, *args): return False if "status" in opt_l: s = self._render_pe(self._pe_status_nohdr, t) @@ -511,7 +511,7 @@ def do_show(self, context, t, *args): "usage: show <pe> [status]" opt_l = [] - if not self._common_pe_render_check(context.get_command_name(), opt_l, *args): + if not self._common_pe_render_check(context, opt_l, *args): return False showfun = self._pe_config if "status" in opt_l: @@ -553,7 +553,7 @@ def do_diff(self, context, t1, t2, *args): "usage: diff <pe> <pe> [status] [html]" opt_l = [] - if not self._common_pe_render_check(context.get_command_name(), opt_l, *args): + if not self._common_pe_render_check(context, opt_l, *args): return False showfun = self._pe_config_plain mkhtml = "html" in opt_l @@ -577,7 +577,7 @@ def do_wdiff(self, context, t1, t2, *args): "usage: wdiff <pe> <pe> [status]" opt_l = [] - if not self._common_pe_render_check(context.get_command_name(), opt_l, *args): + if not self._common_pe_render_check(context, opt_l, *args): return False showfun = self._pe_config_plain if "status" in opt_l: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/ui_report.py new/crmsh/modules/ui_report.py --- old/crmsh/modules/ui_report.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/ui_report.py 2013-12-20 11:02:10.000000000 +0100 @@ -43,4 +43,4 @@ create -f "YYYY-MM-DD H:M:S" [-t "YYYY-MM-DD H:M:S"] [options ...] [dest] ''' - return utils.ext_cmd(self.extcmd + ' '.join(args)) == 0 + return utils.ext_cmd(self.extcmd + ' ' + ' '.join(args)) == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/utils.py new/crmsh/modules/utils.py --- old/crmsh/modules/utils.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/utils.py 2013-12-20 11:02:10.000000000 +0100 @@ -980,13 +980,17 @@ def get_pcmk_version(dflt): version = dflt - if not is_program('crmd'): + if is_program('crmd'): + cmd = 'crmd' + elif os.path.isfile(os.path.join(config.path.crm_daemon_dir, 'crmd')): + cmd = os.path.join(config.path.crm_daemon_dir, 'crmd') + else: return version try: - rc, s = get_stdout("crmd version") + rc, s = get_stdout("%s version" % (cmd)) if rc != 0: - common_err("crmd exited with %d" % rc) + common_err("%s exited with %d" % (cmd, rc)) else: version = s.split()[2] common_debug("found pacemaker version: %s" % version) @@ -1073,10 +1077,28 @@ return is_min_pcmk_ver("1.1.8", cib_f=cib_f) +_cibadmin_features_cached = None + +def cibadmin_features(): + ''' + # usage example: + if 'corosync-plugin' in cibadmin_features() + ''' + global _cibadmin_features_cached + if _cibadmin_features_cached is None: + _cibadmin_features_cached = [] + rc, outp = get_stdout(['cibadmin', '-!'], shell=False) + if rc == 0: + outp = outp.strip() + m = re.match(r'Pacemaker\s(\S+)\s\(Build: ([^\)]+)\):\s(.*)', outp) + if m and len(m.groups()) > 2: + _cibadmin_features_cached = m.group(3).split() + return _cibadmin_features_cached + + def cibadmin_can_patch(): - # cibadmin -P doesn't handle comments, hopefully in v1.1.11 - return False - #return is_min_pcmk_ver("1.1.11") + # cibadmin -P doesn't handle comments in <1.1.11 (unless patched) + return is_min_pcmk_ver("1.1.11") # quote function from python module shlex.py in python 3.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/xmlutil.py new/crmsh/modules/xmlutil.py --- old/crmsh/modules/xmlutil.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/modules/xmlutil.py 2013-12-20 11:02:10.000000000 +0100 @@ -938,7 +938,8 @@ if not is_constraint(node): return [] xml_obj_type = node.tag - if xml_obj_type == "rsc_location": + rsc_list = [] + if xml_obj_type == "rsc_location" and node.get("rsc"): rsc_list = [node.get("rsc")] elif node.xpath("resource_set/resource_ref"): # resource sets diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/test/unittests/test.conf new/crmsh/test/unittests/test.conf --- old/crmsh/test/unittests/test.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/crmsh/test/unittests/test.conf 2013-12-20 11:02:10.000000000 +0100 @@ -0,0 +1,12 @@ +[path] +sharedir = ../../doc +cache = ../../doc +crm_config = . +crm_daemon_dir = . +crm_daemon_user = hacluster +ocf_root = . +crm_dtd_dir = . +pe_state_dir = . +heartbeat_dir = . +hb_delnode = ./hb_delnode +nagios_plugins = . diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/test/unittests/test_parse.py new/crmsh/test/unittests/test_parse.py --- old/crmsh/test/unittests/test_parse.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/test/unittests/test_parse.py 2013-12-20 11:02:10.000000000 +0100 @@ -186,6 +186,23 @@ self.assertEqual(out.score[1], 'INFINITY') self.assertEqual(out.node, 'foo') + out = self.parser.parse('location loc-1 /foo.*/ inf: bar') + self.assertEqual(out.id, 'loc-1') + self.assertEqual(out.rsc_pattern, 'foo.*') + self.assertEqual(out.score[1], 'INFINITY') + self.assertEqual(out.node, 'bar') + #print out.to_list() + + out = self.parser.parse('location loc-1 // inf: bar') + self.assertFalse(out) + + out = self.parser.parse('location loc-1 { one ( two three ) four } inf: bar') + self.assertEqual(out.id, 'loc-1') + self.assertEqual(3, sum(1 for s in out.rsc_set if s[0] == 'resource_set')) + self.assertEqual(out.score[1], 'INFINITY') + self.assertEqual(out.node, 'bar') + #print out.to_list() + out = self.parser.parse('colocation col-1 inf: foo:master ( bar wiz sequential=yes )') self.assertEqual(out.id, 'col-1') self.assertEqual(2, sum(1 for s in out.resources if s[0] == 'resource_set')) @@ -198,7 +215,7 @@ self.assertEqual(3, sum(1 for s in out.resources if s[0] == 'resource_set')) out = self.parser.parse('colocation col-1 0: a:master b') - print out.resources + #print out.resources self.assertEqual(out.id, 'col-1') out = self.parser.parse('colocation col-1 10: ) bar wiz') @@ -221,6 +238,7 @@ out = self.parser.parse('order order_2 Mandatory: [ A B ] C') self.assertEqual(out.id, 'order_2') + self.assertEqual(out.to_list(), [['order', [['id', 'order_2'], ('kind', 'Mandatory')]], ['resource_set', [['require-all', 'false'], ['sequential', 'false'], ['resource_ref', ['id', 'A']], ['resource_ref', ['id', 'B']]]], ['resource_set', [['resource_ref', ['id', 'C']]]]]) out = self.parser.parse('rsc_ticket ticket-A_public-ip ticket-A: public-ip') self.assertEqual(out.id, 'ticket-A_public-ip') @@ -302,7 +320,7 @@ primitive rsc_dummy ocf:heartbeat:Dummy monitor rsc_dummy 30 ''') - print outp + #print outp self.assertEqual(2, len(outp)) outp = self._parse_lines(''' @@ -311,7 +329,7 @@ clone testfs-clone testfs \ meta ordered="true" interleave="true" ''') - print outp + #print outp self.assertEqual(2, len(outp)) inp = ''' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/test/unittests/testrunner.py new/crmsh/test/unittests/testrunner.py --- old/crmsh/test/unittests/testrunner.py 2013-12-09 21:14:30.000000000 +0100 +++ new/crmsh/test/unittests/testrunner.py 2013-12-20 11:02:10.000000000 +0100 @@ -26,28 +26,6 @@ os.chdir(os.path.dirname(os.path.abspath(sys.modules[__name__].__file__))) -def create_config_py(): - "TODO: make config.py.in a runtime, not compile-time generated module" - if not os.path.isfile('../../modules/config.py'): - fake_config_py = """DATADIR = "." -PACKAGE = "../doc" -CRM_CACHE_DIR = "." -CRM_DTD_DIRECTORY = "." -PE_STATE_DIR = "." -CRM_CONFIG_DIR = "." -CRM_DAEMON_DIR = "." -CRM_DAEMON_USER = "hacluster" -VERSION = "dev" -BUILD_VERSION = "dev" -HA_VARLIBHBDIR = "." -OCF_ROOT_DIR = "." -""" - f = open('../../modules/config.py', 'w') - f.write(fake_config_py) - f.close() -create_config_py() - - def test_info(f): m = re.match(r'^test_(.+)\.py$', os.path.basename(f)) if m: @@ -58,8 +36,9 @@ def run_test(name, testfile): print "%s" % (name.capitalize()) - cmd = 'PYTHONPATH=%s python -B %s' % ( + cmd = 'PYTHONPATH=%s CRM_CONFIG_FILE=%s python -B %s' % ( '../../modules', + 'test.conf', testfile ) ret = subprocess.call(cmd, shell=True) -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
