blob: 293c543fabeaa08cfda3294b451b3fcc2ce3f27f [file] [log] [blame]
Shashank Kumar Shankaree2fc052017-09-29 15:49:37 -07001=================================================
2Example usage to bring up a developer environment
3=================================================
4
5In the example, we will bring up a single ONAP component using the Vagrant ONAP
6tool.
7
8There are multiple scenarios in which this tool can be made use of by a
9developer, they usually fall in the following use cases.
10
11Use case 1: Use Vagrant ONAP to just clone project related source code
12----------------------------------------------------------------------
13
14In this use case, the developer needs just the source code of the project to work on.
15
16Since the Vagrant ONAP project supports building docker containers and compiling
17source files, we need to first edit the settings.yaml file to add key value pairs
18indicating we need to only clone repo and not build docker image or compile then.
19By default, Vagrant ONAP clones repo, but to not run the build process and cloning
20docker images, the following are required to be added in the settings file.
21
22.. code-block:: console
23
24 skip_get_images: "True"
25
26.. end
27
28The reason this is done is because as mentioned in the
29`configure execution docs. <https://git.onap.org/integration/tree/bootstrap/vagrant-onap/doc/source/features/configure_execution.rst>`,
30the default values taken are:
31
32.. code-block:: console
33
34 'build_image' => 'True',
35 'clone_repo' => 'True',
36 'compile_repo' => 'False',
37 'enable_oparent' => 'True',
38 'skip_get_images' => 'False',
39 'skip_install' => 'True'
40
41.. end
42
43We override them and skip_get_images is given precedence over build_image.
44
45Use case 2: Use Vagrant ONAP to clone project related source code and clone Docker Images
46-----------------------------------------------------------------------------------------
47
48In this use case, the developer needs to clone docker images of the project to work on.
49
50For this case, we will edit the settings.yaml file to add key value pairs indicating we
51need to clone repo and clone docker image from Nexus.
52
53.. code-block:: console
54
55 build_images: "False"
56 compile_repo: "True"
57 skip_get_images: "False"
58 skip_install: "True"
59
60.. end
61
62Use case 3: Use Vagrant ONAP to clone project related source code and build Docker Images locally
63-------------------------------------------------------------------------------------------------
64
65In this use case, the developer needs to build docker images of the project to work on.
66
67For this case, we will edit the settings.yaml file to add key value pairs indicating we need to
68clone repo and build docker image locally and not fetch them from Nexus.
69
70.. code-block:: console
71
72 build_images: "True"
73 compile_repo: "True"
74 skip_get_images: "False"
75 skip_install: "True"
76
77.. end
78
79Use case 4: Use Vagrant ONAP to clone project related source code and build Docker Images and start services
80------------------------------------------------------------------------------------------------------------
81
82In this use case, the developer needs to build docker images of the project he or
83she wanted to work on and start the services running inside them.
84
85For this case, we will edit the settings.yaml file to add key value pairs indicating
86we need to clone repo, compile repo, build docker image and run the image.
87
88.. code-block:: console
89
90 build_images: "True"
91 compile_repo: "True"
92 skip_get_images: "False"
93 skip_install: "False"
94
95.. end
96
97Once the required changes to the settings file is added, we can use the run.sh
98script in tools directory to setup the development environment.
99
100Example steps for setting up a development environment for VFC project.
101-----------------------------------------------------------------------
102
103In this example we will be using vagrant ONAP to get all the source code of VFC
104project and the developer can point the IDE to the cloned repo in the ./opt directory
105and start the development process.
106
107.. code-block:: console
108
109 $ ./tools/run.sh vfc
110
111.. end
112
113At the end of the setup process, all the VFC related source code will be present
114in the vagrant-onap/opt/ directory. The developer can point an IDE to this directory
115and start contributing. When the changes are done, the developer can SSH into the VM
116running VFC and tests can be executed by running Maven for Java and Tox for Python
117from the ~/opt/vfc directory.
118
119.. code-block:: console
120
121 $ vagrant ssh vfc
122 $ cd ~/opt/vfc/<vfc-subrepo>
123 $ tox -e py27
124
125.. end
126
127This way the tool helps the developer to clone repos of a particular project,
128without having to manually search for repos and setup an environment.
129
130Also, if something gets messed up in the VM, the developer can tear down the VM
131and spin a fresh one without having to lose the changes made to the source code since
132the ./opt files are in sync from the host to the VM.
133
134.. code-block:: console
135
136 $ vagrant destroy vfc
137
Shashank Kumar Shankard52d0af2017-10-20 16:06:08 -0700138.. end
139
140Testing
141-------
142
143Use the run.sh script to test if the provisioning scripts run without errors.
144
145And example test to check the number of covered repositories with this tool.
146
147.. code-block:: console
148
149 $ ./tools/run.sh testing -y -c coverity_repos -s functions
150
Shashank Kumar Shankaree2fc052017-09-29 15:49:37 -0700151.. end