Skip to content

Development Workflow

kapilkalra04 edited this page Feb 24, 2018 · 12 revisions

This page details steps required to get started with the development of BITS-Darshini.

Code Editing

Advice on IDEs

Sublime / Atom are two popular code editors. But none of them provide a continuous compilation and code coverage features supported in Eclipse IDE / JetBrains IntelliJ IDEA. So you are encouraged to use Eclipse or JetBrains IDEs. The following steps illustrate the project development workflow using Eclipse IDE.

Integrate Lombok with Eclipse IDE

We suggest Eclipse IDE for development of this Spring-based project. Eclipse IDE offers automatic JIT compilation and jar file generation options. We use lombok in the project. To integrate lombok with Eclipse, follow the steps given below.

  1. Install Eclipse Oxygen release
  2. Download Lombok jar
  3. Close Eclipse if its running
  4. Run the lombok jar directly (It's an executable jar)
  5. With in lombok jar executable, select the Eclipse installation (which lombok should find and list automatically, or just browse to the installation directory if lombok does not list your preferred Eclipse installation)
  6. Then start Eclipse (Need to restart if it was already running)

The instructions for integration of Lombok into Eclipse IDE are available on lombok website as well.

Development with Eclipse IDE

BITS-Darshini project uses Git version control system. You can get started with the project by performing the following steps.

  1. We use fork and pull model of development. Clone the project code base from your fork.

    > git clone https://github.com/yourgithubusername/BITS-Darshini.git -b dev
  2. Open Eclipse

  3. Select File ---> Open Projects from File System

  4. Click on Directory and select the BITS-Darshini directory that you cloned recently. For example, you cloned BITS-Darshini to /home/ubuntu/BITS-Darshini; then you would select /home/ubuntu/BITS-Darshini directory in this step also.

  5. The "Import Source" form field shows /home/ubuntu/BITS-Darshini as the selected entry.

  6. Eclipse auto-detects the project as a maven project.

  7. You can click on finish to complete the import of the project into Eclipse.

  8. Eclipse downloads the maven dependencies for the project. The project code layout looks as follows.

    conf/
    data/
    script/
    src/
      main/
      test/
        java/
    target/  (will be created by maven, but ignored by .gitignore)
    codecov.yml
    LICENSE
    pom.xml
    README.md
    Vagrantfile
  9. Go to src/test. Right click on java and select "Run As ---> JUnit Test". The JUnit tests should run and pass.

  10. Now you are ready to code for BITS-Darshini.

  11. You would have to checkout the "dev" branch into another branch with an appropriate branch name. To do it, right click on project and select "Team ---> Switch To ---> New Branch".

  12. In the new window, give a name for the branch and remember to keep the checkmark in the checkbox for checkout.

  13. Now you have checked out a new branch, go ahead with the development. Please remember to adhere to coding style and follow coding standards.

  14. Every time you make a change, make sure to check that it doesn't break anything. You can do this by running Unit, Integration and Deployment Tests.

  15. Running Unit and Integration Tests : Right click anywhere in the Project folder inside the Project Explorer Window ---> Run As ---> Run Configurations... ---> JUnit ---> Run all tests in the selected Project (Select the project from the browse menu)

  16. Running Deployment Tests : Right click anywhere in the Project folder inside the Project Explorer Window ---> Run As ---> Run Configurations... ---> Maven Build ---> type tomcat:run in the Goals option and make sure to correctly set the base directory as ${workspace_loc:/protocolanalyzer}, you can also do the second part by simply selecting the project from the browse menu. Before Executing the Maven build check whether the port :8080 on your machine isn't occupied by some other process.

  17. Once the Build is complete, access the application from browser by typing http://localhost:8080/protocolanalyzer/. Now to execute the deployment test just type http://localhost:8080/protocolanalyzer/test?protocolGraphPath=/home/BITS-Darshini/data/graph.p4&pcapPath=/home/BITS-Darshini/data/packet/DNS_Traffic000.pcap in the address bar. If everything is correct you would see "Success" written on the screen. (Make sure you are providing the correct paths of the graph.p4 and the DNS_Traffic.pcap present in your BITS-Darshini Folder. Do this for packet_data.pcap file present in the folder as well)

  18. Once you pass Unit, Integration and Deployment Tests through eclipse, you should now copy the newly changed files from your git fork repository folder to the folder where you have your vagrant machine set up. (NOTE: YOU SHOULD HAVE TWO FOLDERS, ONE FROM WHERE YOU PUSH YOUR COMMITS TO ORIGIN, THE OTHER IS THE ONE FROM WHERE YOU EXECUTE VAGRANT UP). Vagrant Up from the correct folder and see if the application built in there also passes the deployment tests mentioned in the previous step. Only after this you should commit the changes by right clicking on project and selecting "Team ---> Add to Index" and then "Team ---> Commit" from the previous folder.

  19. You get "Git Staging" window, provide commit message and click on "commit" button. Your code is now committed.

  20. Explore other options such as remote push and pull to commit the local changes to your fork of the Darshini repository. Once the new branch is in place in your fork, open a pull request.


Deployment

Complete Application

Please follow the installation and build instructions specified in install page to install the dependencies. Once a version of BITS Darshini is deployed to tomcat 8.5, you can develop in Eclipse and periodically redeploy the application.

To redeploy BITS-Darshini, use the following commands:

> cd <path_to_darshini_git_directory>
> mvn clean package
> bash scripts/redeploy.sh

The application can be accessed from your browser on the url -

http://localhost:8080/protocolanalyzer/

Make sure no other application is running on port 8080.

Front-End Code

If you are a front-end developer modifying files in WEB-INF directory, then you can take a short-cut to the deployment. You can modify the files and then execute the following commands to see the changes reflected in the web application running on Tomcat 8.5 server.

> cd <path_to_darshini_git_directory>
> bash scripts/front-end.sh

References

  1. Egit tutorials - from Eclipse, Vogella
  2. Separating IDE Workspaces from code repositories.
Clone this wiki locally