Sunday, September 25, 2016

Open source DevOps Tools




DevOps Tools

1. Nagios (& Icinga)

Infrastructure monitoring is a field that has so many solutions… from Zabbix to Nagios to dozens of other open-source tools. Despite the fact that there are now much newer kids on the block, Nagios is a veteran monitoring solution that is highly effective because of the large community of contributors who create plugins for the tool. Nagios does not include all the abilities that we had wanted around the automatic discovery of new instances and services, so we had to work around these issues with the community’s plugins. Fortunately, it wasn’t too hard, and Nagios works great.

We also looked into Icinga, which was originally created as a fork of Nagios. Its creators aim to take Nagios to the next level with new features and a modern user experience. There is a debate within the open source community about the merits of Nagios and its stepchild, but for now we are continuing to use Nagios and are satisfied with its scale and performance. The switch to newer technology, such as Icinga, may be appropriate in the future as we progress.


2. Monit

Sometimes the simplest tools are the most useful, as proven by the simple watchdog Monit. Its role is to ensure that any given process on a machine is up and running appropriately. For example, a failure occurs in Apache, Monit will help to restart the Apache process. It is very easy to setup and configure and is especially useful for multi-service architecture with hundreds of micro-services. If you are using Monit, make sure to monitor the restarts that it executes in order to surface problems and implement solutions (rather than just restarting and ignoring the failure). You can do this by monitoring Monit’s log files and ensuring that you are alerted to every restart.


3. ELK – Elasticsearch, Logstash, Kibana – via Logz.io

Stack is the most common log analytics solution in the modern IT world. It collects logs from all services, applications, networks, tools, servers, and more in an environment into a single, centralized location for processing and analysis. We use it for analytical purposes (e.g., to troubleshoot problems, monitor services, and reduce the time it takes to solve operational issues). Another use for this tool is for security and auditing (e.g., to monitor changes in security groups and changes in permissions). After receiving alerts on these issues, it is easy to act on unauthorized users and activities. We also use ELK for business intelligence, such as monitoring our users and their behavior. You can set up your own ELK or buy it as-a-service. We’ve written a guide for the community on using ELK to monitor your application performance.



4. Consul.io


Consul is a great fit for service discovery and configuration in modern, elastic applications that are built from microservices. The open-source tool makes use of the latest technology in providing internal DNS names for services. It acts as a kind of broker to help you sign and register names, enabling you to access service names instead of specific machines. If, for example, you have a cluster of multiple machines, you can simply register them as a single entity under Consul and access the cluster easily. We praise this tool for its efficiency, although we still feel there is more that can be done with it. If you also use it, it would be great to hear about your own use case.


5. Jenkins

Everyone knows Jenkins, right? It’s not the fastest or the fanciest, but it’s really easy to start to use and it has a great ecosystem of plugins and add-ons. It is also optimized for easy customization. We have configured Jenkins to build code, create Docker containers (see the next item), run tons of tests, and push to staging/production. It’s a great tool, but there are some issues regarding scaling and performance (which isn’t so unusual). We’ve explored other cool solutions such as Travis and CircleCI, which are both hosted solutions that don’t require any maintenance on our side. For now, however, since we’ve already invested in Jenkins, we’ll continue with it.


6. Docker

Everything that can be said about how Docker is transforming IT environments has already been said. It’s great…life changing, even — (although we’re still experiencing some challenges with it). We use Docker in production for most services. It eases configuration management, control issues, and scaling by allowing containers to be moved from one place to another.

We have developed our SaaS solution with a twelve-layer pipeline of data processing. Together with Jenkins and Docker, we have been able to run a full pipeline across all layers on a single Mac. It would be wrong to say that there aren’t any complications with Docker, as even small containers can take a significant amount of time to build. However, we want to ensure that our developers are as satisfied as possible and enable them to work rapidly. With all of the management involved in storage, security, networking — and everything surrounding containers — this can be a challenge.

We see Docker progressing and look forward to welcoming the company’s new management and orchestration solutions. For those who might be having issues with Docker, we’ve also compiled a list of challenges and solutions when migrating to Docker.


