Ticket #1503: check_memory.diff

File check_memory.diff, 5.1 KB (added by warner, at 2011-08-25T20:14:52Z)

fix check_memory.py

  • src/allmydata/test/check_memory.py

    diff --git a/src/allmydata/test/check_memory.py b/src/allmydata/test/check_memory.py
    index 3ef32f9..fdce601 100644
    a b class SystemFramework(pollmixin.PollMixin): 
    184184        for i in range(self.numnodes):
    185185            nodedir = os.path.join(self.testdir, "node%d" % i)
    186186            os.mkdir(nodedir)
    187             f = open(os.path.join(nodedir, "introducer.furl"), "w")
    188             f.write(self.introducer_furl)
    189             f.close()
     187            f = open(os.path.join(nodedir, "tahoe.cfg"), "w")
     188            f.write("[client]\n"
     189                    "introducer.furl = %s\n"
     190                    "shares.happy = 1\n"
     191                    "[storage]\n"
     192                    % (self.introducer_furl,))
    190193            # the only tests for which we want the internal nodes to actually
    191194            # retain shares are the ones where somebody's going to download
    192195            # them.
    class SystemFramework(pollmixin.PollMixin): 
    197200                # for these tests, we tell the storage servers to pretend to
    198201                # accept shares, but really just throw them out, since we're
    199202                # only testing upload and not download.
    200                 f = open(os.path.join(nodedir, "debug_no_storage"), "w")
    201                 f.write("no_storage\n")
    202                 f.close()
     203                f.write("debug_discard = true\n")
    203204            if self.mode in ("receive",):
    204205                # for this mode, the client-under-test gets all the shares,
    205206                # so our internal nodes can refuse requests
    206                 f = open(os.path.join(nodedir, "readonly_storage"), "w")
    207                 f.write("\n")
    208                 f.close()
     207                f.write("readonly = true\n")
     208            f.close()
    209209            c = self.add_service(client.Client(basedir=nodedir))
    210210            self.nodes.append(c)
    211211        # the peers will start running, eventually they will connect to each
    this file are ignored. 
    232232        clientdir = self.clientdir = os.path.join(self.testdir, u"client")
    233233        clientdir_str = clientdir.encode(get_filesystem_encoding())
    234234        quiet = StringIO()
    235         create_node.create_node(clientdir, {}, out=quiet)
     235        create_node.create_node({'basedir': clientdir}, out=quiet)
    236236        log.msg("DONE MAKING CLIENT")
    237         f = open(os.path.join(clientdir, "introducer.furl"), "w")
    238         f.write(self.introducer_furl + "\n")
    239         f.close()
    240 
     237        # now replace tahoe.cfg
    241238        # set webport=0 and then ask the node what port it picked.
    242         f = open(os.path.join(clientdir, "webport"), "w")
    243         f.write("tcp:0:interface=127.0.0.1\n")
    244         f.close()
     239        f = open(os.path.join(clientdir, "tahoe.cfg"), "w")
     240        f.write("[node]\n"
     241                "web.port = tcp:0:interface=127.0.0.1\n"
     242                "[client]\n"
     243                "introducer.furl = %s\n"
     244                "shares.happy = 1\n"
     245                "[storage]\n"
     246                % (self.introducer_furl,))
    245247
    246248        if self.mode in ("upload-self", "receive"):
    247249            # accept and store shares, to trigger the memory consumption bugs
    248250            pass
    249251        else:
    250252            # don't accept any shares
    251             f = open(os.path.join(clientdir, "readonly_storage"), "w")
    252             f.write("true\n")
    253             f.close()
     253            f.write("readonly = true\n")
    254254            ## also, if we do receive any shares, throw them away
    255             #f = open(os.path.join(clientdir, "debug_no_storage"), "w")
    256             #f.write("no_storage\n")
    257             #f.close()
     255            #f.write("debug_discard = true")
    258256        if self.mode == "upload-self":
    259257            pass
     258        f.close()
    260259        self.keepalive_file = os.path.join(clientdir,
    261260                                           "suicide_prevention_hotline")
    262261        # now start updating the mtime.
    this file are ignored. 
    379378        if self.mode in ("upload", "upload-self"):
    380379            files[name] = self.create_data(name, size)
    381380            d = self.control_rref.callRemote("upload_from_file_to_uri",
    382                                              files[name], convergence="check-memory convergence string")
     381                                             files[name].encode("utf-8"),
     382                                             convergence="check-memory")
    383383            def _done(uri):
    384384                os.remove(files[name])
    385385                del files[name]
    this file are ignored. 
    403403            files[name] = self.create_data(name, size)
    404404            u = self.nodes[0].getServiceNamed("uploader")
    405405            d = self.nodes[0].debug_wait_for_client_connections(self.numnodes+1)
    406             d.addCallback(lambda res: u.upload(upload.FileName(files[name], convergence="check-memory convergence string")))
     406            d.addCallback(lambda res:
     407                          u.upload(upload.FileName(files[name],
     408                                                   convergence="check-memory")))
    407409            d.addCallback(lambda results: results.uri)
    408410        else:
    409411            raise ValueError("unknown mode=%s" % self.mode)