Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup translib and cvl go test cases #13

Merged
merged 6 commits into from
Jul 9, 2020

Conversation

sachinholla
Copy link
Contributor

- Why I did it

There are few issues in cvl and translib go test code.

- How I did it

1) Fixed compilation is translib test code. Temporarily disabled ACL test codes from translib test since there are too many errors in it. Moved all common utility code in ACL test file into a new common file (app_utils_test.go).
2) Fixed the failures in cvl test code.
3) Added a new app module api_tests_app.go which provides dummy implementations of all app interface APIs for paths starting with /api-tests:. Errors can be simulated by including token /error/ in the path. This can be used by translib test code as well as translib client test code (REST or telemetry) to verify end-to-end of all cases without depending on actual app modules or database state.

- How to verify it

Run translib and cvl go test cases

- Description for the changelog

Cleanup translib and cvl go test cases

Default cvl schema path is now same as the install path. Env varibale
CVL_SCHEMA_PATH need not be set if schema files are installed from
sonic-mgm-common.deb package. This simplifies testing.
Modified transformer to accept custom yang search path through env
variable YANG_MODELS_PATH. Falls back to default path /usr/models/yang
if this env variable is not set. Helps quick testing without install.
1) Introduced new test app module api_tests_app.go which handles paths
starting with "/api-tests:". It returns success or error based on data
in the path. Useful for testing end-to-end functionality from translib
clients, like REST server, without depending on actual app modules.

2) api_tests_app.go will compile only when build tag "test" is set.
Translib makefile sets it during translib test binary compilation only.

3) Temporarily excluded ACL app test code from translib test binary. It
will be added back later once all errors are fixed. ACL app tests can
still be run from source. Moved TestMain function and common utilities
to a new app_utils_test.go go file.

Signed-off-by: Sachin Holla <sachin.holla@broadcom.com>
translib/api_tests_app.go Show resolved Hide resolved
translib/transformer/transformer.go Outdated Show resolved Hide resolved
translib/api_tests_app.go Show resolved Hide resolved
translib/app_utils_test.go Show resolved Hide resolved
@renukamanavalan renukamanavalan merged commit f41af69 into sonic-net:master Jul 9, 2020
renukamanavalan pushed a commit to sonic-net/sonic-mgmt-framework that referenced this pull request Jul 15, 2020
 Why I did it

REST go tests were failing due to failures in ACL request.

- How I did it

1) Modified ProcessXXX testcases to use new api-tests app instead of ACL
app. This allows running end-to-end positive and negative tests without
depending on db state and ACL logic. Added few more test cases.
Depends on sonic-net/sonic-mgmt-common#13.

2) Added few more negative test cases to test translib integration.

3) Added a new tool rest-gotest.sh to run REST server tests from source
or already built test binary. Can be used with tparse or gotestsum too.

rest-gotest.sh               /* run all tests from source */
rest-gotest.sh -bin          /* run already built test binary */
rest-gotest.sh -run Process  /* run only ProcessXXX tests */
rest-gotest.sh -bin -json | tparse
gotestsum -f testname --raw-command -- rest-gotest.sh -json
- How to verify it

REST server gotest

- Description for the changelog

Use translib's new api-tests app in REST gotest
@sachinholla sachinholla deleted the gotestfix branch October 1, 2020 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants