Social media mobile phone apps are increasingly sophisticated. Some of them take advantage of the built-in hardwares such as camera, microphone and GPS: user can take a snapshot, record some voice and upload the snapshot, voice recording, text message and coordinates to share them with friends or public.
As we enjoy so many social media apps, us performance test professionals are also interested in the server capacity. On many performance test platforms, it's easy to emulate users uploading files to a server, so is on NetGend platform. Here is a simple example. It uploads a file whose name is "mynote.txt" and whose content is
fix bug 11223
Update documentation
The script is very short:
http.multipart."filename*mynote.txt" = "fix bug 11223\r\nUpdate documentation";
action(http,"https://www.example.com/upload.php")
For another example, we upload an image file:
This script is short too:
http.multipart."filename*dog.jpg" = readFile("dog.jpg");
action(http,"https://www.example.com/upload.php")
The difference from previous example is the use of a function called readFile() which will get the content of a file for uploading. It will work on both text files and binary files (like the image file in the example).Recently I saw a blog that gives a solution on uploading files with variable contents using loadrunner test platform. It's interesting but quite complex since users will need to understand some intricacies of HTTP multipart such as boundary. We will see how easy it is on NetGend platform with two examples. The first example will upload a directory of image files to the server. Note that there is no need to know about the structure of a multipart message.
function userInit() {
var files = fromDirectory("images"); //read all the files in that directory
}
function VUSER() {
f = getNext(files); //will get a file
http.multipart."filename*${f}" = readFile(f);
action(http,"https://www.example.com/upload.php")
}
The second example shows we can dynamically generate contents and upload them to a server.
function userInit() {
var id = 0;
}
function VUSER () {
id ++;
http.multipart."filename*mynote${id}.txt" = "my note ${id}";
action(http,"https://www.example.com/upload.php")
}
The above example will upload the files "mynote1.txt", "mynote2.txt" .... whose content are dynamically generated: "my note 1", "my note 2", ....File uploading is just one piece of social media mobile phone apps, we don't want spend too much time on it when we are doing the performance test. Is it easy and fast to do it on your favorite test platform?
No comments:
Post a Comment