CSC-519 Spring 2019
Prayani Singh(psingh25@ncsu.edu)
Shefali Agarwal(sdagarwa@ncsu.edu)
Sujal Sujal(ssujal@ncsu.edu)
Vaibhav Singh(vsingh7@ncsu.edu)
git clone https://github.ncsu.edu/ssujal/CSC519_Project.git
MILESTONE 1
In this milestone, we have completed the following tasks:
✅ Provisioning and configuring an jenkins server (on a remote VM), automatically using ansible.
✅ Using a combination of jenkins-job-builder and ansible, automatically setup build jobs for two applications:
- A nodejs web application checkbox.io.
- An "enterprise" Java system iTrust
✅ Using a combination of mocha/pm2, create a test script that will start and stop the checkbox.io service on the server.
✅ Create a simple git hook or GitHub webhook to trigger a build when a push is made to the repo. Demonstrate a passing build for each job after a commit.
- Install VirtualBox - version 5.2.* (Please install this version for baker to run smoothly. Vagrant can be used instead but extra setup and steps will be required to setup successfully)
- Install Vagrant
- Install Baker (Baker website) - latest stable version
- Clone project from git repository
- Create public and private key in ansible-srv directory from CLI using the command:
cd ansible-srv
ssh-keygen -t rsa -b 4096 -C "web-srv" -f web-srv
- Go into directory web-srv
cd web-srv
- Create VM using baker (called from baker.yml).This will also save your public key in directory ~/.ssh/public_key which we need to add in authorized_keys once we are logged into the VM.
baker bake
- Start VM using baker. Use command:
baker ssh
- Set public key: (append key from public_key to authorized_keys)
cat ~/.ssh/public_key >> ~/.ssh/authorized_keys
- Go into directory ansible-srv
cd ansible-srv
- Create VM using baker (called from baker.yml). This will also install ansible in the server directly and save your private key in directory ~/.ssh/web-srv which we need to add in in order to access the web server (Please do not share this key with anybody).
baker bake
- Start VM using baker. Use command:
baker ssh
- Change permission of private key
chmod 600 ~/.ssh/web-srv
- Changed into linked directory for ansible server
cd /ansible-srv/
- Open vars/common.yml in the project directory, add required credentials for database, jenkins, checkbox and iTrust. A few variables have been supplied by us. These include a few URLs and plugins. Please do not make modifications to these existing variables as it may lead to incorrect installation of the project.
Note:
- For github credentials: please specify credentials from github.ncsu.com. These variables are used in our iTrust forked repository which is checked into https://github.ncsu.edu/.
- For mail user and password, please specify credentials for any SMTP server (check for security measures if using server for non-standard protocols).
- Once the required credentials have been added, vault the common.yml file by calling this command:
ansible-vault encrypt vars/common.yml
This will encrypt your variable file and prompt for a password which can be used every time you want to run the Ansible playbook.
- Call Ansible Playbook using inventory from main.yml file
ansible-playbook main.yml -i inventory --ask-vault-pass
This will prompt you for vault password. Enter password as added in step 7. This should run the Ansible Playbook.
- Once everything is installed successfully, Jenkins can be accessed on the following port:
192.168.33.100:8080
It will prompt you for username and password, enter credentials as specified in vars/commons.yml for Jenkins. Once you are logged into Jenkins portal. You should see project builds for Checkbox and iTrust in a healthy state. To check working of the builds through Git hook, go to the next step.
To check Jenkins builds on commit, go into forked repository directory on web server. (as specified in vars/commons.yml).
-
CheckBox: Go into project directory where the server files are located. Commit a few changes into this repository and push it to the server. Open browser on Jenkins port as specified above. Open jenkins on specified location above and check if the build is running.
-
iTrust: Go into project directory where the server files are located. Commit a few changes into this repository and push it to the server. Open browser on Jenkins port as specified above. Open jenkins on specified location above and check if the build is running.
https://drive.google.com/drive/folders/1mXXmxJ1JYzsIzeRBpfsbZqc69qA-OorE?usp=sharing
MILESTONE 2
Prayani Singh(psingh25@ncsu.edu) - Checkbox Static Analysis Implementation and Gates
Shefali Agarwal(sdagarwa@ncsu.edu) - Fuzzer and Test Prioritization
Sujal Sujal(ssujal@ncsu.edu) - iTrust Analysis and Gates
Vaibhav Singh(vsingh7@ncsu.edu) - Code coverage and Build Configuration
In this milestone, we have completed the following tasks:
✅ Code coverage, analysis for iTrust
✅ Fuzzer and Test Prioritization for iTrust
✅ Static Code Analysis for Checkbox
✅ Reports and Analysis
- Renamed main.yml > playbook.yml
- var/common.yml > variables.yml (in root directory)
- Added reports directory containing itrust and Checkbox reports
- Setup web and ansible server as given in Milestone 1
- Please make sure Milestone 1 along with the roles mentioned in scripts are up and running
- Changed into linked directory for ansible server
cd /ansible-srv/
-
Open variables.yml in the project directory, add required config and variable names for jenkins, checkbox and iTrust. A few variables have been supplied by us. These include a few URLs and plugins. Please do not make modifications to these existing variables as it may lead to incorrect installation of the project.
-
Call Ansible Playbook using inventory from playbook.yml file
ansible-playbook playbook.yml -i inventory --ask-vault-pass
- Code coverage uses a plugin called Jacoco
- Static code analysis is conducted through plugin called Checkstyle
- Checkstyle analyses static code and Reports all warnings and errors. Report includes bugs, syntax warnings etc.
- Configured through Jenkins and reports are displayed on Jenkins Job portal
- Build fails when coverage is lesser than 50%
- There are 2 roles called Fuzzer and Test Prioritization. Fuzzer role is not included in playbook.yml and is run inside Test Prioritization role
- Number of runs in variables.yml indicate how many times fuzzer will run
- Number of seconds in variables.yml indicate the wait time before the next build is triggered. We have added the time as 250 seconds but it may differ based on system configuration
- analysis.js is used to run static analyzer on all the Checkbox files.
- Build failing criteria is based on failing one of the following:
- When a method is longer than 80 lines
- When there are more than 6 conditions in a function
- When there are more than 165 characters on a given line
https://github.ncsu.edu/ssujal/CSC519_Project/tree/master/reports Includes:
- Description Report
- Test Prioritization Report
- Sample Coverage Report
- Checkbox Analysis Report
https://drive.google.com/drive/folders/1mXXmxJ1JYzsIzeRBpfsbZqc69qA-OorE?usp=sharing
We have created a Kubernetes cluster on Google Cloud Platform by using service accounts authentication.
- Create a new project on GCP
- Enable Kubernetes on GCP and create a service account. Download the service account key and save it at the location /roles/kubernetes-gcp/templates/
- Save project name and key name in variables.yml
- Run ansible scripts for creating cluster
- Log into your Digital Ocean account and get the IP address of the Virtual Machine where Checkbox is installed
- Check IP of Checkbox VM and open it on browser
- Check microservice for route POST /api/design/survey on Postman OR
- Create a design survey on the site
- This endpoint uses the microservice
https://github.ncsu.edu/ssujal/CSC519_Project/wiki