Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id BB2B36329AA for ; Fri, 11 Dec 2009 18:19:18 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 50344-07 for ; Fri, 11 Dec 2009 22:19:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f216.google.com (mail-ew0-f216.google.com [209.85.219.216]) by mail.postgresql.org (Postfix) with ESMTP id 0E18B6335AF for ; Fri, 11 Dec 2009 18:19:06 -0400 (AST) Received: by ewy8 with SMTP id 8so1596072ewy.35 for ; Fri, 11 Dec 2009 14:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=yNTE/8kFObU/7edV+UP+rZ7d+t6DMqXwRs7Yyb2mR74=; b=qBE2ExQ2DezNeHkFVPJnaH1eYXVgr1+DQX8myjvDcHDl3dwhUBNtz35cvbNwm6kkyW nQrKHQfB+g98YiAU7tuubY+oJhEMkuryr5lWQuSj/4/xfsodJIT9HDxCmDHiPAd1nvHI sODYeFDHUfU72FwCOZwJNLMIgkncPP9ioELoM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=KaoAqHpvJh54SlqurxoZlQxEHyRlVZdxdRGPjdWjSK4Sw8hXvAVsMG/UA93CxaLTPx wip4oIKQ6EgI5v3jehxE8Dee2k0eDBoN/OgRJHTea9tYyN9PS0RIN3b/HCwUvUHfEARe 9yOg16dPomHtROxCnvx8Zx2mQyIIPdMdQe4hI= MIME-Version: 1.0 Received: by 10.216.88.78 with SMTP id z56mr788651wee.37.1260569945111; Fri, 11 Dec 2009 14:19:05 -0800 (PST) In-Reply-To: References: Date: Fri, 11 Dec 2009 15:19:05 -0700 Message-ID: Subject: Re: 8.4.1 ubuntu karmic slow createdb From: Scott Marlowe To: Scott Carey Cc: Nikolas Everett , "jd@commandprompt.com" , Andres Freund , "pgsql-performance@postgresql.org" , Michael Clemmons Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.523 tagged_above=-10 required=5 tests=AWL=0.076, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/159 X-Sequence-Number: 36773 On Fri, Dec 11, 2009 at 3:12 PM, Scott Carey wrot= e: > > On 12/11/09 1:57 PM, "Scott Marlowe" wrote: > >> >> This is my big issue. =A0dropping / creating databases for unit tests is >> overkill. =A0Running any DDL at all for a unit test seems wrong to me >> too. =A0Insert a row if you need it, MAYBE. =A0Unit tests should work wi= th >> a test database that HAS the structure and database already in place. >> >> What happens if your unit tests get lose in production and drop a >> database, or a table. =A0Not good. >> > > Production should not have a db with the same username/pw combination as = dev > boxes and unit tests . . . > > Unfortunately, unit-like (often more than a 'unit') tests can't always re= ly > on a test db being already set up. =A0If one leaves any cruft around, it = might > break later tests later on non-deterministically. =A0Automated tests that > insert data are absolutely required somewhere if the application inserts > data. > > The best way to do this in postgres is to create a template database from > scratch with whatever DDL is needed at the start of the run, and then cre= ate > and drop db's as copies of that template per test or test suite. Debateable. Last job we had 44k or so unit tests, and we gave each dev their own db made from the main qa / unit testing db that they could refresh at any time, and run the unit tests locally before committing code. Actual failures like the one you mention were very rare because of this approach. A simple ant refresh-db and they were ready to test their code before committing it to the continuous testing farm.