Пример #1
0
        def _cb(res):
            from allmydata import normalized_version

            out, err, rc_or_sig = res
            self.failUnlessEqual(rc_or_sig, 0, str(res))

            # Fail unless the __appname__ package is *this* version *and*
            # was loaded from *this* source directory.

            required_verstr = str(allmydata.__version__)

            self.failIfEqual(required_verstr, "unknown",
                             "We don't know our version, because this distribution didn't come "
                             "with a _version.py and 'setup.py update_version' hasn't been run.")

            srcdir = os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
            info = repr((res, allmydata.__appname__, required_verstr, srcdir))

            appverpath = out.split(')')[0]
            (appverfull, path) = appverpath.split('] (')
            (appver, comment) = appverfull.split(' [')
            (branch, full_version) = comment.split(': ')
            (app, ver) = appver.split(': ')

            self.failUnlessEqual(app, allmydata.__appname__, info)
            norm_ver = normalized_version(ver)
            norm_required = normalized_version(required_verstr)
            self.failUnlessEqual(norm_ver, norm_required, info)
            self.failUnlessEqual(path, srcdir, info)
            self.failUnlessEqual(branch, allmydata.branch)
            self.failUnlessEqual(full_version, allmydata.full_version)
Пример #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
Пример #3
0
        def _cb(res):
            from allmydata import normalized_version

            out, err, rc_or_sig = res
            self.failUnlessEqual(rc_or_sig, 0, str(res))

            # Fail unless the __appname__ package is *this* version *and*
            # was loaded from *this* source directory.

            required_verstr = str(allmydata.__version__)

            self.failIfEqual(required_verstr, "unknown",
                             "We don't know our version, because this distribution didn't come "
                             "with a _version.py and 'setup.py update_version' hasn't been run.")

            srcdir = os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
            info = repr((res, allmydata.__appname__, required_verstr, srcdir))

            appverpath = out.split(')')[0]
            (appverfull, path) = appverpath.split('] (')
            (appver, comment) = appverfull.split(' [')
            (branch, full_version) = comment.split(': ')
            (app, ver) = appver.split(': ')

            self.failUnlessEqual(app, allmydata.__appname__, info)
            norm_ver = normalized_version(ver)
            norm_required = normalized_version(required_verstr)
            self.failUnlessEqual(norm_ver, norm_required, info)
            self.failUnlessEqual(path, srcdir, info)
            self.failUnlessEqual(branch, allmydata.branch)
            self.failUnlessEqual(full_version, allmydata.full_version)
Пример #4
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
Пример #5
0
        def _cb(res):
            from allmydata import normalized_version

            out, err, rc_or_sig = res
            self.failUnlessEqual(rc_or_sig, 0, str(res))

            # Fail unless the allmydata-tahoe package is *this* version *and*
            # was loaded from *this* source directory.

            required_verstr = str(allmydata.__version__)

            self.failIfEqual(
                required_verstr, "unknown",
                "We don't know our version, because this distribution didn't come "
                "with a _version.py and 'setup.py darcsver' hasn't been run.")

            srcdir = os.path.dirname(
                os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
            info = (res, allmydata.__appname__, required_verstr, srcdir)

            appverpath = out.split(')')[0]
            (appver, path) = appverpath.split(' (')
            (app, ver) = appver.split(': ')

            self.failUnlessEqual(app, allmydata.__appname__, info)
            self.failUnlessEqual(normalized_version(ver),
                                 normalized_version(required_verstr), info)
            self.failUnlessEqual(path, srcdir, info)
Пример #6
0
        def _cb(res):
            from allmydata import normalized_version

            out, err, rc_or_sig = res
            self.failUnlessEqual(rc_or_sig, 0, str(res))

            # Fail unless the allmydata-tahoe package is *this* version *and*
            # was loaded from *this* source directory.

            required_verstr = str(allmydata.__version__)

            self.failIfEqual(required_verstr, "unknown",
                             "We don't know our version, because this distribution didn't come "
                             "with a _version.py and 'setup.py darcsver' hasn't been run.")

            srcdir = os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
            info = (res, allmydata.__appname__, required_verstr, srcdir)

            appverpath = out.split(')')[0]
            (appver, path) = appverpath.split(' (')
            (app, ver) = appver.split(': ')

            self.failUnlessEqual(app, allmydata.__appname__, info)
            self.failUnlessEqual(normalized_version(ver), normalized_version(required_verstr), info)
            self.failUnlessEqual(path, srcdir, info)
Пример #7
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()
Пример #8
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()
Пример #9
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
Пример #10
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