Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4401722pxj; Tue, 25 May 2021 07:14:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfAYqRtqYzohz7jsq86xAwKQdtj5hKyx6vYIA11iu2ZE46qkym2VC0EzwRTWcd01p7F9+e X-Received: by 2002:a17:906:f996:: with SMTP id li22mr28710378ejb.255.1621952044612; Tue, 25 May 2021 07:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621952044; cv=none; d=google.com; s=arc-20160816; b=RNAc74DQDyS8oofkeiWkxkyu5Y+QevytVWRtSYs1gyuBWNl6lnV/kDeol9J/hwrvv7 hcajRtPNewbocBYAf2Jc7k48rJFMqiO/jZF0cgqYdiPCp1omqRbM+kNKjetLqQC1I5ri OUMRm5wmkQsiY0OfliG1SfCmfAZ25v8706YOmVdAiqzajwfaOD7OYbkrb++YA1C5d98A wTXQPwB5mtXZv7EzMa+85yfoUt46BZe1C3LWFR2sYr8emwLfKbDoneHugQRJv6DG5eam BMYDLxXT6vTYu0R3YJV+bVhGKpOAR65c9AZa0FOVVTQG+/h6QaOGvi2x28MhiU0l9+Pw wPDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yNekuy0qSqT8bjyk6vSVhBPubH1Sm7iFzxVKEvV6/wo=; b=CY6Rnd4dirtEDIbP0PYczr2auBWJu6YHF+ZgXfKiy6me/aHvFd3B+6gRh5x1qX+i3K RfDKhRB9/MqVrjNKWPvPFMMxgXIF7Lpbe8pI6FaT6qNQt/7NF5U/l4XpdBU+Rgr32Z/q UyYhp3Wr/eZzBMap1ACpOJUSB/06OCBka6qWfII9BFGaQ6QzwnXIqcBeqRkl+KJ40sQ3 8KtR22C9PWHsVp8erw+e1gHZFYHbnta95gkXLSe6aFc9muI+SZljN3YOU2vX2OLrHZc6 /3WNCfA3bYSLP4QQJDd/8Wz1zRKYI+JFZLHJezOXHeJblbD0QDmCBZ9FRS0580SGCUTm d7Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yv4cy1Nj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si18048335ejo.341.2021.05.25.07.13.33; Tue, 25 May 2021 07:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Yv4cy1Nj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233441AbhEYOMF (ORCPT + 99 others); Tue, 25 May 2021 10:12:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32519 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbhEYOMF (ORCPT ); Tue, 25 May 2021 10:12:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621951835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yNekuy0qSqT8bjyk6vSVhBPubH1Sm7iFzxVKEvV6/wo=; b=Yv4cy1Nj7zvDszixISUkz2UrBq5suXpQpeXX1/0dWGtI+KE9Br2LELep1zggC72fhuGIzK rZadWVCXKC87eceqIi+IDzyySqG/hZ3WNOGzHDLZF85lj8u1lB1qOpm36AjKxhXB6HJzE0 SEWZot90vJ6/4uNFjBQnUs5cusXtc5Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-jZH_RPysN3WmTJuUGxIX_Q-1; Tue, 25 May 2021 10:10:33 -0400 X-MC-Unique: jZH_RPysN3WmTJuUGxIX_Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 268EB107ACF3; Tue, 25 May 2021 14:10:32 +0000 (UTC) Received: from pick.fieldses.org (ovpn-117-74.rdu2.redhat.com [10.10.117.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC22C5C1B4; Tue, 25 May 2021 14:10:31 +0000 (UTC) Received: by pick.fieldses.org (Postfix, from userid 2815) id 2AF76120639; Tue, 25 May 2021 10:10:31 -0400 (EDT) Date: Tue, 25 May 2021 10:10:31 -0400 From: "J. Bruce Fields" To: Petr Vorel Cc: linux-nfs@vger.kernel.org, "Yong Sun (Sero)" Subject: Re: [PATCH pynfs 2/3] server: Allow to print JSON format Message-ID: References: <20210524144251.30196-1-pvorel@suse.cz> <20210524144251.30196-2-pvorel@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210524144251.30196-2-pvorel@suse.cz> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org I've got nothing against this, but I'm curious why you need it. --b. On Mon, May 24, 2021 at 04:42:50PM +0200, Petr Vorel wrote: > Signed-off-by: Petr Vorel > --- > nfs4.0/testserver.py | 7 ++++++- > nfs4.1/testmod.py | 40 +++++++++++++++++++++++++++++++++++++++- > nfs4.1/testserver.py | 6 +++++- > 3 files changed, 50 insertions(+), 3 deletions(-) > > diff --git a/nfs4.0/testserver.py b/nfs4.0/testserver.py > index 0ef010a..f2c4156 100755 > --- a/nfs4.0/testserver.py > +++ b/nfs4.0/testserver.py > @@ -85,6 +85,8 @@ def scan_options(p): > help="Skip final cleanup of test directory") > p.add_option("--outfile", "--out", default=None, metavar="FILE", > help="Store test results in FILE [%default]") > + p.add_option("--jsonout", "--json", default=None, metavar="FILE", > + help="Store test results in JSON format [%default]") > p.add_option("--xmlout", "--xml", default=None, metavar="FILE", > help="Store test results in xml format [%default]") > p.add_option("--debug_fail", action="store_true", default=False, > @@ -378,8 +380,11 @@ def main(): > if fail: > print("\nWARNING: could not clean testdir due to:\n%s\n" % err) > > - if opt.xmlout is not None: > + if opt.jsonout is not None: > + testmod.json_printresults(tests, opt.jsonout) > + elif opt.xmlout is not None: > testmod.xml_printresults(tests, opt.xmlout) > + > if nfail < 0: > sys.exit(3) > if nfail > 0: > diff --git a/nfs4.1/testmod.py b/nfs4.1/testmod.py > index e368853..4b4ed24 100644 > --- a/nfs4.1/testmod.py > +++ b/nfs4.1/testmod.py > @@ -13,6 +13,7 @@ import re > import sys > import time > from traceback import format_exception, print_exc > +import json > import xml.dom.minidom > import datetime > > @@ -467,6 +468,43 @@ def printresults(tests, opts, file=None): > (count[SKIP], count[FAIL], count[WARN], count[PASS]), file=file) > return count[FAIL] > > +def json_printresults(tests, file_name, suite='all'): > + with open(file_name, 'w') as fd: > + failures = 0 > + skipped = 0 > + total_time = 0 > + data = {} > + data["tests"] = len(tests) > + data["errors"] = 0 > + data["timestamp"] = str(datetime.datetime.now()) > + data["name"] = suite > + data["testcase"] = [] > + for t in tests: > + test = { > + "name": t.name, > + "classname": t.suite, > + "time": str(t.time_taken), > + } > + > + total_time += t.time_taken > + if t.result == TEST_FAIL: > + failures += 1 > + test["failure"] = { > + "message" : t.result.msg, > + "err" : ''.join(t.result.tb) > + } > + elif t.result == TEST_OMIT: > + skipped += 1 > + test["skipped"] = 1 > + > + data["testcase"].append(test) > + > + data["failures"] = failures > + data["skipped"] = skipped > + data["time"] = total_time > + > + fd.write(json.dumps(data, indent=4, sort_keys=True)) > + > def xml_printresults(tests, file_name, suite='all'): > with open(file_name, 'w') as fd: > failures = 0 > @@ -484,7 +522,7 @@ def xml_printresults(tests, file_name, suite='all'): > testsuite.appendChild(testcase) > testcase.setAttribute("name", t.name) > testcase.setAttribute("classname", t.suite) > - testcase.setAttribute("time", str(t.time_taken)) > + testcase.setAttribute("time", t.time_taken) > > total_time += t.time_taken > if t.result == TEST_FAIL: > diff --git a/nfs4.1/testserver.py b/nfs4.1/testserver.py > index d3c44c7..085f007 100755 > --- a/nfs4.1/testserver.py > +++ b/nfs4.1/testserver.py > @@ -68,6 +68,8 @@ def scan_options(p): > help="Skip final cleanup of test directory") > p.add_option("--outfile", "--out", default=None, metavar="FILE", > help="Store test results in FILE [%default]") > + p.add_option("--jsonout", "--json", default=None, metavar="FILE", > + help="Store test results in JSON format [%default]") > p.add_option("--xmlout", "--xml", default=None, metavar="FILE", > help="Store test results in xml format [%default]") > p.add_option("--debug_fail", action="store_true", default=False, > @@ -363,7 +365,9 @@ def main(): > if fail: > print("\nWARNING: could not clean testdir due to:\n%s\n" % err) > > - if opt.xmlout is not None: > + if opt.jsonout is not None: > + testmod.json_printresults(tests, opt.jsonout) > + elif opt.xmlout is not None: > testmod.xml_printresults(tests, opt.xmlout) > > if __name__ == "__main__": > -- > 2.31.1 >