-
Notifications
You must be signed in to change notification settings - Fork 76
Running tests on Travis CI
Open the travis CI test script in an editor from the cloned ydk-gen repo (example: vi ydk-gen/test/travis_ci.sh
) and edit the below lines to add/modify any build-time tests and/or run-time sanity tests:
# sanity tests
function run_sanity_tests {
virtualenv myenv
source myenv/bin/activate
pip install gen-api/python/dist/ydk-0.4.0.tar.gz
source gen-api/python/env.sh
cd gen-api/python
run_test python tests/test_sanity_codec.py
run_test python tests/test_sanity_types.py
run_test python tests/test_sanity_filters.py
run_test python tests/test_sanity_levels.py
run_test python tests/test_sanity_filter_read.py
run_test python tests/test_sanity_netconf.py
run_test python tests/test_sanity_rpc.py
cd ydk/tests
run_test python import_tests.py
}
Travis CI has docker service, which could be used along with free version of confd to provide a sandbox like environment. And we can use this combination to replace the testVM/netsim environment used in gitlab. We can push the preconfigured docker image to docker hub and pull them when running test ci.
In an example travis.yml:
sudo: required
services:
- docker
language: python
python:
- "2.7"
before_install:
- docker pull ydkdev/confd
script:
- docker run ydkdev/confd /root/confd_all.sh -r https://github.com/$TRAVIS_REPO_SLUG.git -b $TRAVIS_BRANCH
When commits and pull requests come in, the travis ci worker will pull the image from docker hub repository ydkdev/confd, create and run the script /root/confd_all.sh
in a container based on this image.
A docker hub account is needed to push changes to existing preconfigured image hosted on docker hub.
For OSX, please follow this tutorial. Note: docker will have timeout issue when using along with cisco anyconnect.
Open up a Dokcer Quickstart Terminal, it will take a few minutes for initializing:
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
After this information is shown in the terminal, pull image from docker hub, run command below in the same terminal:
$ docker pull ydkdev/confd
In the same terminal, run the command:
$ docker run -it ydkdev/confd
root@da1b0c5ff16f:~#
Then you will be logged into this container, with name da1b0c5ff16f for example. This is an image based on ubuntu, so feel free to use apt-get to install necessary softwares.
After modifying files in that container, open up another Docker Quickstart Terminal, and commit your changes:
$ docker commit da1b0c5ff16f ydktest/confd
sha256:a11ab3b501deb048fa616ce08abdbdead5cdbbaeb1f558c477bfb946c6f0fbf8
And push your changes to docker hub(a docker hub account is required and you need to be added to the ydkdev team. Please contact Xiaoqin if you need to be added):
$ docker login --username=yourhubusername --email=youremail@company.com
Password:
Login Succeeded
$ docker push ydkdev/confd
The way confd works is to first compile yang models to fxs files, then use those fxs files to start daemon. If for example one more yang model is needed, first compile it:
$ source /root/confd/confdrc
$ cd /path/to/yang
$ confdc -c example.yang
Then you will get example.fxs compiled in /path/to/yang
.
To compile yang model with deviation, use:
$ confdc -c example.yang --deviation example-devaition.yang --deviation example-deviation-1.yang
Copy those files to /root/confd/etc/confd
. It is recommended to copy those fxs files at run time , for example(in /root/confd_install_ydktest.sh
), instead of pushing changes to docker hub. So the image is kept clean.