From: david-sarah Date: Wed, 10 Nov 2010 03:36:49 +0000 (-0800) Subject: test_system.py: test for 'tahoe mv' with the http_proxy and HTTP_PROXY variables... X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/reliability?a=commitdiff_plain;h=01a53650510a9a4ee33ee8624d1090e4dab9b048;p=tahoe-lafs%2Ftahoe-lafs.git test_system.py: test for 'tahoe mv' with the http_proxy and HTTP_PROXY variables set. refs #1253 --- diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 7ebafeb8..f2770bba 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -4,6 +4,8 @@ from cStringIO import StringIO from twisted.trial import unittest from twisted.internet import defer from twisted.internet import threads # CLI tests use deferToThread +from twisted.internet import utils + import allmydata from allmydata import uri from allmydata.storage.mutable import MutableShareFile @@ -29,6 +31,9 @@ from twisted.web.error import Error from allmydata.test.common import SystemTestMixin +# TODO: move these to common or common_util +from allmydata.test.test_runner import bintahoe, SkipMixin + LARGE_DATA = """ This is some data to publish to the remote grid.., which needs to be large enough to not fit inside a LIT uri. @@ -47,7 +52,7 @@ class CountingDataUploadable(upload.Data): self.interrupt_after_d.callback(self) return upload.Data.read(self, length) -class SystemTest(SystemTestMixin, unittest.TestCase): +class SystemTest(SystemTestMixin, SkipMixin, unittest.TestCase): timeout = 3600 # It takes longer than 960 seconds on Zandr's ARM box. def test_connections(self): @@ -1589,9 +1594,23 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d.addCallback(_check_ls_rouri) - d.addCallback(run, "mv", "tahoe-file-stdin", "tahoe-moved") + d.addCallback(run, "mv", "tahoe-file-stdin", "tahoe-moved-first-time") d.addCallback(run, "ls") - d.addCallback(_check_ls, ["tahoe-moved"], ["tahoe-file-stdin"]) + d.addCallback(_check_ls, ["tahoe-moved-first-time"], ["tahoe-file-stdin"]) + + def _mv_with_http_proxy(ign): + env = os.environ + env['http_proxy'] = env['HTTP_PROXY'] = "http://127.0.0.0:12345" # invalid address + return self._run_cli_in_subprocess(["mv"] + nodeargs + ["tahoe-moved-first-time", "tahoe-moved"], env=env) + d.addCallback(_mv_with_http_proxy) + + def _check_mv_with_http_proxy(res): + out, err, rc_or_sig = res + self.failUnlessEqual(rc_or_sig, 0, str(res)) + d.addCallback(_check_mv_with_http_proxy) + + d.addCallback(run, "ls") + d.addCallback(_check_ls, ["tahoe-moved"], ["tahoe-moved-firsttime"]) d.addCallback(run, "ln", "tahoe-moved", "newlink") d.addCallback(run, "ls") @@ -1745,6 +1764,15 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d.addCallback(_done) return d + def _run_cli_in_subprocess(self, argv, env=None): + self.skip_if_cannot_run_bintahoe() + + if env is None: + env = os.environ + d = utils.getProcessOutputAndValue(sys.executable, args=[bintahoe] + argv, + env=env) + return d + def _test_checker(self, res): ut = upload.Data("too big to be literal" * 200, convergence=None) d = self._personal_node.add_file(u"big file", ut)