Load Testing WebDAV Servers
In this post, we'll give a tutorial that covers how to load test the unique abilities of the WebDAV server that are working on.
Join the DZone community and get the full member experience.
Join For FreeWebDAV is a set of extensions to the HTTP protocol, enabling more operations to resources. If you are using a WebDAV server, you should learn how to load test its unique abilities. This blog post will cover just that! We will explain how you can use Apache JMeter™ to load test COPY, MOVE, MKCOL, and more. Let's get started.
WebDAV ("Web-based Distributed Authoring and Versioning") is a set of extensions to the HTTP protocol that allows clients to perform remote Web content authoring operations.
Since WebDAV is an extension to the HTTP protocol, let's review a few things about the HTTP protocol first.
HTTP stands for Hypertext Transfer Protocol. It is the most widely used protocol for communication over the World Wide Web. The HTTP protocol defines the following methods: GET, PUT, POST, OPTIONS, HEAD, TRACE, CONNECT, and DELETE.
WebDAV adds the following new functionalities to HTTP: create, change and move resources (documents) on a server, namespace management (collections), management of properties about an author, modification of the date or anything else and overwrite protection. WebDAV extends HTTP without changing the existing functionality. The WebDAV protocol supports all HTTP methods and adds the following methods: MKCOL, COPY, MOVE, LOCK, UNLOCK, PROPPATCH, and PROPFIND.
The list below displays the most commonly used HTTP and WebDAV methods.
- PUT - Upload new or update an old resource.
- GET - Read resource data.
- DELETE - Delete resources or collections.
- MKCOL - Create a collection.
- COPY - Copy resources or collections.
- MOVE - Move resources or collections.
- LOCK- Lock a resource or collection to avoid overwrite conflicts.
- UNLOCK - Unlock a locked resource or collection to make it available for writing.
- PROPPATCH - Manage properties defined on a resource.
- PROPFIND - Get property values from a resource.
WebDAV Methods on JMeter
JMeter supports all of these methods with the HTTP request sampler. So we don't need any plugins or extensions to work with WebDAV servers.
However, we do need a WebDAV server to see how it works. I used a public service https://www.webdavserver.com/, which provides a free personal WebDAV server for testing purposes.
While this service is free, they do ask that users keep their load testing to a reasonable size. Let's take this into account when we do our performance testing.
Of course, if you have your own WebDAV server you can test as thoroughly as you would like.
All WebDAV related methods can be divided into several groups: Resource management (PUT, GET), Namespace management (MKCOL, COPY, MOVE, DELETE), Lock management (LOCK, UNLOCK) and Properties management (PROPPATCH, PROPFIND). We will go over all of them. Let's get started.
1. Resource Management
Standard HTTP methods allow you to read, write, and delete resources on a WebDAV server. Let's take a look at how to manage the documents below.
PUT Method
Writing content to a WebDAV server can be done in several ways by using an HTTP Request sample in JMeter.
The first way is to send to the body of the resource with the Body Data option of the HTTP Request.
Add an HTTP request sample and open the Body Data tab.
Fill in the following values:
- Protocol: https
- Server Name or IP: www.webdavserver.com
- Port Number: 443
- Method: PUT
- Path: your_path/blazefile.txt
- Body data:
- BlazeMeter WebDAV blog post
- BlazeMeter WebDAV blog post
- BlazeMeter WebDAV blog post
- BlazeMeter WebDAV blog post
After running this request, we can see the newly created blazefile.txt file in the web UI of the service. The text in the "Body Data" is what will appear in the file.
Another way to write to resources is to use the Files Upload option of an HTTP request sample.
Add an HTTP request sample and go to the Files Upload tab. Copy the web server values from the previous request.
Fill in the following values:
- Method: PUT
- Path: your_path/blazefile.pdf
- Files Upload:
- File path: /path_to_file/blazefile.pdf
- MIME Type: application/pdf
We are able to upload any file from a local machine to the WebDAV server. I used a 1MB pdf file.
GET Method
Use the GET method to read resources from a WebDAV server.
Add an HTTP request sample.
Fill in the following values:
- Method: GET
- Path: your_path/blazefile.txt
This request will show the content of the file in the response. You can verify this by using the View Results Tree listener.
2. Namespace Management
The MKCOL, COPY, MOVE, and DELETE methods are designed to manage hierarchical namespaces (collections) that have resources located under those namespaces.
MKCOL Method
Requests with the MKCOL method will create an empty collection.
Add an HTTP request sample and fill in the following fields.
Required values:
- Method: MKCOL
- Path: your_path/blazecollection
Execution of this request creates a blazecollection collection. You can check it by using the web UI.
COPY Method
You can use the copy operation for a single resource and for collections. Copying a collection will also copy all its nested collections and resources.
NOTE: the destination location should be set in the HTTP header.
To copy a single resource:
Add an HTTP request sample.
Fill in the following values:
- Method: COPY
- Path: your_path/blazefile.txt
Add an HTTP Header Manager to the HTTP request sample to set the destination file for this resource.
Add one row to this Config Element: Destination: https://www.webdavserver.com:443/your_path/blazefile_copy.txt
After execution, a copy of the file will be placed in the same location as the copied file. Verify it by using the web UI.
To copy a collection:
Add another HTTP request or update the previous request to copy a collection.
Fill in the following values:
- Method: COPY
- Path: your_path/blazecollection
Type in the collection destination instead of the location of a particular resource.
Add an HTTP Header Manager and also set the destination location.
Add one row: Destination: https://www.webdavserver.com:443/your_path/blazecollection_copy
This request will copy the whole collection, together with its nested elements, to a new place.
MOVE Method
The move operation is also possible for single resources as well as collections. Moving a collection will move all of its nested collections and resources.
NOTE: the destination location should be sent to the server in the HTTP header.
To move a single resource:
Use an HTTP request sample just like our other requests.
Fill in the following values:
- Method: MOVE
- Path: your_path/blazefile.txt
The document specified in the path field is a source document and will be deleted after successfully moving it to a new location.
Add an HTTP Header Manager to the HTTP request sample.
Add a row to this Config Element: Destination: https://www.webdavserver.com:443/your_path/blazefile_move.txt
The Blazefile.txt will be moved to blazefile_move.txt after execution of this request.
How to move a collection:
Add an HTTP request sample or update the previous one.
Fill in the following values:
- Method: MOVE
- Path: your_path/blazecollection
Add an HTTP Header Manager to the HTTP request sample.
Set the destination in the HTTP Header Manager: Destination: https://www.webdavserver.com:443/your_path/blazecollection_move
This request will move the whole collection along with its nested elements to a new place.
DELETE Method
A delete request will destroy a single resource or collection with all of its nested collections and resources.
To delete a single resource:
Add an HTTP request sample.
Fill in the required values:
- Method: DELETE
- Path: your_path/blazefile.txt
This request will delete the blazefile.txt resource from the WebDAV server.
To delete a collection:
To delete a collection add a HTTP request sample.
Fill in the following values:
- Method: DELETE
- Path: your_path/blazecollection
Execution of this sample will delete the entire collection including all nested elements.
3. Lock Management
Locking resources is necessary to avoid problems with overwriting conflicts between concurrently active users. It is common practice when an author makes an exclusive lock before writing an object and unlocking it after editing is done. WebDAV allows two kinds of locks: shared locks and exclusive locks.
Locking is available for single resources and for collections. Let's see how to lock a single resource below.
LOCK Method
Add an HTTP request sample as usual.
Required values:
- Method: LOCK
- Path: your_path/blazefile.txt
- Body Data:
<?xml version="1.0" encoding="utf-8"?>
<lockinfo xmlns='DAV:'>
<lockscope><exclusive/></lockscope>
<locktype><write/></locktype><owner>BlazeMeter</owner>
</lockinfo>
This is an example of an exclusive lock. This type of lock is important because some servers support only exclusive locks.
Run this request and check the response.
The response contains a lock token which is necessary to send as an HTTP header with an UNLOCK request to pass authorization.
Add an XPath Extractor to the HTTP Request to retrieve the token.
Fill in the following values:
- Reference Name: locktoken
- XPath query: //*[name()='d:locktoken']/*[name() = 'd:href']
- Default Value: ERROR
The lock token will be saved to the locktoken variable and we will be able to use it to unlock the request.
UNLOCK Method
To unlock a request add an HTTP request sample.
Required values:
- Method: UNLOCK
- Path: your_path/blazefile.txt
Add an HTTP Header manager to send the lock token as an HTTP header.
Add row: Lock-Token <${locktoken}>
The execution of this request should unlock the file for future changes by other authors.
4. Properties Management
WebDAV has two kinds of properties: live properties and dead properties. A live property is a property that is determined and managed by the server. Each resource has a fixed number of live properties. For example, the live "getlastmodified" property presents the last modification time. This value is automatically updated by the server each time a resource changes. A dead property, on the other hand, is a property that is determined and managed by the user. The server only records the value of this property. For example, the dead "version" property contains the version of the current document. The user is responsible for updating the value of these properties.
PROPPATCH Method
Let's see how to set dead properties via JMeter.
Add an HTTP Request sample.
Fill in the following values:
- Method: PROPPATCH
- Path: your_path/blazefile.txt
- Body Data:
<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:">
<D:set><D:prop><prop0 xmlns="https://www.blazemeter.com/">blazevalue0</prop0></D:prop></D:set>
<D:set><D:prop><prop1 xmlns="https://www.blazemeter.com/">blazevalue1</prop1></D:prop></D:set>
<D:set><D:prop><prop2 xmlns="https://www.blazemeter.com/">blazevalue2</prop2></D:prop></D:set>
</D:propertyupdate>
Run this request to assign three dead properties (prop0, prop1, prop2) to the blazefile.txt file.
PROPFIND Method
Reading dead or live properties can be accomplished by using the PROPFIND request.
To read dead properties:
Add an HTTP Request sample.
Fill in the following values:
- Method: PROPFIND
- Path: your_path/blazefile.txt
- Body Data:
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:"><prop>
<prop0 xmlns="https://www.blazemeter.com/"/>
<prop1 xmlns="https://www.blazemeter.com/"/>
<prop2 xmlns="https://www.blazemeter.com/"/>
</prop></propfind>
Execute the sample and see the response.
The response contains a list of asked properties with their values.
To read live properties:
Add an HTTP Request sample.
Fill in the following values:
- Method: PROPFIND
- Path: your_path/blazefile.txt
- Body Data:
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:"><prop>
<creationdate xmlns="DAV:"/>
<getlastmodified xmlns="DAV:"/>
<resourcetype xmlns="DAV:"/>
<supportedlock xmlns="DAV:"/>
<lockdiscovery xmlns="DAV:"/>
<getcontentlength xmlns="DAV:"/>
<getetag xmlns="DAV:"/>
<getcontentlanguage xmlns="DAV:"/>
<getcontenttype xmlns="DAV:"/>
<supportedlock xmlns="DAV:"/>
</prop></propfind>
Check the response after running the request.
The response contains all of the requested properties with the actual values.
Script and Test Run
Now let's create a simple script to run a performance test on the WebDAV server to see how it goes. Download the JMX file from here.
Here is a short description of the test script:
- MKCOL: Create a 'blazecollection' collection.
- PUT: Put 1MB file ('blazefile.pdf') in this collection.
- PROPPATCH: Set dead properties to file 'blazefile.pdf.'
- PROPFIND: Get dead properties from the 'blazefile.pdf' file.
- PROPFIND: Get live properties from the 'blazefile.pdf' file.
- COPY: Copy 'blazefile.pdf' file to 'blazefile_copy.pdf' file.
- MOVE: Move 'blazefile_copy.pdf' to 'blazefile_move.pdf.'
- LOCK: Lock 'blazefile.pdf' file.
- UNLOCK: Unlock 'blazefile.pdf' file.
- DELETE: Delete 'blazecollection' collection.
This script can be compiled from the samples that we learned in this blog post above with some minor changes. Collections should have unique names to avoid conflicts with other virtual users. This can be accomplished by adding the Thread Number to the name of each collection. An example of a collection name: blazecollection${__threadNum}.
I have created a Thread Group with the following parameters: Number of Threads is 10; Ramp-up period is 10 seconds; Loop count is 10. Let's keep in mind that WebDAV service holders asked that we keep the load to a reasonable size.
The results of the test run are presented in the Aggregate Report below.
As you can see, we can draw some conclusions. This WebDAV server can work with 10 active users simultaneously. Uploading a 1MB file will take about 4 seconds. Locking is slower than unlocking, etc.
That's it! Now you can start writing your own awesome WebDAV server script.
To learn more JMeter, check out our free JMeter academy with advanced and basic courses.
Published at DZone with permission of George Maksimenko, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments