Visual Studio 2010 Lab Management Overview

In PDC 2008 it was announced that Visual Studio Team System 2010 would contain functionality for managing test labs. Most of us don’t have one, but should we care?

What is a test lab?

Test labs are groups of computers dedicated for the sole task of running test copies of your applications. In more advanced scenarios, the operation of the test lab is highly automated – in practice machines should be scripted to initialize themselves, run a set of tests and report the results.

For simple applications, such labs are not usually necessary. For complex applications involving lots of OS version sensitive parts and localization issues, testing the app on all the platform combinations by hand would be impossible, so lots of machines and some sort of automation is called for.

Visual Studio 2010 now offers to put all this under your command with an easy interface. It also throws in SCVMM/Hyper-V virtualization to balance the testing load and save on hardware resources.

How does VS2010 manage test labs?

Essentially, the lab-driven test workflow goes like this:

  1. IT administrators allocate machine pools consisting of virtual server hosts that can be used for the test lab purpose.
  2. IT administrators or testers configure a set of virtual machines that can be used as testing environments. Such VMs would then be saved into a VM library for further use. Typical virtual machines might include configurations such as “Windows XP 64-bit Finnish” or “Windows Server 2008 with SQL Server 2005”.
  3. Testers configure “test environments” into VSTS 2010, forming a group of machines used for the purpose. A test environment might be called “FooSoft 1.3 integration test” or “Jouni’s FooSoft 1.4 beta test”.
  4. As the tester picks machines to add to the environment, VSTS forwards a request to a System Center Virtual Machine Manager instance to spin up new VMs based on the VM images created earlier on. When the new VMs are up, the test environment is ready.
  5. The tester runs the tests, automated or manual, on the testing environment.
  6. The testing machines can then be torn down and the machine capacity reused.

What you’re essentially gaining is higher usage of test-dedicated hardware, combined with reduced complexity. Your testers don’t have to work with test environment setup which improves efficiency, of course. For bonus points, hard bugs are no more flagged as non-repro, as the tester can snapshot the virtual machine at the time of the bug’s occurrence and then deliver the VM to the developer, giving him an instant repro case.

Do I need one of these?

If you’re developing a well-behaving web application, chances are you don’t need one. Installation of ASP.NET web apps is generally pretty easy to automate (by, for example, PowerShell), and often even multiple simultaneous test runs can be executed in the same logical OS using separate IIS sites and databases.

If you’re writing WinForms, WPF or Windows Service applications, the separate lab installation is more appealing, as there are often components that would benefit from getting installed onto a clean server every time, perhaps making even installer testing worthwhile. But remember, even in these cases you can also do without VS2010 – creating a simple Hyper-V –based virtual test environment isn’t really that hard. If you can read Finnish, check out some of Jani Järvinen’s notes from one of our ITpro.fi sessions.

On the other hand, if you have Visual Studio Team System + SCVMM running already, have extra Hyper-V –capable hardware and actually can use the testing environment (i.e. you have sufficient manual testing power and/or unit test automation), why not? A test lab need to be tens of computers. It can even be one relatively modern box, 64-bitness and hardware virtualization support being the key requirements. For most of the time, even desktop hardware will do quite nicely.

More info

July 3, 2009  Tags: , , ,   Posted in: .NET  No Comments

Kodu is out, get your kids coding

Microsoft has released Kodu (formerly known as Boku) for Xbox and limited PC distribution. It’s essentially a virtual world development environment for kids. The “programming” is done through logic primitives, which are assembled together through a graphical interface and the Xbox controller.

Long Zheng has some pretty good screenshots, and if you want to see Kodu in action, take a look at the PDC 2008 Day 3 Keynote at time index 71:40 – 82:50. Looks like fun!

July 1, 2009  Tags: ,   Posted in: Misc. programming  No Comments

Trivia: Equality of objects and strings

A small trivia question for a change; some of my colleagues and friends may already have heard this from me.

Take a look at the following snippet of C# code:

T x1 = V1;
T x2 = V2;

Console.WriteLine(x1 == x2);
Console.WriteLine(x1.ToString() == x2.ToString());

