October 2010 - Posts

PDC 2010 thoughts - the next morning
Fri, Oct 29 2010 4:02

I sat in the office yesterday with a beer in my hand watching the PDC2010 keynote. I have to say I preferred this to the option of a flight, jet lag and a less than comfortable seat in a usually overly cooled conference hall. With the Silverlight streaming the experience was excellent, especially as we connected an Acer 1420P to our projector/audio via a single HDMI cable and it just worked.

So what do you lose by not flying out? Well the obvious is the ‘free’ Windows Phone 7 the attendees got; too many people IMHO get hooked up on the swag at conferences, you go for knowledge not toys. They also forget they (or their company) paid for item anyway in their conference fee. More seriously you miss out on the chats between the sessions, and as the conference is on campus the easier access to the Microsoft staff. Also the act of travelling to a conference isolates you from the day to day interruptions of the office, the online experience does not and you will have to stay up late to view sessions live due to timezones. The whole travelling experience still cannot be replaced by the online experience, not matter how good the streaming.

However, even though I don’t get the ‘conference corridor experience’ it does not mean I cannot check out sessions, it is great to see they are all available free and live, or immediately available recordings if I don’t want to stay up.

The keynote was pretty much as I had expected. There were new announcements but nothing that was ground breaking, but good vNext steps. I thought the best place to start for me was the session “Lessons learned from moving team foundation server to the cloud”, this was on TFS, and obvious area of interest for me, but more importantly no real world experience to move a complex application to Azure. This is something that is going to effect all of us if Microsoft’s bet on the cloud is correct. Seems, though there are many gottas, the process was not as bad as you would expect. For me the most interesting point was the port to Azure caused changes to the codebase that actually improved the original implementation either in manageability or performance. Also that many of the major stumbling blocks were business/charging models not technology. This is going to effect us all as we move to service platforms like Azure or even internally host equivalents like AppFabic

So one session watched, what to watch next?

Common confusion I have seen with Visual Studio 2010 Lab Management
Mon, Oct 25 2010 16:34

With any new product there can be some confusion over the exact range and scope of features, this is just as true for VS2010 Lab Management as any other. In fact given the number of moving parts (infrastructure you need in place to get it running) it can be more confusing than average. In this post I will cover the questions I have seen most often.

What does ‘Network Isolation’ really mean?

The biggest confusion I have seen is that Lab Management allows you to run a number of copies of a given test environment, each instance of an environment is ‘network isolated’ from the others. This means that each instance of the environment can have server VMs named the same without errors being generated. WHAT IS DOES NOT MEAN is that each of these environments are fully isolated from your corporate or test LAN. Think about it, how could this work? I am sad to say it there is still no shipment date for Microsoft Magic Pixie Net (MMPN), until this is available then we will still need a logical connection to any virtual machine under test else we cannot control/monitor it.

So what does ‘Network Isolation’ actually mean? Well it basically means Lab Manager will add a second network card to each VM in your environment (with the exception of domain controllers, I will come back to that). These secondary connections are the way you usually manage the VMs in the environment, so you end up with something like the following

image

Lab Manager creates the 192.168.23.x virtual LAN which all the VMs in the environment connect to. If you want to change the IP address range this is set in the TFS administration console, but I suspect needing to change this will be rare.

If the PCs in your environment are in a workgroup the is no more to do, but if you have a domain within your environment (i.e. you included a test domain controller VM in your environment, as shown above) you also need to tell the Lab Management environment which server is the domain controller. THIS IS VERY IMPORTANT. This is done in the Visual Studio 2010 Test Manager application where you setup the environment.

When all this is done and the environment is deployed, a second LAN card is added to all VMs in the environment (with the exception of the domain controller you told it about, if present). These LAN cards are connected to the corporate LAN and an IP address is provided using your corporate LAN DHCP server and assign a name in the form something like LAB[Guid].corpdomain.com (you can alter this domain name to something like LAB[Guid].test.corpdomain.com if you want in TFS administration console). This second LAN is a special connection in that the VMs NETBIOS names are not broadcast over it onto the corporate LAN, thus allowing multiple copies of the ‘network isolated’ to be run. In each case each VM will have a unique name on the corporate LAN, but the original names within the test (192.168.x.x) environment.

