Subject: [yang-doctors] XPath validation during development

From: Scott Mansfield <[email-masked]>
Date: Mon, 2 Mar 2020 19:24:12 +0000

Hello YANG Doctors!

I searched through the yang-doctors mailing list and didn't see an answer to
my question, so apologies if this has been covered before.

While development a YANG module, how is the best way to ensure that my XPath
(must etc) statements are syntactically and semantically correct?  Is the
best way to use YUMA123 or confd and build a set of test cases that can be
run on an instantiated model?  What do you do to test your XPath during
development of YANG?

Many thanks,

-scott.

---

From: Kent Watsen <[email-masked]>
Date: Mon, 2 Mar 2020 20:14:20 +0000

“Best” is hard to qualify, but perhaps best would be to 1) validate the YANG module(s) and 2) validate as many instance documents as it takes to have near 100% coverage; and doing both is these things with as many validation tools as possible.

I do this myself for all my models, though I only ave access to `yanglint` and `yangson`.  For drafts, my Makefiles do this for each build (pro-tip: the time setting up the automation pays for itself in the long run).

A couple additional comments:

1) `yangson` has an ability to output test-coverage statistics per https://github.com/CZ-NIC/yangson/issues/13 <https://github.com/CZ-NIC/yangson/issues/13>.

2) testing against multiple implementation has two benefits: a) some implementation catch things others don’t and b) sometimes inconsistencies arise that resolve by either i) one implementation being improved or ii) discovery of a clarification-issue with YANG (RFC 7950).  Example open clarification issues include how NP-containers and implicit-case statements are handled.  My modules are now constructed in such a way to be behaviorally-correct across a greater set of tools (e.g., avoid implicit-case statements, always use a presence-container if a descendent contains a “must” statement, etc.)

Kent

> On Mar 2, 2020, at 2:24 PM, Scott Mansfield <scott.mansfield=[email-masked]> wrote:
> 
> Hello YANG Doctors!
>  
> I searched through the yang-doctors mailing list and didn’t see an answer to my question, so apologies if this has been covered before.
>  
> While development a YANG module, how is the best way to ensure that my XPath (must etc) statements are syntactically and semantically correct?  Is the best way to use YUMA123 or confd and build a set of test cases that can be run on an instantiated model?  What do you do to test your XPath during development of YANG?
>  
> Many thanks,
> -scott.
> _______________________________________________
> yang-doctors mailing list
> [email-masked] <mailto:[email-masked]>
> https://www.ietf.org/mailman/listinfo/yang-doctors <https://www.ietf.org/mailman/listinfo/yang-doctors>

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 03 Mar 2020 18:57:18 +0100

Kent Watsen <[email-masked]> writes:

> 1) `yangson` has an ability to output test-coverage statistics per https://github.com/CZ-NIC/yangson/issues/13

The test module in Yangson distribution [1] contains a large number of XPath tests in the test_xpath function. It is possible to prepare similar tests for XPath expressions appearing in a specific data model.

Lada

[1] https://github.com/CZ-NIC/yangson/blob/master/tests/test_model.py

> [email-masked]
> https://www.ietf.org/mailman/listinfo/yang-doctors

-- 
Ladislav Lhotka 
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67

---

From: Mahesh Jethanandani <[email-masked]>
Date: Tue, 3 Mar 2020 11:09:40 -0800

+1

I make sure I develop instance data examples as I am developing the model to make sure that if I do make changes, that they do not break the model. And I rely on other examples to develop some of my own.

Cheers.

> On Mar 2, 2020, at 12:14 PM, Kent Watsen <[email-masked]> wrote:
> 
>> On Mar 2, 2020, at 2:24 PM, Scott Mansfield <scott.mansfield=[email-masked] <mailto:scott.mansfield=[email-masked]>> wrote:
>> 
>> Hello YANG Doctors!
>>  

Mahesh Jethanandani
[email-masked]