Commit 50164891 authored by Paul Rich's avatar Paul Rich
Browse files

get_location_statistics for Cray systems added.

parent defc2ef5
......@@ -28,6 +28,7 @@ from Queue import Queue
_logger = logging.getLogger(__name__)
init_cobalt_config()
DEFAULT_DEPTH = int(get_config_option('alps', 'default_depth', 72))
UPDATE_THREAD_TIMEOUT = int(get_config_option('alpssystem', 'update_thread_timeout', 10))
TEMP_RESERVATION_TIME = int(get_config_option('alpssystem', 'temp_reservation_time', 300))
SAVE_ME_INTERVAL = float(get_config_option('alpsssytem', 'save_me_interval', 10.0))
......@@ -1576,6 +1577,49 @@ class CraySystem(BaseSystem):
self.logger.warning("%s: Interactive job not found", str(jobid))
return
@exposed
def get_location_statistics(self, locations):
'''Get a list of the aggregate location statistics for a list of node locations.
Inputs:
locations -- String containing location names. At this time all locations must
exist as compute nodes on the Cray system as reported by ALPS.
Outputs:
A dictionary containing key-value pairs for resources submitted.
ex: {'nodect': 512:, 'nprocs':8192}
statistics
Exceptions:
KeyError -- if an invalid location name is given, a key error will be raised
Notes: returned statistics are system-component dependent.
'''
try:
loc_list = locations.split(':')
except AttributeError as exc:
extra_msg = 'Location list %s cannot be split.' % locations
exc.message += ' ', extra_msg
self.logger.warning(extra_msg)
stats = {'nodect': 0,
'nproc': 0,
}
stats['nodect'] = 0
for loc in loc_list:
try:
expanded_loc = expand_num_list(loc)
except TypeError:
#if there is no block for the location raise that we have a bad value in the list
err_str = "Node list %s is not valid, or bad format." % loc
self.logger.error(err_str)
raise
else:
stats['nodect'] += len(expanded_loc)
stats['nproc'] = stats['nodect'] * DEFAULT_DEPTH
self.logger.debug("Reservation request stats: %s", stats)
return stats
class ALPSReservation(object):
'''Container for ALPS Reservation information. Can be used to update
reservations and also internally relases reservation.
......
......@@ -32,6 +32,7 @@ from testsuite.TestCobalt.Utilities.Time import timeout
from Cobalt.Components.system.CrayNode import CrayNode
import Cobalt.Exceptions
import time
import Cobalt.Components.system
from Cobalt.Components.system.CraySystem import CraySystem
from Cobalt.Components.system.base_pg_manager import ProcessGroupManager
import Cobalt.Components.system.AlpsBridge as AlpsBridge
......@@ -143,12 +144,14 @@ class TestCraySystem(object):
'queue':'default', 'nodes': 1, 'walltime': 60,
}
self.fake_reserve_called = False
Cobalt.Components.system.CraySystemDEFAULT_DEPTH = 72
Cobalt.Components.system.CraySystem.BACKFILL_EPSILON = 120
Cobalt.Components.system.CraySystem.DRAIN_MODE = "first-fit"
def teardown(self):
del self.system
del self.base_job
Cobalt.Components.system.CraySystem.DEFAULT_DEPTH = 72
Cobalt.Components.system.CraySystem.BACKFILL_EPSILON = 120
Cobalt.Components.system.CraySystem.DRAIN_MODE = "first-fit"
self.fake_reserve_called = False
......@@ -1166,6 +1169,37 @@ class TestCraySystem(object):
assert_match(info, node_id_list, 'Bad reservation info returned')
TestCraySystem.verify_alps_reservation_dict(self.system)
def test__get_location_statistics_single_node(self):
'''CraySystem.get_location_statistics single node'''
expected = {'nodect': 1, 'nproc': 72}
loc_stat = self.system.get_location_statistics("100")
assert_match(loc_stat, expected, "node statistic mismatch")
def test__get_location_statistics_location_list(self):
'''CraySystem.get_location_statistics location list'''
expected = {'nodect': 204, 'nproc': 14688}
loc_stat = self.system.get_location_statistics("1-100,200-299,3728,9932-9934")
assert_match(loc_stat, expected, "node statistic mismatch")
def test__get_location_statistics_depth_adjust(self):
'''CraySystem.get_location_statistics modified default depth'''
expected = {'nodect': 1, 'nproc': 32}
Cobalt.Components.system.CraySystem.DEFAULT_DEPTH = 32
loc_stat = self.system.get_location_statistics("100")
assert_match(loc_stat, expected, "node statistic mismatch")
def test__get_location_statistics_colon_list(self):
'''CraySystem.get_location_statistics colon-delimited list'''
expected = {'nodect': 103, 'nproc': 7416}
loc_stat = self.system.get_location_statistics("100-199:3000-3002")
assert_match(loc_stat, expected, "node statistic mismatch")
@raises(ValueError)
def test__get_location_statistics_bad_list(self):
'''CraySystem.get_location_statistics exception for bad list'''
self.system.get_location_statistics("foo")
assert False, "No exception raised"
class TestALPSReservation(object):
'''Tests for the ALPSReservation class in src/lib/Components/system/CraySystem.py'''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment