From nobody Mon Dec 15 03:19:52 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 206.53.239.180 is neither permitted nor denied by domain of freelists.org) client-ip=206.53.239.180; envelope-from=patchew-devel-bounce@freelists.org; helo=turing.freelists.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=none (zoho.com: 206.53.239.180 is neither permitted nor denied by domain of freelists.org) smtp.mailfrom=patchew-devel-bounce@freelists.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from turing.freelists.org (turing.freelists.org [206.53.239.180]) by mx.zohomail.com with SMTPS id 1520412397379927.8949450077932; Wed, 7 Mar 2018 00:46:37 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id C7ABB26352; Wed, 7 Mar 2018 03:46:36 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R4TINhDCtDB4; Wed, 7 Mar 2018 03:46:36 -0500 (EST) Received: from turing.freelists.org (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 6DFFD260D3; Wed, 7 Mar 2018 03:46:36 -0500 (EST) Received: with ECARTIS (v1.0.0; list patchew-devel); Wed, 07 Mar 2018 03:46:36 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4348326352 for ; Wed, 7 Mar 2018 03:46:36 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UPtJ1lniXNbV for ; Wed, 7 Mar 2018 03:46:36 -0500 (EST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 19C5B260D3 for ; Wed, 7 Mar 2018 03:46:36 -0500 (EST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B01B64023B98 for ; Wed, 7 Mar 2018 08:46:35 +0000 (UTC) Received: from lemon.usersys.redhat.com (ovpn-12-131.pek2.redhat.com [10.72.12.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 277DF1C716; Wed, 7 Mar 2018 08:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org; s=turing; t=1520412396; bh=3divtXa8x5Robhh84g0g3JeSYeH4lDQmD3lAtPxxIcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:List-help: List-unsubscribe:List-Id:List-subscribe:List-owner:List-post: List-archive; b=afm1p09LIa7SofwuhVkJ5h9kmkr+oPeChbHNj8giWSsTJKZnkPVPjCYnoYBCTCR9w alqvzSJ4j224aBdksePDMrMjFdiwx3B0j+/I/hDHZ/oggoq37PbUsOz4r/ZXVRDvw+ gOBXFUKBtXz4UsLNNh1ANS3pocolxDubXHol7xF4= X-Virus-Scanned: Debian amavisd-new at turing.freelists.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org; s=turing; t=1520412396; bh=3divtXa8x5Robhh84g0g3JeSYeH4lDQmD3lAtPxxIcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:List-help: List-unsubscribe:List-Id:List-subscribe:List-owner:List-post: List-archive; b=afm1p09LIa7SofwuhVkJ5h9kmkr+oPeChbHNj8giWSsTJKZnkPVPjCYnoYBCTCR9w alqvzSJ4j224aBdksePDMrMjFdiwx3B0j+/I/hDHZ/oggoq37PbUsOz4r/ZXVRDvw+ gOBXFUKBtXz4UsLNNh1ANS3pocolxDubXHol7xF4= X-Original-To: patchew-devel@freelists.org X-Virus-Scanned: Debian amavisd-new at turing.freelists.org From: Fam Zheng To: patchew-devel@freelists.org Cc: pbonzini@redhat.com Subject: [patchew-devel] [PATCH 7/7] tester: Test multiple projects Date: Wed, 7 Mar 2018 16:46:09 +0800 Message-Id: <20180307084609.8515-8-famz@redhat.com> In-Reply-To: <20180307084609.8515-1-famz@redhat.com> References: <20180307084609.8515-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 08:46:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Mar 2018 08:46:35 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'famz@redhat.com' RCPT:'' X-archive-position: 91 X-ecartis-version: Ecartis v1.0.0 Sender: patchew-devel-bounce@freelists.org Errors-to: patchew-devel-bounce@freelists.org X-original-sender: famz@redhat.com Precedence: normal Reply-To: patchew-devel@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: patchew-devel X-List-ID: patchew-devel List-subscribe: List-owner: List-post: List-archive: X-list: patchew-devel X-ZohoMail-DKIM: pass (identity @freelists.org) X-ZohoMail-Owner: <20180307084609.8515-8-famz@redhat.com>+zmo_0_patchew-devel-bounce@freelists.org X-ZohoMail: RDKM_0 RSF_4 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Allow project list in --project option, and round-robin test them one by one. Signed-off-by: Fam Zheng --- patchew-cli | 50 +++++++++++++++++++++---------------- tests/test_testing.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++-= ---- 2 files changed, 92 insertions(+), 27 deletions(-) diff --git a/patchew-cli b/patchew-cli index 52329e1..51a89c5 100755 --- a/patchew-cli +++ b/patchew-cli @@ -449,13 +449,15 @@ class TesterCommand(SubCommand): parser.add_argument("--singleton", "-S", action=3D"store_true", help=3D"quit if another singleton mode tester = is running") parser.add_argument("--project", "-p", required=3DTrue, - help=3D"which project to run test") + help=3D"comma separated project names to run t= est") parser.add_argument("--name", "-n", help=3D"name of this tester (default is the lo= gged in username)") parser.add_argument("--num", "-N", type=3Dint, default=3D0, help=3D"max number of tests to run") parser.add_argument("--no-clean-up", action=3D"store_true", help=3D"skip cleaning up after finish") + parser.add_argument("--no-wait", action=3D"store_true", + help=3D"don't wait if nothing to test") =20 def _make_script(self, wd, name, content): filename =3D os.path.join(wd, name) @@ -484,17 +486,18 @@ class TesterCommand(SubCommand): pass return ret =20 - def test_one(self, args, capabilities): - r =3D self.api_do("testing-get", project=3Dargs.project, tester=3D= args.name, - capabilities=3Dcapabilities) + def test_one(self, name, project, no_clean_up, capabilities): + r =3D self.api_do("testing-get", project=3Dproject, tester=3Dname, + capabilities=3Dcapabilities) if not r: return False print("Running test '%s'" % r["test"]["name"]) - if r["project"] !=3D args.project: + if r["project"] !=3D project: return =20 wd =3D tempfile.mkdtemp(prefix=3D"patchew-tester-tmp-", dir=3D"/va= r/tmp/") print(" Workdir:", wd) + print(" Project:", r["project"]) print(" Identity:", str(r["identity"])) logf =3D open(os.path.join(wd, "log"), "w+", encoding=3D"utf-8", errors=3D"ignore") @@ -565,7 +568,7 @@ class TesterCommand(SubCommand): self.api_do("testing-report", project=3Dr["project"], identity=3Dr["identity"], test=3Dr["test"]["name"], - tester=3Dargs.name, + tester=3Dname, head=3Dr["head"], base=3Dr["base"], passed=3Dpassed, @@ -573,7 +576,7 @@ class TesterCommand(SubCommand): is_timeout=3Dis_timeout) logf.close() finally: - if not args.no_clean_up: + if not no_clean_up: shutil.rmtree(wd) return True =20 @@ -591,25 +594,30 @@ class TesterCommand(SubCommand): if args.singleton: self._check_singleton() subprocess.check_output(["git", "version"]) - rest =3D False count =3D 0 cap_refresh =3D 10 + projects =3D [x.strip() for x in args.project.split(",") if len(x.= strip())] + if not projects: + raise Exception("No project specified") + capabilities =3D {} while True: - if count % cap_refresh =3D=3D 0: - capabilities =3D self._refresh_capabilities(args.project, - args.name) - count +=3D 1 - if self.test_one(args, capabilities=3Dcapabilities): + progress =3D False + for p in projects: + if count % cap_refresh =3D=3D 0: + for sp in projects: + capabilities[sp] =3D self._refresh_capabilities(sp= , args.name) + if self.test_one(args.name, p, args.no_clean_up, + capabilities=3Dcapabilities[p]): + progress =3D True + count +=3D 1 if count =3D=3D args.num: - break - rest =3D False - continue - if count =3D=3D args.num: - break - if not rest: + return 0 + if not progress: + if args.no_wait: + print("Nothing to test") + return 0 print("No more work, having a rest...") - rest =3D True - time.sleep(60) + time.sleep(60) return 0 =20 class ApplyFailedException(Exception): diff --git a/tests/test_testing.py b/tests/test_testing.py index 300201b..a68e237 100755 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -11,10 +11,20 @@ import sys import os import datetime +import subprocess sys.path.append(os.path.dirname(__file__)) from patchewtest import PatchewTestCase, main from api.models import Message, Project =20 +def create_test(project, name): + prefix =3D "testing.tests." + name + "." + project.set_property(prefix + "timeout", 3600) + project.set_property(prefix + "enabled", True) + project.set_property(prefix + "script", "#!/bin/bash\ntrue") + project.set_property(prefix + "requirements", "") + project.set_property(prefix + "users", "") + project.set_property(prefix + "tester", "") + class TestingTest(PatchewTestCase): =20 def setUp(self): @@ -22,12 +32,7 @@ class TestingTest(PatchewTestCase): self.p =3D self.add_project("QEMU", "qemu-devel@nongnu.org") self.PROJECT_BASE =3D '%sprojects/%d/' % (self.REST_BASE, self.p.i= d) =20 - self.p.set_property("testing.tests.a.timeout", 3600) - self.p.set_property("testing.tests.a.enabled", True) - self.p.set_property("testing.tests.a.script", "#!/bin/bash\ntrue") - self.p.set_property("testing.tests.a.requirements", "") - self.p.set_property("testing.tests.a.users", "") - self.p.set_property("testing.tests.a.tester", "") + create_test(self.p, "a") =20 self.cli_login() self.cli_import('0001-simple-patch.mbox.gz') @@ -85,5 +90,57 @@ class TestingTest(PatchewTestCase): self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'sorry no good') =20 +class TesterTest(PatchewTestCase): + + def setUp(self): + self.create_superuser() + + p1 =3D self.add_project("QEMU", "qemu-devel@nongnu.org") + create_test(p1, "a") + p2 =3D self.add_project("UMEQ", "qemu-devel@nongnu.org") + create_test(p2, "b") + + self.cli_login() + self.cli_import('0001-simple-patch.mbox.gz') + self.cli_logout() + + self.repo =3D os.path.join(self.get_tmpdir(), "repo") + os.mkdir(self.repo) + subprocess.check_output(["git", "init"], cwd=3Dself.repo) + for f in ["foo", "bar"]: + subprocess.check_output(["touch", f], cwd=3Dself.repo) + subprocess.check_output(["git", "add", f], cwd=3Dself.repo) + subprocess.check_output(["git", "commit", "-m", "add " + f], + cwd=3Dself.repo) + base =3D subprocess.check_output(["git", "rev-parse", "HEAD~1"], + cwd=3Dself.repo).decode() + subprocess.check_output(["git", "tag", "test"], cwd=3Dself.repo) + + for msg in Message.objects.all(): + msg.set_property("git.repo", self.repo) + msg.set_property("git.tag", "test") + msg.set_property("git.base", base) + + def test_tester(self): + self.cli_login() + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + "--no-wait"]) + self.assertIn("Project: QEMU\n", out) + self.assertIn("Project: UMEQ\n", out) + self.cli_logout() + + def test_tester_single(self): + self.cli_login() + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + "--no-wait", "-N", "1"]) + self.assertIn("Project: QEMU\n", out) + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + "--no-wait", "-N", "1"]) + self.assertIn("Project: UMEQ\n", out) + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + "--no-wait", "-N", "1"]) + self.assertIn("Nothing to test", out) + self.cli_logout() + if __name__ =3D=3D '__main__': main() --=20 2.14.3