def test_get_leases(self):
     fail = False
     network_devices = get_target.get_all()
     for device in network_devices:
         output = ssh.ssh("root", device[1], "ndsctl status")
         self.log.write(output)
     self.assertFalse(fail)
    def test_iperf(self):
        fail = False
        network_devices = get_target.get_all()
        for device in network_devices:
	    self.log.write("Destination: " + device[1] + "\n")
            start_iperf(device[1])
            traceroute = subprocess.Popen(["traceroute", "-n", device[1]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            iperf = subprocess.Popen(["iperf", "-c", device[1]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            self.log.write(traceroute.communicate()[0])
            self.log.write(iperf.communicate()[0])
            stop_iperf(device[1])
        self.assertFalse(fail)
 def test_iperf(self):
     fail = False
     network_devices = get_target.get_all()
     for device in network_devices:
         print("Destination: " + device[1] + "\n")
         self.log.write("Destination: " + device[1] + "\n")
         print("starting iperf on server")
         start_iperf(device[1])
         print("running traceroute on server")
         traceroute = subprocess.Popen(["traceroute", "-n", device[1]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         print("starting iperf on client")            
         iperf = subprocess.Popen(["iperf", "--client", device[1]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         print("logging")            
         self.log.write(traceroute.communicate()[0])
         self.log.write(iperf.communicate()[0])
         print("stopping iperf on server")
         stop_iperf(device[1])
     self.assertFalse(fail)
 def test_ping_time(self):
     fail = False
     destinations = ["8.8.8.8", "127.0.0.1"]
     network_devices = get_target.get_all()
     for i in network_devices:
         destinations.append(i[1])
     for ping_dest in destinations:
         ping = subprocess.Popen(["ping", "-c", "4", ping_dest], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         tail = subprocess.Popen(["tail", "-1"], stdin=ping.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)            
         awk = subprocess.Popen(["awk", "{print $4}"], stdin=tail.stdout, stdout=subprocess.PIPE, stderr=sys.stdout.fileno())
         test_set = awk.communicate()[0][0:-2]
         l = test_set.split("/")
         total = None
         if len(l) != 1:
             nums = [float(n) for n in l]
             total = sum(nums) / float(len(nums))
         if total:
             self.log.write("Average ping time to "+ping_dest+" was "+str(total)+" seconds\n")
         else:
             fail = True
             self.log.write(ping_dest+" could not be reached\n")
     self.assertFalse(fail)