Beispiel #1
0
    def test_version_no_noise(self):
        self.skip_if_cannot_run_bintahoe()

        from allmydata import get_package_versions, normalized_version
        twisted_ver = get_package_versions()['Twisted']

        if not normalized_version(twisted_ver) >= normalized_version('9.0.0'):
            raise unittest.SkipTest(
                "We pass this test only with Twisted >= v9.0.0")

        d = self.run_bintahoe(["--version"])

        def _cb(res):
            out, err, rc_or_sig = res
            self.failUnlessEqual(rc_or_sig, 0, str(res))
            self.failUnless(out.startswith(allmydata.__appname__ + ':'),
                            str(res))
            self.failIfIn("DeprecationWarning", out, str(res))
            errlines = err.split("\n")
            self.failIf([
                True for line in errlines
                if (line != "" and "UserWarning: Unbuilt egg for setuptools"
                    not in line and
                    "from pkg_resources import load_entry_point" not in line)
            ], str(res))
            if err != "":
                raise unittest.SkipTest(
                    "This test is known not to pass on Ubuntu Lucid; see #1235."
                )

        d.addCallback(_cb)
        return d
Beispiel #2
0
    def test_version_no_noise(self):
        self.skip_if_cannot_run_bintahoe()

        from allmydata import get_package_versions, normalized_version
        twisted_ver = get_package_versions()['Twisted']

        if not normalized_version(twisted_ver) >= normalized_version('9.0.0'):
            raise unittest.SkipTest(
                "We pass this test only with Twisted >= v9.0.0")

        d = self.run_bintahoe(["--version"])

        def _cb(res):
            out, err, rc_or_sig = res
            self.failUnlessEqual(rc_or_sig, 0, str(res))
            self.failUnless(
                out.startswith(allmydata.__appname__ + ':'), str(res))
            self.failIfIn("DeprecationWarning", out, str(res))
            errlines = err.split("\n")
            self.failIf([
                True for line in errlines
                if (line != "" and "UserWarning: Unbuilt egg for setuptools"
                    not in line and
                    "from pkg_resources import load_entry_point" not in line)
            ], str(res))
            if err != "":
                raise unittest.SkipTest(
                    "This test is known not to pass on Ubuntu Lucid; see #1235."
                )

        d.addCallback(_cb)
        return d
Beispiel #3
0
    def test_read_default_css(self):
        """
        Sometimes Nevow can't find its resource files such as its default css file.
        """

        from allmydata import get_package_versions, normalized_version
        nevow_ver = get_package_versions()['Nevow']

        if not normalized_version(nevow_ver) >= normalized_version('0.9.33'):
            raise unittest.SkipTest("We pass this test only with Nevow >= v0.9.33, which is the first version of Nevow that has our patch from http://www.divmod.org/trac/ticket/2527")

        webform.defaultCSS.openForReading()
Beispiel #4
0
    def test_read_default_css(self):
        """
        Sometimes Nevow can't find its resource files such as its default css file.
        """

        from allmydata import get_package_versions, normalized_version
        nevow_ver = get_package_versions()['Nevow']

        if not normalized_version(nevow_ver) >= normalized_version('0.9.33'):
            raise unittest.SkipTest(
                "We pass this test only with Nevow >= v0.9.33, which is the first version of Nevow that has our patch from http://www.divmod.org/trac/ticket/2527"
            )

        webform.defaultCSS.openForReading()
Beispiel #5
0
            "control.port",
            "enabled",
            "launch",
            "socks.port",
            "tor.executable",
            "onion",
            "onion.local_port",
            "onion.external_port",
            "onion.private_key_file",
        ),
    }


# Add our application versions to the data that Foolscap's LogPublisher
# reports.
for thing, things_version in get_package_versions().iteritems():
    app_versions.add_version(thing, str(things_version))

# group 1 will be addr (dotted quad string), group 3 if any will be portnum (string)
ADDR_RE = re.compile(
    "^([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*)(:([1-9][0-9]*))?$")