In the code, you need to fill in three missing parts: Name of a type T, and two values of that type, V1 and V2. T is a reasonably common CLR type (i.e. one of the very basic types in .NET).

The question: For which type and values does the application print True and False? In other words, what is the case when objects’ logical comparison considers them equal, but their string representations differ? There may be multiple answers, and I’m glad to hear some more.

After you have carefully thought about it, you can take a look at one answer. If you have others, please post a comment!

June 30, 2009  Tags:   Posted in: .NET  2 Comments

Getting answers from Experts-Exchange.com

If your search for answers to technical questions yield links to Experts Exchange, you’ll probably find yourself frustrated by the “This answer is only available for Premium Members” blocks. However, it’s good to know that the content really is freely available.

This popped up again today, so it’s worth a heads-up. The whole issue has, of course, already been documented elsewhere. The simplest way is to just scroll down enough on the result pages, and you’ll see the answers – they had to include them in order to get indexed by Google! To see this, try this search and click the results. Note that you can’t see the results if you go directly to an answer page – they probably check for referrer headers. You can also use the search engine’s “view cached page” feature, which also shows the answers.

The demise of good spirit

A few words on EE while I’m at it: It’s a community-based site where you can purchase a subscription to a vast base of questions and answers on a variety of topics. Years ago I was a member of the site, answering C# and .NET questions sporadically. As a compensation, the site gave free full access to all the content and unlimited ability to ask new questions. And many of the active people on the site actually had fun, competing on who’s the first to answer a specific question.

Since then, the site has gradually become more and more restricted, finally ending in a point where almost everything seems to require a credit card. I’m not sure if everybody’s fun has been as totally spoiled as mine, but I certainly found the more open spirit encouraging. The idea of contributing to EE now feels odd – why would I bother?

A site like EE isn’t easy to monetize, but let’s face it, that milk did go sour a long time ago. Compare with the modern competitor, stackoverflow, which relies on sufficient interpersonal incentive to fuel the answering rage, and also improves the answer quality by making the question pages wikilike. EE has so many years under its belt that it will absolutely remain a valuable resource for many IT questions – the amount of knowledge therein is huge. Stackoverflow is quickly becoming more useful for modern-technology developers; its traction on IT professional questions remains to be seen.