Other than blocking NETBIOS, the ‘special connection’ is in no other way restricted. So any of the test VMs can use their own connection to the corporate LAN to access any corporate (or internet resources) such as patch update servers. The only requirement will be to login to the corporate domain if authentication is required, remember on the test environment you will be logged into the test domain or local workgroup.

I mentioned that the test domain controller is not connected to the corporate LAN. This is to make sure corporate users don’t try to authenticate against it by mistake and to stop different copies of the test domain controller trying to sync.

All clear? So ‘network isolated’ does not mean fully isolated, but the ability to have multiple copies of the same environment running at the same time with the magic done behind the scenes auto-magically by Lab Management. Maybe not the best piece of feature naming in the world!

So how does a tester actually connect to the test VMs from their PC?

Well obviously they don’t use a magic MMPN connection, there has to be a valid logical connection. There are actually two possible answers here; I suspect the most common will be via remote desktop straight to the guest test VMs, this will be via the LAB[Guid].corpdomain.com name. You might be thinking how do I know these IDs, well you can get them from the Test Manager application looking at VMs system info in any running environment. Because you can look them up in this way, a tester can either use the Windows RDP application itself or more probably just connect to the VMs from within Test Manager where it will use RDP behind the scenes.

The other option is to use what is called a host connection. This is when Test Manager connects to the test VMs via the Hyper-V host. For this to work the tester needs suitable Hyper-V rights and the correct tools on their local PC, not just the Test Manager. This could also be achieved using the Hyper-V manager or SCVMM console. Host mode is the way you would use to connect to a test domain controller that has no direct connection to a corporate LAN.

The choice of connection and tool will depend on what the tester is trying to do. I would expect Test Manager to be the tool of choice in most cases.

Do I need Network Isolation – is there another option?

This all depends on what you want to do, there are good description of the possible architectures in Lab Management documentation. If you don’t think ‘network isolation’ as described above is right for you the only other option that can provide similar environment separation is to not run them ‘network isolate’ but to provided the environment with a single explicit connection to the corporate LAN via a firewall such as TMG allow there connection.

This goes without saying is more complex than using the standard ‘network isolated’ model built into Lab Management, so make sure it is really worth the effort before starting down this route.

What agents do I need to install?

There are a number of agents involved in Lab Management, these allow network isolation management, deployment and testing. The ones you need depend on what you are trying to do. If you want all the feature, not unsurprisingly you need them all. If this is what you want to do then use the VMPrep tool, it makes life easier. If you don’t want it all (and it might be easier to just install all of them as standard) you can choose.

If you want to gather test data you need the test agent, and you want to deploy code you need the lab workflow agent. The less obvious one is that for ‘network isolation’ you need the Lab Agent installed, it is though this agent that network isolation LAN is configured.

Any other limitations I might have missed?

The most obvious is that many companies will use failover clustering and a SAN to make a resilient Hyper-V cluster. Unfortunately technology his is not currently supported by Lab Management. This is easy to miss as it is only referred to once in the documentation to my knowledge in an FAQ section.

The effect of this is to not allow shared SAN storage between any Hyper-V hosts or more importantly between the VMM Library and the Hyper-V hosts. This means that all deployment of environments has to be over the LAN, the faster SAN to SAN operations cannot be used as these need clustering.

I suppose there is also the limitation of no clustering that you cannot hot migrate environments around between Hyper-V hosts, but I don’t see this as much of an issue, these are meant to be lab test environments, not live production high resilience VMs.

This is a good reason to make sure that you separate you production Hyper-V hosts from your test ones,. Make the production servers a failover cluster and the test one just a hosts group. Let Lab Manager work out which server in the host group (assuming there is more than one) to place the environment on.

 

 

