forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transformer Infra Unit Test (sonic-net#81)
* Added openconfig style test yang for transformer unit-test * Add sonic test yang and annotation files, Makefile changes to build the test yangs * Transfomer callbacks for transfomer test yang annotations for unit testing Makefile rules to build transformer test binary Unit tests for transformer test yang exercising subtree-xfmr, virtual-table, table-name, key and field transformer cases. * Add unit test utility functions, test xfmr yang calbacks and UT cases for table and key transformers and sonic yang SET and GET operations * Added readme for transformer unit test * corrected copyright * Corrected copyright info * Addressed review comments * Updated transformer test README file * Added review comments addressed files missing in last commit * Modified the make file rules for test yang as per review comments * Made sure test yangs are present before building transformer test binary * Avoid building test xfmr callbacks into transformer pkg as part of tranlib test due to build tag being same * include transformer test yang in models_list --------- Co-authored-by: ranjinidn <ranjini.nagaraj@dell.com> Co-authored-by: ranjinidn <ranjini_nagaraj@dell.com>
- Loading branch information
1 parent
1340e29
commit cc214fb
Showing
12 changed files
with
2,359 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Transformer Unit Testing | ||
|
||
Following are the instructions on how to build and execute transformer unit test. | ||
The transformer folder (sonic-mgmt-common/translib/transformer) contains all the necessary source code files that includes transformer unit test framework files, callbacks to serve the annotations, unit-test file to exercise the transformer-translations.The test folder (sonic-mgmt-common/translib/transformer/test) contains the test-yangs and annotations. All these files are needed to build and execute transformer test binary. | ||
|
||
* Generate transformer.test by building sonic-mgmt-common with the MAKE flag INCLUDE_TEST_MODELS=y to have the test yangs built | ||
* Copy the openconfig-test-xfmr.yang, openconfig-test-xfmr-annot.yang, sonic-test-xfmr.yang, sonic-test-xfmr-annot.yang to mgmt-framework docker /usr/models/yang directory | ||
* Edit the models_list file in mgmt-framework docker /usr/models/yang directory to include openconfig-test-xfmr.yang, openconfig-test-xfmr-annot.yang and sonic-test-xfmr-annot.yang files | ||
* Copy the sonic-test-xfmr.yin file from sonic-mgmtcommon/build/cvl/schema/ to /usr/sbin/schema/ in mgmt-framework docker | ||
* Copy the transformer.test binary to mgmt-framework docker in /usr/sbin directory and then execute : | ||
```shell | ||
(./transformer.test -test.v -test.coverprofile=transformer.cover -logtostderr -v=5 | tee transformer.out ) >& transformer.log | ||
``` | ||
* View the results in file transformer.out (All test-cases should have PASS prefix) | ||
* View the transformer.log file to view debug logs for debugging the test-case failures if any. |
144 changes: 144 additions & 0 deletions
144
translib/transformer/test/openconfig-test-xfmr-annot.yang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
module openconfig-test-xfmr-annot { | ||
|
||
yang-version "1"; | ||
|
||
namespace "http://openconfig.net/yang/annotation/oc-test-xfmr-annot"; | ||
prefix "oc-test-xfmr-annot"; | ||
|
||
import openconfig-extensions { prefix oc-ext; } | ||
import openconfig-test-xfmr { prefix oc-test-xfmr; } | ||
import sonic-extensions { prefix sonic-ext; } | ||
|
||
deviation /oc-test-xfmr:test-xfmr { | ||
deviate add { | ||
sonic-ext:pre-transformer "test_pre_xfmr"; | ||
sonic-ext:post-transformer "test_post_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group { | ||
deviate add { | ||
sonic-ext:table-name "TEST_SENSOR_GROUP"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:config/oc-test-xfmr:id { | ||
deviate add { | ||
sonic-ext:field-transformer "test_sensor_group_id_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:config/oc-test-xfmr:group-colors { | ||
deviate add { | ||
sonic-ext:field-name "colors"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:state/oc-test-xfmr:id { | ||
deviate add { | ||
sonic-ext:field-transformer "test_sensor_group_id_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:state/oc-test-xfmr:group-colors { | ||
deviate add { | ||
sonic-ext:field-name "colors"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:state/oc-test-xfmr:counters { | ||
deviate add { | ||
sonic-ext:table-name "TEST_SENSOR_GROUP_COUNTERS"; | ||
sonic-ext:db-name "COUNTERS_DB"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:test-sensor-types { | ||
deviate add { | ||
sonic-ext:table-name "NONE"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:test-sensor-types/oc-test-xfmr:test-sensor-type { | ||
deviate add { | ||
sonic-ext:table-transformer "test_sensor_type_tbl_xfmr"; | ||
sonic-ext:key-transformer "test_sensor_type_key_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:test-sensor-types/oc-test-xfmr:test-sensor-type/oc-test-xfmr:config/oc-test-xfmr:type { | ||
deviate add { | ||
sonic-ext:field-transformer "test_sensor_type_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:test-sensor-types/oc-test-xfmr:test-sensor-type/oc-test-xfmr:config/oc-test-xfmr:exclude-filter { | ||
deviate add { | ||
sonic-ext:field-transformer "exclude_filter_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:test-sensor-types/oc-test-xfmr:test-sensor-type/oc-test-xfmr:state/oc-test-xfmr:type { | ||
deviate add { | ||
sonic-ext:field-transformer "test_sensor_type_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sensor-groups/oc-test-xfmr:test-sensor-group/oc-test-xfmr:test-sensor-types/oc-test-xfmr:test-sensor-type/oc-test-xfmr:state/oc-test-xfmr:exclude-filter { | ||
deviate add { | ||
sonic-ext:field-transformer "exclude_filter_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sets/oc-test-xfmr:test-set { | ||
deviate add { | ||
sonic-ext:table-name "TEST_SET_TABLE"; | ||
sonic-ext:key-transformer "test_set_key_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sets/oc-test-xfmr:test-set/oc-test-xfmr:config/oc-test-xfmr:type { | ||
deviate add { | ||
sonic-ext:field-transformer "test_set_type_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sets/oc-test-xfmr:test-set/oc-test-xfmr:config/oc-test-xfmr:name { | ||
deviate add { | ||
sonic-ext:field-transformer "test_set_name_field_xfmr"; | ||
} | ||
} | ||
|
||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sets/oc-test-xfmr:test-set/oc-test-xfmr:config/oc-test-xfmr:description { | ||
deviate add { | ||
sonic-ext:field-transformer "test_set_description_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sets/oc-test-xfmr:test-set/oc-test-xfmr:state/oc-test-xfmr:name { | ||
deviate add { | ||
sonic-ext:field-transformer "test_set_name_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sets/oc-test-xfmr:test-set/oc-test-xfmr:state/oc-test-xfmr:type { | ||
deviate add { | ||
sonic-ext:field-transformer "test_set_type_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:test-sets/oc-test-xfmr:test-set/oc-test-xfmr:state/oc-test-xfmr:description { | ||
deviate add { | ||
sonic-ext:field-transformer "test_set_description_field_xfmr"; | ||
} | ||
} | ||
|
||
deviation /oc-test-xfmr:test-xfmr/oc-test-xfmr:interfaces { | ||
deviate add { | ||
sonic-ext:subtree-transformer "test_port_bindings_xfmr"; | ||
sonic-ext:virtual-table "true"; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.