But as it is, EE is more and more starting to sound like a moneymaking scheme instead of clever web development, and thus I felt no sting in my conscience in highlighting the “cheats” above. It’s so easy to lose respect. :-(

June 29, 2009   Posted in: Misc. programming  No Comments

The anatomy of Bing search results

Microsoft recently published Bing White Paper for Webmasters and Publishers. While offering little in the actual SEO sense, it does provide other interesting viewpoints, especially for usability guys and web site developers.

The anatomy of a Google and Bing SERP (Search Engine Result Page) are definitely different. Google’s result on “Helsinki” is reasonably simple:

google-results

On the other hand, the Bing result provides a bit more context (note that Bing still requires certain locale settings for full experience):

bing-results

 

In this particular example, Bing certainly manages to give me a better impression of Helsinki and also a more meaningful search result. However, this is not to make a statement on which one is better – Google certainly seems to win some cases hands down. Also, in the above example, Google has 50% more results, although I’m not sure on the relevance of the numbers here.

Bing also seems to focus more on providing decision-making context and less on directing traffic, hence the label of a decision engine. The document preview extraction feature (see the picture below) is probably one of the most useful features I have so far encountered in Bing. When searching with technical terms, the context is often difficult to grasp, and browsing through long forum pages is sometimes painful. The document snippet is sometimes bogus, but much of the time saves me from actually following the link. This is markedly different from Google, which does create far more passthrough traffic for sites.

image

 

Anyway, the white paper gives a nice view into the design principles that go into search engine result page. While the battle between Google, Yahoo and Bing doesn’t touch most of us directly, a few ideas on how to improve search results might be quite useful even for searches spanning your local web application.

In technical sense, the only new thing in the white paper is the nopreview rel keyword for links (disabling the preview feature described above). But the merits of the white paper lie more in its general readability and thought-provocation, some of which also applies outside the field of search. So, recommended reading for web developers!

 

PS. Regarding my Bing trial, I’m still wavering. I always Bing first and am happy for most of the time, but Google does better when searching for things in Finnish – perhaps due my forced locale configurations with Bing. Also, Google seems to index new content a bit faster and provide more results with obscure keywords such as rare error codes. Yet still, Bing would seem to give me better satisfaction on searches related to casual life. Well, I’ll keep on testing!

June 29, 2009  Tags: , , ,   Posted in: Web  No Comments

A look into the last ten years

I turned 30 on Wednesday. It doesn’t really feel like anything, but it’s a good time to take a trip down the memory lane from a web technology perspective. So how has the world changed? (lots of Wikipedia links included!)

I have been programming since I was six and started working full-time in IT almost 15 years ago. Software development, while far from being my only professional interest, has been the most dominant one so far. Ten years ago I was formally leading a team in charge of MikroBitti Magazine’s New Media operations, including ISP services (ISDN! Dial-up!), a BBS and one of Finland’s first consumer-oriented web sites, MBnet. But whenever I had the time, I wrote code. And that’s what this post is all about.

A dissection of a 1999 web project

Ten years ago I had just fathered a computer components price watch site which thereafter evolved into the service nowadays known as www.hintaseuranta.fi. Essentially, it was a web site with a database backend, but also a cluster of background processes that crawled the retailers’ web stores to retrieve pricing information.

As we didn’t have ASP.NET yet, the web front-end code was classic ASP with its nasty VBScript language. Since ASP’s tools for managing complex layouts pretty much ended in the ability to include other source files, masses and masses of copy-pasted source were general. At that time, development tools were far from what they are now. Although Microsoft produced Visual Interdev to support ASP development, most developers preferred text editors for simplicity. Not Notepad though, but there was an extensive market of developer-oriented text editors at the time. They still exist, but Visual Studio grabbed much of the market by growing into an excellent all-around tool.

The produced HTML was chaotic. No surprise there, given that the first browser war was afoot. Internet Explorer 4 had swept the floor with the former king, Netscape Navigator. CSS layouts were nothing but a dream – the specs were pretty well done, but the support was limited to changing the foreground color, switching fonts and a few other things. It was <table>, <font> and <hr> all over.

JavaScript was hardly useful as browser implementations varied heavily. Also, security concerns were high – corporations and governments sometimes totally blocked JavaScript at their firewalls. The term AJAX would be coined no sooner than 2005, and its predecessor XMLHTTP was just shipped in March 1999 (Internet Explorer 5.0). However, given that automatic updates through Windows Update had not been invented yet, new browser versions were spreading pretty slowly. It took quite some time before the JavaScript fever took off.

Behind the web user interface, component-orientation was the buzz – the idea of separating the business logic from your HTML code was something pretty radical, given that SQL statements and markup tags were frequently intertwined in the .asp files. However, creating reusable modules to be run behind the somewhat wobbly (and security-wise questionable) Internet Information Services 4.0 wasn’t easy, and certainly not helped by the fact that Visual Basic and VBScript didn’t support a useful notion of objects.

VB worked well to an extent, and thus COM objects became the mainstream way to package functionality. But when it was too clumsy, you generally resorted to C++. I worked mostly with Borland’s (then short-livedly known as Inprise) C++Builder. There were all the pains of C++, such as the hideously complex templates and manual memory management, but also the lovely freedom of doing whatever you wanted, up to the assembly language level. Usually the bugs soured the taste of freedom, but at least you felt like the old time coders hand-crafting software with love, just for the CPU.

And finally, the backend database choice of SQL Server 6.5 was the first real relational database for me. It was a dramatic change driven by web’s need for “huge” number of simultaneous users. There was this whole new notion of a database server! Before that, we had managed years and years with just files on the disk. And with less demanding applications, Access, Paradox and other flat-file storage mechanisms were still thriving. SQL as a language was just beginning to become a necessity – a few years before, people with SQL skills were really rare.

Why is it good to be here now?

A few reasons why I wouldn’t switch back:

  • There is now significant open-source movement also in the Microsoft scene. So much is done already, and most basic tasks can be significantly sped up by assembling packed solutions from others.
  • Visual Studio is great. Comparing to the command line compilers (ouch), print-based debugging and clumsy editing, the current toolset with IntelliSense, syntax highlighting and remote debugging makes all the difference. In 1999 we already had some of that, but not consistently.
  • Many error sources have been eliminated. Oh, the ease of Garbage Collection! Also, compilers and IDEs catch much of what we fumbled with earlier. In general, technology works much better now: CSS, JavaScript, IIS – much of it just works.
  • Languages live better together. The concept of sharing code libraries between languages sounds like a no-brainer, but until the advent of .NET, finding a Visual Basic solution for a problem didn’t help much, as leveraging that code from a C++ program would’ve been ridiculously difficult. Binary compatibility was a dream, COM was a pain and porting between languages almost an impossibility. What difference does a language-independent framework do!
  • From the database perspective, surprisingly little has changed – SQL is still written as it used to be, and while databases have much more features, most of the basic web apps still repeat the same patterns they did ten years ago.

Kudos to some visionaries

While much of web’s development has happened outside of Microsoft, there are two leading minds in Redmond who greatly influenced so much of what I just wrote. They certainly do deserve special mention at this time.

First, Anders Hejlsberg created the influential Delphi back in Borland times, then stormed on to Microsoft and helped spawn the C# language. While C# 1.0 didn’t have that much edge over Java, the existence of a modern OOP language on the new .NET platform was the key driver to make people flip. Without that, I would’ve quite possibly chosen Java as my next framework of choice (not to say that would’ve been a bad alternative!).

Second, Scott Guthrie was fresh out of university in 1997 and had just joined Microsoft, when he and Mark Anders were tasked to design the next generation web framework. The resulting XSP was first written in Java, then rewritten in C# (dubbed “Cool” at that time), rebranded as ASP+ and finally released ASP.NET. And while much of the modern criticism on Web Forms is well-founded, the ability to come up with something like that over ten years ago shows quite some insight. Oh and by the way, Scott wrote the first version of XSP over Christmas holidays. That’s the only proper way to build a new framework, isn’t it?

 

I hope I’m still here after 10 more years to document the inevitable progress. There is some comfort knowing that technology evolution isn’t slowing down. But will I be a dinosaur with obsolete technical knowledge when I’m 40? Looking forward to seeing that!

June 26, 2009  Tags:   Posted in: .NET, General, Web  No Comments

Moving Windows Help .hxw files ain’t easy

After all these years, wouldn’t you think all the system-generated data could be easily moved away from the boot partition?

Let’s say your C: drive gets full. Windows Vista and beyond make repartitioning a snap, but it only helps if said disk has space available on another partition. If not, you’re in for some exercise in freeing some space.

Using WinDirStat, you’ll quickly find some culprits. If you’re a developer, the C:\Users\All Users\Microsoft Help directory usually springs up. Said directory contains the Microsoft’s Help system’s built indexes, and if you have some Windows SDKs, SQL Server Books Online collections and whatnot installed, quite a few megabytes are sucked into maintaining the help index.

More out of perfectionism than practical need, I tried moving them out. But as hard as I Googled and Binged (or “bang” perhaps?), I couldn’t find out how to do it (surprisingly little has been written on the topic!). The Help system simply doesn’t seem to have a switch for the job. Oh well. What about moving the whole C:\Users\All Users then?

That’s actually an alias for C:\ProgramData. It would appear that I can move it by moving the files and then changing the paths in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Shell Folders, but the numerous shortcuts in the ProgramData folder make copying stuff quite complex. And, of course, there is the somewhat scary KB949977 which isn’t heartily recommending the move (and even if it did, the article itself wouldn’t help unless you were re-installing). TweakVI supports moving parts of the ProgramData, but not the whole thing.

So after delving a bit into the ProgramData move path, I decided to drop it. I might have succeeded, but the risk to gain a few gigs wouldn’t be worth it. If you need space on your C:, move the most of your swap file out (not all if you want to get memory dumps on crashes), read up on the Installer directory and move the other profiles if they have significant data on them. Wasting time on moving your Help files isn’t worth the effort.

As usual, I’d be delighted to be proven wrong by a comprehensive set of instructions on the matter.

June 23, 2009  Tags:   Posted in: Windows IT  No Comments

Which gwaddagak would you pick?

All the noise about adding a browser choice ballot screen on Windows Installation, and who even knows how to use all that power of selection?

My colleague Aki blogged about an interesting video by Google. They’re interviewing people in New York, asking about browsers and search engines. Less than 8% knew what a browser is!

Why would European Commission want people to make an explicit choice on something where nine out of ten citizens would not have the necessary knowledge to back up their choice anyway? Arguing that Europeans might be more knowledgeable than Americans might be a valid point, given the larger percentage of Firefox users in the old world. But still, I’m not ready to bet on more than a few percents more knowledge. Hmm… I guess we’ll see the showdown soon enough.

June 22, 2009  Tags:   Posted in: Web  4 Comments

Visual Studio web debugging: Attaching to IIS with a keyboard shortcut

Nothing new here, but why do we tolerate repetitive chores so easily?

For some reason web developers seem to have extreme patience when it comes to attaching the Visual Studio debugger to the IIS process (w3wp.exe, aspnet_wp.exe or what have you). It’s ridiculously clumsy to open the Attach to Process window and then find the correct process name, even if you knew the proper keyboard shortcuts. And it’s not like the problem hadn’t already been solved. It’s just that the solution is forgotten every now and then – and almost nobody uses it!

The easiest way to fix this is to define a macro for attaching to w3wp.exe process and hey presto, you can start debugging your web application with a single keypress. Read Janne Mattila’s blog post on how to set it up to boost your attach performance. :-)

