Improving load test tool.

This commit is contained in:
lotodore
2011-02-27 13:40:55 +00:00
parent 1f833d106a
commit 22718fad46
+41 -9
View File
@@ -169,10 +169,21 @@ main(int argc, char *argv[])
return 1;
}
PokerTHMessage_t *msg;
PokerTHMessage_t *msg = NULL;
int errorCode;
char *tmpOut;
size_t tmpOutSize;
string nextGsaslMsg;
NetSession **sessionArray = new NetSession *[numGames * 10];
unsigned *gameId = new unsigned[numGames];
for (int i = 0; i < numGames * 10; i++) {
const int LoginsPerLoop = 50;
for (int t = 0; t < (numGames * 10) / LoginsPerLoop + 1; t++) {
int startNum = t * LoginsPerLoop;
int endNum = (t + 1) * LoginsPerLoop;
if (endNum > numGames * 10) {
endNum = numGames * 10;
}
for (int i = startNum; i < endNum; i++) {
sessionArray[i] = new NetSession(ioService);
NetSession *session = sessionArray[i];
@@ -192,8 +203,11 @@ main(int argc, char *argv[])
InitMessage_t *netInit = &msg->choice.initMessage;
netInit->requestedVersion.major = 2;
netInit->requestedVersion.minor = 0;
int errorCode = gsasl_client_start(authContext, "SCRAM-SHA-1", &session->authSession);
if (errorCode == GSASL_OK) {
errorCode = gsasl_client_start(authContext, "SCRAM-SHA-1", &session->authSession);
if (errorCode != GSASL_OK) {
cout << "Auth start error." << endl;
return 1;
}
ostringstream param;
param << "test" << i + firstId;
cout << "User " << param.str() << " logging in." << endl;
@@ -204,9 +218,6 @@ main(int argc, char *argv[])
netInit->login.present = login_PR_authenticatedLogin;
AuthenticatedLogin_t *authLogin = &netInit->login.choice.authenticatedLogin;
char *tmpOut;
size_t tmpOutSize;
string nextGsaslMsg;
errorCode = gsasl_step(session->authSession, NULL, 0, &tmpOut, &tmpOutSize);
if (errorCode == GSASL_NEEDS_MORE) {
nextGsaslMsg = string(tmpOut, tmpOutSize);
@@ -223,7 +234,10 @@ main(int argc, char *argv[])
cout << "Init auth request failed" << endl;
return 1;
}
}
for (int i = startNum; i < endNum; i++) {
NetSession *session = sessionArray[i];
msg = receiveMessage(session);
if (!msg || msg->present != PokerTHMessage_PR_authMessage) {
cout << "Auth request failed" << endl;
@@ -255,13 +269,16 @@ main(int argc, char *argv[])
cout << "Init auth response failed" << endl;
return 1;
}
}
for (int i = startNum; i < endNum; i++) {
NetSession *session = sessionArray[i];
msg = receiveMessage(session);
if (!msg || msg->present != PokerTHMessage_PR_authMessage) {
cout << "Auth response failed" << endl;
return 1;
}
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
}
// Receive init ack
msg = receiveMessage(session);
@@ -280,6 +297,7 @@ main(int argc, char *argv[])
}
}
}
}
for (int g = 0; g < numGames; g++) {
NetSession *session = sessionArray[g * 10];
@@ -336,7 +354,13 @@ main(int argc, char *argv[])
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
}
for (int i = 0; i < numGames * 10; i++) {
for (int t = 0; t < (numGames * 10) / LoginsPerLoop + 1; t++) {
int startNum = t * LoginsPerLoop;
int endNum = (t + 1) * LoginsPerLoop;
if (endNum > numGames * 10) {
endNum = numGames * 10;
}
for (int i = startNum; i < endNum; i++) {
if (i % 10 == 0) {
continue;
}
@@ -359,6 +383,12 @@ main(int argc, char *argv[])
return 1;
}
msg = NULL;
}
for (int i = startNum; i < endNum; i++) {
if (i % 10 == 0) {
continue;
}
NetSession *session = sessionArray[i];
// Receive join game ack
do {
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
@@ -377,6 +407,8 @@ main(int argc, char *argv[])
return 1;
}
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
msg = NULL;
}
}
bool terminated = false;
while (!terminated) {