def formatTimeTahoeStyle(self, when):
    """
    Format the given (UTC) timestamp in the way Tahoe-LAFS expects it,
    for example: 2007-10-12 00:26:28.566Z

    :param when: UTC POSIX timestamp
    :type when: float
    :returns: datetime.datetime
Beispiel #6
0
from twisted.python import log as twlog
from twisted.application import service
from foolscap.api import Tub, app_versions
import foolscap.logging.log
from allmydata import get_package_versions, get_package_versions_string
from allmydata.util import log
from allmydata.util import fileutil, iputil
from allmydata.util.assertutil import _assert
from allmydata.util.fileutil import abspath_expanduser_unicode
from allmydata.util.encodingutil import get_filesystem_encoding, quote_output
from allmydata.util import configutil

# Add our application versions to the data that Foolscap's LogPublisher
# reports.
for thing, things_version in get_package_versions().iteritems():
    app_versions.add_version(thing, str(things_version))

# group 1 will be addr (dotted quad string), group 3 if any will be portnum (string)
ADDR_RE=re.compile("^([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*)(:([1-9][0-9]*))?$")


def formatTimeTahoeStyle(self, when):
    # we want UTC timestamps that look like:
    #  2007-10-12 00:26:28.566Z [Client] rnp752lz: 'client running'
    d = datetime.datetime.utcfromtimestamp(when)
    if d.microsecond:
        return d.isoformat(" ")[:-3]+"Z"
    else:
        return d.isoformat(" ") + ".000Z"
Beispiel #7
0
    def test_client_no_noise(self):
        self.skip_if_cannot_daemonize()

        from allmydata import get_package_versions, normalized_version
        twisted_ver = get_package_versions()['Twisted']

        if not normalized_version(twisted_ver) >= normalized_version('9.0.0'):
            raise unittest.SkipTest(
                "We pass this test only with Twisted >= v9.0.0")

        basedir = self.workdir("test_client_no_noise")
        c1 = os.path.join(basedir, "c1")
        HOTLINE_FILE = os.path.join(c1, "suicide_prevention_hotline")
        TWISTD_PID_FILE = os.path.join(c1, "twistd.pid")
        PORTNUM_FILE = os.path.join(c1, "client.port")

        d = self.run_bintahoe(
            ["--quiet", "create-client", "--basedir", c1, "--webport", "0"])

        def _cb(res):
            out, err, rc_or_sig = res
            errstr = "cc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
            assert rc_or_sig == 0, errstr
            self.failUnlessEqual(rc_or_sig, 0)

            # By writing this file, we get two minutes before the client will exit. This ensures
            # that even if the 'stop' command doesn't work (and the test fails), the client should
            # still terminate.
            fileutil.write(HOTLINE_FILE, "")
            # now it's safe to start the node

        d.addCallback(_cb)

        def _start(res):
            return self.run_bintahoe(["--quiet", "start", c1])

        d.addCallback(_start)

        def _cb2(res):
            out, err, rc_or_sig = res
            errstr = "cc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
            fileutil.write(HOTLINE_FILE, "")
            self.failUnlessEqual(rc_or_sig, 0, errstr)
            self.failUnlessEqual(
                out, "", errstr)  # If you emit noise, you fail this test.
            errlines = err.split("\n")
            self.failIf([
                True for line in errlines
                if (line != "" and "UserWarning: Unbuilt egg for setuptools"
                    not in line and
                    "from pkg_resources import load_entry_point" not in line)
            ], errstr)
            if err != "":
                raise unittest.SkipTest(
                    "This test is known not to pass on Ubuntu Lucid; see #1235."
                )

            # the parent (twistd) has exited. However, twistd writes the pid
            # from the child, not the parent, so we can't expect twistd.pid
            # to exist quite yet.

            # the node is running, but it might not have made it past the
            # first reactor turn yet, and if we kill it too early, it won't
            # remove the twistd.pid file. So wait until it does something
            # that we know it won't do until after the first turn.

        d.addCallback(_cb2)

        def _node_has_started():
            return os.path.exists(PORTNUM_FILE)

        d.addCallback(lambda res: self.poll(_node_has_started))

        # now we can kill it. TODO: On a slow machine, the node might kill
        # itself before we get a chance to, especially if spawning the
        # 'tahoe stop' command takes a while.
        def _stop(res):
            self.failUnless(os.path.exists(TWISTD_PID_FILE),
                            (TWISTD_PID_FILE,
                             os.listdir(os.path.dirname(TWISTD_PID_FILE))))
            return self.run_bintahoe(["--quiet", "stop", c1])

        d.addCallback(_stop)
        d.addBoth(self._remove, HOTLINE_FILE)
        return d
Beispiel #8
0
    def test_client_no_noise(self):
        self.skip_if_cannot_daemonize()

        from allmydata import get_package_versions, normalized_version
        twisted_ver = get_package_versions()['Twisted']

        if not normalized_version(twisted_ver) >= normalized_version('9.0.0'):
            raise unittest.SkipTest(
                "We pass this test only with Twisted >= v9.0.0")

        basedir = self.workdir("test_client_no_noise")
        c1 = os.path.join(basedir, "c1")
        HOTLINE_FILE = os.path.join(c1, "suicide_prevention_hotline")
        TWISTD_PID_FILE = os.path.join(c1, "twistd.pid")
        PORTNUM_FILE = os.path.join(c1, "client.port")

        d = self.run_bintahoe(
            ["--quiet", "create-client", "--basedir", c1, "--webport", "0"])

        def _cb(res):
            out, err, rc_or_sig = res
            errstr = "cc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
            assert rc_or_sig == 0, errstr
            self.failUnlessEqual(rc_or_sig, 0)

            # By writing this file, we get two minutes before the client will exit. This ensures
            # that even if the 'stop' command doesn't work (and the test fails), the client should
            # still terminate.
            fileutil.write(HOTLINE_FILE, "")
            # now it's safe to start the node

        d.addCallback(_cb)

        def _start(res):
            return self.run_bintahoe(["--quiet", "start", c1])

        d.addCallback(_start)

        def _cb2(res):
            out, err, rc_or_sig = res
            errstr = "cc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
            fileutil.write(HOTLINE_FILE, "")
            self.failUnlessEqual(rc_or_sig, 0, errstr)
            self.failUnlessEqual(
                out, "", errstr)  # If you emit noise, you fail this test.
            errlines = err.split("\n")
            self.failIf([
                True for line in errlines
                if (line != "" and "UserWarning: Unbuilt egg for setuptools"
                    not in line and
                    "from pkg_resources import load_entry_point" not in line)
            ], errstr)
            if err != "":
                raise unittest.SkipTest(
                    "This test is known not to pass on Ubuntu Lucid; see #1235."
                )

            # the parent (twistd) has exited. However, twistd writes the pid
            # from the child, not the parent, so we can't expect twistd.pid
            # to exist quite yet.

            # the node is running, but it might not have made it past the
            # first reactor turn yet, and if we kill it too early, it won't
            # remove the twistd.pid file. So wait until it does something
            # that we know it won't do until after the first turn.

        d.addCallback(_cb2)

        def _node_has_started():
            return os.path.exists(PORTNUM_FILE)

        d.addCallback(lambda res: self.poll(_node_has_started))

        # now we can kill it. TODO: On a slow machine, the node might kill
        # itself before we get a chance to, especially if spawning the
        # 'tahoe stop' command takes a while.
        def _stop(res):
            self.failUnless(
                os.path.exists(TWISTD_PID_FILE),
                (TWISTD_PID_FILE, os.listdir(
                    os.path.dirname(TWISTD_PID_FILE))))
            return self.run_bintahoe(["--quiet", "stop", c1])

        d.addCallback(_stop)
        d.addBoth(self._remove, HOTLINE_FILE)
        return d