Tuesday 17 April 2012

Friday 13 April 2012

Team Foundation Server 2010: Build - Deploy - Test (Part 1)

Visual Studio - Lab Management (An Introduction)

Overview 

  • Visual Studio Lab Management is an extension of Microsoft Test Manager that helps you to optimize the use of Microsoft Hyper-V technology to manage and use virtual machines in testing, building, and developing applications in Visual Studio 2010.  
  • Visual Studio Lab Management is integrated with System Centre Virtual Machine Manager (SCVMM) to enable managing multiple physical computers that host virtual machines and to manage the storage of virtual machines, virtual machine templates, and other configuration files in SCVMM library servers.

 Benefits:

  • Visual Studio Lab Management can enable developers & testers can easily create virtual environments
    • Provides the ability to create an environment by using Microsoft Test Manager and assign virtual machines to each role that is required for the application that you intend to develop, test, or run. For example, you might be developing a multi-tiered application that requires three roles:
      • Desktop client
      • Web server
      • Database server
    • By using Lab Management, you can:
      • Create a virtual environment that assigns a virtual machine to each role
      • Deploys each part of the application to the relevant virtual machine by using Team Foundation Build
      • Runs the three virtual machines as a single instance of the application for testing.
    • A virtual environment can also be setup where only some components of the application are deployed whereas other components are shared across environments. For example, if your application needs a large database, you can decide to host a shared database on a physical machine. All virtual environments will have only virtual machines for the client and application tiers that can connect to the shared database as required.
  • Enables the automation build-deploy-test cycle
    • The Visual Studio Lab Management’s Workflow (build-deploy-test) is as follows:
      • When the build is complete, restore the virtual environment to a clean snap shot
      •  Deploy the build to the environment and take a snapshot when the build is deployed (*this snapshot is optional)
      • Run automated tests that validate the build quality
  • It lets you test the build quality early and often with little effort
    • Reproduce the exact conditions of a bug or other development issue:
      • Lab Management snapshots capture the state of all computers in the environment at a point in time.
      • A snapshot of environment can be shared with members of a project team.
      • A reference to the stored snapshot can be included in Visual Studio Team Foundation Server work item so that a copy of the environment can be created with a few clicks of the mouse.
      • When Microsoft IntelliTrace data is included in the work item, the execution path of the application to the bug can be fully reproduced on the exact configuration where the bug occurred.
    • Build, deploy, and test applications automatically in a clean environment:
      • Using Lab Management workflows for Visual Studio Team Foundation Server builds, environments, snapshots and Microsoft Test Manager automated tests, you can stage daily builds of your application to a clean environment.
      • After tests have been run, you can store the environment in a snapshot and then restore the environment to its original state so that it can be used again.
    • Reduce the time required to create and configure machines for testing an application:
      • Using Lab Management stored virtual machines and templates, you can quickly deploy customized environments that recreate the configuration of customer's production environments.
    • Run multiple copies of a test or development at the same time
      • Using Lab Management stored virtual environments, you can deploy multiple copies of a virtual environment at the same time without the computer name conflicts that can limit the use of unmanaged virtual machines in a domain.
    • Enable members of a team to create and manage virtual environments without requiring system administrator privileges:
      • You can use Lab Management permissions to create role-based self- service groups of team members who can deploy, create and manage virtual environments without requiring system administrator privileges.
      • You can also combine Lab Management permissions with Visual Studio Team Foundation Server and SCVMM permissions to meet the specific requirements of your organization.

Generic SQL Server 2008 R2 Installation

I recently had to create some virtual machine tempaltes which needed Microsoft SQL Server 2008 R2 installed on it, so I thought I'd document it as I went along.

In the example shown below, I'll be installing SQL Server on a machine running Windows Server 2008 R2 (Entreprise Edition). I'll be doing a very generic installation however if you need to customise it, it should not be too difficult.

Before You Begin

Before you begin, you will need the following:
  • Microsoft SQL Server 2008 R2 - ISO/DVD 
  • Visual Studio 2008 (With Service Pack 1 installed)

Installation Steps

  • On mounting the image you should get an autorun prompt which will bring up the setup application. If it does not show up, navigate to the base folder of the image and click on setup.exe
  • This should open up the SQL Server Installation Center as shown below
  • Click the Installation tab as shown below. This should open up the Setup Support Rules 
  • Now click the New installation or add features to an existing installation link as shown below
  •  Click OK and procees to the next step as shown below
  •  The installer should now prompt you for your Product Key. You can either enter a valid product key or choose the Evaluation edition as shown below. You then need to click Next.
  •  The install will then list the License Terms. Click the I accept the license checkbox as shown below and then click Next.
  • The installer will then try to install the Setup Support Files.  You need to click Install as shown below.
  • A new Setup Support Rules window will now pop up as shown below
  • Keep clicking Next till you reach the Setup Role window. Select the SQL Server Feature Installation radio button as shown below. (Note: If you want to add features to an existing installation, you need to select the last option and it will prompt you for an Instance Name. This option only shows up if you have an existing instance of SQL Server installed.)
  • Now choose the Select All check box and click Next. You then need to specify the Instance Name in the Instance Configuration section as shown below. (Note: By default the instance name is MSSQLSERVER but you can change this if you wish.)
  • The installer will then show you a Disk Usage Summary as shown below. Click Next & move on to the Server Configuration section.
  • In the Server Configuration section you need to click the Use the same account for all SQL Services button and choose NT AUTHORITY\NETWORK SERVICE. This account does not need a password to be entered.


  • In the Database Engine Configuration section select the Mixed Mode (Sql Server authentication and Windows authentication) option.
  • Enter a password for the SQL Server Administrator account (Note: The user name is sa) and also add your Windows account to the list of administrators by clicking the Add Current User button as shown below and click Next. You also need to add your Windows account in the Analysis Services Configuration section. (Note: You must remember the password that you typed in for the sa account!)

  • In the next section, select Install the native mode default configuration option to configure Reporting Services. Click Next. This should bring you to the Error Reporting section, click Next  again.

  • You should now see the Installation Configuration Rules screen. Click Next and proceed to the Ready to Install section as shown below. Now all you need to do is click Install.

  • This should start your installation. This will take a good 10 to 15 minutes depending on your machine so this would be a good time to get some coffee :) ...
  • The installer will prompt you when your installation has completed. You can now test you SQL Server by logging in using either your Windows credentials or your SQL Server credentials that you configured earlier. (Start - All Programs - Microsoft SQL Server 2008 R2 - SQL Server Management Studio)  


References: SQL Server Installation (SQL Server 2008 R2)

Preface

So, for the past few months we've been working on a proof of concept which has now finally drawn to a close.

We developed a web-based application written using various technologies/frameworks/concepts like Microsoft .NET MVC 3, Dependency Injection with Unity, NHibernate, SQL Server Reporting Services, Moq Framework, Command and Query Responsibility Segregation (CQRS), TFS Build-Test-Deploy automation and many others.

Additionally, the application that we developed had specific user interface requirements which also warranted the heavy use of client-side scripting using cross browser scripting libraries of  JQuery, JQuery UI and Ajax.

It was a great learning experience for me as it was the first time I had worked with many of these technologies/frameworks/concepts that we used.

While I'm no expert on the technologies listed above (well, not yet anyway J), I thought I'd document the things that I've learned over the past few months to benefit others that might be starting with these technologies.

I hope my ramblings are able to help others.