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

Source Code for Module starcluster.tests.test_sge_balancer

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