Package starcluster :: Package tests :: Module test_sge_balancer
[hide private]
[frames] | no frames]

Source Code for Module starcluster.tests.test_sge_balancer

 1  import datetime 
 2   
 3  from starcluster.balancers import sge 
 4  from starcluster.tests import StarClusterTest 
 5  from starcluster.tests.templates import sge_balancer 
 6   
 7   
8 -class TestSGELoadBalancer(StarClusterTest):
9 stat_hash = None 10 host_hash = {} 11
12 - def test_qhost_parser(self):
13 stat = sge.SGEStats() 14 self.host_hash = stat.parse_qhost(sge_balancer.qhost_xml) 15 assert len(self.host_hash) == 3 16 assert len(self.host_hash) == stat.count_hosts() 17 assert stat.count_total_slots() == 3 18 assert stat.slots_per_host() == 1
19
21 stat = sge.SGEStats() 22 self.host_hash = stat.parse_qhost(sge_balancer.loaded_qhost_xml) 23 assert len(self.host_hash) == 10 24 assert len(self.host_hash) == stat.count_hosts() 25 assert stat.count_total_slots() == 80 26 assert stat.slots_per_host() == 8
27
28 - def test_qstat_parser(self):
29 stat = sge.SGEStats() 30 self.stat_hash = stat.parse_qstat(sge_balancer.qstat_xml) 31 assert len(self.stat_hash) == 23 32 assert stat.first_job_id == 1 33 assert stat.last_job_id == 23 34 assert len(stat.get_queued_jobs()) == 20 35 assert len(stat.get_running_jobs()) == 3 36 assert stat.num_slots_for_job(21) == 1 37 oldest = datetime.datetime(2010, 6, 18, 23, 39, 14) 38 assert stat.oldest_queued_job_age() == oldest
39
40 - def test_qacct_parser(self):
41 stat = sge.SGEStats() 42 now = datetime.datetime.utcnow() 43 self.jobstats = stat.parse_qacct(sge_balancer.qacct_txt, now) 44 assert stat.avg_job_duration() == 90 45 assert stat.avg_wait_time() == 263
46
48 stat = sge.SGEStats() 49 self.stat_hash = stat.parse_qstat(sge_balancer.loaded_qstat_xml) 50 assert len(self.stat_hash) == 192 51 assert stat.first_job_id == 385 52 assert stat.last_job_id == 576 53 assert len(stat.get_queued_jobs()) == 188 54 assert len(stat.get_running_jobs()) == 4 55 assert stat.num_slots_for_job(576) == 20 56 oldest = datetime.datetime(2010, 7, 8, 4, 40, 32) 57 assert stat.oldest_queued_job_age() == oldest
58
59 - def test_node_working(self):
60 #TODO : FINISH THIS 61 pass
62