Esempio n. 1
0
    def run(self):
        """Starts all nodes defined in netsim's config directory."""

        if self.nrnodes or self.nodes or self.topology:
            if self.nodes:
                nodes = self.nodes.split(",")
            else:
                nodes = []

            if self.nrnodes and (self.nrnodes > len(nodes)):
                nodes += [
                    "Node{}".format(i)
                    for i in range(self.nrnodes - len(nodes))
                ]
        else:
            nodes = self.nodes

        network = Network(name=self.name,
                          nodes=nodes,
                          topology=self.topology,
                          new=self.new,
                          force=True)
        network.start()

        while True:
            time.sleep(0.1)
Esempio n. 2
0
def run_sim_backend(node_names, sim_backend):
    logger.debug(
        f"Starting simulaqron sim_backend process with nodes {node_names}")
    check_sim_backend(sim_backend=sim_backend)
    simulaqron_settings.sim_backend = sim_backend.value
    network = Network(name="default", nodes=node_names, force=True, new=True)
    network.start()
    return network
Esempio n. 3
0
 def test_start_stop(self):
     network = Network(force=True)
     network.start(wait_until_running=True)
     for p in network.processes:
         self.assertTrue(p.is_alive())
     network.stop()
     for p in network.processes:
         self.assertFalse(p.is_alive())
Esempio n. 4
0
 def test_start_stop(self):
     network = Network()
     network.start()
     for p in network.processes:
         self.assertTrue(p.is_alive())
     network.stop()
     for p in network.processes:
         self.assertFalse(p.is_alive())
Esempio n. 5
0
 def test_start(self):
     network = Network(nodes=self.nodes, force=True)
     self.assertEqual(len(network.processes), 2 * len(self.nodes))
     for p in network.processes:
         self.assertFalse(p.is_alive())
     network.start(wait_until_running=True)
     self.assertTrue(network.running)
     for p in network.processes:
         self.assertTrue(p.is_alive())
Esempio n. 6
0
    def test_no_wait(self):
        network = Network(nodes=self.nodes, force=True)
        network.start(wait_until_running=False)
        self.assertFalse(network.running)

        # Check that network starts running eventually
        max_time = 10  # s
        t_start = timer()
        while timer() < t_start + max_time:
            if network.running:
                break
            else:
                time.sleep(0.1)

        self.assertTrue(network.running)
Esempio n. 7
0
 def test_del(self):
     network = Network(force=True)
     network.start(wait_until_running=True)
     del network
Esempio n. 8
0
 def test_del(self):
     network = Network(force=True)
     network.start()
     del network
Esempio n. 9
0
 def test_del(self):
     network = Network()
     network.start()
     del network