Permalink
Browse files

Remove attempts to parse last_queuelen_* values from state json

For OOIION-466
  • Loading branch information...
1 parent 637036c commit 120a0bff3932547c971240fe13663b7dea36c668 @oldpatricka oldpatricka committed Aug 17, 2011
@@ -105,8 +105,6 @@ def __init__(self):
self.de_state = None # stable engine or not - (a decision engine is not required to implement this)
self.de_conf_report = None # Configuration report - (a decision engine is not required to implement this)
- self.last_queuelen_size = -1 # 0-N integer, or -1 if no report
- self.last_queuelen_time = -1 # seconds since epoch or -1
# List of WorkerInstanceState
self.instances = []
@@ -117,8 +115,6 @@ def __repr__(self):
repr += "controller_name: '%s' " % self.controller_name
repr += "de_state: '%s' " % self.de_state
repr += "de_conf_report: '%s' " % self.de_conf_report
- repr += "last_queuelen_size: '%s' " % self.last_queuelen_size
- repr += "last_queuelen_time: '%s' " % self.last_queuelen_time
repr += "instances: '%s' " % self.instances
return repr
@@ -360,8 +360,6 @@ def _intake_query_result_from_file(self, local_filename):
state.de_state = info['de_state']
state.de_conf_report = info['de_conf_report']
state.controller_name = controller
- state.last_queuelen_size = int(info['last_queuelen_size'])
- state.last_queuelen_time = int(info['last_queuelen_time'])
state.instances = []
for nodeid in info['instances'].keys():
@@ -61,7 +61,7 @@
REPORT_SERVICE = ControlArg("service-report", None, metavar="COLUMNS")
#a.append(REPORT_SERVICE)
-REPORT_SERVICE.help = "Used with '--action %s'. Batch mode for machine parsing service status. Report selected columns from choice of the following separated by comma: service,last_queuelen_size,last_queuelen_time,de_state,de_conf" % ACTIONS.STATUS
+REPORT_SERVICE.help = "Used with '--action %s'. Batch mode for machine parsing service status. Report selected columns from choice of the following separated by comma: service,de_state,de_conf" % ACTIONS.STATUS
STATUS_NOUPDATE = ControlArg("no-update", None, noval=True)
a.append(STATUS_NOUPDATE)
@@ -133,7 +133,7 @@ def _get_provisioner_vm(allvms):
return provisioner_vm
def _update_controller_states(c, m, run_name, controller_map, controller_state_map, allvms):
- """Generate "de_state", "de_conf_report", and "last_queuelen_size" cloudyvents.
+ """Generate "de_state" and "de_conf_report" cloudyvents.
"""
trace = False
@@ -280,17 +280,6 @@ def _get_events_from_controller_state(state, vm, controller, trace, c):
if trace:
c.log.debug("de_conf_report for controller %s: %s" % (controller, state.de_conf_report))
- if state.last_queuelen_size >= 0:
- event = CYvent(controller,
- "last_queuelen_size",
- str(uuid.uuid4()),
- datetime.fromtimestamp(state.last_queuelen_time),
- extra={"last_queuelen_size": state.last_queuelen_size})
- vm.events.append(event)
- newevent = True
- if trace:
- c.log.debug("last_queuelen_size for controller %s: %s" % (controller, state.last_queuelen_size))
-
return newevent
def _get_vm_with_nodeid(nodeid, allvms):
@@ -366,9 +355,9 @@ def _get_vm_with_controller(controller, vm_list):
def _latest_controller_state(vm):
if not vm:
- return None, None
+ return None
if not vm.events:
- return None, None
+ return None
latest_destate = None
for ev in vm.events:
if ev.name == "de_state":
@@ -377,14 +366,6 @@ def _latest_controller_state(vm):
latest_destate = ev
else:
latest_destate = ev
- latest_qlen = None
- for ev in vm.events:
- if ev.name == "last_queuelen_size":
- if latest_qlen:
- if latest_qlen.timestamp < ev.timestamp:
- latest_qlen = ev
- else:
- latest_qlen = ev
ret_state = latest_destate
if latest_destate:
@@ -393,12 +374,7 @@ def _latest_controller_state(vm):
if latest_destate.extra.has_key("state"):
ret_state = latest_destate.extra["state"]
- ret_qlen = latest_qlen
- if latest_qlen:
- if latest_qlen.extra.has_key("last_queuelen_size"):
- ret_qlen = latest_qlen.extra["last_queuelen_size"]
-
- return ret_state, ret_qlen
+ return ret_state
# ----------------------------------------------------------------------------------------------------
# REPORT
@@ -480,13 +456,11 @@ def _report(allvms):
vm = _get_vm_with_controller(controller, services)
if vm:
- latest_destate, latest_qlen = _latest_controller_state(vm)
+ latest_destate = _latest_controller_state(vm)
if latest_destate:
txt += " EPU state: %s" % latest_destate
else:
txt += " EPU state: unknown"
- if latest_qlen is not None:
- txt += ", Queue length: %s" % latest_qlen
txt += "\n Workers:\n"
for vm_info in by_controller[controller]:
@@ -4,16 +4,13 @@ class Event:
"""
def __init__(self, name="", timestamp="", state=None, source="",
- last_queuelen_size=None, de_state=None, iaas_id=None,
- node_id=None, public_ip=None):
+ de_state=None, iaas_id=None, node_id=None, public_ip=None):
self.name = name
self.timestamp = timestamp
self.source = source
self.extra = {}
if state:
self.extra["state"] = state
- if last_queuelen_size:
- self.extra["last_queuelen_size"] = last_queuelen_size
if de_state:
self.extra["de_state"] = de_state
if public_ip:
@@ -1,13 +1,11 @@
class State:
- def __init__(self, de_state=None, de_conf_report=None, last_queuelen_size=None,
+ def __init__(self, de_state=None, de_conf_report=None,
capture_time=None):
self.de_state = de_state
self.de_conf_report = de_conf_report
- self.last_queuelen_size = last_queuelen_size
- self.last_queuelen_time = 0
self.capture_time = capture_time
@@ -25,11 +23,8 @@ def __init__(self, iaas_state=None, iaas_state_time=None, nodeid=None,
class EPUControllerState:
- def __init__(self, de_state=None, de_conf_report=None, last_queuelen_size=None,
- capture_time=None):
+ def __init__(self, de_state=None, de_conf_report=None, capture_time=None):
self.de_state = de_state
self.de_conf_report = de_conf_report
- self.last_queuelen_size = last_queuelen_size
- self.last_queuelen_time = 0
self.capture_time = capture_time
self.instances = []
@@ -153,6 +153,8 @@ def test_worker_state(self):
assert re.match(".*epu-state.*%s" % controllers[1], ssh_command)
+
+
def test_reconcile_relative_conf(self):
absolute_dir = "/path/to/conf"
@@ -180,8 +182,6 @@ def test_intake_query_result_from_file(self):
controller_name = "test-controller"
de_state = "STABLE_DE"
de_conf_report = "balala"
- last_queuelen_size = 5
- last_queuelen_time = 1234
instance_0 = "fashfjsahfjksa"
instance_0_state = "600-RUNNING"
iaas_state_time = 12312142
@@ -192,13 +192,12 @@ def test_intake_query_result_from_file(self):
(json_file, json_filename) = tempfile.mkstemp()
os.close(json_file)
test_json = """
- {"%s": {"de_state":"%s", "de_conf_report":"%s", "last_queuelen_size":%s,
- "last_queuelen_time": %s,
+ {"%s": {"de_state":"%s", "de_conf_report":"%s",
"instances": {
"%s": {"iaas_state":"%s", "iaas_state_time": %s,
"heartbeat_state":"%s", "heartbeat_time": %s}}}}
- """ % (controller_name, de_state, de_conf_report, last_queuelen_size,
- last_queuelen_time, instance_0, instance_0_state, iaas_state_time,
+ """ % (controller_name, de_state, de_conf_report
+ , instance_0, instance_0_state, iaas_state_time,
heartbeat_state, heartbeat_time)
with open(json_filename, "w") as j_file:
@@ -211,8 +210,6 @@ def test_intake_query_result_from_file(self):
controller = map[controller_name]
assert controller.de_state == de_state
assert controller.de_conf_report == de_conf_report
- assert controller.last_queuelen_size == last_queuelen_size
- assert controller.last_queuelen_time == last_queuelen_time
assert len(controller.instances) == 1
instance = controller.instances[0]
assert instance.nodeid == instance_0
@@ -221,6 +218,19 @@ def test_intake_query_result_from_file(self):
assert instance.heartbeat_state == heartbeat_state
assert instance.heartbeat_time == heartbeat_time
+ def test_intake_query_result_from_file_new_json(self):
+ """Test that new json is parsed correctly
+
+ This test can be used to parse real examples of json produced
+ by the system.
+ """
+
+ test_dir = os.path.dirname(__file__)
+
+ test_file = os.path.join(test_dir, "data/test_intake_query_result_from_file_new_json.dat")
+ map = self.svc_adapter._intake_query_result_from_file(test_file)
+ assert map
+
def test_intake_query_result(self):
provisioner = RunVM()
@@ -233,8 +243,6 @@ def test_intake_query_result(self):
controller_name = "test-controller"
de_state = "STABLE_DE"
de_conf_report = "balala"
- last_queuelen_size = 5
- last_queuelen_time = 1234
instance_0 = "fashfjsahfjksa"
instance_0_state = "600-RUNNING"
iaas_state_time = 12312142
@@ -243,13 +251,12 @@ def test_intake_query_result(self):
test_json = """
- {"%s": {"de_state":"%s", "de_conf_report":"%s", "last_queuelen_size":%s,
- "last_queuelen_time": %s,
+ {"%s": {"de_state":"%s", "de_conf_report":"%s",
"instances": {
"%s": {"iaas_state":"%s", "iaas_state_time": %s,
"heartbeat_state":"%s", "heartbeat_time": %s}}}}
- """ % (controller_name, de_state, de_conf_report, last_queuelen_size,
- last_queuelen_time, instance_0, instance_0_state, iaas_state_time,
+ """ % (controller_name, de_state, de_conf_report,
+ instance_0, instance_0_state, iaas_state_time,
heartbeat_state, heartbeat_time)
with open(local_abs_filepath, "w") as j_file:
@@ -55,22 +55,12 @@ def setup(self):
self.first_de_state = "great"
self.second_de_state_time = 100
self.second_de_state = "paranoid"
- self.first_last_queuelen_size_time = 60
- self.first_last_queuelen_size = 1
- self.second_last_queuelen_size_time = 200
- self.second_last_queuelen_size = 2
events.append(mocks.event.Event(name="de_state",
timestamp=self.first_de_state_time,
state=self.first_de_state))
events.append(mocks.event.Event(name="de_state",
timestamp=self.second_de_state_time,
state=self.second_de_state))
- events.append(mocks.event.Event(name="last_queuelen_size",
- timestamp=self.first_last_queuelen_size_time,
- last_queuelen_size=self.first_last_queuelen_size))
- events.append(mocks.event.Event(name="last_queuelen_size",
- timestamp=self.second_last_queuelen_size_time,
- last_queuelen_size=self.second_last_queuelen_size))
self.controller.events = events
# VM with no events
@@ -164,25 +154,23 @@ def test_get_vm_with_controller(self):
def test_latest_controller_state(self):
from epumgmt.main.em_core_status import _latest_controller_state
- nostate, noqlen = _latest_controller_state(None)
+ nostate = _latest_controller_state(None)
+ print nostate
assert nostate == None
- assert noqlen == None
- nostate, noqlen = _latest_controller_state(self.vm_no_events)
+ nostate = _latest_controller_state(self.vm_no_events)
assert nostate == None
- assert noqlen == None
- state, qlen = _latest_controller_state(self.controller)
+ state = _latest_controller_state(self.controller)
assert state == self.second_de_state
- assert qlen == self.second_last_queuelen_size
extra_state = "okay"
extra_event = mocks.event.Event(name="de_state",
timestamp=self.second_de_state_time + 10,
de_state=extra_state)
self.controller.events.append(extra_event)
- state, _ = _latest_controller_state(self.controller)
+ state = _latest_controller_state(self.controller)
assert state == extra_state
@@ -224,20 +212,6 @@ def test_get_events_from_controller_state(self):
assert test_vm.events[0].source == controller
assert test_vm.events[0].name == "de_conf_report"
- # Reset events
- test_vm.events = []
- assert len(test_vm.events) == 0
-
- last_queuelen_size = 42
- controller = "test_controller"
- test_state = State(last_queuelen_size=last_queuelen_size, capture_time=0)
- got_event = _get_events_from_controller_state(test_state, test_vm, controller, True, common)
-
- assert got_event == True
- assert len(test_vm.events) == 1
- assert test_vm.events[0].source == controller
- assert test_vm.events[0].name == "last_queuelen_size"
-
def test_get_events_from_wis(self):
from epumgmt.main.em_core_status import _get_events_from_wis
@@ -412,9 +386,11 @@ def test_find_state_from_events_not_yet_started(self):
svc_adapter.worker_state_raises = worker_state_exception
_find_latest_worker_status(common, modules, "", None, allvms)
- warnings = [warning for warning in common.log.transcript if warning[0] == "WARNING"]
- _, last_warning = warnings[-1]
- assert last_warning.find("Unable to get worker state for controllers") != -1
+ print common.log.transcript
+
+ errors = [error for error in common.log.transcript if error[0] == "ERROR"]
+ _, last_error = errors[-1]
+ assert last_error.find("Unable to get worker state for controllers") != -1
def test_update_worker_parents(self):

0 comments on commit 120a0bf

Please sign in to comment.