Thursday, 14 November 2013

TF259641: To use the environment, you must install a compatible test agent in all machines of the environment. Click 'Install Agents' to complete this task.


I have been trying to configure a TFS standard lab environment with below topology having full trust two domains. This I have done few times and I have  not faced any difficulty in previous attempts. But this time I faced a bit of a challenge with error TF259641.


I was using a configured test controller, for the project collection previously, and that is used in other lab environments without any issues.


The error  "TF259641: To use the environment, you must install a compatible test agent in all machines of the environment. Click 'Install Agents' to complete this task." encountered when I tried to configure my lab environment.


Checked the event log in Test Agent installed machine...




Error was "Unable to connect to the controller on 'myTESTcontroller:6901'. The agent can connect to the controller but the controller cannot connect to the agent because of following reason: The requested name is valid, but no data of the requested type was found. Make sure that the firewall on the test agent machine is not blocking the connection"

Searching for this error pointed to Windows Firewall settings for port (TCP port 6910 for inbound connectivity for agent allowed) of test agent and File and Printer Sharing settings. Verified all OK.



What could be wrong here..I was bit worried. Back to basics and went through MSDN.

This article How to: Bind a Test Controller or Test Agent to a Network Adapter was interesting and I applied binding to my test agent service config file.

Stopped the service.


Opened the config.


Added binding ("This will let test controller to find my test agent machine" was my assumption).


It worked....and my Lab environment configured successfully..


But it was giving a completely different name to my lab environment machine. Then I realized who was the culprit, it was none other but ME.

I have done an experiment to support a payment gateway some time back, with this standard environment machine I used for lab set up now. I have added an entry in hosts (for local IP) file which was causing the error in the first place, not allowing test controller to connect back with the test agent.


Removed this entry from hosts file. I proceeded to remove the binding I applied to Test Agent service config. Restarted Test Agent and refreshed the lab environment. Correct name appeared for my Lab standard environment machine.



Cool...It was working as it should when configured in an environment having multiple domains with full trust. 

Posted this to help crazy fellows like me..who are lazy to create a new machine and use an old virtual machine hoping to run.. often into problems. :)

Thursday, 7 November 2013

Build-Deploy-Test Automation Session @ Sri Lanka .Net User Group

 Today I did a session on "Automating Build-Deploy-Test" at Sri Lanka .Net forum. Response from the participants was great. We have gone through the concept, benefits and set the background for many "How to Do"s. Hoping to do the continuation of this session in coming months, with deep dive into setting up lab environments, builds, build customizations, deployment and test automation.



Session in YouTube







Thursday, 31 October 2013

TFS - Lab Build - Deployment Script - Copy Build Output Zip to Lab Env. Machine and Extract

As a continuation to my last post "TFS - Lab Build - Create Zip File with Build Output in the Drop Folder", today I am going to explain how to use a deployment script with lab build (Build-Deply-Test workflow), to copy the build out put zip file, to Lab Environment Machine and extract.

1. First I am going to create a batch file and a PS script. My PS script will do all the work. Batch file (.bat) will be used to initiate the powershell script from Lab Workflow. To get this to work I need to make sure my batch file and the PS script is copied to build output folder, since it is the place that I can execute a deployment script from Lab Work Flow.

I have added my .bat file and the PS script file under a VS project that is under a solution I am building, and set the Copy to Output as always.


2. This will copy my .bat and PS script to Build Drop folder.


3. This is what I have in my .bat file. It is simply executing the PS script making sure execution policy is not blocking anything. Build location here is passed as an argument from the Lab Workflow.


4. In my Lab Build in the deployment steps I specify the .bat file to run as below. For more information and how to use xcopy to copy build out put have a look at "Creating Deployment Scripts for Build-Deploy-Test Workflows". I used a poweshell script since I am going to do lot more than just copying files, like adding dlls to GAC, etc which I will explain in a next post.

$BuildLocation is giving the build output location of the build that is queued/used by  Lab workflow.



5. In my poweshell script I am copying zip to my lab environment machine. The path C:\ ..refers to the path in the lab environment machine, since  the deployment script get executed in the context of given lab environment machine as specified in the above screenshot.