June 17, 2009  Tags: , ,   Posted in: .NET  No Comments

PowerShell: PSObject, custom types and the add-member cmdlet

PowerShell is .NET-based in the sense that it allows reasonably free manipulation of CLR objects. However, the shell language differs drastically from the familiar object-oriented languages that are typically used with classes and objects. In this post, I’ll discuss some of the aspects involved in handling custom objects in PowerShell.

What is PSObject and why should I care?

PowerShell is a shell, and a shell is a demanding environment. Shells should be scriptable by reasonably casual IT administrators without in-depth knowledge of object oriented programming or somesuch. PowerShell’s type abstraction system aims at simplifying the syntax required for manipulation of complex object graphs.

For example, let’s say you were about to read an XML document and parse a single value from it using C#.

XmlDocument d = new XmlDocument();
d.LoadXml("<parent><subnode>value</subnode></parent>");

Constructing the document is pretty straightforward, but reading the node takes a bit more effort.

Console.WriteLine(
  d.ChildNodes.Cast<XmlNode>().First(n => n.LocalName == "parent")
  .ChildNodes.Cast<XmlNode>().First(n => n.LocalName == "subnode")
  .InnerText
);

Of course you can cut corners if you know XPath, but purely on object level, this is pretty much what you’re facing. No admin would write scripts if it were this complex to handle arbitrary XML. To make the most basic tasks easier, PowerShell objects include some shortcut functionality:

