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