Friday, July 31, 2009

JMeter - Tests recording and sending binary files (multipart/mixed requests)

Few weeks ago I wanted to test uploading a binary file to HTTP server using JMeter. It is a very good tool, but there are some issues. Theoretically there are three ways of doing this in JMeter.

1. Creating a single request file from scratch

The hardest approach is to create a full HTTP request, containing all the headers and content of the binary file and use that file in a definition of a test case.

2. Recording a test case

JMeter allows recording traffic between a server and a client. Unfortunately for some reason a recorded http request was corrupted. There was a problem with some characters, so the server wasn't able to parse even a header of the request. I thought that the problem is in a wrong encoding. I changed it to "UTF-8" in "HTTP Request Defaults" and it started to work. The file appeared on the server. After that, I wanted to check if it works with other encoding types, it worked the same with all of them. Than I removed completely the encoding setting and it still worked. Then I removed JMeter and installed (unpacked) it again and tried without setting the encoding - it worked. It seems that setting the encoding solves the problem, but I have no idea why it still worked although I removed it. Unfortunately I didn't have time to investigate it deeper.

3. Creating a test case manually using a JMeter UI

In the JMeter UI there is a dialog which allows defining a test case. Tester is able to add a http request header paramters and attach files which will be send as a content of the http request. The problem is that there is no way to set a content type as multipart/mixed, what was required in my case.

JMeter as a proxy - binary files corrupted

During investigation I noticed that when JMeter is set as a proxy, uploaded files are somehow corrupted. It might be related to previously mentioned encoding settings. For those who want to do performance tests I think that it doesn't matter that much.

I need to mention that I didn't spend too much time to investigate the problem and I used JMeter with GUI. If someone knows better solutions, comments will be appreciated.

Besides described issues, JMeter is a really useful tool.

Saturday, June 6, 2009

Scrum Master Role

I've been working in Scrum projects about two and half years. Scrum and Agile were interesting for me since the beginning so I've been reading about it, watching how it is implemented and discussing it with friends. I thought that I got an idea and CSM training is just a mere formality. I wasn't right...

I thought that the Scrum Master role is to kind of help the Team or the Product Owner to figure out some solution for a certain problem, or even find it for them. This is the point where I misunderstood the role, I went to far. The Scrum Master responsibility is just to make sure that the Scrum is properly implemented. That's all. Scrum Master has to make sure that appropriate tasks are handled by appropriate Scrum roles, that responsibilities are divided in a Scrum way, that all Scrum tools are used when it is necessary and what is the most important that people want to use the Scrum because they understand it and found it useful. In order to achieve that the Scrum Master should react when roles don't follow the process and by asking appropriate questions and using appropriate Scrum tools find a reason and escalate a problem to an appropriate level and let it be handled by an appropriate role - this is one of the main goal of the Scrum. It means that the difficulty is to figure out questions which force people to take the responsibility and help them to find a real cause of a problem or understand the Scrum. I realized that my tendency was to make a decision which were in other roles responsibility.

It actually in a sense simplify a role, since Scrum Master doesn't have to make any decisions, doesn't have to know solutions for the Product Owner or the Team problems, he just have to take care about the Scrum - like actually the Scrum Master title says.

Recommended book: "Agile Project Management with Scrum" Ken Schwaber

Quotes

"The definition of insanity is doing the same thing over and over again and expecting different results" Albert Einstein

"A complex system that works is invariably found to have evolved from a simple system that worked. The inverse proposition also appears to be true: A complex system designed from scratch never works and cannot be made to work. You have to start over, beginning with a working simple system." John Gall's

"The best is an enemy of good"

Thursday, September 11, 2008

UI Virtualization, UI Recycling, Data Virtualization and Efficient Scrolling in WPF

Some time ago I decided to write an efficient panel in WPF. I wanted that it arranges controls inside in multiple columns and rows, loads data very fast without blocking UI, and saves memory. I didn't want to implement a completely new control from scratch.

I found only several articles about this issue:

Dan Crevier - a virtualized panel and Ben Constable - IScrollInfo implementation:
http://rhnatiuk.wordpress.com/2006/12/13/implementing-a-virtualized-panel-in-wpf/
Dr.WPF - very good information about classes used to implement the panel:
http://www.drwpf.com/blog/ItemsControlSeries/tabid/59/Default.aspx
Wired Prairie - a multithreaded data loading (PhotoScroller):
http://www.wiredprairie.us/journal/2007/04/photoscroll_the_worst_named_wp.html

Cedric Dussud's - good overview of possible optimalization approaches in WPF:
http://download.microsoft.com/download/2/d/b/2db72dcf-5ae0-445f-b709-7f34437d8b21/Scrolling_in_WPF.doc
Beatriz Costa - other useful information:
http://www.beacosta.com/blog/

Only one article describes how to do a UI recycling but unfortunately by creating a control from scratch so I was forced to figure out my own way of doing this. Below you can find the result.

To proceed you need to know sources of examples of Dan Crevier, Ben Constable and Wired Prairie (PhotoScroller).

UI Recycling, UI Virtualization and Smoothly Scrolling

In the MeassureOverride method I check the maximum number of items which can be visible at once. Then I create such number of containers and add them to the internal children list of the panel. To create them I use GenerateNext and PrepareItemContainer methods of ItemContainerGenerator. I use GenerateNext method because the generator asks ItemsControl to create an appropriate UI element representing an item so I don't have to know what is its type. Because I'm not sure how the generator is implemented inside after that I remove created items from the generator. Then during scrolling, also in MeassureOverride I fill containers (starting always from the beginning) with appropriate data using DataContext:

(children[i] as ContentPresenter).DataContext = _itemsControl.Items[firstVisibleItemIndex + i];

In order to get smoothly scrolling (per pixel) I update _trans.Y in this way:

_trans.Y = -(offset%ChildSize);

in SetVerticalOffset method.

Data Virtualization

In order to load data for visible items only, in a way which doesn't block a UI, I created DataLoader (see the PhotoScroller example). It has a list of objects which need to be fill with data (for example loaded from a hard disk). The data are loaded in LIFO (Last In, First Out) order, after loading they are removed from the list. The objects are removed from the list also when they are not visible anymore, so the DataLoader doesn't load unnecessary data. The DataLoader works in a separate thread. Objects which needs to be fill are added in the MeassureOverride method, when the DataContext is set.

This is very short description. I'm going to describe it soon in more details, with sources.

Summary

I presented here just an overview of the solution. A lot of issues, like for example a panel resizing or a synchronization between threads weren't described here yet. I'm also not sure that this solution is correct from the WPF point of view. Anyway it seems to works fine and very fast :).