7. Ansible

Again, simplicity is key. Ansible is a configuration management tool that is similar to Puppet and Chef. Personally, we found those two to have more overhead and complexity to our use case– so we decided to go with Ansible instead. We know that Puppet and Chef probably have a richer feature set, but simplicity was our desired KPI here. We see some tradeoffs between configuration management using Ansible and the option to simply kill and spin new application instances using a Docker container. With Docker, we almost never upgrade machines but opt to spin new machines instead, which reduces the need to upgrade our EC2 cloud instances. Ansible is used mostly for deployment configuration mostly. We use it to push changes and re-configure newly-deployed machines. In addition, its ecosystem is great, with an easy option to write custom applications.



8. Collectd/Collectl

Collectd/l are nifty little tools that gather and store statistics about the system on which they run and are much more flexible than other tools. They allow users to measure the values of multiple system metrics and unlike other log collection tools that are designed to measure specific system parameters, Collectd/l can monitor different parameters in parallel. We use these two tools to measure customer performance parameters and ship them to our ELK-as-a-Service platform. We’ve specifically wrapped a Collectl agent in a Docker container and push it with Ansible to all of our servers. It collects information every couple of seconds and then ships it to ELK to allow us to run reports and send alerts. If you’d like to see a specific example of how we do this process in our environment and how others can do the same, we’ve created a guide for everyone.



9. Git (GitHub)




githubGit was created 10 years ago following the Linux community’s need for SCM (Source Control Management) software that could support distributed systems. Git is probably the most common source management tool available today. After running Git internally for a short period of time, we realized that we were better suited with GitHub. In addition to its great forking and pull request features, GitHub also has plugins that can connect with Jenkins to facilitate integration and deployment. I assume that mentioning Git to modern IT teams is not breaking news, but I decided to add to it to the list due to its great value to us.

DevOps






A clipped compound of development and operations is a culture, movement or practice that emphasizes the collaboration and communication of both software developers and other information-technology (IT) professionals while automating the process of software delivery and infrastructure changes.



Monday, September 19, 2016

Correlation in JMeter





Correlation in JMeter

What is correlation and why it is required?

Correlation is the most important aspect of scripting. It generally includes fetching dynamic data from preceding requests/calls and posting it to the subsequent requests.

Let's take an example to find out why exactly we need correlation-
Suppose we have recorded a scenario in which -
>User enters login details and click OK button
>Home page opens and user take further actions

Now, if we just playback this script, the test will fail even for a single user. This is because of the authentication mechanism used. When we login to a website, session variables are dynamically created. These session variables are passed to the subsequent requests and help validation and authentication of the actions performed. So, one cannot just record and playback the requests having these variables. Here, we need to correlate the web requests with the dynamic variables. And for correlation, we need to use the "Regular Expression Extractor" which makes use of regular expressions.

A brief insight to regular expressions-
Regular expressions are used to fetch data from a string based on a search pattern. Basically, what we do is- in order to extract any value (generally a dynamically created value) from a string (text response), we define a left bound of the variable then some wildcard characters and then right bound- (Left Bound)(Wildcard Characters)(Right Bound)

E.g. for if we have text response like-
.......__EVENTVALIDATION"value="weriudflsdfspdfusdjfsisdpfjpsdfohsdihffgdfgpdfjsdjfpj" />...
And we need to extract the value of Event validation variable using regular expressions; the regular expression for the same will be-
__EVENTVALIDATION" value="(.+?)" />
where, Left Bound = __EVENTVALIDATION" value="
Wildcard characters = (.+?)
Right Bound = " />

If you do not want to get deeper into regular expressions, then the wildcard characters (.+?) would suffice in most of the cases. For more information on regular expressions and meaning of each wild card character visit http://www.regular-expressions.info/tutorialcnt.html.

Regular Expression Extractor-


Coming back to JMeter, consider an example where we have two operations-
1. User launch website
2. User fill details and click on OK button
Now, the call user launch website creates a dynamic variable event validation that we can check in Response Data tab of "View Result Tree" listener for the call. The value of this variable is then passed to subsequent call related to "User fill details and click on OK button" as Http post parameter.