After copying this script will extract contents to the copied location and remove the zip file from the Build Drop folder. Build Location is passed to the poweshell script from the above .bat file as a parameter.


6. I queue a build and I can see my zip file copying actions get executed in the Build Log as below.


7. In my lab environment machine I see the extracted files .


This is cool .. don't you think..


TFS - Lab Build - Create Zip File with Build Output in the Drop Folder

Sometimes it takes long time to copy files from drop folder to the lab environment when you have your lab environment in different locations( distributed environments), and you have several hundred files in your drop folder (example - published website with lot of files).

I will explain how to use a Build Activity to zip, by customizing LabDefaultTemplate.11.xaml.

How to add a custom code activity to a build template is clearly explained in this article http://www.ewaldhofman.nl/post/2010/04/29/Customize-Team-Build-2010-e28093-Part-4-Create-your-own-activity.aspx

Go through the above article if you want to know the basics.

So lets look at how to add a build activity to zip the build output.

1. First you need to have a code activity similar to below


2. Once compiled and add reference to your build template project you can view the New Activity --> Zip in the Toolbox when you open the build template.


3. Drag and drop the  Zip activity to LabDefaultTemplate.11.xaml after the "Compute build location needed" activity to make sure BuildLocation variable is filled with the correct build location (This variable will contain the Build Folder path of the Build queued or used by the Build task of the Lab Workflow).



4. Set the properties as below in the Zip build activity. DirectoryLocation is set to Build Location and Zip file path will be Build Location path with ".zip" extension. This will make sure zip file is created at the drop location of the build used by the lab workflow.


5. Create a build definition using the lab template and set the lab workflow build step to use the release build definition of yours (Output of this build will be used to create the zip file).


6. Queue a build with the lab build and you will see lab(build-deploy-test) build, queues  the release build, once complete use the build location and create the build output as a zip file.


7. In the drop location of the release build you will have the build out put files and the zip file of the output.


In my next post, I will explain "How to use a deployment task of the Lab Workflow to copy the output zip file and extract it in the Lab Environment Machine".

Sunday, 27 October 2013

TFS - Delete WIT Custom Fields Permanently


When you delete a custom filed from a Work Item Template and import is it really deleted from TFS fully? Or is it only hidden from that work item type and remains in TFS?

To find out the answer I have done a small experiment.

1. Fist I have added a new HTML type filed "CH.Test1" and added a HTML field control to User Story work item.



2. When I have imported the template I can see my new field in User Story work item.


3. I saved some data to newly created field.


4. Then I deleted the HTML field control and the filed "CH.Test1" in the template.


5. When viewed the previous user story I could not see the field and that is correct and field is deleted.


6. But what happens if I add the field again? To Investigate I tried adding the field with Same Reference Name but with a different name.



7. Import failed with

Error importing work item type definition:

TF26177: The field CH.Test1 cannot be renamed from 'Chaminda Test 1' to 'Chaminda Deleted And Added Field'.


8. This means that the field was not really deleted. To test I changed to the initial name "Chaminda Test 1"


9. Import was successful and when I viewed the same user story data I had entered before deleting the field was still available. It looked clear that even if I deleted a field from WIT template and import it did not delete the field or the data from TFS Collection.


8. Search in MSDN got me here Manage work item fields [witadmin]
I used witadmin listfields with Reference Name to see my field. The command gave the details of the field, whether it was used, In which project it was used.


9. Again I tried deleting from template and import.


10. When I used witadmin listfields with Reference Name, it clearly showed field is existing in collection but "Not In Use" in any team project.


11. How to delete permanently? I used witadmin deletefield with Reference Name, this gave me a warning and a confirmation question. When said Yes deleted. To verify I executed witadmin listfields with Reference Name again and an error shown that the field does not exist.


12. To confirm I tried re-adding the field with same Reference Name but with a different Name, and a different data type (String).



13. This time I did not get TF26177 when the template was imported.


Conclusion: When a field is deleted from the work item template and imported it remains in TFS collection and previously entered data related to work item also preserved. To delete the field permanently witadmin deletefield can be used and all data and the field will be completely destroyed with this command.

Popular Posts