Beispiel #1
0
 def __init__(self, config, specs=None):
     self.config = config
     if specs is None:
         specs = self.config.getxspecs()
     self.roots = self.config.getrsyncdirs()
     self.gwmanager = GatewayManager(specs)
     self.nodes = []
     self._nodesready = py.std.threading.Event()
Beispiel #2
0
 def test_hostmanage_rsync_same_popen_twice(self, mysetup, _pytest):
     source, dest = mysetup.source, mysetup.dest
     rec = _pytest.gethookrecorder(py.execnet._HookSpecs)
     hm = GatewayManager(["popen//chdir=%s" % dest] * 2)
     hm.makegateways()
     source.ensure("dir1", "dir2", "hello")
     hm.rsync(source)
     call = rec.popcall("pyexecnet_gwmanage_rsyncstart")
     assert call.source == source
     assert len(call.gateways) == 1
     assert hm.gateways[0] == call.gateways[0]
     call = rec.popcall("pyexecnet_gwmanage_rsyncfinish")
Beispiel #3
0
 def test_popens_rsync(self, mysetup):
     source = mysetup.source
     hm = GatewayManager(["popen"] * 2)
     hm.makegateways()
     assert len(hm.gateways) == 2
     for gw in hm.gateways:
         gw.remote_exec = None
     l = []
     hm.rsync(source, notify=lambda *args: l.append(args))
     assert not l
     hm.exit()
     assert not len(hm.gateways)
Beispiel #4
0
 def test_popen_makegateway_events(self, _pytest):
     rec = _pytest.gethookrecorder(py.execnet._HookSpecs)
     hm = GatewayManager(["popen"] * 2)
     hm.makegateways()
     call = rec.popcall("pyexecnet_gwmanage_newgateway")
     assert call.gateway.id == "[1]"
     assert call.platinfo.executable == call.gateway._rinfo().executable
     call = rec.popcall("pyexecnet_gwmanage_newgateway")
     assert call.gateway.id == "[2]"
     assert len(hm.gateways) == 2
     hm.exit()
     assert not len(hm.gateways)
Beispiel #5
0
 def test_rsync_popen_with_path(self, mysetup):
     source, dest = mysetup.source, mysetup.dest
     hm = GatewayManager(["popen//chdir=%s" % dest] * 1)
     hm.makegateways()
     source.ensure("dir1", "dir2", "hello")
     l = []
     hm.rsync(source, notify=lambda *args: l.append(args))
     assert len(l) == 1
     assert l[0] == ("rsyncrootready", hm.gateways[0].spec, source)
     hm.exit()
     dest = dest.join(source.basename)
     assert dest.join("dir1").check()
     assert dest.join("dir1", "dir2").check()
     assert dest.join("dir1", "dir2", 'hello').check()
Beispiel #6
0
    def test_multi_chdir_popen(self, testdir):
        import os
        hm = GatewayManager(["popen"] * 2)
        testdir.tmpdir.chdir()
        hellopath = testdir.tmpdir.mkdir("hello")
        hm.makegateways()
        hm.multi_chdir("hello", inplacelocal=False)
        l = hm.multi_exec(
            "import os ; channel.send(os.getcwd())").receive_each()
        assert len(l) == 2
        curwd = os.path.realpath(os.getcwd())
        assert l == [curwd] * 2

        hm.multi_chdir("hello")
        l = hm.multi_exec(
            "import os ; channel.send(os.getcwd())").receive_each()
        assert len(l) == 2
        assert l[0] == l[1]
        assert l[0].startswith(curwd)
        assert l[0].endswith("hello")
Beispiel #7
0
 def test_multi_chdir_popen_with_path(self, testdir):
     import os
     hm = GatewayManager(["popen//chdir=hello"] * 2)
     testdir.tmpdir.chdir()
     hellopath = testdir.tmpdir.mkdir("hello").realpath()
     hm.makegateways()
     l = hm.multi_exec(
         "import os ; channel.send(os.getcwd())").receive_each()
     paths = [x[1] for x in l]
     assert l == [str(hellopath)] * 2
     py.test.raises(hm.RemoteError,
                    'hm.multi_chdir("world", inplacelocal=False)')
     worldpath = hellopath.mkdir("world")
     hm.multi_chdir("world", inplacelocal=False)
     l = hm.multi_exec(
         "import os ; channel.send(os.getcwd())").receive_each()
     assert len(l) == 2
     assert l[0] == l[1]
     curwd = os.getcwd()
     assert l[0].startswith(curwd)
     assert l[0].endswith("world")
Beispiel #8
0
 def test_default_chdir(self):
     l = ["ssh=noco", "socket=xyz"]
     for spec in GatewayManager(l).specs:
         assert spec.chdir == "pyexecnetcache"
     for spec in GatewayManager(l, defaultchdir="abc").specs:
         assert spec.chdir == "abc"
Beispiel #9
0
 def test_popen_no_default_chdir(self):
     gm = GatewayManager(["popen"])
     assert gm.specs[0].chdir is None