Steps for correlating the Event validation values-

1. Run the script containing the both the above stated operations
2. Go to Response tab (Text mode) in "View Result Tree" listener of "User launch website" operation. BTW, we see the second operation "User fill details and click on OK button" in red because it is not yet correlated.

See more at: http://testingattheedge.blogspot.in


3. Create a Regular expression for extracting the value of Event validation variable's value. As stated above the Regular Expression. for this will be- __EVENTVALIDATION" value="(.+?)" />

4. Go to http request under "User Launch Website" transaction controller-> Add -> Post Processor -> Regular Expression Extractor.


Adding "Regular Expression Extractor" control


Regular Expression Extractor Parameters Filled

5. The reference name inserted is the name of the variable created that will capture the Event validation value generated by the http request under "User launch website" operation.

6. Now pass this variable to the subsequent http request under "User fill details and click on OK button" as post request- overriding the already present hard-coded value of Event Validation variable.


Request without correlation (Hard-coded values)



Request with correlation (Dynamic values)

7. Run the Test plan again. All green? That's it.

Customers report strange hissing sound when the iPhone 7 is under stress







THOSE lucky enough to get their hands on a new iPhone 7 have been reporting a strange defect with the device.


When the handset is pushed to its processing limits it has a hissy fit, according to users. Basically, if the phone is working overtime by, for example, running lots of applications at once, it begins to make a faint hissing sound.

The noise was first pointed out by Stephen Hackett at 512 Pixels and was quickly followed by other users reporting the same thing.

In terms of malfunctions it absolutely pales in comparison to the exploding battery issue in Samsung’s Note 7 that prompted a global recall recently. But nevertheless, Apple customers and technologists have been debating the exact cause of the curious hissing sound.

“Some suspect coil whine or similar electromagnetic effects, but there’s no guarantee that this is the case,” claimed Jon Fingas from engadget.

Not all news phones are making the unsettling noise though. A number of customers reported putting their iPhone 7 under enormous stress and heard no hissing sound at all, leading some to speculate the problem could be a manufacturing issue rather than an inherent design quirk.

Samsung begins to replace Galaxy Note 7





Samsung Electronics has begun delivering the new Galaxy Note 7 to users after a worldwide recall following reports of several handsets exploding.

"The exchange program began today (Monday) and is being carried out without problems," a Samsung spokesperson told EFE.

Note 7 users who had returned their old devices will receive a new smartphone of the same model and color unless they opted for a refund.

In South Korea, the exchange is taking place 17 days after the company announced the recall and will take place in other parts of the world in the coming days, except Canada and Singapore, where the company began handing out the new devices last week.

The new Galaxy Note 7 has a green battery indicator that separates it from the earlier version.

Of the 2.5 million Note 7 sold worldwide since its launch on August 19, around 400,000 were sold in South Korea and one million in the US.

Samsung recalled Note 7 on September 2 after admitting that in 35 cases the devices had caught fire while they were being charged owing to faulty batteries.

Wednesday, March 23, 2016

Assertions in JMeter





Assertions in JMeter

Assertion help verify that your server under test returns the expected results.
Following are some commonly used Assertion in JMeter:


• Response Assertion
• Duration Assertion
• Size Assertion
• XML Assertion
• HTML Assertion



Response Assertion


The response assertion lets you add pattern strings to be compared against various fields of the server response.
For example, you send a user request to the website http://www.google.com and get the server response. You can use Response Assertion to verify if the server response contains expected pattern string (e.g. "OK").

Duration Assertion

The Duration Assertion tests that each server response was received within a given amount of time. Any response that takes longer than the given number of milliseconds (specified by the user) is marked as a failed response.
For example, a user request is sent to www.google.com by JMeter and get a response within expected time 5 ms then test case pass, else, test case failed.


Size Assertion

The Size Assertion tests that each server response contains the expected number of byte in it. You can specify that the size be equal to, greater than, less than, or not equal to a given number of bytes.
JMeter sends a user request to www.google.com and gets response packet with size less than expected byte 5000 bytes àtest case pass. If else, test case failed.

