DevOps Tutorial in 2020

DevOps is a trending cutting edge practices. It is a powerful way to redefine the development and testing. This tutorial focuses on following important topics.

  1. How to integrate Selenium with Jenkins?
  2. How to integrate SonarQube with Jenkins?
  3. Automated testing of API with Jenkins.
  4. How to integrate GIT with Jenkins.
  5. Interview Questions for Docker.

How can we integrate the Jenkins with the Selenium?

One of the best automated tools for testing the web apps is Selenium. It is the tool of open source. This tool is CI tool which is developed on Java platform. Now we will see the method for integrating the Selenium tool with the Jenkins tool. 

We have many advantage in integrating the Selenium tool with the Jenkins tool. It will definitely help to reach the testing automation to the upcoming level. This process allows the tester for testing continuously. Also, it allows to integrate the codes in the development process of the software. It has many added advantages. This automates all the arrangements from development environments to test. Also, for staging as well as production environment.

As we know Jenkins has lot of features. Especially, for integrating with the SVG as well as GIT & defining the CI pipelines. The main function of Jenkins tool is executing all the task which are predefined. Also, to check the code changes continuously. These code changes are happened in various modules. Finally, it will integrate all of them.

Advantages of integrating the Selenium with the Jenkins:

Advantages of integrating the Selenium with the Jenkins are given below. They are,

  • Both the tools are open sourced. Both has very huge knowledge as well as support for community.
  • These two are tools of cross platform. So that, we can able to use it with Windows, Mac OS, Linux as well as Solaris.
  • CI and testing can be performed at the same time. 
  • Many technologies are supported by these tools. Also, it supports tools in development process of the apps.

Integration Process:

Integration process of the Selenium with the Jenkins are done in three steps. They are explained in the following sessions.

1st Step:

Step of downloading the Jenkins:

  1. We have to go for official websites of the Jenkins in our browser. There we can able to download files named jenkins.war.
  2. We need to download the files named jenkins.war from the http://jenkins.io/download as shown below. Then save this in our favorite location. Either in the Desktop / some folders as per our wish.

  1. Once we download it. We will get file named jenkins.war. Then we need to execute it for the installation of the Jenkins.

2nd Step:

Step of Integration:

  1. We need to open the path where we have stored the file with the name jenkins.war. 
  2. Then we want to open the CMD command prompt in our system. After that, we need to go to projects home. Then we can use the server of Jenkins with the help of following command.

Begin cmd> Project_home_Directory> java – jar jenkins.war

  1. While we run the above command, the server gets up & start running. Jenkins will run on the 8080 port by default. We can able to explore Jenkins UI now. At this time, we need to open our browser & type .URL as http://localhosts:8080.

At this time, the Jenkins gets up and start running. We want to create the goals for executing all the test cases. This is possible with the help of Selenium plugins.

  1. Once we install the plugins of Selenium, we finish these installation processes. Now we need to set the goals of Jenkins. This helps them to recognize other tools. Some of them are Java, Maven & more. This is shown in the below diagram.

  1. Now we need to click configure the systems as shown in the below diagram.

Then we need to go to JDK area & there we need to click Add the JDK. This helps the Jenkins to know about the correct java path as shown below.

  • We need to uncheck the check box of install automatically. This helps the Jenkins just to take the java.
  • We need to name it as JAVA_HOME & then mention JDK ways.

In this CI, we have effective component. This will allow us for arranging all the email notifications. Especially for clients. It is really optional. But if we want to design all the email notification, then we need to make small settings. This should be done at the same time when Jenkins solves these bugs. 

We can also change the details of login as shown below then click apply.


After making all the changes we need to click save. After that we need to click apply. Now our Selenium is integrated with the Jenkins. 

3rd step:

Step of test execution:

All the test cases of Jenkins can be executed with 4 different methods. This is shown below.

Here, we will see to execute using windows batch commands.

  1. Now we want to create the batch documents. After that, we want to add similar cluster documents to the Jenkins. Here we split this into three parts and explained below.

1st Part:

For creating the batch document, we need to set class path of the TestNG. By this we can able to execute all testng.XML. The structure of our task should be like the figure shown below.

2nd Part:

Open command invokes as well as set the class path. This should be set as the same way as bins as well as libs are set.

Home index > set classpaths=C:\User\Learnautomations\bin; C:\User\Learn-automations\lib\*;

3rd Part:

Now we need to open notepad / text editor. Then we should write the below mentioned command. After that, we should save the file with .bat extension. 

