User Creation for Load Testing

In the leading edge digital world comprising of various applications built upon a portal technology, we land up to a situation of performance testing of the application. There-in we need users in bulk to be created for a load run which is a time consuming task with the manual process. In this scenario we can have a query to dump users into the corresponding tables in the Liferay schema instead of manually creating them. The query deals in with auto insertion of data into the Liferay tables like user_, contact_, group_. This makes user creation in Liferay a simpler task.

The bulk user creation process is as follows:

 

 

  • The user details (emailaddress, screenname, firstname etc.) available in external file (.xls or .csv etc.) is loaded into the test table.
  • Execute the query to load the data into corresponding tables in portal schema.

 

The below query to be execute to creat the users

DECLARE
  v_accountId       := '10001';
  v_companyId       := '10002';
  v_userClassNameId := '10003';
  v_userId     NUMBER;
  v_userName   VARCHAR2(50);
  v_userEmail  VARCHAR2(50);
  v_screenName VARCHAR2(50);
  v_UUID       VARCHAR2(50);
BEGIN
  FOR(var currentTestUser IN
  (SELECT * FROM testUserData
  ))
  LOOP
    dbms_output.put_line(currentTestUser.userid);
    v_userId     := currentTestUser.userid;
    v_userName   := currentTestUser.username;
    v_userEmail  := currentTestUser.useremail;
    v_screenName := currentTestUser.screenname;
    -- Insert into contact_
    INSERT
    INTO Contact_
      (
        v_userId,          --contactId
        v_companyId,       --companyId,
        v_userId,          --userId,
        v_userName,        --userName,
        sysdate,           --createDate,
        sydate,            --modifiedDate,
        v_userClassNameId, --classNameId.
        v_userId,          --classPK,
        v_accountId,       --accountId,
        0,                 --parentContactId,
        v_userEmail,       --emailAddress,
        v_userFirstName,   --firstName,
        NULL,              --middleName,
        v_userLastName,    --lastName,
        0,                 --prefixId,
        0,                 --suffixId,
        1,                 --male,
        sysdate,           --birthday,
        NULL,              --smsSn,
        NULL,              --aimSn,
        NULL,              --facebookSn,
        NULL,              --icqSn,
        NULL,              --jabberSn,
        NULL,              --msnSn,
        NULL,              --mySpaceSn,
        NULL,              --skypeSn,
        NULL,              --twitterSn,
        NULL,              --ymSn,
        NULL,              --employeeStatusId,
        NULL,              --employeeNumber,
        NULL,              --jobTitle,
        NULL,              --jobClass,
        NULL,              --hoursOfOperation,
      );
    -- Insert into user_
    INSERT user_
    INTO VALUES
      (
        v_UUID,       --uuid_,
        v_userId,     --userId,
        v_companyId,  --companyId,
        sysdate,      --createDate,
        sysdate,      --modifiedDate,
        0,            --defaultUser,
        v_userId,     --contactId,
        'Password1',  --password_,
        0,            --passwordEncrypted,
        0,            --passwordReset,
        NULL,         --passwordModifiedDate,
        NULL,         --digest,
        NULL,         --reminderQueryQuestion,
        NULL,         --reminderQueryAnswer,
        0,            --graceLoginCount,
        v_screenName, --screenName,
        v_userEmail,  --emailAddress,
        0,            --facebookId,
        -1            --ldapServerId,
        NULL,         --openId,
        0,            --portraitId,
        'en_US'       --languageId,
        'UTC'         --timeZoneId,
        'Welcome'
        || v_screenName, --greeting,
        NULL,            --comments,
        v_userFirstName, --firstName,
        NULL,            --middleName,
        v_userLastName,  --lastName,
        NULL,            --jobTitle,
        NULL,            --loginDate,
        NULL,            --loginIP,
        NULL,            --lastLoginDate,
        NULL,            --lastLoginIP,
        NULL,            --lastFailedLoginDate,
        0,               --failedLoginAttempts,
        0,               --lockout,
        NULL,            --lockoutDate,
        1,               --agreedToTermsOfUse,
        0,               --emailAddressVerified,
        0                --status
      );
    INSERT
    INTO group_ VALUES
      (
        v_GroupUUID, --uuid_,
        v_userId,    -- groupId
        v_companyId, -- companyId,
        v_userId,    -- creatorUserId,
        '10005',     -- classNameId,
        v_userId,    -- classPK,
        0,           -- parentGroupId,
        0,           -- liveGroupId,
        '/'
        ||v_userId
        ||'/'     -- treePath,
        v_userId, -- name,
        NULL,     -- description,
        0,        -- type_,
        NULL,     -- typeSettings,
        1,        -- manualMembership,
        0,        -- membershipRestriction,
        '/'
        || v_screenName -- friendlyURL,
        0,              -- site,
        0,              -- remoteStagingGroupCount,
        1               -- active_,
      );
  END LOOP;
END;
 
NOTE :  The below values should be hardcoded with corresponding values from portal schema :
  • v_accountId       := '10001';
  • v_companyId       := '10002';
  • v_userClassNameId := '10003';

ADVANTAGES:

  • Automated process for bulk user creation.
  • Saves time and manual effort.
  • Supports performance test activities with minimal effort.
  • Process of bulk user creation in Liferay simplifies the performance tests execution. 
Blogs
I'm sorry, I have to disagree here. Inserting data to Liferay's Database through SQL is not a good idea. You will (sooner or later, hopefully sooner) run into issues that will look like malfunction of the portal.

I can identify 3 different potential issues out of the box - but if I'd name them here it would look like they just need to be fixed. As I do believe that I'm not thinking of all issues, I'm rather not listing them here and rather advise against the use of SQL for writing data. Use the API - that's what it's there for.
Hi Olaf,

This activity is for the User Load testing with Limited functionality. It is not recommended for the Production environment.
This SQL can be modified as per custom requirement. SQL are more faster than API and It is use full when we require to have 20 K- 40 K user for a load test.
It is similar to creating user into the DB with help of SQL during the initial portal start up.