XML Assertion
The XML Assertion tests that the response data consists of a formally correct XML document.


HTML Assertion
The HTML Assertion allows the user to check the HTML syntax of the response data. It means the response data must be met the HTML syntax.



Handson - Assertion

We will continue on the script we developed in the earlier.
In this test, we are using Response Assertion to compare the response packet from www.google.com matches your expected string.

Roadmap of test:


The response assertion control panel lets you add pattern strings to be compared against various fields of the response.
Step 1) Add Response Assertion

Right-Click Thread Group -> Add -> Assertions -> Response Assertion


Response Assertion Pane displays as below figure:




Step 2) Add Pattern to test

When you send a request to Google server, it may return some response code as below:
404: Server error
200: Server OK
302: Web server redirect to other page. This usually happens when you access google.com from outside USA. Google re-directs to country specific website. As shown below, google.com redirects to google.co.in for Users.


Assume that you want to verify that the web server google.com responses code contains pattern 302,
On Response Field To Test, choose Response Code,
On Response Assertion Panel, click Add -> a new blank entry display -> enter 302 in Pattern to Test.


Step 3) Add Assertion Results
Right click Thread Group, Add -> Listener -> Assertion Results



Step 4) Run your test
Click on Thread Group -> Assertion Result
When you ready to run test, click Run button on the menu bar, or short key Ctrl+R.
The test result will display on Assertion Results pane. If Google server response code contains the pattern 302, the test case is passed. You will see the message displayed as follows:


Now back to Response Assertion Panel, you change the Pattern to test to from 302 to 500.


Because Google server response code doesn't contain this pattern, you will see the test case Failed as following:


Troubleshooting:


Any issue while running the above scenarios ... do the following:

1. Check whether you are connecting to internet via a proxy. If yes, remove the proxy.
2. Open a new instance of JMeter
3. Open the AssertionTestPlan.jmx in JMeter
4. Click on Thread Group -> Assertion Result
5. Run the Test



For More about JMeter follow on http://testingattheedge.blogspot.in

Thursday, March 17, 2016

Parameterization in Jmeter





Parameterization in Jmeter:

We parameterize the input to run the test with different set of data for each user. We will provide the data in a file and provide as input for a field.

For this we will create a .csv file in Excel and save it. For this example, we will parameterize four fields. They are from Port, to Port, passFirst0 and passLast0.

The details to corresponding fields are as follows:





We have our requests as shown below:


To add the data to the test we need to add the config element as below:
Right Click on Thread Group -> Add -> Config Element -> CSV Data Set Config



The CSV Data Set details were entered as follows:



Parameters for the CSV Data Set config is as below:


Now once the CSV Data Set is configured, we need to set the variables at appropriate position as shown:



The value is set as ${Variablename} for the required fields. For example here passFirst0 is set as ${FirstName} and passLast0 is set as ${LastName}.

Let us now verify the values are passed correctly to the required parameters from the csv file. To perform this we will add a Listener -> View Results tree as below:


In Thread group set the Number of users as 2 and run. We see that there are two sample results as we ran for two users. We check the first thread we see that from Port is Frankfurt and to Port is London which is same as first record of our .csv file.


Now, let us verify the second thread results, we see that from Port is London and to Port is New York. So for two different customers there are two different input provided.


In the same way we can check for the customer firstname and lastname also.

Thursday, March 10, 2016

Uses of Controllers in JMeter





Uses of Controllers in JMeter
JMeter in-built function controller is basically a Logic Controller provides control on “when & how” to send a user request to a web server under test. Logic Controller having command of the order of the request sends to the server.

Logic Controllers

Logic Controllers facilitates users to describe the sequence of processing request sends to the server in a Thread like; JMeter’s Random Controllers can be used to send HTTP requests randomly to the server. Logic Controllers define the order in which user request are executed.
Some useful Logic Controllers comes in operation are,

• Recording Controller
• Simple Controller
• Loop Controller
• Random Controller
• Module Controller


Recording Controller