So I hope that helps a bit. I am sure I will find more common question, I will post about them as they emerge.

First look at Postsharp AOP framework for .NET
Mon, Oct 25 2010 10:13

At the Software Craftsmanship 2010 conference I met Gael Fraiteur of Sharpcrafters, he had given a talk on Aspect Oriented Programming AOP.Since the conference I have had a chance to look at his Postsharp AOP product for .NET.

I decided to do a quick spike project for a tender I have been working on, the requirement is to add a security model to an existing .NET assembly. Usually this would have entailed adding some security logic at the start of each public method to implement the security model. Using AOP I hoped I would be able to get the same effect by adding an attribute to the classes/methods, hopefully making the changes easier to read and quicker to develop.

So I have the following business logic I wish to added security too. All I did was add the [Security] attribute to the business logic method

public class BusinessLogic
{
    IDataProvider data;
 
    public BusinessLogic(IDataProvider data)
    {
        this.data = data;
    }
 
    [Security]
    public DataRecord GetItem(int customerId)
    {
        Debug.WriteLine("BusinessLogic.GetItem");
        return this.data.GetItemFromDB(customerId);
    }
}

So what is in the AOP attribute? Basically I use the AOP framework to intercept the method call, and before the method is invoked I make a call to a factory method to get an instance of the security provider and check if I have the rights to run the method.

[Serializable]
 public class SecurityAttribute :MethodInterceptionAspect
 {
     public override void OnInvoke(MethodInterceptionArgs args)
     {
         Debug.WriteLine("SecurityAttribute.OnInvoke");
 
         // this assumes we know the type of arguement and that we can 
         if (MembershipProviderFactory.GetProvider().CanCurrentUserViewThisItem((int)args.Arguments[0]) == true)
         {
             Debug.WriteLine("SecurityAttribute.OnInvoke: We have rights to view");
             base.OnInvoke(args);
         }
         else
         {
             Debug.WriteLine("SecurityAttribute.OnInvoke: We dont have rights to view");
         }
     }
 }

As it was a spike project I did not bother to write the security provider (or the DB provider for that matter). I used Typemock Isolator to fake it all, so my tests were as shown below. I found this way of working much quicker for my purposes.

/// <summary>
  /// test for both the success and failure paths of the attribute
  /// </summary>
  [TestClass]
  public class Tests
  {
      [Isolated]
      [TestMethod]
      public void When_the_membership_provider_gives_access_the_data_is_returned()
      {
          // arrange
 
          // create a fake objects
          var fakeIMembershipProvider = Isolate.Fake.Instance<IMembershipProvider>();
          var fakeISqlProvider = Isolate.Fake.Instance<ISqlProvider>();
 
          // create real objects
          var fakeData = new DataRecord();
          var bl = new BusinessLogic(fakeISqlProvider);
 
          // Set that when we call the factory method we get the fake membership system
          Isolate.WhenCalled(() => MembershipProviderFactory.GetProvider()).WillReturn(fakeIMembershipProvider);
                      // Set when we call the DB layer we get the fake object
          Isolate.WhenCalled(() => fakeISqlProvider.GetItemFromDB(0)).WillReturn(fakeData);
          // Set that we are allowed to see the item
          Isolate.WhenCalled(() => fakeIMembershipProvider.CanCurrentUserViewThisItem(0)).WillReturn(true);
 
          // act
          var actual = bl.GetItem(1);
 
          // assert
          Assert.AreEqual(fakeData, actual);
          Isolate.Verify.WasCalledWithExactArguments(() => fakeISqlProvider.GetItemFromDB(1));
      }
 
      [Isolated]
      [TestMethod]
      public void When_the_membership_provider_does_not_give_access_the_data_is_returned()
      {
          // arrange
 
          // create a fake objects
          var fakeIMembershipProvider = Isolate.Fake.Instance<IMembershipProvider>();
          var fakeISqlProvider = Isolate.Fake.Instance<ISqlProvider>();
 
          // create real objects
          var fakeData = new DataRecord();
          var bl = new BusinessLogic(fakeISqlProvider);
 
          // Set that when we call the factory method we get the fake membership system
          Isolate.WhenCalled(() => MembershipProviderFactory.GetProvider()).WillReturn(fakeIMembershipProvider);
          // Set when we call the DB layer we get the fake object
          Isolate.WhenCalled(() => fakeISqlProvider.GetItemFromDB(0)).WillReturn(fakeData);
          // Set that we are not allowed to see the item
          Isolate.WhenCalled(() => fakeIMembershipProvider.CanCurrentUserViewThisItem(0)).WillReturn(false);
 
          // act
          var actual = bl.GetItem(1);
 
          // assert
          Assert.AreEqual(null, actual);
          Isolate.Verify.WasNotCalled(() => fakeISqlProvider.GetItemFromDB(1));
      }
 
  }

