def setUp(self): self.cluster = Cluster() lb = LoadBalancer(self.cluster) self.cluster.loadBalancer = lb self.s1 = Server() self.s2 = Server() self.s1.WAKE_UP_TIME = 0 self.s2.WAKE_UP_TIME = 0 emodel1 = EnergyModel(self.s1) emodel2 = EnergyModel(self.s1) peakPerf = [1,2,3] busy = [3,4,5] idle = [1,1,1] emodel1.assignSamples(busy, idle, peakPerf) emodel2.assignSamples(busy, idle, peakPerf) self.s1.energyModel = emodel1 self.s2.energyModel = emodel2 freqs = [1.0,2.0] self.s1.processor.availableFreqs = freqs self.s2.processor.availableFreqs = freqs cont1 = DVFSController(self.s1) cont2 = DVFSController(self.s2) self.s1.dvfsCont = cont1 self.s2.dvfsCont = cont2
def init_servers(no_of_servers, server_schedulers, server_service_rates): list_of_servers = [] for i in range(int(no_of_servers)): scheduler_i = FIFO() if server_schedulers[i] == 1 else PS() server_i = Server(server_service_rates[i], scheduler_i) list_of_servers.append(server_i) return list_of_servers
def testReadSensors(self): s = Server() core = Core() s.processor.cores.append(core) core = Core() s.processor.cores.append(core) s.updateSensors() '''
def init_servers(no_of_servers, server_scheduler, job_distribution): list_of_servers = [] for i in range(int(no_of_servers)): scheduler_i = FIFO() if server_scheduler[i] == 1 else PS() job_size_i = Expo(job_distribution[i]) server_i = Server(job_size_i, scheduler_i) list_of_servers.append(server_i) return list_of_servers
def setUp(self): self.job = Job(0, 0.5) self.stats = stats.Statistics() self.world = global_state.Global(self.stats) self.service = Expo(1) self.scheduler = schedulers.FIFO() self.server = Server(self.service, self.scheduler) self.policy = policies.RND()
def testInvalidData(self): ''' Expected results when the functions are called with invalid or incomplete data ''' #Parameters: self.assertRaises(AssertionError, self.configurator.getConfiguration, None, None, None) self.assertRaises(AssertionError, self.configurator.applyConfiguration, None) #Malformed Server: s = Server() self.assertRaises(AttributeError, self.configurator.getConfiguration, 100, [s], self.configurator._gamma)
def createServer(name): server = Server() server._hostname = name energyModel = EnergyModel(server) server.energyModel = energyModel if name == 'ampere': server.processor.availableFreqs = [1.0, 1.8, 2.0] server.energyModel._idlePower = [66.3, 70.5, 72.7] server.energyModel._busyPower = [81.5, 101.8, 109.8] server.energyModel._peakPerformance = [99.8, 179.6, 199.6] elif name == 'coulomb': server.processor.availableFreqs = [1.0, 1.8, 2.0, 2.2, 2.4] server.energyModel._idlePower = [67.4, 70.9, 72.4, 73.8, 75.2] server.energyModel._busyPower = [75.2, 89.0, 94.5, 100.9, 107.7] server.energyModel._peakPerformance = [53.8, 95.4, 104.8, 113.6, 122.3] elif name == 'joule': server.processor.availableFreqs = [1.0, 1.8, 2.0, 2.2] server.energyModel._idlePower = [66.6, 73.8, 76.9, 80.0] server.energyModel._busyPower = [74.7, 95.7, 103.1, 110.6] server.energyModel._peakPerformance = [51.2, 91.2, 101.4, 111.4] elif name == 'ohm': server.processor.availableFreqs = [1.0, 1.8, 2.0, 2.2, 2.4, 2.6] server.energyModel._idlePower = [65.8, 68.5, 70.6, 72.3, 74.3, 76.9] server.energyModel._busyPower = [ 82.5, 99.2, 107.3, 116.6, 127.2, 140.1 ] server.energyModel._peakPerformance = [ 99.4, 177.4, 197.2, 218.0, 234.6, 255.2 ] elif name == 'hertz': server.processor.availableFreqs = [1.0, 1.8, 2.0, 2.2, 2.4] server.energyModel._idlePower = [63.9, 67.2, 68.7, 69.9, 71.6] server.energyModel._busyPower = [71.6, 85.5, 90.7, 96.5, 103.2] server.energyModel._peakPerformance = [53.6, 92.9, 103.4, 112.4, 122.8] else: raise Exception('No server with the name "%s" found' % name) cont = DVFSController(server) server.dvfsCont = cont return server
class ServerTest(unittest.TestCase): core = Core() proc = Processor() proc.cores = [core] server = Server() server.processor = proc server.processor.availableFreqs = [1.0] cont = DVFSController(server) server.dvfsCont = cont server._status = Server.OFF server.WAKE_UP_TIME = 0 def testTurnOn(self): self.server.turnOn() #if the server is already on, nothing should happen: self.server.turnOn() def testTurnOff(self): self.server._status = Server.ON self.server.turnOff() #if the server is already off, nothing should happen: self.server.turnOff() def testSwitching(self): ''' Switching a server ON, then OFF then ON again ''' self.server.turnOn() self.server.turnOff() self.server.turnOn() def testReadSensors(self): s = Server() core = Core() s.processor.cores.append(core) core = Core() s.processor.cores.append(core) s.updateSensors() '''
#service = RequestBuffer() #cluster.service = service cluster.loadBalancer = lBalancer cluster._availableServers = servers for server in servers: cluster.servers[server.status].append(server) return cluster ''' Setup Cluster ''' cluster = Cluster() ampere = Server() coulomb = Server() hertz = Server() joule = Server() ohm = Server() servers = [ampere, coulomb, hertz, joule, ohm] ampere._hostname = 'ampere' coulomb._hostname = 'coulomb' hertz._hostname = 'hertz' joule._hostname = 'joule' ohm._hostname = 'ohm' joinServers(servers, cluster) ''' Create Modules