$d = [xml]"<parent><subnode>value</subnode></parent>"
$d.parent.subnode

The variable $d contains a normal CLR object, an XmlDocument to be exact (take a look at $d.GetType() if you want to check). However, technically $d is actually an XmlDocument wrapped into a PSObject. PSObject class represents a generic PowerShell object and supports features such as dynamic properties.

In this case, $d would seem to have a property called “parent”, even though XmlDocument doesn’t define such a thing. But when PowerShell gets its hand on a Xml object, it automatically provides aliases to access the child elements as properties. While this would be rather unwieldy in a programming language, it suits a scripting language quite fine.

So yes, you should care about PSObjects: They’re all about making your life easier. If you want more theory, take a look at the MSDN documentation.

Classes or objects?

In C# and VB, an object’s properties are defined through their classes. In more dynamic languages such as JavaScript or PowerShell, features can be added to objects directly, meaning that two objects of the same class could have wildly different properties and methods available.

To prove the point, we’ll use the add-member cmdlet to add a custom field to a normal object. We’ll get back to add-member’s usage later on.

PS C:\> dir c:\autoexec.bat |
>> add-member -passthru NoteProperty "Foo" 123 |
>> format-table -a Name, Length, Foo
>>

Name         Length Foo
----         ------ ---
autoexec.bat     24 123

