rhmessaging commits: r1622 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-01-29 14:40:29 -0500 (Tue, 29 Jan 2008)
New Revision: 1622
Modified:
mgmt/cumin/python/cumin/brokergroup.py
Log:
Fix filtering in the group broker list.
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-01-29 19:07:08 UTC (rev 1621)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-01-29 19:40:29 UTC (rev 1622)
@@ -93,9 +93,19 @@
def get_item_count(self, session, group):
return group.brokers.count()
- def do_get_items(self, session, group):
- return group.brokers
-
+ def get_where_sql(self, session):
+ # XXX ugh, get rid of None arg
+ group = self.frame().get_object(session, None)
+ subquery = \
+ "select 1 from broker_group_mapping " + \
+ "where broker_group_id = %i " % group.id + \
+ "and broker_registration_id = b.id"
+
+ return "where exists (%s)" % subquery
+
+ def render_none(self, session, model):
+ return fmt_none()
+
class BrokerGroupForm(CuminForm):
def __init__(self, app, name):
super(BrokerGroupForm, self).__init__(app, name)
17 years, 1 month
rhmessaging commits: r1621 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-01-29 14:07:08 -0500 (Tue, 29 Jan 2008)
New Revision: 1621
Modified:
mgmt/cumin/python/cumin/broker.py
Log:
Use a correlated subquery instead of a join. We were getting
duplicate rows back when a broker was in more than one group.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-01-29 18:14:33 UTC (rev 1620)
+++ mgmt/cumin/python/cumin/broker.py 2008-01-29 19:07:08 UTC (rev 1621)
@@ -25,10 +25,6 @@
self.add_sql_column("id", "b.id")
self.add_sql_column("name", "b.name")
- self.add_sql_join("broker_group_mapping bgm",
- "bgm.broker_registration_id",
- "b.id")
-
self.ids = CheckboxIdColumn(app, "id")
self.add_column(self.ids)
self.add_form_parameter(self.ids)
@@ -498,8 +494,13 @@
#cluster = self.parent.cluster.get(session)
if group:
- elems.append("bgm.broker_group_id = %i" % group.id)
+ subquery = \
+ "select 1 from broker_group_mapping " + \
+ "where broker_group_id = %i " % group.id + \
+ "and broker_registration_id = b.id"
+ elems.append("exists (%s)" % subquery)
+
if elems:
return "where %s" % " and ".join(elems)
17 years, 1 month
rhmessaging commits: r1619 - store/trunk/cpp/tests.
by rhmessaging-commits@lists.jboss.org
Author: aconway
Date: 2008-01-29 11:53:02 -0500 (Tue, 29 Jan 2008)
New Revision: 1619
Modified:
store/trunk/cpp/tests/SimpleTest.cpp
Log:
Removed reference to defunct framing::ChannelAdapter.
Modified: store/trunk/cpp/tests/SimpleTest.cpp
===================================================================
--- store/trunk/cpp/tests/SimpleTest.cpp 2008-01-29 12:34:41 UTC (rev 1618)
+++ store/trunk/cpp/tests/SimpleTest.cpp 2008-01-29 16:53:02 UTC (rev 1619)
@@ -29,7 +29,6 @@
#include <qpid/framing/AMQFrame.h>
#include <qpid/framing/AMQHeaderBody.h>
#include <qpid/framing/AMQMethodBody.h>
-#include <qpid/framing/ChannelAdapter.h>
#include <qpid/framing/FieldValue.h>
#include <qpid/broker/Message.h>
#include <qpid/broker/Queue.h>
17 years, 1 month
rhmessaging commits: r1618 - in mgmt/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-01-29 07:34:41 -0500 (Tue, 29 Jan 2008)
New Revision: 1618
Modified:
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/wooly/tables.py
Log:
Interim check in of a "jobs" ui, for displaying the status of the
users actions.
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2008-01-28 20:57:09 UTC (rev 1617)
+++ mgmt/cumin/python/cumin/client.py 2008-01-29 12:34:41 UTC (rev 1618)
@@ -221,11 +221,9 @@
self.page().set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
- try:
- client = Client.get(id)
- client.close(self.app.model.data, client.managedBroker, doit)
- except Exception, e:
- self.add_error(session, e)
+ client = Client.get(id)
+ action = self.app.model.client.close
+ action.invoke(client)
def render_item_content(self, session, id):
return "Close Client %s" % Client.get(id).address
@@ -334,11 +332,9 @@
self.page().set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
- try:
- session_ = Session.get(id)
- session_.detach(self.app.model.data, session_.managedBroker, doit)
- except Exception, e:
- self.add_error(session, e)
+ session_ = Session.get(id)
+ action = self.app.model.session.detach
+ action.invoke(session_)
def render_item_content(self, session, id):
return "Detach Session '%s'" % Session.get(id).name
@@ -355,11 +351,9 @@
self.page().set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
- try:
- session_ = Session.get(id)
- session_.close(self.app.model.data, session_.managedBroker, doit)
- except Exception, e:
- self.add_error(session, e)
+ session_ = Session.get(id)
+ action = self.app.model.session.close
+ action.invoke(session_)
def render_item_content(self, session, id):
return "Close Session '%s'" % Session.get(id).name
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2008-01-28 20:57:09 UTC (rev 1617)
+++ mgmt/cumin/python/cumin/model.py 2008-01-29 12:34:41 UTC (rev 1618)
@@ -19,6 +19,8 @@
self.client = CuminClient(self)
self.session = CuminSession(self)
+ self.action_invocations = set()
+
def check(self):
self.data.check()
@@ -46,17 +48,24 @@
self.mint_stats_class = None
self.stats = list()
+ self.actions = list()
self.model.add_class(self)
def add_stat(self, stat):
self.stats.append(stat)
+ setattr(self, stat.name, stat)
+ # XXX get rid of this
def get_stat(self, name):
for stat in self.stats:
if stat.name == name:
return stat
+ def add_action(self, action):
+ self.actions.append(action)
+ setattr(self, action.name, action)
+
def get_object_name(self, object):
return object.name
@@ -81,6 +90,42 @@
writer.write("</%s>" % self.name)
+class CuminAction(object):
+ def __init__(self, cls, name):
+ self.model = cls.model
+ self.cumin_class = cls
+ self.name = name
+ self.title = None
+
+ self.cumin_class.add_action(self)
+
+ def invoke(self, object):
+ invoc = CuminActionInvocation(self)
+
+ def callback(status, args):
+ invoc.status = status
+ invoc.args = args
+ invoc.show()
+
+ self.do_invoke(object, callback)
+
+ self.model.action_invocations.add(invoc)
+
+ return invoc
+
+ def do_invoke(self, object, callback):
+ pass
+
+class CuminActionInvocation(object):
+ def __init__(self, action):
+ self.action = action
+ self.when = datetime.now()
+ self.error = None
+ self.args = None
+
+ def show(self):
+ print "action", self.action.name, self.when, self.error, self.args
+
class CuminStat(object):
def __init__(self, cls, name, type):
self.model = cls.model
@@ -360,6 +405,15 @@
stat.unit = "byte"
stat.categories = ("byte", "persistent")
+ self.Purge(self, "purge")
+
+ class Purge(CuminAction):
+ def get_title(self, session):
+ return "Purge"
+
+ def do_invoke(self, object, callback):
+ object.purge(self.model.data, object.managedBroker, callback)
+
class CuminExchange(CuminClass):
def __init__(self, model):
super(CuminExchange, self).__init__(model, "exchange", Exchange)
@@ -448,9 +502,18 @@
stat.unit = "frame"
stat.categories = ("general")
+ self.Close(self, "close")
+
def get_object_name(self, client):
return client.address
+ class Close(CuminAction):
+ def get_title(self, session):
+ return "Close"
+
+ def do_invoke(self, object, callback):
+ object.close(self.model.data, object.managedBroker, callback)
+
class CuminSession(CuminClass):
def __init__(self, model):
super(CuminSession, self).__init__(model, "session", Session)
@@ -470,3 +533,38 @@
stat = CuminStat(self, "attached", "bool")
stat.title = "Attached"
stat.categories = ("general")
+
+ self.Close(self, "close")
+ self.Detach(self, "detach")
+ self.ResetLifespan(self, "resetLifespan")
+ self.SolicitAck(self, "solicitAck")
+
+ class Close(CuminAction):
+ def get_title(self, session):
+ return "Close"
+
+ def do_invoke(self, object, callback):
+ object.close(self.model.data, object.managedBroker, callback)
+
+ class Detach(CuminAction):
+ def get_title(self, session):
+ return "Detach"
+
+ def do_invoke(self, object, callback):
+ object.detach(self.model.data, object.managedBroker, callback)
+
+ class ResetLifespan(CuminAction):
+ def get_title(self, session):
+ return "Reset Lifespan"
+
+ def do_invoke(self, object, callback):
+ object.resetLifespan(self.model.data, object.managedBroker,
+ callback)
+
+ class SolicitAck(CuminAction):
+ def get_title(self, session):
+ return "Solicit Acknowledgment"
+
+ def do_invoke(self, object, callback):
+ object.solicitAck(self.model.data, object.managedBroker,
+ callback)
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-01-28 20:57:09 UTC (rev 1617)
+++ mgmt/cumin/python/cumin/page.py 2008-01-29 12:34:41 UTC (rev 1618)
@@ -164,6 +164,43 @@
object = frame.get_object(session, self.object.get(session))
return frame.render_title(session, object)
+class ActionInvocationSet(ItemTable):
+ def __init__(self, app, name):
+ super(ActionInvocationSet, self).__init__(app, name)
+
+ col = self.ActionColumn(app, "action")
+ self.add_column(col)
+
+ col = self.WhenColumn(app, "when")
+ self.add_column(col)
+
+ col = self.StatusColumn(app, "status")
+ self.add_column(col)
+
+ class ActionColumn(ItemTableColumn):
+ def get_title(self, session, object):
+ return "Action"
+
+ def render_content(self, session, item):
+ return item.action.name
+
+ class WhenColumn(ItemTableColumn):
+ def get_title(self, session, object):
+ return "When"
+
+ def render_content(self, session, item):
+ return fmt_datetime(item.when)
+
+ class StatusColumn(ItemTableColumn):
+ def get_title(self, session, object):
+ return "Status"
+
+ def render_content(self, session, item):
+ return item.error
+
+ def do_get_items(self, session, object):
+ return sorted_by(self.app.model.action_invocations, "when")
+
class MainView(TabSet):
def __init__(self, app, name):
super(MainView, self).__init__(app, name)
@@ -173,6 +210,7 @@
#self.add_tab(BrokerProfileSet(app, "profiles"))
#self.add_tab(BrokerClusterSet(app, "clusters"))
#self.add_tab(self.TagTab(app, "tags"))
+ self.add_tab(self.ActionTab(app, "actions"))
def show_broker_group(self, session, group):
mode = self.show_mode(session, self.brokers)
@@ -185,3 +223,7 @@
class TagTab(Widget):
def get_title(self, session, model):
return "Tags"
+
+ class ActionTab(ActionInvocationSet):
+ def get_title(self, session, model):
+ return "Actions"
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2008-01-28 20:57:09 UTC (rev 1617)
+++ mgmt/cumin/python/cumin/queue.py 2008-01-29 12:34:41 UTC (rev 1618)
@@ -481,11 +481,9 @@
self.page().set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
- try:
- queue = Queue.get(id)
- queue.purge(self.app.model.data, queue.managedBroker, doit)
- except Exception, e:
- self.add_error(session, e)
+ queue = Queue.get(id)
+ action = self.app.model.queue.purge
+ action.invoke(queue)
def render_item_content(self, session, id):
return "Purge Queue '%s'" % Queue.get(id).name
Modified: mgmt/cumin/python/wooly/tables.py
===================================================================
--- mgmt/cumin/python/wooly/tables.py 2008-01-28 20:57:09 UTC (rev 1617)
+++ mgmt/cumin/python/wooly/tables.py 2008-01-29 12:34:41 UTC (rev 1618)
@@ -78,16 +78,11 @@
column, object = args
return column.get_class_attr(session)
- def render_cells(self, session, data):
- data_map = dict()
-
- for col, datum in zip(self.columns, data):
- data_map[col.name] = datum
-
+ def render_cells(self, session, item):
writer = Writer()
for col in self.columns:
- writer.write(col.render(session, data_map))
+ writer.write(col.render(session, item))
return writer.to_string()
@@ -239,15 +234,6 @@
return cursor
- def render_items(self, session, object):
- writer = Writer()
- cursor = self.get_items(session, object)
-
- for row in cursor:
- self.item_tmpl.render(session, row, writer)
-
- return writer.to_string()
-
def render_cells(self, session, data):
data_map = dict()
17 years, 1 month
rhmessaging commits: r1617 - in store/trunk/cpp: tests/jrnl/jtt and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2008-01-28 15:57:09 -0500 (Mon, 28 Jan 2008)
New Revision: 1617
Added:
store/trunk/cpp/tests/jrnl/jtt/args.cpp
store/trunk/cpp/tests/jrnl/jtt/args.hpp
Removed:
store/trunk/cpp/tests/jrnl/jtt/options.cpp
store/trunk/cpp/tests/jrnl/jtt/options.hpp
Modified:
store/trunk/cpp/lib/jrnl/jcntl.hpp
store/trunk/cpp/tests/jrnl/jtt/Makefile.am
store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp
store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
store/trunk/cpp/tests/jrnl/jtt/main.cpp
store/trunk/cpp/tests/jrnl/jtt/test_case.cpp
store/trunk/cpp/tests/jrnl/jtt/test_case.hpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
Log:
Journal test tool enhancements and bugfixes
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -161,6 +161,7 @@
virtual ~jcntl();
inline const std::string& id() const { return _jid; }
+ inline const std::string& jrnl_dir() const { return _jdir.dirname(); }
/**
* \brief Initialize the journal for storing data.
Modified: store/trunk/cpp/tests/jrnl/jtt/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-01-28 20:57:09 UTC (rev 1617)
@@ -47,11 +47,11 @@
_ut_jrnl_instance
jtt_SOURCES = \
+ args.cpp \
data_src.cpp \
jrnl_init_params.cpp \
jrnl_instance.cpp \
main.cpp \
- options.cpp \
test_case.cpp \
test_case_result.cpp \
test_case_result_agregation.cpp \
Modified: store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -45,7 +45,7 @@
test_case::shared_ptr p(new test_case(1, 0, 0, 0, false, 0, 0, test_case::JTT_PERSISTNET,
test_case::JDL_INTERNAL, "t1"));
jrnl_instance ji(jid, jdir, bfn, num_jfiles, jfsize_sblks);
- ji.init_tc(p, false, true);
+ ji.init_tc(p, false);
ji.run_tc();
ji.tc_wait_compl();
try { jdir::verify_dir(jdir, bfn); }
@@ -67,7 +67,7 @@
jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
jfsize_sblks));
jrnl_instance ji(jpp);
- ji.init_tc(p, false, true);
+ ji.init_tc(p, false);
ji.run_tc();
ji.tc_wait_compl();
try { jdir::verify_dir(jdir, bfn); }
@@ -89,7 +89,7 @@
jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
jfsize_sblks));
jrnl_instance ji(jpp);
- ji.init_tc(p, false, true);
+ ji.init_tc(p, false);
ji.run_tc();
ji.tc_wait_compl();
try { jdir::verify_dir(jdir, bfn); }
@@ -111,12 +111,12 @@
jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
jfsize_sblks));
jrnl_instance ji(jpp);
- ji.init_tc(p, false, true);
+ ji.init_tc(p, false);
ji.run_tc();
ji.tc_wait_compl();
try { jdir::verify_dir(jdir, bfn); }
catch (const jexception& e) { BOOST_ERROR(e.what()); }
- ji.init_tc(p, true, true);
+ ji.init_tc(p, true);
ji.run_tc();
ji.tc_wait_compl();
try { jdir::verify_dir(jdir, bfn); }
@@ -138,7 +138,7 @@
jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
jfsize_sblks));
jrnl_instance ji(jpp);
- ji.init_tc(p, true, true);
+ ji.init_tc(p, true);
ji.run_tc();
ji.tc_wait_compl();
try { jdir::verify_dir(jdir, bfn); }
@@ -146,32 +146,3 @@
jdir::delete_dir(jdir);
}
-BOOST_AUTO_TEST_CASE(jrnl_instance_no_jrnl_keep)
-{
- const std::string jid = "jid7";
- const std::string jdir = "/tmp/test7";
- const std::string bfn = "test";
- const u_int16_t num_jfiles = 20;
- const u_int32_t jfsize_sblks = 128;
-
- using rhm::jtt::test_case;
- test_case::shared_ptr p(new test_case(7, 0, 0, 0, false, 0, 0, test_case::JTT_PERSISTNET,
- test_case::JDL_INTERNAL, "t7"));
- jrnl_instance ji(jid, jdir, bfn, num_jfiles, jfsize_sblks);
- ji.init_tc(p, false, false);
- ji.run_tc();
- ji.tc_wait_compl();
- try
- {
- jdir::verify_dir(jdir, bfn);
- BOOST_ERROR("Failed to delete journal directory.");
- }
- catch (const jexception& e)
- {
- if (e.err_code() != rhm::journal::jerrno::JERR_JDIR_STAT)
- BOOST_ERROR(e.what());
- }
- jdir::delete_dir(jdir);
-}
-
-
Copied: store/trunk/cpp/tests/jrnl/jtt/args.cpp (from rev 1615, store/trunk/cpp/tests/jrnl/jtt/options.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/jtt/args.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -0,0 +1,152 @@
+/**
+* Copyright 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "args.hpp"
+
+#include <iostream>
+
+namespace po = boost::program_options;
+
+namespace rhm
+{
+namespace jtt
+{
+
+args::args(std::string opt_title):
+ _options_descr(opt_title),
+ jrnl_format_chk(false),
+ keep_jrnls(false),
+ num_jrnls(1),
+ pause_secs(0),
+ randomize(false),
+ recover_mode(false),
+ repeat_flag(false),
+ reuse_instance(false),
+ seed(0)
+{
+ _options_descr.add_options()
+ ("csv-file,c",
+ po::value<std::string>(&test_case_csv_file_name)->default_value("jtt.csv"),
+ "CSV file containing test cases")
+ ("help,h", "This help message")
+ ("jrnl-format-chk", po::value<bool>(&jrnl_format_chk)->zero_tokens(),
+ "If true, will check the format of each journal file")
+ ("keep-jrnls", po::value<bool>(&keep_jrnls)->zero_tokens(),
+ "If true, will keep all test journals in backup dirs")
+ ("num-jrnls", po::value<unsigned>(&num_jrnls)->default_value(1),
+ "Number of simultaneous journal instances to test")
+ ("pause", po::value<unsigned>(&pause_secs)->default_value(0),
+ "Pause in seconds between test cases (allows disk to catch up)")
+ ("randomize", po::value<bool>(&randomize)->zero_tokens(),
+ "Randomize the order of the test case execution")
+ ("recover-mode", po::value<bool>(&recover_mode)->zero_tokens(),
+ "If true, will cause the journal from the previous test to be recovered")
+ ("repeat", po::value<bool>(&repeat_flag)->zero_tokens(),
+ "If true, will repeat tests in csv file indefinitely")
+ ("reuse-instance", po::value<bool>(&reuse_instance)->zero_tokens(),
+ "If true, will cause first journal instance to be reused for all test cases")
+ ("seed", po::value<unsigned>(&seed)->default_value(0),
+ "Seed for use in random number generator");
+}
+
+const bool
+args::parse(int argc, char** argv) // return true if error, false if ok
+{
+ try
+ {
+ po::store(po::parse_command_line(argc, argv, _options_descr), _vmap);
+ po::notify(_vmap);
+ }
+ catch (const std::exception& e)
+ {
+ std::cout << "ERROR: " << e.what() << std::endl;
+ return usage();
+ }
+ if (_vmap.count("help"))
+ return usage();
+ if (num_jrnls == 0)
+ {
+ std::cout << "ERROR: num_jrnls must be 1 or more." << std::endl;
+ return usage();
+ }
+ if (repeat_flag && keep_jrnls)
+ {
+ std::string resp;
+ std::cout << "WARNING: repeat and keep-jrnls: Monitor disk usage as test journals will"
+ " accumulate." << std::endl;
+ std::cout << "Continue? <y/n> ";
+ std::cin >> resp;
+ if (resp.size() == 1)
+ {
+ if (resp[0] != 'y' && resp[0] != 'Y')
+ return true;
+ }
+ else if (resp.size() == 3) // any combo of lower- and upper-case
+ {
+ if (resp[0] != 'y' && resp[0] != 'Y')
+ return true;
+ if (resp[1] != 'e' && resp[1] != 'E')
+ return true;
+ if (resp[2] != 's' && resp[2] != 'S')
+ return true;
+ }
+ else
+ return true;
+ }
+ return false;
+}
+
+const bool
+args::usage() const
+{
+ std::cout << _options_descr << std::endl;
+ return true;
+}
+
+const void
+args::print_flags() const
+{
+ if (jrnl_format_chk || keep_jrnls || randomize || recover_mode || repeat_flag ||
+ reuse_instance)
+ {
+ std::cout << "Options:";
+ // TODO: Get flag args and their strings directly from _options_descr.
+ if (jrnl_format_chk)
+ std::cout << " jrnl-format-chk";
+ if (keep_jrnls)
+ std::cout << " keep-jrnls";
+ if (randomize)
+ std::cout << " randomize";
+ if (recover_mode)
+ std::cout << " recover-mode";
+ if (repeat_flag)
+ std::cout << " repeat-flag";
+ if (reuse_instance)
+ std::cout << " reuse-instance";
+ std::cout << std::endl;
+ }
+ std::cout << std::endl;
+}
+
+} // namespace jtt
+} // namespace rhm
Copied: store/trunk/cpp/tests/jrnl/jtt/args.hpp (from rev 1615, store/trunk/cpp/tests/jrnl/jtt/options.hpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.hpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/jtt/args.hpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -0,0 +1,60 @@
+/**
+* Copyright 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#ifndef rhm_jtt_args_hpp
+#define rhm_jtt_args_hpp
+
+#include <boost/program_options.hpp>
+
+namespace rhm
+{
+namespace jtt
+{
+
+ struct args
+ {
+ boost::program_options::options_description _options_descr;
+ boost::program_options::variables_map _vmap;
+
+ // Add args here
+ std::string test_case_csv_file_name;
+ bool jrnl_format_chk;
+ bool keep_jrnls;
+ unsigned num_jrnls;
+ unsigned pause_secs;
+ bool randomize;
+ bool recover_mode;
+ bool repeat_flag;
+ bool reuse_instance;
+ unsigned seed;
+
+ args(std::string opt_title);
+ const bool parse(int argc, char** argv); // return true if error, false if ok
+ const bool usage() const; // return true
+ const void print_flags() const;
+ };
+
+} // namespace jtt
+} // namespace rhm
+
+#endif // ifndef rhm_jtt_args_hpp
Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -46,9 +46,7 @@
_dtok_master_txn_list(),
_dtok_deq_list(),
_tcp(),
- _tcrp(),
- _recover_mode(false),
- _keep_jrnls(false)
+ _tcrp()
{
pthread_mutex_init(&_ddl_mutex, 0);
}
@@ -61,9 +59,7 @@
_dtok_master_txn_list(),
_dtok_deq_list(),
_tcp(),
- _tcrp(),
- _recover_mode(false),
- _keep_jrnls(false)
+ _tcrp()
{
pthread_mutex_init(&_ddl_mutex, 0);
}
@@ -75,7 +71,7 @@
void
-jrnl_instance::init_tc(test_case::shared_ptr& tcp, const bool recover_mode, const bool keep_jrnls)
+jrnl_instance::init_tc(test_case::shared_ptr& tcp, const bool recover_mode)
throw ()
{
test_case_result::shared_ptr p(new test_case_result(_jpp->jid()));
@@ -83,13 +79,11 @@
try
{
_tcp = tcp;
- _recover_mode = recover_mode;
- _keep_jrnls = keep_jrnls;
_dtok_master_enq_list.clear();
_dtok_master_txn_list.clear();
_dtok_deq_list.clear();
- if (_recover_mode)
+ if (recover_mode)
{
try
{
@@ -139,10 +133,6 @@
catch (...) { _tcrp->add_exception("Unknown exception"); }
_tcrp->set_stop_time();
_tcp->add_result(_tcrp);
-
- if (!_recover_mode && !_keep_jrnls)
- try { rhm::journal::jdir::delete_dir(_jpp->jdir()); }
- catch (...) {} // TODO - work out exception strategy for failure here...
}
void
Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -56,8 +56,6 @@
pthread_t _read_thread;
test_case::shared_ptr _tcp;
test_case_result::shared_ptr _tcrp;
- bool _recover_mode;
- bool _keep_jrnls;
public:
jrnl_instance(const std::string& jid, const std::string& jdir,
@@ -70,7 +68,7 @@
inline const jrnl_init_params::shared_ptr& params() const { return _jpp; }
inline const std::string& jid() const { return _jpp->jid(); }
- void init_tc(test_case::shared_ptr& tcp, const bool recover_mode, const bool keep_jrnls)
+ void init_tc(test_case::shared_ptr& tcp, const bool recover_mode)
throw ();
void run_tc() throw ();
void tc_wait_compl() throw ();
Modified: store/trunk/cpp/tests/jrnl/jtt/main.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/main.cpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/main.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -25,7 +25,7 @@
#include "test_mgr.hpp"
#include <iostream>
-#include "options.hpp"
+#include "args.hpp"
#include <signal.h>
namespace po = boost::program_options;
@@ -39,12 +39,12 @@
std::ostringstream oss;
oss << PACKAGE_NAME << " options";
- rhm::jtt::options opts(oss.str());
- if (opts.validate(argc, argv)) return 1;
+ rhm::jtt::args args(oss.str());
+ if (args.parse(argc, argv)) return 1;
try
{
- rhm::jtt::test_mgr tm(opts);
+ rhm::jtt::test_mgr tm(args);
tm.run();
}
catch (const std::exception& e)
Deleted: store/trunk/cpp/tests/jrnl/jtt/options.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/options.cpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/options.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -1,139 +0,0 @@
-/**
-* Copyright 2008 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "options.hpp"
-
-#include <iostream>
-
-namespace po = boost::program_options;
-
-namespace rhm
-{
-namespace jtt
-{
-
-options::options(std::string opt_title):
- _options_descr(opt_title),
- jrnl_format_chk(false),
- reuse_instance(false),
- recover_mode(false),
- repeat_flag(false),
- keep_jrnls(false)
-{
- _options_descr.add_options()
- ("help,h", "This help message")
- ("num-jrnls", po::value<unsigned>(&num_jrnls)->default_value(1),
- "Number of simultaneous journal instances to test")
- ("csv-file,c",
- po::value<std::string>(&test_case_csv_file_name)->default_value("jtt.csv"),
- "CSV file containing test cases")
- ("jrnl-format-chk", po::value<bool>(&jrnl_format_chk)->zero_tokens(),
- "If true, will check the format of each journal file")
- ("reuse-instance", po::value<bool>(&reuse_instance)->zero_tokens(),
- "If true, will cause first journal instance to be reused for all test cases")
- ("recover-mode", po::value<bool>(&recover_mode)->zero_tokens(),
- "If true, will cause the journal from the previous test to be recovered")
- ("repeat", po::value<bool>(&repeat_flag)->zero_tokens(),
- "If true, will repeat tests in csv file indefinitely")
- ("keep-jrnls", po::value<bool>(&keep_jrnls)->zero_tokens(),
- "If true, will keep all test journals in backup dirs");
-}
-
-const bool
-options::validate(int argc, char** argv) // return true if error, false if ok
-{
- try
- {
- po::store(po::parse_command_line(argc, argv, _options_descr), _vmap);
- po::notify(_vmap);
- }
- catch (const std::exception& e)
- {
- std::cout << "ERROR: " << e.what() << std::endl;
- return usage();
- }
- if (_vmap.count("help"))
- return usage();
- if (num_jrnls == 0)
- {
- std::cout << "ERROR: num_jrnls must be 1 or more." << std::endl;
- return usage();
- }
- if (repeat_flag && keep_jrnls)
- {
- std::string resp;
- std::cout << "WARNING: repeat and keep-jrnls: Monitor disk usage as test journals will"
- " accumulate." << std::endl;
- std::cout << "Continue? <y/n> ";
- std::cin >> resp;
- if (resp.size() == 1)
- {
- if (resp[0] != 'y' && resp[0] != 'Y')
- return true;
- }
- else if (resp.size() == 3) // any combo of lower- and upper-case
- {
- if (resp[0] != 'y' && resp[0] != 'Y')
- return true;
- if (resp[1] != 'e' && resp[1] != 'E')
- return true;
- if (resp[2] != 's' && resp[2] != 'S')
- return true;
- }
- else
- return true;
- }
- return false;
-}
-
-const bool
-options::usage() const
-{
- std::cout << _options_descr << std::endl;
- return true;
-}
-
-const void
-options::print_flags() const
-{
- if (jrnl_format_chk || reuse_instance || recover_mode || repeat_flag || keep_jrnls)
- {
- std::cout << "Options:";
- // TODO: Get flag options and their strings directly from _options_descr.
- if (jrnl_format_chk)
- std::cout << " jrnl-format-chk";
- if (reuse_instance)
- std::cout << " reuse-instance";
- if (recover_mode)
- std::cout << " recover-mode";
- if (repeat_flag)
- std::cout << " repeat-flag";
- if (keep_jrnls)
- std::cout << " keep-jrnls";
- std::cout << std::endl;
- }
- std::cout << std::endl;
-}
-
-} // namespace jtt
-} // namespace rhm
Deleted: store/trunk/cpp/tests/jrnl/jtt/options.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/options.hpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/options.hpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -1,57 +0,0 @@
-/**
-* Copyright 2008 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#ifndef rhm_jtt_options_hpp
-#define rhm_jtt_options_hpp
-
-#include <boost/program_options.hpp>
-
-namespace rhm
-{
-namespace jtt
-{
-
- struct options
- {
- boost::program_options::options_description _options_descr;
- boost::program_options::variables_map _vmap;
-
- // Add options here
- unsigned num_jrnls;
- std::string test_case_csv_file_name;
- bool jrnl_format_chk;
- bool reuse_instance;
- bool recover_mode;
- bool repeat_flag;
- bool keep_jrnls;
-
- options(std::string opt_title);
- const bool validate(int argc, char** argv); // return true if error, false if ok
- const bool usage() const; // return true
- const void print_flags() const;
- };
-
-} // namespace jtt
-} // namespace rhm
-
-#endif // ifndef rhm_jtt_options_hpp
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case.cpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -113,6 +113,15 @@
ari->second->add_test_result(tcrp);
}
+void
+test_case::set_fmt_chk_res(const bool res, const std::string& jid)
+{
+ _result_average.set_fmt_chk_res(res);
+ res_map_citr ari = _result_jmap.find(jid);
+ if (ari != _result_jmap.end())
+ ari->second->set_fmt_chk_res(res);
+}
+
const test_case_result::shared_ptr
test_case::jmap_last(std::string& jid) const
{
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case.hpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case.hpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -90,6 +90,7 @@
inline const std::string& comment() const { return _comment; }
void add_result(test_case_result::shared_ptr& p);
+ void set_fmt_chk_res(const bool res, const std::string& jid);
inline const test_case_result_agregation& average() const { return _result_average; }
inline const u_int32_t num_results() const { return _result_average.num_results(); }
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -34,6 +34,8 @@
test_case_result_agregation::test_case_result_agregation():
test_case_result("Average"),
_tc_average(true),
+ _fmt_chk_done(false),
+ _fmt_chk_err(false),
_rlist()
{
}
@@ -41,6 +43,8 @@
test_case_result_agregation::test_case_result_agregation(const std::string& jid):
test_case_result(jid),
_tc_average(false),
+ _fmt_chk_done(false),
+ _fmt_chk_err(false),
_rlist()
{}
@@ -128,6 +132,8 @@
oss << "average (" << _rlist.size() << "):";
oss << test_case_result::str_summary();
+ if (_fmt_chk_done)
+ oss << " fmt-chk=" << (_fmt_chk_err ? "ok" : "fail");
if (_exception_list.size())
{
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -43,6 +43,8 @@
private:
bool _tc_average;
+ bool _fmt_chk_done;
+ bool _fmt_chk_err;
tcrp_list _rlist;
public:
@@ -53,6 +55,10 @@
void add_test_result(const test_case_result::shared_ptr& tcrp);
inline const bool tc_average_mode() const { return _tc_average; }
+ inline const bool fmt_chk_done() const { return _fmt_chk_done; }
+ inline const bool fmt_chk_res() const { return _fmt_chk_err; }
+ inline void set_fmt_chk_res(const bool err)
+ { _fmt_chk_done = true; if (!_fmt_chk_err && err) _fmt_chk_err = err; }
inline const u_int32_t num_results() const { return _rlist.size(); }
inline tcrp_list_citr rlist_begin() const { return _rlist.begin(); }
inline tcrp_list_citr rlist_end() const { return _rlist.end(); }
Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -31,11 +31,14 @@
namespace jtt
{
-test_mgr::test_mgr(options& opts):
+test_mgr::test_mgr(args& args):
_ji_list(),
- _opts(opts)
+ _args(args),
+ _random_fn_ptr(random_fn)
{
- std::cout << "Number of journals: " << _opts.num_jrnls << std::endl;
+ std::cout << "Number of journals: " << _args.num_jrnls << std::endl;
+ if (args.seed)
+ ::srandom(args.seed);
}
test_mgr::~test_mgr()
@@ -51,8 +54,8 @@
// defualt: none of these, similar to current summary = true version.
const bool summary = true;
- std::cout << "CSV file: \"" << _opts.test_case_csv_file_name << "\"";
- test_case_set tcs(_opts.test_case_csv_file_name, _opts.recover_mode);
+ std::cout << "CSV file: \"" << _args.test_case_csv_file_name << "\"";
+ test_case_set tcs(_args.test_case_csv_file_name, _args.recover_mode);
const unsigned num_test_cases = tcs.size();
if (num_test_cases)
{
@@ -61,7 +64,7 @@
if (tcs.ignored())
std::cout << "WARNING: " << tcs.ignored() << " test cases were ignored. "
"(recover-mode selected and test has no auto-dequeue.)" << std::endl;
- _opts.print_flags();
+ _args.print_flags();
}
else
std::cout << " (WARNING: This CSV file is empty or does not exist.)" << std::endl;
@@ -69,6 +72,8 @@
do
{
unsigned u = 0;
+ if (_args.randomize)
+ random_shuffle(tcs.begin(), tcs.end(), _random_fn_ptr);
for (test_case_set::tcl_itr tci = tcs.begin(); tci != tcs.end(); tci++, u++)
{
if (summary)
@@ -76,39 +81,42 @@
(*tci)->comment() << "\"" << std::endl;
else
std::cout << (*tci)->str() << std::endl;
- if (!_opts.reuse_instance || _ji_list.empty())
+ if (!_args.reuse_instance || _ji_list.empty())
initialize_jrnls();
for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
- (*jii)->init_tc(*tci, _opts.recover_mode, _opts.keep_jrnls);
+ (*jii)->init_tc(*tci, _args.recover_mode);
for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
(*jii)->run_tc();
for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
(*jii)->tc_wait_compl();
- if (_opts.jrnl_format_chk)
+ if (_args.jrnl_format_chk)
{
for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
{
jrnl_init_params::shared_ptr jpp = (*jii)->params();
std::ostringstream oss;
- oss << "jfile_chk.py -q";
+ oss << "./jfile_chk.py -q";
oss << " -d " << jpp->jdir();
oss << " -b " << jpp->base_filename();
- oss << " -c" << _opts.test_case_csv_file_name;
+ oss << " -c" << _args.test_case_csv_file_name;
oss << " -t" << (*tci)->test_case_num();
- if (system(oss.str().c_str()))
- {
- std::cout << " Format check of journal in \"" << jpp->jdir() <<
- "\" failed." << std::endl;
- std::cout << (*tci)->str() << std::endl;
- }
+ bool res = system(oss.str().c_str()) == 0;
+ (*tci)->set_fmt_chk_res(res, jpp->jid());
}
}
+ if (!_args.recover_mode && !_args.keep_jrnls)
+ for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
+ try { rhm::journal::jdir::delete_dir((*jii)->jrnl_dir()); }
+ catch (...) {} // TODO - work out exception strategy for failure here...
+
print_results(*tci, summary);
- if (_abort || (!_opts.repeat_flag && _signal))
+ if (_abort || (!_args.repeat_flag && _signal))
break;
+ if (_args.pause_secs && tci != tcs.end())
+ ::usleep(_args.pause_secs * 1000000);
}
}
- while (_opts.repeat_flag && !_signal);
+ while (_args.repeat_flag && !_signal);
}
// static fn:
@@ -132,7 +140,7 @@
test_mgr::initialize_jrnls()
{
_ji_list.clear();
- for (unsigned i=0; i<_opts.num_jrnls; i++)
+ for (unsigned i=0; i<_args.num_jrnls; i++)
{
std::ostringstream jid;
jid << std::hex << std::setfill('0');
Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp 2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp 2008-01-28 20:57:09 UTC (rev 1617)
@@ -25,7 +25,7 @@
#define rhm_jtt_test_mgr_hpp
#include "jrnl_instance.hpp"
-#include "options.hpp"
+#include "args.hpp"
#include <signal.h>
namespace rhm
@@ -41,12 +41,13 @@
private:
ji_list _ji_list;
- options& _opts;
+ args& _args;
+ ptrdiff_t (*_random_fn_ptr)(const ptrdiff_t i);
static volatile sig_atomic_t _signal;
static volatile bool _abort;
public:
- test_mgr(options& opts);
+ test_mgr(args& args);
~test_mgr();
void run();
@@ -55,6 +56,8 @@
private:
void initialize_jrnls();
void print_results(test_case::shared_ptr tcp, const bool summary);
+ inline static ptrdiff_t random_fn(const ptrdiff_t i)
+ { return static_cast<ptrdiff_t>(1.0 * i * random() / RAND_MAX); }
};
} // namespace jtt
17 years, 1 month
rhmessaging commits: r1616 - mgmt/mint/python/mint.
by rhmessaging-commits@lists.jboss.org
Author: nunofsantos
Date: 2008-01-28 11:00:39 -0500 (Mon, 28 Jan 2008)
New Revision: 1616
Modified:
mgmt/mint/python/mint/__init__.py
mgmt/mint/python/mint/schemaparser.py
Log:
simplifying arg list to broker method calls
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2008-01-27 20:09:44 UTC (rev 1615)
+++ mgmt/mint/python/mint/__init__.py 2008-01-28 16:00:39 UTC (rev 1616)
@@ -243,12 +243,6 @@
return label
- def getConnectedBroker(self, label):
- if (label in self.connectedBrokers):
- return self.connectedBrokers[label].managedBroker
- else:
- return None
-
def registerCallback(self, callback):
self.currentMethodId += 1
methodId = self.currentMethodId
Modified: mgmt/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/mint/python/mint/schemaparser.py 2008-01-27 20:09:44 UTC (rev 1615)
+++ mgmt/mint/python/mint/schemaparser.py 2008-01-28 16:00:39 UTC (rev 1616)
@@ -113,11 +113,11 @@
formalArgs = formalArgs[:-2]
else:
formalArgs = ""
- self.pythonOutput += "\n def %s(self, model, managedBrokerLabel, callbackMethod%s):\n" % (elem["@name"], formalArgs)
+ self.pythonOutput += "\n def %s(self, model, managedBroker, callbackMethod%s):\n" % (elem["@name"], formalArgs)
self.pythonOutput += comment
self.pythonOutput += actualArgs
self.pythonOutput += " methodId = model.registerCallback(callbackMethod)\n"
- self.pythonOutput += " model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \\\n"
+ self.pythonOutput += " model.managedBroker.method(methodId, self.idOriginal, \\\n"
self.pythonOutput += " classToSchemaNameMap[self.__class__.__name__], \"%s\", " % (elem["@name"])
self.pythonOutput += "args=actualArgs, packageName=\"qpid\")\n"
17 years, 1 month
rhmessaging commits: r1615 - in mgmt/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-01-27 15:09:44 -0500 (Sun, 27 Jan 2008)
New Revision: 1615
Modified:
mgmt/cumin/python/cumin/formats.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/wooly/__init__.py
mgmt/cumin/python/wooly/pages.py
mgmt/cumin/python/wooly/resources.py
mgmt/cumin/python/wooly/tables.py
Log:
Resolve some XXX cleanup items.
Modified: mgmt/cumin/python/cumin/formats.py
===================================================================
--- mgmt/cumin/python/cumin/formats.py 2008-01-27 20:08:47 UTC (rev 1614)
+++ mgmt/cumin/python/cumin/formats.py 2008-01-27 20:09:44 UTC (rev 1615)
@@ -14,7 +14,6 @@
return tstamp
-# XXX change this to millis or nanos? whatever python wants to give us
def fmt_duration(secs):
"""Takes a duration in seconds, which can be a float"""
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2008-01-27 20:08:47 UTC (rev 1614)
+++ mgmt/cumin/python/cumin/model.py 2008-01-27 20:09:44 UTC (rev 1615)
@@ -2,6 +2,7 @@
from wooly import *
from time import mktime
from datetime import datetime, timedelta
+from types import *
from util import *
from formats import *
@@ -129,8 +130,10 @@
text = ""
elif value == 0:
text = "0"
+ elif isinstance(value, IntType) or isinstance(value, LongType):
+ text = "%i" % value
else:
- text = "%i" % value # XXX handle other types
+ text = "%r" % value
return text
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2008-01-27 20:08:47 UTC (rev 1614)
+++ mgmt/cumin/python/wooly/__init__.py 2008-01-27 20:09:44 UTC (rev 1615)
@@ -92,8 +92,8 @@
class Widget(object):
def __init__(self, app, name):
self.app = app
- self.name = name # XXX undo this
- self.parent = None # XXX undo this
+ self.name = name
+ self.parent = None
self.children = list()
self.attributes = list()
self.parameters = list()
@@ -408,8 +408,6 @@
self.parameter_index = None
self.finder = ResourceFinder()
- self.cached_css = None
- self.cached_javascript = None
self.debug = None
@@ -477,54 +475,12 @@
def get_resource(self, name):
return self.finder.find(name)
- # XXX move this to CssPage
- def get_css(self):
- if not self.cached_css:
- writer = Writer()
-
- for cls in sorted(self.widget_classes):
- strs = cls.get_module_strings()
-
- if strs:
- css = strs.get(cls.__name__ + ".css")
-
- if css:
- writer.write(css)
- writer.write("\r\n") # HTTP newline
-
- self.cached_css = writer.to_string()
-
- return self.cached_css
-
- def get_javascript(self):
- if not self.cached_javascript:
- writer = Writer()
-
- for cls in sorted(self.widget_classes):
- strs = cls.get_module_strings()
-
- if strs:
- javascript = strs.get(cls.__name__ + ".javascript")
-
- if javascript:
- writer.write(javascript)
- writer.write("\r\n")
-
- self.cached_javascript = writer.to_string()
-
- return self.cached_javascript
-
- def clear_caches(self):
- self.cached_css = None
- self.cached_javascript = None
-
class Session(object):
def __init__(self, app, trunk=None):
self.app = app
self.trunk = trunk
self.page = None
self.values = dict()
- self.errors = dict() # widget => list of str # XXX remove this
if self.app.debug:
self.debug = self.Debug(self)
Modified: mgmt/cumin/python/wooly/pages.py
===================================================================
--- mgmt/cumin/python/wooly/pages.py 2008-01-27 20:08:47 UTC (rev 1614)
+++ mgmt/cumin/python/wooly/pages.py 2008-01-27 20:09:44 UTC (rev 1615)
@@ -1,36 +1,74 @@
from datetime import datetime
-from wooly import Page, Parameter
+from wooly import Page, Parameter, Writer
class CssPage(Page):
def __init__(self, app, name):
super(CssPage, self).__init__(app, name)
- self.then = datetime.utcnow()
+ self.__then = datetime.utcnow()
+ self.__css = None
def get_last_modified(self, session):
- return self.then
+ return self.__then
def get_content_type(self, session):
return "text/css"
+ def get_css(self):
+ if not self.__css:
+ writer = Writer()
+
+ for cls in sorted(self.app.widget_classes):
+ strs = cls.get_module_strings()
+
+ if strs:
+ css = strs.get(cls.__name__ + ".css")
+
+ if css:
+ writer.write(css)
+ writer.write("\r\n") # HTTP newline
+
+ self.__css = writer.to_string()
+
+ return self.__css
+
def do_render(self, session, object):
- return self.app.get_css()
+ return self.get_css()
class JavascriptPage(Page):
def __init__(self, app, name):
super(JavascriptPage, self).__init__(app, name)
- self.then = datetime.utcnow()
+ self.__then = datetime.utcnow()
+ self.__javascript = None
def get_last_modified(self, session):
- return self.then
+ return self.__then
def get_content_type(self, session):
return "text/javascript"
+ def get_javascript(self):
+ if not self.__javascript:
+ writer = Writer()
+
+ for cls in sorted(self.app.widget_classes):
+ strs = cls.get_module_strings()
+
+ if strs:
+ javascript = strs.get(cls.__name__ + ".javascript")
+
+ if javascript:
+ writer.write(javascript)
+ writer.write("\r\n")
+
+ self.__javascript = writer.to_string()
+
+ return self.__javascript
+
def do_render(self, session, object):
- return self.app.get_javascript()
+ return self.get_javascript()
class ResourcePage(Page):
def __init__(self, app, name):
Modified: mgmt/cumin/python/wooly/resources.py
===================================================================
--- mgmt/cumin/python/wooly/resources.py 2008-01-27 20:08:47 UTC (rev 1614)
+++ mgmt/cumin/python/wooly/resources.py 2008-01-27 20:09:44 UTC (rev 1615)
@@ -13,7 +13,6 @@
try:
file = open(self.path)
self.strings = parse_catalog_file(file)
- # XXX catch file not found
finally:
file.close()
Modified: mgmt/cumin/python/wooly/tables.py
===================================================================
--- mgmt/cumin/python/wooly/tables.py 2008-01-27 20:08:47 UTC (rev 1614)
+++ mgmt/cumin/python/wooly/tables.py 2008-01-27 20:09:44 UTC (rev 1615)
@@ -39,7 +39,7 @@
def is_reversed(self, session):
return self.reversed.get(session)
- def get_items(self, session, object):
+ def do_get_items(self, session, object):
"""Gets the rows"""
return None
@@ -224,8 +224,7 @@
return data[0]
- # XXX shouldn't this be do_get_items?
- def get_items(self, session, object):
+ def do_get_items(self, session, object):
conn = self.get_connection(session)
if conn:
17 years, 1 month
rhmessaging commits: r1614 - mgmt/cumin/bin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-01-27 15:08:47 -0500 (Sun, 27 Jan 2008)
New Revision: 1614
Modified:
mgmt/cumin/bin/cumin
mgmt/cumin/bin/cumin-test
Log:
Make path handling less unix convention dependent.
Modified: mgmt/cumin/bin/cumin
===================================================================
--- mgmt/cumin/bin/cumin 2008-01-26 05:12:23 UTC (rev 1613)
+++ mgmt/cumin/bin/cumin 2008-01-27 20:08:47 UTC (rev 1614)
@@ -43,21 +43,22 @@
if "-h" in sys.argv or "--help" in sys.argv:
usage()
- if "CUMIN_HOME" not in os.environ:
- os.environ["CUMIN_HOME"] = "/usr/share/cumin"
+ home = os.environ.get("CUMIN_HOME")
+ if not home:
+ home = os.path.normpath("/usr/share/cumin")
+
config = Config()
config.add_param("data", "s", "postgresql://cumin@localhost/cumin")
config.add_param("port", "i", 80)
config.add_param("debug", "b", False)
- config.load_file(os.path.expandvars("${CUMIN_HOME}/etc/cumin.conf"))
- config.load_file(os.path.expanduser("~/.cumin.conf"))
+ config.load_file(os.path.join(home, "etc", "cumin.conf"))
+ config.load_file(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
config.load_args(sys.argv)
config.show()
- home = os.environ["CUMIN_HOME"]
data = config.get("data")
port = config.get("port")
debug = config.get("debug")
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2008-01-26 05:12:23 UTC (rev 1613)
+++ mgmt/cumin/bin/cumin-test 2008-01-27 20:08:47 UTC (rev 1614)
@@ -44,9 +44,11 @@
if "-h" in sys.argv or "--help" in sys.argv:
usage()
- if "CUMIN_HOME" not in os.environ:
- os.environ["CUMIN_HOME"] = "/usr/share/cumin"
+ home = os.environ.get("CUMIN_HOME")
+ if not home:
+ home = os.path.normpath("/usr/share/cumin")
+
config = Config()
config.add_param("data", "s", "postgresql://cumin@localhost/cumin")
config.add_param("port", "i", 80)
@@ -54,8 +56,8 @@
config.add_param("bench", "i", 1000)
config.add_param("profile", "b", False)
- config.load_file(os.path.expandvars("${CUMIN_HOME}/etc/cumin.conf"))
- config.load_file(os.path.expanduser("~/.cumin.conf"))
+ config.load_file(os.path.join(home, "etc", "cumin.conf"))
+ config.load_file(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
config.load_args(sys.argv)
config.show()
17 years, 1 month
rhmessaging commits: r1613 - in mgmt: cumin/bin and 4 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-01-26 00:12:23 -0500 (Sat, 26 Jan 2008)
New Revision: 1613
Added:
mgmt/cumin/doc/
mgmt/cumin/doc/installation.txt
Modified:
mgmt/cumin-test-0/etc/cumin.conf
mgmt/cumin/bin/cumin
mgmt/cumin/bin/cumin-test
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/util.py
mgmt/mint/python/mint/__init__.py
Log:
Overhauls the scripts for starting cumin.
* Makes debug=on the default for the cumin-test-0 instance
* Moves connection configuration into MintModel init
* Proxies the init and check methods on CuminModel to MintModel
* Introduces a Config class for reading basic config parameters from
various sources
* Rewrites cumin and cumin-test to use the new facilities
* Adds the interim installation notes to the doc dir
Modified: mgmt/cumin/bin/cumin
===================================================================
--- mgmt/cumin/bin/cumin 2008-01-25 20:26:45 UTC (rev 1612)
+++ mgmt/cumin/bin/cumin 2008-01-26 05:12:23 UTC (rev 1613)
@@ -1,97 +1,68 @@
#!/usr/bin/env python
import sys, os
+from wooly.server import WebServer
-if "CUMIN_HOME" not in os.environ:
- os.environ["CUMIN_HOME"] = "/usr/share/cumin"
+from cumin import *
+from cumin.util import *
def usage():
- print """
-Usage: cumin OPTIONS
+ print """Usage: cumin OPTIONS...
Options:
- --port PORT
- --data DATABASE-URL
-""",
+ -h, --help Print this message
+ --data URL Use database url URL
+ --port PORT Run web server on port PORT
+ --debug Enable debugging"""
+
sys.exit(1)
-from ConfigParser import SafeConfigParser
+def do_main(home, data, port, debug):
+ app = Cumin(home, data)
-def load_args(argv):
- args = dict()
+ if debug:
+ app.enable_debug()
- sconf = os.path.expandvars("${CUMIN_HOME}/etc/cumin.conf")
- hconf = os.path.expanduser("~/.cumin.conf")
+ try:
+ app.check()
+ except Exception, e:
+ if hasattr(e, "message"):
+ print e.message
- conf = SafeConfigParser()
- rconfs = conf.read((sconf, hconf))
+ sys.exit(1)
- if rconfs:
- print "Config files read:"
+ app.init()
- for name in rconfs:
- print " " + name
+ server = WebServer(app, port)
- if (conf.has_section("main")):
- for key, value in conf.items("main"):
- args[key] = value
-
- key = None
+ try:
+ server.run()
+ except KeyboardInterrupt:
+ pass
- for arg in sys.argv:
- if arg.startswith("--"):
- key = arg[2:]
- args[key] = None
- elif key:
- args[key] = arg
- key = None
+def main():
+ if "-h" in sys.argv or "--help" in sys.argv:
+ usage()
- if args:
- print "Config parameters set:"
+ if "CUMIN_HOME" not in os.environ:
+ os.environ["CUMIN_HOME"] = "/usr/share/cumin"
- for key in args:
- print " " + key + " " + args[key]
+ config = Config()
+ config.add_param("data", "s", "postgresql://cumin@localhost/cumin")
+ config.add_param("port", "i", 80)
+ config.add_param("debug", "b", False)
- return args
+ config.load_file(os.path.expandvars("${CUMIN_HOME}/etc/cumin.conf"))
+ config.load_file(os.path.expanduser("~/.cumin.conf"))
+ config.load_args(sys.argv)
-from sqlobject import *
+ config.show()
-args = load_args(sys.argv)
-
-try:
- connuri = args["data"]
- conn = connectionForURI(connuri)
- sqlhub.processConnection = conn
-except KeyError:
- print "No data source"
- usage()
-
-try:
- sqlhub.getConnection().getConnection()
-except Exception, e:
- if hasattr(e, "message") and e.message.find("does not exist"):
- print "Database not found; run cumin-database-init"
- sys.exit(1)
- else:
- print "Failed connecting to database"
- raise e
-
-from wooly.server import WebServer
-from cumin import *
-
-def do_main(port):
- app = Cumin()
- app.enable_debug()
-
- server = WebServer(app, port)
- server.run()
-
-def main():
- port = int(args.get("port", 80))
+ home = os.environ["CUMIN_HOME"]
+ data = config.get("data")
+ port = config.get("port")
+ debug = config.get("debug")
- try:
- do_main(port)
- except KeyboardInterrupt:
- pass
+ do_main(home, data, port, debug)
if __name__ == "__main__":
main()
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2008-01-25 20:26:45 UTC (rev 1612)
+++ mgmt/cumin/bin/cumin-test 2008-01-26 05:12:23 UTC (rev 1613)
@@ -1,97 +1,80 @@
#!/usr/bin/env python
import sys, os
+from time import time
+from wooly.devel import BenchmarkHarness
+from cumin import *
+from cumin.demo import *
+from cumin.model import *
+
def usage():
- print """
-Usage: cumin-test OPTIONS
+ print """Usage: cumin-test OPTIONS...
Options:
- --port PORT
--data DATABASE-URL
--bench [HITS]
--profile
- --no-debug
-""",
+ --debug"""
sys.exit(1)
-from ConfigParser import SafeConfigParser
+def do_main(home, data, bench_hits, debug):
+ app = Cumin(home, data)
-def load_args(argv):
- args = dict()
+ if debug or bench_hits:
+ app.enable_debug()
- conf = SafeConfigParser()
- conf.read(os.path.expanduser("~/.cumin.conf"))
+ try:
+ app.check()
+ except Exception, e:
+ if hasattr(e, "message"):
+ print e.message
- if (conf.has_section("main")):
- for key, value in conf.items("main"):
- args[key] = value
-
- key = None
+ sys.exit(1)
- for arg in sys.argv:
- if arg.startswith("--"):
- key = arg[2:]
- args[key] = None
- elif key:
- args[key] = arg
- key = None
+ app.init()
- if args:
- print "Parameters:"
+ harness = BenchmarkHarness(app)
- for key in args:
- print " %10s %s" % (key, args[key])
+ try:
+ harness.run(bench_hits)
+ except KeyboardInterrupt:
+ pass
- return args
+def main():
+ if "-h" in sys.argv or "--help" in sys.argv:
+ usage()
-from sqlobject import *
+ if "CUMIN_HOME" not in os.environ:
+ os.environ["CUMIN_HOME"] = "/usr/share/cumin"
-args = load_args(sys.argv)
+ config = Config()
+ config.add_param("data", "s", "postgresql://cumin@localhost/cumin")
+ config.add_param("port", "i", 80)
+ config.add_param("debug", "b", True)
+ config.add_param("bench", "i", 1000)
+ config.add_param("profile", "b", False)
-try:
- connuri = args["data"]
- conn = connectionForURI(connuri)
- sqlhub.processConnection = conn
-except KeyError:
- print "No data source"
- usage()
+ config.load_file(os.path.expandvars("${CUMIN_HOME}/etc/cumin.conf"))
+ config.load_file(os.path.expanduser("~/.cumin.conf"))
+ config.load_args(sys.argv)
-from time import time
-from wooly.devel import BenchmarkHarness
-from wooly.server import WebServer
+ config.show()
-from cumin import *
-from cumin.demo import *
-from cumin.model import *
+ home = os.environ["CUMIN_HOME"]
+ data = config.get("data")
+ bench = config.get("bench")
+ profile = config.get("profile")
+ debug = config.get("debug")
-def do_main(port, bench_hits, debug=True):
- app = Cumin()
-
- if debug or bench_hits:
- app.enable_debug()
-
- if bench_hits:
- harness = BenchmarkHarness(app)
- harness.run(bench_hits)
- else:
- server = WebServer(app, port)
- server.run()
-
-def main():
- in_port = int(args.get("port", 9090))
- in_profile = "profile" in args
- in_debug = "no-debug" not in args
- in_bench = "bench" in args and int(args.get("bench", None) or 1000) or 0
-
- if in_profile:
+ if profile:
from profile import Profile
from pstats import Stats
prof = Profile()
try:
- statement = "do_main(%i, %r, %r)" % \
- (in_port, in_bench, in_debug)
+ statement = "do_main('%s', '%s', %i, %r)" \
+ % (home, data, bench, debug)
prof.run(statement)
@@ -113,10 +96,7 @@
stats.strip_dirs()
else:
- try:
- do_main(in_port, in_bench, in_debug)
- except KeyboardInterrupt:
- pass
+ do_main(home, data, bench, debug)
if __name__ == "__main__":
main()
Added: mgmt/cumin/doc/installation.txt
===================================================================
--- mgmt/cumin/doc/installation.txt (rev 0)
+++ mgmt/cumin/doc/installation.txt 2008-01-26 05:12:23 UTC (rev 1613)
@@ -0,0 +1,55 @@
+Thanks for evaluating our preview release of the MRG management web
+UI.
+
+The following instructions assume you are running as root, unless
+otherwise indicated:
+
+1. Install packages
+
+ First, use yum to install the management packages. If you haven't
+ already, you may want to install the messaging packages as well.
+
+ # yum install mrg-management
+ # yum install mrg-messaging
+
+2. Prepare the database
+
+ In order to access the database, you must change the authentication
+ method of the postgresql database.
+
+ First start the postgresql service to initialize the postgresql
+ database files.
+
+ # service postgresql start
+
+ Now, edit the following authentication config file. For each local
+ connection line, change "ident sameuser" to "trust".
+
+ # vi /var/lib/pgsql/data/pg_hba.conf
+
+ Now you can restart the database:
+
+ # service postgresql restart
+
+ Load the cumin database and schema:
+
+ # cumin-database-init
+
+3. Start a managed broker
+
+ To make your local broker manageable, edit /etc/rhmd.conf and add
+ "mgmt=yes" on its own line.
+
+4. Start cumin (cumin is the name of the web console)
+
+ As root:
+
+ # cumin
+
+ As an unprivileged user:
+
+ $ cumin --port 8080 # On an unprivileged port
+
+ In a browser, go to localhost (or localhost:8080). You should be
+ able to click "Register Brokers" and add brokers by their address
+ and port.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2008-01-25 20:26:45 UTC (rev 1612)
+++ mgmt/cumin/python/cumin/__init__.py 2008-01-26 05:12:23 UTC (rev 1613)
@@ -19,20 +19,14 @@
from stat import StatChartPage
class Cumin(Application):
- def __init__(self):
+ def __init__(self, home, data_url):
super(Cumin, self).__init__()
- try:
- self.home = os.environ["CUMIN_HOME"]
- except KeyError:
- sys.exit(1)
-
+ self.home = home
self.add_resource_dir(os.path.join(self.home, "resources"))
- self.model = CuminModel()
-
+ self.model = CuminModel(data_url)
self.broker_connect_thread = BrokerConnectThread(self.model)
- self.broker_connect_thread.start()
self.cumin_page = CuminPage(self, "cumin.html")
self.set_default_page(self.cumin_page)
@@ -46,8 +40,20 @@
self.add_page(ClientXmlPage(self, "client.xml"))
self.add_page(StatChartPage(self, "stats.png"))
+ def check(self):
+ if not os.path.isdir(self.home):
+ raise Exception \
+ ("Error: cumin home '%s' not found or not a directory" \
+ % self.home)
+
+ self.model.check()
+
+ def init(self):
+ self.model.init()
+ self.broker_connect_thread.start()
+
class CuminServer(WebServer):
- def __init__(self, port=9090):
+ def __init__(self, port):
model = DummyModel()
app = Cumin(model)
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2008-01-25 20:26:45 UTC (rev 1612)
+++ mgmt/cumin/python/cumin/model.py 2008-01-26 05:12:23 UTC (rev 1613)
@@ -7,8 +7,8 @@
from formats import *
class CuminModel(object):
- def __init__(self):
- self.data = MintModel()
+ def __init__(self, data_url):
+ self.data = MintModel(data_url)
self.classes = list()
@@ -17,6 +17,12 @@
self.binding = CuminBinding(self)
self.client = CuminClient(self)
self.session = CuminSession(self)
+
+ def check(self):
+ self.data.check()
+
+ def init(self):
+ self.data.init()
def add_class(self, cls):
self.classes.append(cls)
Modified: mgmt/cumin/python/cumin/util.py
===================================================================
--- mgmt/cumin/python/cumin/util.py 2008-01-25 20:26:45 UTC (rev 1612)
+++ mgmt/cumin/python/cumin/util.py 2008-01-26 05:12:23 UTC (rev 1613)
@@ -1,4 +1,5 @@
from time import mktime
+from ConfigParser import SafeConfigParser
def sorted_by(seq, attr="name"):
return sorted(seq, cmp, lambda x: getattr(x, attr))
@@ -25,3 +26,109 @@
class Identifiable(object):
def __init__(self, id=None):
self.id = id
+
+class Config(object):
+ def __init__(self):
+ self.__params = list()
+ self.__param_specs = dict() # param name => (type, default)
+ self.__values = dict()
+
+ self.verbose = True
+
+ def add_param(self, name, type, default):
+ self.__params.append(name)
+ self.__param_specs[name] = (type, default)
+
+ def set(self, name, value):
+ self.__values[name] = value
+ return value
+
+ def unmarshal(self, name, string):
+ type, default = self.__param_specs[name]
+
+ if type == "i":
+ value = int(string)
+ elif type == "b":
+ value = bool(string)
+ elif type == "s":
+ value = string
+ else:
+ raise Error("Invalid type '%s'" % type)
+
+ return value
+
+ def get(self, name):
+ if name not in self.__params:
+ raise Error("Parameter '%s' not found" % name)
+
+ type, default = self.__param_specs[name]
+
+ if name in self.__values:
+ value = self.__values.get(name)
+ else:
+ value = default
+
+ return value
+
+ def load_file(self, file):
+ print "Looking for config file '%s':" % file,
+
+ conf = SafeConfigParser()
+ found = conf.read(file)
+
+ if found:
+ print "found"
+ else:
+ print "not found"
+
+ params = dict()
+
+ if (conf.has_section("main")):
+ for key, value in conf.items("main"):
+ params[key] = value
+
+ self.load_string_params(params)
+
+ def load_args(self, argv):
+ params = dict()
+ key = None
+
+ for arg in argv:
+ if arg.startswith("--"):
+ key = arg[2:]
+ params[key] = None
+ elif key:
+ params[key] = arg
+ key = None
+
+ self.load_string_params(params)
+
+ def load_string_params(self, params):
+ for name, value in params.items():
+ if name in self.__params:
+ self.set(name, self.unmarshal(name, value))
+ else:
+ print "Warning: ignoring unrecognized parameter '%s'" % name
+
+ def require(self, params):
+ missing = list()
+
+ for param in params:
+ if param not in self.__values:
+ missing.append(param)
+
+ return missing
+
+ def show(self):
+ print "Configuration:"
+
+ for param in self.__params:
+ type, default = self.__param_specs[param]
+ value = self.get(param)
+
+ if param in self.__values:
+ flag = ""
+ else:
+ flag = " [default]"
+
+ print " %s = %s%s" % (param, value, flag)
Modified: mgmt/cumin-test-0/etc/cumin.conf
===================================================================
--- mgmt/cumin-test-0/etc/cumin.conf 2008-01-25 20:26:45 UTC (rev 1612)
+++ mgmt/cumin-test-0/etc/cumin.conf 2008-01-26 05:12:23 UTC (rev 1613)
@@ -1,3 +1,3 @@
[main]
-data: postgresql://cumin@localhost/cumin
port: 9090
+debug: True
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2008-01-25 20:26:45 UTC (rev 1612)
+++ mgmt/mint/python/mint/__init__.py 2008-01-26 05:12:23 UTC (rev 1613)
@@ -119,13 +119,27 @@
class MintModel:
- def __init__(self, debug=False):
+ def __init__(self, data_url, debug=False):
+ self.data_url = data_url
self.currentMethodId = 1
self.outstandingMethodCalls = dict()
self.connectedBrokers = dict()
self.debug = debug
self.lock = Lock()
+ def check(self):
+ try:
+ connectionForURI(self.data_url)
+ except Exception, e:
+ if hasattr(e, "message") and e.message.find("does not exist"):
+ print "Database not found; run cumin-database-init"
+
+ raise e
+
+ def init(self):
+ conn = connectionForURI(self.data_url)
+ sqlhub.processConnection = conn
+
def setDebug(self, debug=True):
self.debug = debug
17 years, 1 month
rhmessaging commits: r1612 - store/trunk/cpp/lib.
by rhmessaging-commits@lists.jboss.org
Author: cctrieloff
Date: 2008-01-25 15:26:45 -0500 (Fri, 25 Jan 2008)
New Revision: 1612
Modified:
store/trunk/cpp/lib/StorePlugin.cpp
Log:
corrected license
Modified: store/trunk/cpp/lib/StorePlugin.cpp
===================================================================
--- store/trunk/cpp/lib/StorePlugin.cpp 2008-01-25 19:39:32 UTC (rev 1611)
+++ store/trunk/cpp/lib/StorePlugin.cpp 2008-01-25 20:26:45 UTC (rev 1612)
@@ -1,20 +1,26 @@
/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+ Copyright (C) 2007 Red Hat Software
+
+ This file is part of Red Hat Messaging.
+
+ Red Hat Messaging is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ USA
+
+ The GNU Lesser General Public License is available in the file COPYING.
+*/
+
#include "qpid/broker/Broker.h"
#include "qpid/Plugin.h"
#include "qpid/Options.h"
17 years, 1 month