This all work beautifully and I have to say this was nice and straight forward to code. The code looks clean and using Reflector the generated code is OK tool.

My only worries are

  1. That of performance, but after looking at the code I can’t see that the AOP framework generated code is any great deal less efficient that me adding security methods calls in all the business method. Using Postsharp would certainly require much less repetitive coding. In my spike the security factory strikes me as the bottleneck, but this is my problem, not the frameworks, and can be addressed with a better design pattern to make sure it is not created on every method call.
  2. I can see complexity appearing depending on handling the parameters being passed between the attribute and method being invoked. In my spike I need to know order of the parameters so I could pass the correct one to my security methods, however again I don’t see this as being a major stumbling block, the framework could provide something I am unaware of or I just need to write few forms of the security aspect constructor.

So will I be using Postsharp? I suppose immediately it depends if I win this tender, but I have to say I like what I saw from this first usage.

Video interviews from Software Craftsman 2010
Fri, Oct 22 2010 16:25

Gael Fraiteur of Sharpcrafters recorded some interviews at the Software Craftsmen conference a couple of weeks ago. The interviewees include Ben Hall, Jason Gorman, Sandro Mancuso, Zi Makki and myself. They are all up on Youtube

 

I am speaking at NEBytes in November on Mocking with Typemock Isolator
Tue, Oct 19 2010 15:51

On the 17th of November I will be speaking in Newcastle at the NEBytes user group on the subject ‘Using Typemock Isolator to enable testing of both well designed code and nasty legacy systems’.

NEBytes meetings have an interesting format of a developer and an IT Pro talk at each meeting. The IT Pro session in November is to be given by another member of Black Marble staff, Rik Hepworth, and is on Sharepoint I think.

Hope to see you there.

All our futures behind us?
Mon, Oct 18 2010 14:58

I had a strangely thought provoking weekend, I took my son to do the tour of Concorde at Manchester Airport, and whilst in the area popped into Jodrell Bank to look at the Radio Telescope and the arboretum. Two great technological achievement, well worth a visit, but I felt both seemed to be in our past. I remember Concorde, I remember Apollo (just) and I remember sitting in a room at school to watch the first Shuttle launch, but where is the equivalent today? I started to feel that this ‘thrusting to the future’ style of project no longer exists; there seem to be few children saying ‘I want to be an engineer’ or ‘an astronaut’. I fear they are too often now saying ‘I just want to be famous’.

image

But then I thought a bit more and I think these projects are still there; we have had the LHC switched on last year and just last week BBC News covered the break through of the Gotthard Rail Tunnel. Big science/technology is still a news story, but I have to say more usually not in the positive sense, too many stories are presented in the ‘science gone mad’ category. We (or should I have said the media) have lost the awe for big science and replaced it with fear or at least a mistrust.

Maybe I am just looking at the past with rose tinted spectacles, Jodrell Bank was over budget about 10x and people complained ‘why send men to the moon when people are starving on earth’, so maybe the coverage was the same. The current mainstream tone of reporting could just be a factor of living in a less deferential age. For me there is no question it is good to question the value of science, but this has to be done from an informed position, you have to least start to understand the question to give an reasonable opinion (or even ask a reasonable question in the first place).

