X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=test%2Fresources%2Flinux%2Fns3%2Fserialization.py;h=2eea5b6ae1fc5fb6444ec6a12fd50314fe6244f8;hb=039fbd9629d7570d4c175a5448d24badcd0f3aba;hp=fb6d352abf108f3972174431b96026f90e772692;hpb=999ef8574031b2e3facce8607b6e91f42af6dc66;p=nepi.git diff --git a/test/resources/linux/ns3/serialization.py b/test/resources/linux/ns3/serialization.py index fb6d352a..2eea5b6a 100755 --- a/test/resources/linux/ns3/serialization.py +++ b/test/resources/linux/ns3/serialization.py @@ -4,9 +4,8 @@ # Copyright (C) 2013 INRIA # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation; # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,6 +17,8 @@ # # Author: Alina Quereilhac +from __future__ import print_function + from nepi.execution.ec import ExperimentController from nepi.execution.trace import TraceAttr @@ -145,7 +146,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec = ExperimentController(exp_id = "test-ns3-wifi-ping") - node = ec.register_resource("LinuxNode") + node = ec.register_resource("linux::Node") if host == "localhost": ec.set(node, "hostname", "localhost") else: @@ -156,7 +157,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.set(node, "cleanProcesses", True) #ec.set(node, "cleanHome", True) - simu = ec.register_resource("LinuxNS3Simulation") + simu = ec.register_resource("linux::ns3::Simulation") ec.set(simu, "verbose", True) ec.register_connection(simu, node) @@ -184,7 +185,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.register_connection(ping, nsnode2) filepath = ec.save(dirpath) - print filepath + print(filepath) ec.deploy() @@ -231,7 +232,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec = ExperimentController(exp_id = "test-ns3-routes") - node = ec.register_resource("LinuxNode") + node = ec.register_resource("linux::Node") if host == "localhost": ec.set(node, "hostname", host) else: @@ -242,7 +243,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.set(node, "cleanProcesses", True) #ec.set(node, "cleanHome", True) - simu = ec.register_resource("LinuxNS3Simulation") + simu = ec.register_resource("linux::ns3::Simulation") ec.set(simu, "verbose", True) ec.register_connection(simu, node) @@ -324,7 +325,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.register_connection(ping, nsnode1) filepath = ec.save(dirpath) - print filepath + print(filepath) ec.deploy() @@ -361,7 +362,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec = ExperimentController(exp_id = "test-ns3-dce") - node = ec.register_resource("LinuxNode") + node = ec.register_resource("linux::Node") if host == "localhost": ec.set(node, "hostname", host) else: @@ -372,10 +373,8 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.set(node, "cleanProcesses", True) #ec.set(node, "cleanHome", True) - simu = ec.register_resource("LinuxNS3Simulation") + simu = ec.register_resource("linux::ns3::Simulation") ec.set(simu, "verbose", True) - #ec.set(simu, "buildMode", "debug") - #ec.set(simu, "nsLog", "DceApplication") ec.register_connection(simu, node) nsnode1 = add_ns3_node(ec, simu) @@ -394,7 +393,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.register_connection(chan, p2p2) ### create applications - udp_perf = ec.register_resource("ns3::DceApplication") + udp_perf = ec.register_resource("linux::ns3::dce::Application") ec.set (udp_perf, "binary", "udp-perf") ec.set (udp_perf, "stackSize", 1<<20) ec.set (udp_perf, "arguments", "--duration=10;--nodes=2") @@ -402,7 +401,7 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.set (udp_perf, "StopTime", "20s") ec.register_connection(udp_perf, nsnode1) - udp_perf_client = ec.register_resource("ns3::DceApplication") + udp_perf_client = ec.register_resource("linux::ns3::dce::Application") ec.set (udp_perf_client, "binary", "udp-perf") ec.set (udp_perf_client, "stackSize", 1<<20) ec.set (udp_perf_client, "arguments", "--client;--nodes=2;--host=10.0.0.1;--duration=10") @@ -411,12 +410,15 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec.register_connection(udp_perf_client, nsnode2) filepath = ec.save(dirpath) - print filepath ec.deploy() ec.wait_finished([udp_perf_client]) + # Give time to flush the streams + import time + time.sleep(5) + expected = "udp-perf --duration=10 --nodes=2" cmdline = ec.trace(udp_perf, "cmdline") self.assertTrue(cmdline.find(expected) > -1, cmdline) @@ -429,10 +431,6 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): stdout = ec.trace(udp_perf, "stdout") self.assertTrue(stdout.find(expected) > -1, stdout) - stderr = ec.trace(simu, "stderr") - expected = "DceApplication:StartApplication" - self.assertTrue(stderr.find(expected) > -1, stderr) - ec.shutdown() # Load serialized experiment @@ -440,7 +438,10 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): ec2.deploy() ec2.wait_finished([udp_perf_client]) - + + # Give time to flush the streams + time.sleep(5) + self.assertEquals(len(ec.resources), len(ec2.resources)) expected = "udp-perf --duration=10 --nodes=2" @@ -455,10 +456,6 @@ class LinuxNS3SimulationSerializationTest(unittest.TestCase): stdout = ec2.trace(udp_perf, "stdout") self.assertTrue(stdout.find(expected) > -1, stdout) - stderr = ec2.trace(simu, "stderr") - expected = "DceApplication:StartApplication" - self.assertTrue(stderr.find(expected) > -1, stderr) - ec2.shutdown() shutil.rmtree(dirpath)