domingo, 16 de abril de 2017

HLS Load Testing with Jmeter

HLS Load Testing with Jmeter


  1. What’s HLS?
  2. What’s the approach for Jmeter Tool?
  3. How to script it?

1.What is HLS?

(HLS) HTTP Live Streaming

HLS is an HTTP based media streaming communication protocol implemented by Apple. It resembles MPEG-DASH in that it works by breaking the overall stream into a sequence of small HTTP based files, each downloaded file loads one short Chunk of an overall potentially unbounded transport stream. As the stream is played, the client may select from many different alternate streams containing the same material encoded at a variety of data rates, allowing the streaming session to adapt to the available data rate. At the start of the streaming session, HLS downloads an extended M3U playlist containing the metadata for the various sub-streams which are available.
So, it’s an easy way to get a rid of all the complex protocols, because its HTTP based. The best thing of HLS is that M3U8 and Chunk files are simple text, so it’s easy to correlate and just send HTTP requests to download the video pieces.

2. What’s the approach for Jmeter Tool?
Jmeter is an open source tool that is based in HTTP protocol, then if the HLS is also HTTP based, we have a good tool for the testing purposes, my approach will be the following:
Assets:
1.- Install Jmeter version 3.1+ and Java 1.8+ JDK.
2.- The URL of the HLS Server and the path of the m3u8 file.
3.- Basic knowledge of Jmeter.
Logic:
1.- The m3u8 file contains the Chunk files or streams with different qualities of streams that could be retrieved from the server, so depending on you scope if select a random stream and then in the next iteration select another random or iterate over all of them in sequence.
2.- The Chunk file contains the TS files or video slides that will contain the information that will be show in the player.
Scope:
1.- Select one random stream per iteration.
2.- Select all the streams in sequence.

3. How to script it?
We are going to use the following testing video, please don’t run load over it or we could lose the service.
https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8
Server: bitdash-a.akamaihd.net
Path: /content/MI201109210084_1/m3u8s/
File: f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8
1.- We need to define this values as a variables in Jmeter, add "User Defined Variables" item in the test plan. The following image describes it. Also those could be defined also at Test plan level.

2.- We need to define an HTTP request to retrieve the m3u8 file from the HLS server, the HTTP request is going to be a GET, it's very important to select the correct protocol, in this case we are using HTTPS and over the port 443. The way that Jmeter access the variables is using ${VAR_NAME}, so the ServerPath and File variables that we defined previously could be accessed easily as the image shows.

3.- We need to define a regular expression to correlate the Chunk or Chunks that we will use to retrieve the streams. If you need any assistance in this step contact me atantoniojn@hotmail.com, the main idea is to create a regular expression to grab the value or values, in this case I’m grabbing all the values, because Im executing the scenario #2. If you want to select a random Chunk, modify the value "-1" to "0".

4.- The best way to iterate over all the values grabbed from the regular expression is to use a “ForEach Controller”, it also could be by programming in bean shell scripting, your choice, the idea is to iterate over all the Chunks retrieved. If your scope is the scenario #1, this is step is not needed.

5.- Now we need to retrieve the Chunk’s file to get the TS slices, another GET HTTP request is needed, the request is like the first one, but the difference is the substitution of the Chunk variable in the “Path”.

6.- Another regular expression extractor is needed to grab the TS slides, this time the values will be stored in the Streams variable.

7.- Another “ForEach Controller” is also needed, but this time to grab all the TS files of the streaming, in this case the values are in the variable Streams and will iterate over each one of the TS slices.

8.- Finally, we need to generate a the last GET HTTP request to retrieve the video slices or TS files.

Validations
Step #2 and #3
From Step #2 we can see the GET HTTP request to retrieve the m3u8 file.

From Step #3 we can see the values retrieved, here we might test the regular expression "if it does match" to grab the streams.

Step #5 and #6
From Step #5 we can see the GET HTTP request to retrieve the m3u8 Chunk file.

From Step #6 we can see the values retrieved, here we might test the regular expression "if it also matches" to grab the TS slice files.

Step #8
The final request of the TS files, won’t show information in the response data section, because we don’t have installed a proper plug in to visualize it, but we can validate the Content in the Header in the Sample Result section.
I hope you have enjoyed this HLS Tutorial for Jmeter, if you have any question or want to comment something reach me at antoniojn@hotmail.com

0 comentarios:

Publicar un comentario