What I worry is that this move, this lack of awe and excitement in science, will drive children away from wanted to be involved in science and technology. At least we are seeing a return to accessible science on the BBC (worth every penny of the license fee) in Bang Goes the Theory, the World of Invention and the new archive of The Great Egg Race (proper 1970’s mad scientists, I doubt you would get a 30 minute programme today with people fiddling with bits of string and rubber bands whist wearing wing collar nylon shirts, think of the health and safety static risk alone!).

So I guess my initial fear is unfounded, there is the sense of wonder out there, maybe we just have to make more of an effort go to find it.

ALM Rangers ship SCOM Management pack for TFS2010
Fri, Oct 15 2010 15:26

Want to monitor the health of your TFS system? Then wait no longer, the ALM Rangers have just shipped a SCOM Management pack for Visual Studio 2010.

The management pack provides availability and configuration monitoring, performance data collection, and default thresholds.  So if you use any SKU of SCOM 2007 and TFS 2010 why not download it and have a look.

by But it works on my PC!
Filed under: ,
Leeds Hack Day 2010 registration open
Thu, Oct 14 2010 9:08

To quote their site….

Leeds Hack is a 24 hour hack day in the city of Leeds (surprise!). 100+ people in a room – Feed them, water them, take them out for walks every now and them and let them create some amazing things.

Best of all… It’s free..

For more details have a look at http://leedshack.com/

Speaking at the Developer Group on Typemock Isolator on the 20th of October
Thu, Oct 7 2010 16:46

The detailed agenda for the Developer Group Meeting on the 20th of October in London has been published. I am speaking  in the afternoon on ‘Using Typemock Isolator to enable testing of both well designed code and nasty legacy systems’

Hope to see you there

Thoughts on the Software Craftsmanship 2010
Thu, Oct 7 2010 16:38

I have reached my hotel after the days events at Software Craftsmanship 2010 at Bletchley Park and got a chance to write up my thoughts. I had planned to Tweet during the day, but just never got round to it, too busy.

So how was the event? I have to say I don’t think I enjoyed it as much as last year’s event. That is not to say this was not a good event, but this years seemed to focus on hands on programming tasks. This is great but I always feel that I could have been doing this at home, or in a dojo session in the office (not that I do this  oftan enough). Last year the sessions were more Randori Kata format and the group discussion this engendered I found very useful. I think conferences like this are probably at their best when they open your mind to new technique and ideas; yes coding kata can do this, but I feel that a conference needs to focus on the meta level of ‘why do this kata’ and how to ‘best run a kata’ and leave the actual kata sessions to usergroups meetings.

Maybe there should be more sessions on the discussion on how to best evangelise software craftsmanship. Today‘s event was full of people who have already decided a craftsmanship approach is the answer for them and our industry, the big question is how to bring more people with us, especially the group who don’t attend conferences, user group or even try to keep up with current trends. I suppose it is down to all of us who do attend such groups to spread the word, so why not get down to your local group and help improve our industry, if you are in Yorkshire why not try Agile Yorkshire next week? If you can’t make why not try setting up a lunchtime coding dojo – there are loads of ideas out there on the web.

Error –4002 on Access services on Sharepoint 2010
Mon, Oct 4 2010 4:45

We have had an internal timesheeting system written in Access services running without any problems for the past through months. At the end of last week, when people tried to submit their timesheets they started getting a -4002 error saying the macro (that saves the weekly sheet) could not be started.

Checking the server event logs, Sharepoint logs and Access services log tables showed nothing. So as all good IT staff do we tried the traditional IISRESET command (on both our Sharepoint web servers) and it all leapt back into life. The only change on our server in the past week has been been the ASP.NET security fix, and associated reboot, but I cannot see why this should effect Access Services, it looked as if it had basically Access services just failed to restart fully after the server reboot.

One to keep an eye on.