If you want to test some new feature in Opencontrail or want to test your current environment. You run test using scons commands. Some test are module specific and some are file specific. You may run then as you need. Also if you change some code in Opencontrail you need to re-built Opencontrail. Here are some useful and basic commands to re-build files, schema and tests. Please also read some important notes in this blog, that might help you in working with Opencontrail.
If that doesn't work in your environment use this
Your compiled file will be placed in contrail/build/debug/ folder. Then you run control service from debug which is currently running from contrail/build/production/ .
Go to contrail screen and select control service. Stop control service using Ctrl + c and then run this in same screen service where you stop control service
Then run this command to check either previous command generate code or not
Note: Run stack.sh to compile all environment. It is compulsory to run stack.sh after changes in schema
In contrail you run test as a whole or by module or individually
If you want to ignore error and run test until end, use -i flag with this command
If you want to run test of specific module test, use this command
OR
If you want to run test of specific file, you first compile that file and then manually run it's object file.
Compile that file using this command
Then go to contrail/build/production/bgp/test , and run using this command
If any error occurred while running test, you can see log file of that file in contrail/build/production/bgp/test with name [test_file_name].log
Note: All Scons command must run in /opt/stack/contrail folder
Note: To write result of Scons command in file, run command using 'Command > file_name.txt'
For compilation
Use this command to compile any file in controller.
sudo scons src/control-node/ co=1 -u
If that doesn't work in your environment use this
sudo scons control-node co=1 -u
Your compiled file will be placed in contrail/build/debug/
Go to contrail screen and select control service. Stop control service using Ctrl + c and then run this in same screen service where you stop control service
sudo /opt/stack/contrail/build/debug/control-node/contrail-control --conf_file /etc/contrail/contrail-control.conf & echo $! >/opt/stack/status/contrail/control.pid; fg || echo "control failed to start" | tee "/opt/stack/status/contrail/control.failure"
Change in Schema
If you make changes in any schema *.xsd file. You must first run this command to generate api's and other utility tools used by contrail
scons controller/src/api-lib
Then run this command to check either previous command generate code or not
grep bgp-origin build/debug/api-lib/vnc_api/gen/*
Note: Run stack.sh to compile all environment. It is compulsory to run stack.sh after changes in schema
Contrail test commands
In contrail you run test as a whole or by module or individually
Complete Contrail test
If you want to run all test in contrail you run this command (It may take 6-8 hours)
scons test
If you want to ignore error and run test until end, use -i flag with this command
scons -i test
Module wise test
If you want to run test of specific module test, use this command
scons -u --optimization=production controller/src/bgp:test
OR
scons -u -i --optimization=production controller/src/bgp:test
Individual Test
If you want to run test of specific file, you first compile that file and then manually run it's object file.
Compile that file using this command
scons -u --optimization=production src/bgp:[test_file_name]
Then go to contrail/build/production/bgp/test , and run using this command
./[test_file_name]
If any error occurred while running test, you can see log file of that file in contrail/build/production/bgp/test with name [test_file_name].log
Note: All Scons command must run in /opt/stack/contrail folder
Note: To write result of Scons command in file, run command using 'Command > file_name.txt'