After recording of testing process happens in JMeter, Recording Controller role is to store those recordings.


Simple Controller
Simple Controller is a container, holds user request. It does not provide any customization, randomization or change of loop count, etc as other logic controllers do.


Loop Controller
Loop Controller creates a situation where user request runs either; for limited time or forever, which is better explained in the figure,


Random Controller
Random Controller creates a situation where user request runs in random order in each loop period. Suppose, the website http://www.google.com is having 3 user requests in following order,

1. HTTP request
2. FTP request
3. JDBC request


Each user request runs 5 times i.e,HTTP request runs 5 times, FTP request runs 5 times and JDBC request runs 5 times,means; total user requests send to the Google server is 15 = 5*3 by JMeter.


In each loop, user requests send sequentially in following order,
HTTP request -> FTP request-> JDBC request
In each loop, user requests send randomly in following order,
FTP request -> HTTP request-> JDBC request
Or
JDBC request -> FTP request-> HTTP request

Module Controller
Module Controller sets the modularity in each module of JMeter function stored in Simple Controller. For example; any web application consists of numbers of functions like; sign – in, sign – out, and account creation, password change, Simple Controller stores these functions as modules then Module Controller chooses which module needs to run.Suppose, simulation happens when 50 users sign-in, 100 users sign-out, and 30 users search on website www.google.com.


Using JMeter, user can create 3 modules where each module simulates each user activity: sign-in, sign-out, and Search. Module controller selects which module wants to run.
Some More Vital Controllers
Interleave Controller: Select only one user request which runs in one particular loop of thread.
Runtime Controller: Determines that till how long its children are permitted to run.For example; if user has detailed Runtime Controller 10 seconds then JMeter will run the test for 10 seconds.
Transaction Controller:Evaluates the overall time taken to complete a test execution
Include Controller: It is created to utilize an external test plan. This controller permits you to utilize multiple test plans in JMeter.
Brief Look on Loop Controller
Here you will get to know each and every step involved in adding Loop Controller to at present performance test plan.
The Loop Controller helps samplers run at specific number of times with the loop value you definite for the Thread Group. Suppose user, add one HTTP Request to a Loop Controller with a loop count 50, configure the Thread Group loop count to 2, and then JMeter will send a total of 50 * 2 = 100 HTTP Requests. These examples are explained below in better manner,

• Configuring Thread Group
• Adding Loop Controller
• Configuring Loop Controller
• Add View Result in Table
• Run the Test


First Step: Configuring Thread Group

Add Thread Group:
To add the Thread Group, first run JMeter, from opened interface of JMeter choose Test Plan from the tree and right click to choose Add -> Threads (Users) -> Thread Group.



After opening thread Group, enter Thread Properties as shown in figure below,


In the above figure, Number of Threads: 1 user is connected to target website, Loop Count: run it 2 times, and Ramp-Up Period: 1.
The Thread Count and The Loop Counts both are different. In the Thread Count, it simulates 1 user trying to connect the targeted website. In the Loop Counts, it simulates 1 user trying to connect the targeted website 2 times.
Add JMeter elements:
Here we will Add HTTP request Default” element.
To get this element, go to Thread Group and right-clicking, from context menu select Add -> Config Element -> HTTP Request Defaults.


In the HTTP Request Defaults page, enter the Website name (www.google.com) under Web server -> Server name or IP.


Adding Loop Controller:

To open the Loop Controller pane, right click on Thread Group -> Logic Controller -> Loop Controller.


Second Step: Configuring Loop Controller:
Given below figure shows Loop Count: 50 which means one user request sends to the web server google.com run 50 times.Jmeter with take loop value =2 specified for Thread Group in the above figure to send the total HTTP Requests: 2 * 50 = 100.


Right click on Loop Controller, from context menu, click on Add -> Sampler -> HTTP request.


Third Step: Add View Results in Table:
To view the test result in tabular format, right click on Add -> Listener -> View Result in Table


View Results in Table will display like given below figure,


Fourth Step: Run the test:
After opening View Results in Table, click on Start button on Menu bar (Ctrl+R) to run test.