Table of Contents | ||
---|---|---|
|
Setting up the IDE
You can set up the SDNC IDE by following instructions from Setting Up Your Development Environment.
...
Downloading the Source Code
...
Creating Your Linux Foundation Account
If you already have a Linux Foundation account, you can skip this section.
...
Filling the information and click on Create new account to proceed account creation.
...
Downloading SDN-C Projects
Follow steps in Get git command from ONAP gerrit to get the git clone command and clone each of the following SDNC projects:
...
Note: The ONAP SDNC projects are more like a demo version of ECOMP's SDN-GC.
...
Downloading CCSDK Projects
Follow steps in Get git command from ONAP gerrit to get the git clone command and clone each of the following CCSDK projects:
Project Name | Project Description | has code |
---|---|---|
ccsdk/dashboard | Opeations Manager Dashboard | |
ccsdk/distribution | CCSDK distribution packaging (e.g. docker containers) | |
ccsdk/parent | Parent POMs to be used by CCSDK clients | |
ccsdk/platform/blueprints | Blueprints. not in Amesterdam release | |
ccsdk/platform/nbapi | Northbound API | |
ccsdk/platform/plugins | Platform plugins | |
ccsdk/sli/adaptors | Common adaptors for use by directed graphs | |
ccsdk/sli/core | Core Service Logic Interpreter classes | |
ccsdk/sli/northbound | Common northbound APIS related to service logic interpreter | |
ccsdk/sli/plugins | Common plugins used by direcged graphs | python |
ccsdk/storage/esaas | Elastic Storage as a Service. not in Amesterdam release | |
ccsdk/storage/pgaas | PGAAS (PostgreSQL as a Service) | java, python, bash |
ccsdk/utils | Utilities | bash, yaml |
Anchor | ||||
---|---|---|---|---|
|
...
from ONAP gerrit
Use your linux foundation account to login onto ONAP projects.
...
The git clone command for the selected project is now copied into your clipboard. You do paste to use it at where-ever you want to.
View Code
...
on gerrit Website
ONAP code can also be viewed from gerrit web site as below (sdnc/adaptors project is used as the example here):
...
To view the coce through gerrit client, first follow steps in SDNC - Development Environment SetupGet git command from ONAP gerrit to get the Projects list page.
Then, choose either one of the following option to view the code of the desired project.
Option 1:
...
View Through "gitweb"
...
Option in Project List Page
Note: this option will bring you to, and only to, the HEAD branch which is the master branch.
...
Now, the repo details page will be shown and you can view the code in master branch from there.
Option 2:
...
View from "Branches"
...
Option in
...
Project Page
Note: this This option allows you to select a particular branch to view it code.
...
In this tutorial, we recommend to use Junit4 and Mockito for writing the junit test.
Add
...
Dependency
Add Junit and mockito dependency in the pom.xml if they are not there.
...
For more information about how to use Mockito, refer to https://www.tutorialspoint.com/mockito/.
Mock
...
Class Level Attributes
Since we don't recommend to use Powermockito, however, if sometimes you do want to set/get class level attributes to satisfy complex test code and still keep the test coverage in sonar achievable.
...
static Object | getInternalState(Object target, String field) |
static void | setInternalState(Object target, String field, Object value) |
Issue of
...
Using Powermockito
There are multiple advantages of using Powermock to easily write the junit test, but it does break the design of the code and even sometimes, the written Junit doesn't contain any real test value.
...
...
Commiting Code
Install git-review
To commit code to ONAP, you must have git-review installed.
...
GIT Config Key | Expected Value | Setting Command |
---|---|---|
core.eol | lf | git config --global core.eol lf |
core.autocrlf | true | git config --global core.autocrlf true |
user.name | your name | git config --global user.name <your name> |
user.email | your email address | git config --global user.email <your email address> |
Anchor | ||||
---|---|---|---|---|
|
...
Creating A Review
Checkout the master branch, work on your changes, once you are ready for submission, do the following to create a review.
...
Steps | Command | Notes | |||||||
---|---|---|---|---|---|---|---|---|---|
1 | git commit -sam <comment summary> | Commit summary should not exceed 50 char. See ONAP Commit Messages for more details. | |||||||
2 | git log --shortstat | To ensure change lines are properly done and your commit has the following:
Here's an example:
If the Change-Id does not exist, do not proceed. You need to following SDNC - Development Environment Setup Fix no change-id to fix it before proceeding further. | |||||||
3 | git commit --amend | Use this command to do the following:
| |||||||
4 | git review | This command will create the review at Gerrit. Once this command is completed, your newly created review can be found from Outgoing reviews in Gerrit self dashboard . |
...
- If the verify jenkins build is passed for your review
- If it is passed, ONAP Jobbuilder will add a +1 to the Verified field in your review.
- If there's any comments in your review
- the comments details can be view from the History section by clicking on the description or Expand All button
- If your review has been merged
- If your review is merged or in process to be merged, you will see in the Code-Review field, you have a +2 from one of the committer you have added in your Reviewers.
Tips
How to Change the Comments in
...
a Review
Oops, I made a mistake in my review comments. It cannot be changed in the gerrit review.
...
Steps | Command | Notes |
---|---|---|
1 | git commit --amend | update the comment as desired |
2 | git log --shortstat | validate your commit now has the updated comments, as well as the Change-Id as the one in the gerrit review |
3 | git review | push the changed comment to the review again. Once the command is completed, go to your review, you will see
|
How to Update the Code in
...
a Review
Now, I got comments in my view, and I have made the code adjustment in my workspace and tested.
...
Steps | command | notes |
---|---|---|
1 | git commit -sam "my updated code" | To create a new commit with your updated code |
2 | git log --shortstat | you will see the most 2 recent commits are from
|
3 | git rebase -i HEAD~2 | To run rebase interactively for the most recent 2 commits In the interactive mode, it will bring up the text which contains pick for your last 2 commits along with the following content: Do the following:
Once this command is completed, 2 commits will be merged into 1 commit. |
4 | git log --shortstat | you will see there's only 1 commit which replaces the 2 commit you have seen in step 2. validate your commit has the Change-Id as the one in the gerrit review |
5 | git review | push the changed comment to the review again. Once the command is completed, go to your review, you will see
|
Anchor | ||||
---|---|---|---|---|
|
...
a Commit which Does Not
...
have a Change-Id
The would only happen when you are creating your very first review in a repo. It mainly because your workspace might have some mis-config which lead your repo clone was not done properly with the Clone with commit-msg hook option.
...
Steps | Command | Notes |
---|---|---|
1 | git reset HEAD~1 | to undo the commit |
2 | from github helper page, download commit-msg, and place it under your <repo>/.git/hook directory | set the proper commit-msg hook this will set the Change-Id properly in your commit |
3 | Use your previous command to create the commit again | |
4 | git log --shortstat | to check the existence of Change-Id |
How to Find All of
...
Your Merged Changes
You can find your recent merged changes from Gerrit self dashboard, however, it only works for Recent changes.
To find all of your changes, you can type in "is:closed(owner:self)" in the Search field at Gerrit self dashboard, then click on the Search button.
...
Deploying a
...
Minimal ONAP SDN-C Environment
This tutorial is based on ONAP-integration project[1] which utilizes Vagrant[2], a deployment tool to build an ONAP environment.
...
Windows: Open Gitbash As Administrator
Convert Line
...
Endings
cd integration/bootstrap/vagrant-onap/lib
...
Code Block | ||
---|---|---|
| ||
... configuration = { ... 'docker_version' => '1.2-STAGING-latest', ... } ... |
Modify
...
the SDN-C Deployment Script
vim integration/bootstrap/vagrant-onap/lib/sdnc
...
cd integration/bootstrap/vagrant-onap
./tools/run.sh sdnc
Configure Port
...
Forwarding
This could be replaced by adding scripts in Vagrantfile.
...
Credentials: admin/Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
Basic
...
Usage of
...
Vagrant and
...
Docker
// check running vm instances
...
[4] Virtualbox Download link: https://www.virtualbox.org/wiki/Linux_Downloads
...
Deploying New Code (based on the standard ONAP lab setup)
coming soon
Remote Debugging
...