Monday, March 22, 2010

MySites Testing

Recently, we were tasked with testing of concurrent MySites creation. In another words, simulating X (e.g. 50) users clicking on MySites link within their SP portal. You can obviously use SharePoint API and SSP Profiles (UserProfile.CreatePersonalSite()) to kick of MySite creation but that was not going to work in our case as a certain set of customizations was kicked off upon the first visit to the MySite home page. 

Thanks to couple handy tools, namely Fiddler and VS 2010 Web Test suite we were able to determine how to mimic users behavior. Long story short:

  1. When user clicks on MySite link, HTTP GET is issued to MySite Host URL.
  2. Read response from the server, extract ViewState and RequestDigest context parameters (need them for follow up POST).
  3. Issue HTTP POST back to the same MySite Host URL with the couple of context parameters retrieved from GET. NOTE: Don't forget to append the empty "?create=" querystring parameter.
  4. Rest is up to you: e.g. loop which spawns multiple threads which start make calls to #1.

Obviously, both of these HTTP requests need to be authenticated with the given user's credentials so in real life/production scenario you will most likely not have that luxury but in Test/DEV environment you might be able to have access to test accounts + their passwords. 

Below is the screenshot of the sample code that performs steps 1-3.