The addition thus made is very simple and only affects the object we just created in the pipeline. Any future objects produced by dir wouldn’t be affected.

While customizing things on an object level is certainly handy, you don’t usually want to make objects of the same class differ from each other. But the separation of class vs. object allows you to extend objects whose classes you cannot access, thus providing lots of possibilities. As you might guess, you can add not only plain text members, but also methods and formulas that can be used to derive values from the object.

Custom types – why?

Creating your own types in PowerShell isn’t really an everyday task. If you create commandlets to manage an application, you might write new classes to represent the data within the application’s domain, but if you’re just using PowerShell, you won’t be likely to even need a single type-defining construct, ever.

However, there is a scenario where custom types make sense: returning complex information. And it is this situation where the loose coupling between classes and objects plays to your advantage, as you can just create objects without a real class, just adding the necessary properties to them. So in classic .NET terms, you’re creating a bunch of System.Objects and then tagging the required features onto them.

Now, suppose we want to create a PowerShell script that iterates through the applications set to start immediately after Windows boots. We can simply use the following:

(Get-Item 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run').Property

However, it will only get us the list of friendly names for the software to run. The registry also contains the executable paths to be run, and we want them returned as well. Were you writing this in C#, you’d probably start with something like “public class StartupApplicationInfo” and then roll in properties for application name and path, finally returning a List<T> of such objects.

In PowerShell you essentially want to do the same, but you don’t need to specify things all that much. Let’s look at using add-member now, and then dig into this a bit more.

Using add-member

Getting the executable paths for the software being run at startup is easy, so we’ll focus on the object construction. Here’s the code you need:

$runkey = Get-Item 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run'
$values = Get-ItemProperty $runkey.PSPath
foreach ($app in $runkey.Property) {
    $result = New-Object PSObject
    Add-Member -input $result NoteProperty 'Application' $app
    Add-Member -input $result NoteProperty 'Path' $values.$app    Write-Output $result
}

What we get as a result is a cute table including the names and executables:

Application                  Path
-----------                  ----
SynTPStart                   C:\Program Files\Synaptics\SynTP\SynTPStart.exe
SoundMAXPnP                  C:\Program Files\Analog Devices\Core\smax4pnp.exe
…

Each row represents a real object; we could manipulate them one-by-one and access the variables through the dot-notation. But now, let’s consider how the result construction part inside the foreach loop above works.

Add-member is a commandlet that takes an input object, either from the pipeline or a parameter called input. We use the latter syntax here. The input object gets the new member added; in this case, we’re defining a new NoteProperty (note properties are pretty much like normal variables on the object). Our property is called Application and has the initial value of $app, the variable holding the name of the application such as SynTPStart. Then we create another NoteProperty for the path and dig its value from the registry as well. When all is said and done, we just write the output object into the pipeline, delivering it for the next consumer or the display.

A syntactic shortcut: Select-Object

The example above should outline the steps required for adding simple properties. The syntax for Add-Member isn’t exactly compact, so at times you might want to consider an alternative. A commandlet called Select-Object comes to the rescue. Although Select-Object is intended to just select a subset of properties in an object (say dir | select Name, Length), it also creates properties it cannot find from the original object. This allows alternate, perhaps cleaner syntax to be used:

$result = New-Object PSObject | select Application, Path
$result.Application = $app
$result.Path = $values.$app

Since the properties were already created by the select-object commandlet, the values can then be set using the normal assignment operator. This could be considered a better approach than using the clumsyish Add-Member, but using Select-Object with nonexistent properties isn’t that great either. Choice between the two should probably depend on circumstances. Particularly, if you’re using add-member anyway (for example, to add more complex members such as methods to the object), you might want to use the same syntax for all additions.

While both alternatives have some clunkiness in their syntaxes, either approach will work and allow you to return structured data from your PowerShell functions. Given that PowerShell is all about structuring of data and getting rid of parsing, this is an essential aspect left with perhaps a bit too little attention on Microsoft’s part. Hope this helps!

June 14, 2009  Tags:   Posted in: .NET  No Comments