java – cp bins;lib/* org.testng.TestNG testng.XML

  1. After that we need to make the task in the Jenkins. This will execute all our builds. Just open the Jenkins in the browser. Then just click New Items. Don’t need to worry here items are nothing other than tasks. Just give the task name. Then select the Build free-styles software projects. Finally, click the OK. This is shown in the below diagram.

Next, we need to move to the advanced projects option. There we need to select utilization customers workspace. We need to determine home catalogs of the project in index. Then we need to determine the App Build steps.

Give a click to execute the window batch command. We need to mention batch commands which we have created earlier in command area. Then click save. Finally, click apply.

  1. Now, it is ready for running the builds. Just open the Jenkins on the browser then click Build Now button. 
  2. We can able to check history of the builds which is in Console outputs. Then we need to confirm the outcomes. The Selenium which is integrated with the Jenkins always runs the scripts. This is whenever we made the changes with source codes. Or when we move codes from existing environment to other. This will save all the information which are related with the execution history as well as test report. This will be very useful when we run the Selenium in Jenkins with the test cases which we prepared. We can able to run them simply with single click. Also, we can able to schedule these test cases with the help of batch documents in the Jenkins.

How can we integrate the SonarQube with the Jenkins?

SonarQube is the tool. It is used for the static analysis of the source code. For integrating the SonarQube with the Jenkins, we must use the plugins of Jenkins SonarQube. 

We must follow the following steps for setting the reports of the SonarQube in the Jenkins Dashboard. 

  1. First, we need to sign into the Jenkins. Then go to manage Jenkins. After that install the Plugins of the SonarQube scanners. Then we want to restart the Jenkins after installing the plugins.
  1. We want to go to the home page of the Jenkins. Then we need to create the new jobs in Jenkins. Then we need to go to the post build. After that, we need to select the options of execute the SonarQube scanner.
  1. At this time, we want to give path of the properties of the project as well as Analysis.

Now we need to note down the file paths to the project properties as well as sonar. We should have the source in the same path where we have installed the SonarQube in our machine.

  1. During build, selections provides path of the pom.xml. In goals & option, we need to mention Clean install the Sonar: Sonar.
  1. Just we can execute our Jenkins Jobs. Then our Extent Reports are available in the Jenkins dashboard.

Automated Testing of API with the Jenkins:

For all automation framework, it is very important to run & execute the test script. Especially, from the CI tools like the Jenkins. Now, we are going to see how to run the API test with the help of Jenkins. 

Following are the steps used to run the API test with the help of Jenkins. 

  1. First, we need to sign up into the Jenkins. Then go to manage the Jenkins. After that, select mange the plugins install the Maven integration plugins.
  1. After that, we need to create the new items from the home page of Jenkins. Then we need to select Maven project.
  1. In Build selection we need to give the path of our POM.Xml. This will internally keep the information of our TestNg.Xml.
  2. We need to give clean install in the goals & options.
  1. Then we need to click save & apply on the Jenkins job.
  2. After we execute the Jenkins job, the API test is executed successfully.

Jenkins-GIT- Jira for the CI & Test:

Now we are going to see how to integrate Jenkins, GIT as well as JIRA. This is to achieve the CI and CD. 

Following are the steps to be followed in this integration.

  1. First, we need to go to the home page of the Jenkins. Then go to manage Jenkins. Then select install, below that select JIRA Plugins.
  1. We need to create the new Jenkins Job. In the Source codes management, we need to select the GIT.
  2. We need to give path of GIT repository as well as Credentials.
  1. In add the post-build actions, we need to select the JIRA issues updater.
  1. We need to give path for URL of the Rest Base. After that, we need to give the details like username, passwords of the JIRA.
  2. In the JQL we need to select the issues which is to be updated the JIRA key & the issue status based on the JIRA workflow. We want to check we are not using any other.
  1. At this time, we can execute the Jenkins jobs.
  1. In case of any failure issues, we can see them in the JIRA with the needed logs.

Interview Questions for the Docker

  1. What do you mean by Docker?

Ans:

Docker generally gives the container to manage the software workloads which is on the shared infrastructure when we keep them isolated. Simply we can say that Docker is the tool. This tool is designed for easy development, deployment as well as running the apps with the help of containers.

Containers will generally allow the developers for the package of the app with all the parts which it requires. This is like libraries as well as other requirements and packed in single package. Using this we can able to give assurance that our app will run on another Linux machine without any setting change where the cloud may vary from machine which we use for creating and testing the codes. 

We can also say that Docker is similar to VM instead of creating the full virtual OS. It allows the apps for using Linux kernel which is similar to the system in which the app is running. Also, the app needs to be shifted from the host system. It provides the boost for the performance as well as it will reduce the app size.


2.Explain about the Docker Hub?

Ans:

The registry service which is cloud based is known as Cloud Hub. It helps you for linking with the code repositories. Then build our images as well as test and store them manually. Also, link with the Docker Cloud. So, we can able to deploy the images to our host. 

This provides the centralized resources for the containers image discovery, distribute & change managements, User & team collaboration. Also, the workflow automations allover the development of the pipelines.


3.How can you create the Docker Container?

Ans:

We want to use the Docker image for creating the Docker container with the help of the following command. 

docker run-t-II name of the command

Using this command, we can able to create & start the container. Also, for checking all the running container list with status on the host we should use the following command. 

docker ps-aa 


4.Can you able to list what are the stages which we can use the Docker container?

Ans:

Following are the four stages which we can use the Docker container. They are,

  • Run.
  • Pause.
  • Restart.
  • Exit.

5.Can you explain how to monitor the Docker in the production?

Ans:

Generally, Docker gives us tools such us docker stats as well as docker events for monitoring the docker in the production. Also, we can able to get the important statistics reports.

Docker stats:

Once we call the docker stats using the container id, it will list CPU, usage of memory of the container. This is exactly same as that of the top Linux command.

Docker events:

It is the command for viewing the streaming the activities which are currently going on the docker daemon. Following are some commonly used docker events. They are,

  • Attach.
  • Rename.
  • Commit.
  • Die.
  • Detach. 
  • Destroy. 

6.Can you explain about the Linux containers?

Ans:

In general, we can say that the container applications will keep themselves isolated from host computer which they are running on. Container allows the developers for designing the package of an app including all parts it wants like libraries as well as other requirements into the single package.

This will make the process easier with consistence experience. Then the system admins will move these codes from the development environment to the production environments. This will be very fast.


7.Explain about the Docker Swam?

Ans:

The native clustering of the docker is known as the Docker Swam. This will turn all the pool of the docker host into one virtual docker hosts. It serves many standard dockers API. Tools which are already communicating with the docker daemon will use the swarm for scaling to many hosts.

8.Can you explain about the stopping & restarting the Docker containers?

Ans:

For stopping the docker container we should use the following commands. 

docker stop ID of the container

For restarting the docker container we should use the following commands. 

docker restart ID of the container

9.Can you state the difference between the repository as well as registry?

Ans:

Registry is the service of host as well as distributing image. Repository is the collection of related dockers images.

10.Can you state the difference between the Docker run, ENTRYPOINT and CMD?

Ans:

The CMD will not execute during the build, but it specifies intended commands for images. Runs will run these commands and the commit these results. When we want to run same executables each and every time, then we should use ENTRYPOINT with the CMD.

11.Who can use Docker?

Ans:

It is the tool which is designed in the such a way which suits for both the developers as well as system admins. It will be the part of DevOps tool chain.

Developers can mainly concentrate on developing the codes rather than concentrating about system in which the code is running. Also, it will allow the developers to use any of the languages which is designed for running the docker. 

Docker is very flexible and reduce the required system numbers for the operation staffs.

12.Can you explain the basic usage workflow of the Docker?

Ans:

We start everything with Dockerfiles. These are source codes of the images. After creating the dockerfiles, we can build it for creating the container images. These images are complied versions of source codes. After getting the container image, we should redistribute this with the help of the registry. This is just like the GIT repository. we can able to push as well as pull these images. Using these images, we can able to run the containers. 

13.Can you explain how we can able to scale the docker containers?

Ans:

We can able to scale the docker containers at any level. It may start from hundreds to thousands / millions of the containers. We have only one condition. That is the container must have memory as well as OS every time. We should have any constrains while scaling the docker containers.

14.Can you list down the platforms where the docker will run?

Ans:

It will run on both the Linux as well as cloud platforms. 

Linux platform:

  • Fedora 19/20+
  • CentOS 6+
  • ArchLinux
  • CRUX 3.0+
  • openSUSE 12.3+
  • Gentoo
  • RHEL 6.5+
  • Ubuntu 12.04, 
  • Ubuntu 13.04 et al

Cloud Platform:

  • Google Compute Engine
  • Rackspace
  • Microsoft Azure
  • Amazon EC2

15.Can you explain in the host how many numbers of contains can be run?

Ans:

Number of the containers which is run on the host will depend on the environments. The app size and available resources will affect the total number of the containers which are run in our environments. Containers can’t able to create the new CPU which are from the scratch. It provides more effective productions. They are very lightweight.

16.Where do we use the dockerfiles?

Ans:

It is the text document. This document will contain all commands which the user called on command lines for assembling the images. Using the docker build the developers can able to develop the automated build which executes many command lines.


17.Can you differentiate the dockers from the other containers?

Ans:

The docker container is very easy for deploying in the cloud. We can able to get more apps which are running in same hardware. This is very easy for the developers for developing, run – run apps. It is very easy to mange as well as deploy the apps.

18.How can we link the containers?

Ans:

This is possible with the help of the networks port mapping. We can also use the link flag. 

19.Can you list some of the common instructions which are in the dockerfiles?

Ans:

Following are some of the common instructions which are in the dockerfiles. They are,

  • FROM.
  • LABEL.
  • RUN.
  • CMD.

20.State the different between the docker run & docker create:

Ans:

The docker create is used to create the containers. Especially in the stopped state. By using the docker create we can able to store the output of the container ID which can be used later. 

Conclusion:

We have discussed in detail about how we can integrate the Selenium and other useful tools with the Jenkins. These two tools are most powerful, and this integration will have many advantages. And the other topics regarding CI/CD are important and would help you in your day to day work. Hope this article will validate your time. Also, this will be very useful for you.

December 16, 2020
© 2023 Hope Tutors. All rights reserved.

Site Optimized by GigCodes.com

Request CALL BACK