Server performance testing is based on client emulation. At a high level, all the client emulation boils down to some simple networking operations:
- client connects to server,
- get into a sequence of message exchanges with server, i.e. get into a loop of
- receive a message from server
- send one or more messages to server
- close the connection.
Make a connection:
//syntax
connect(<hostname|ip>, <port>);
//example
connect("example.com", 25);
Receive a message:
//syntax
recv(<varName>);
//example
recv(msg);
//this will put the received message in variable "msg"
To send a message,
//syntax
send(<msg>);
//example 1
send("Hello my name is John");
//example 2
name = "John";
msg = "Hello my name is ${name}";
send(msg);
To close a connection,
//syntax
close();
What about SSL/TLS based sessions? Yes, we support them. In fact, you can start SSL/TLS at any time when the connection is setup.
starttls();
After that, all the messages you send will be encrypted, all the message you receive will be decrypted. You can process messages as if they are clear text. This makes it very easy to debug a SSL/TLS based transaction: you can simply print the message you sent or message you received. This is invaluable since packet captured by sniffers like wireshark may not help (all packets are encrypted!).
Now combined with variables, conditions supported in EP scripting, we can emulate any complex TCP/IP based protocols.
As a simplified real world example, let's emulate a simple SMTP client.
//read from a file and populate variables email and receipant
connect("example.com", 25);
//wait for server greating
recv(msg);
send("HELO myhost");
recv(msg);
send("MAIL FROM: <${email}>");
recv(msg);
send("RCPT TO: <${receipant}@example.com>");
recv(msg);
send("DATA");
recv(msg);
send("Subject: Test Message\nTest Body\n.");
recv(msg);
send("QUIT");
recv(msg);
close();
You may notice that we don't do any error checking here, that's because we want to make the basic example look as simple as possible. Adding error checking and handling is not hard with an "if" condition. For instance, we can do the following to check if the server greeting begins with "220",
//read from a file and populate variables email and receipant
connect("example.com", 25);
//wait for server greating
recv(msg);
if (! contains(msg, /^220/)) {
totalFailure ++;
return;
}
Of course, adding error checking for all received messages is going to make the script much longer.Our platform can emulate a large number of clients - 50,000! If I were a server, I would be worried :-)
No comments:
Post a Comment