From: Shyam Saini <mayhs11saini@gmail.com>
To: Arturo Borrero Gonzalez <arturo@netfilter.org>
Cc: Netfilter Development Mailing list <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH V2] tests: json: Add test cases for json format
Date: Thu, 24 Aug 2017 17:38:57 +0530 [thread overview]
Message-ID: <CAOfkYf5CDMihfi9tkUQcOv5eFMDFi2nfr012QwTy-DJ4fy65Zw@mail.gmail.com> (raw)
In-Reply-To: <CAOkSjBhaLkRbVFo9TENJ=tKWfOw3Hvcmx+Brp9vU0AoryZiwGA@mail.gmail.com>
>
> > These test cases can be used to test upcoming "import json" command.
> >
> > Here is the short description of the files:
> > all_ruleset_list -> contains list of all the individual rules
>
> Wait. You are generating the JSON files from this ruleset, right?
>
yes.
>
> Then, why not simplify the tests by:
>
> * load a ruleset model (your all_ruleset_list file)
> * export it in JSON format (nft export json)
> * import it again in JSON format (nft import)
> * comparte resulting ruleset (nft list ruleset) with the original
> file (all_ruleset_list file)
>
> This way we test in the same run all the JSON code paths.
>
> You will need a simple testcase, like this:
>
> === 8< ===
> #!/bin/bash
> set -e
> TMP=$(mktmp)
> RULESET="table ip { ... } "
> echo $RULESET > $TMP
> $NFT -f $TMP
> $NFT export json > $TMP
> cat $TMP | $NFT import json)
> RESULT=$($NFT list ruleset)
> # compare result and initial ruleset, if fail show diff
> === 8< ===
>
> That was quick and dirty code for you to get the idea.
> Please follow the example of other testcases [0] to compare ruleset,
> create tempfiles and so on.
>
One issue with this approach, incase of set rules
nft will throw this error
"Error: Could not process rule: File exists"
So, i need to flush ruleset before import them with json.
Is it okay?
>
> Please, if possible, try to add a testcase that is [OK]. Not sure what
> is wrong with the dup statement.
>
I tried, but they always throw the same error.
Shouldn't we keep them in testsuite so that we know that these set of
rules needs to be fixed.
>
> [0] http://git.netfilter.org/nftables/tree/tests/shell/testcases/netns/0001nft-f_0
Thanks,
Shyam
next prev parent reply other threads:[~2017-08-24 12:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 8:49 [PATCH V2] tests: json: Add test cases for json format Shyam Saini
2017-08-24 9:56 ` Arturo Borrero Gonzalez
2017-08-24 12:08 ` Shyam Saini [this message]
2017-08-24 13:00 ` Arturo Borrero Gonzalez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOfkYf5CDMihfi9tkUQcOv5eFMDFi2nfr012QwTy-DJ4fy65Zw@mail.gmail.com \
--to=mayhs11saini@gmail.com \
--cc=arturo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).