woensdag 30 maart 2016

Tosca > {DATE} or {DATE[][][]} function

For some reason I ALWAYS forget what the correct syntax is with this function. So hereby a post to forever remember:

First: a good search term in the Tosca documentation:
DATE AND TIME EXPRESSIONS

Syntax:
{<EXPRESSION>[<Basedate>][<Offset>][<Format>]}

In normal human readable:
{DATE[basedate][offset][format]}

Key-letters for specifying the format:
d
days
M
months
y
years
h
hours
m
minutes
s
seconds

dinsdag 15 maart 2016

Visual Studio & Git & BitBucket: how to get started

I am not very knowledgeable when it comes to version control systems (something I really have to develop myself further in), but luckily many tools work pretty well out of the box. A very simple way to get started with VCS is to use Visual Studio's built-in-Git with BitBucket.

HOW TO:

  • Create a new empty repository in BitBucket
  • Create your to-be-version-controlled project in Visual Studio
  • Add the project to version control and choose 'Git'
  • Go to Team Explorer
    • Go to 'Changes'
    • Type 'initial commit' in the textbox
    • Click to the 'Commit' button
      • Choose 'Commit and push'
    • VS will give an error message that no remote repository is linked to the project
      • In that same error-message-screen will be a textbox where you can add the url of the remote repo.
      • Copy-paste there the URL to your BitBucket repo and...
    • Done!

donderdag 3 maart 2016

Dabbling in TTT > Powershell script to assist with development/deployment

When working on SETs/Adapter customizations/Addins one of the very annoying activities is 'deploying' your .dll to Tosca after building it:


  • Find the directory where the newly built .dll was placed
  • Copy the newly built .dll to %TRICENTIS_HOME%\Automation\Framework
  • "Oh shit, forgot to 'End Process' the 'Tricentis.Automation.Agent.exe'"
  • End Process@Tricentis.Automation.Agent.exe
  • Re-find the directory where the newly built .dll was placed
  • Finally copy the newly built .dll to %TRICENTIS_HOME\Automation\Framework
  • In the case of an Addin-deploy we even need to add killing the actual Tosca Commander client to this checklist.
Let's write a powershell script which takes care of all that. We'll have to write two scripts. One for SET/CustomAdapter deploys and one for Addin deploys. Because of the aforementioned reasons

The SET/CA deploy script is easily done... [added:] actually it was not so easily done. The script posted earlier would often generate error message because the copy-item would be called before the old .dll would truly be released. With the help of stackoverflow we modified the script to be more robust:

#IsFileLocked was literally copied from Stackoverflow
function IsFileLocked([string]$filePath){
    Rename-Item $filePath $filePath -ErrorVariable errs -ErrorAction SilentlyContinue
    return ($errs.Count -ne 0)
}
$newFile = "[fullpath of new .dll]"
$targetDirectory = "C:\Program Files (x86)\TRICENTIS\TOSCA Testsuite\Automation\Framework"
$TAA_Id = Get-Process -Name "Tricentis.Automation.Agent" -ErrorAction SilentlyContinue
if($TAA_Id)
{
Stop-Process -inputobject $TAA_Id
Wait-Process -inputobject $TAA_Id
}
Do
{
Start-sleep -m 500
} While(IsFileLocked $newFile)
Copy-Item $newFile $targetDirectory -Force

It bugs me that the above script has a hard 500ms wait in it, but I couldn't get the script to consistently work without it and won't waste time on half a second. The only caveat here is that you have to run Powershell in administrator mode. A quick Google showed it would be possible to make the script self-elevating but that's an exercise for another time. The above very simple script seemed to work fine and is a real time saver.

After updating the SETDeploy the AddinDeploy becomes trivial:
function IsFileLocked([string]$filePath){
    Rename-Item $filePath $filePath -ErrorVariable errs -ErrorAction SilentlyContinue
    return ($errs.Count -ne 0)
}
$newFile = "[fullpath new .dll]"
$targetDirectory = "C:\Program Files (x86)\TRICENTIS\TOSCA Testsuite\ToscaCommander\Addins"
$TAA_Id = Get-Process -Name "TOSCACommander" -ErrorAction SilentlyContinue
if($TAA_Id)
{
Stop-Process -inputobject $TAA_Id
Wait-Process -inputobject $TAA_Id
}
Do
{
Start-sleep -m 500
} While(IsFileLocked $newFile)
Copy-Item $newFile $targetDirectory -Force
Start-Process "C:\Program Files (x86)\TRICENTIS\TOSCA Testsuite\ToscaCommander\TOSCACommander.exe"

zaterdag 27 februari 2016

Tosca > Ideas to manage your artefacts

A fully developed TA framework based on Tosca can potentially have many artefacts, such as:
  • The Tosca version
  • The Tosca repository (One would almost forget!)
  • Tosca customizations in the form of .dll-s:
    • Special Execution Tasks (SETs)
    • Adapter Customizations
    • Add-ins
  • ODBC drivers for DB access
  • Tosca (.tcs) scripts to run Tosca via the commandline
  • PowerShell scripts which call the .tcs scripts
I am currently faced with the challenge of getting several scrum teams to start using a Tosca TA framework on a daily basis. This means that the framework userbase will increase from 2-4 TA project members which are intimately familiar with the product to 10-20 testers and devs which aren't. And, oh yeah, somewhere amidst all that a CI/CD pipeline will also be set up which will run Tosca scripts as part of its automated testing suite.

We clearly need:
  • A way to 'push' artefact updates to the (vastly increased) userbase
  • Version control on the artefacts
After a bit of research we have decided to go with the "Chocolatey, NuGet, Artifactory, OneGet" stack of technologies to try and implement this. I have next to no experience with these technologies so this should be interesting.

(Note: The technology of our company is predominantly Microsoft based (Windows desktops, Windows servers, C# .NET applications) which has been taken into account when choosing these tools.)

Update:
Ok, let's see if we can get a proof of concept going. We're going with:

  • A powershell script which calls an...
  • Executable which in turn calls
  • UniversalGreeter.dll which reads the target of its greeting from a
  • universalgreeter.config file which contains the word 'World'
Goal #1
  • Squeeze all that in one NuGet (using OneGet?)
  • Commit the NuGet to Artifactory
  • Pull the NuGet from Artifactory for a local install
  • I have as yet no idea where Chocolately comes into play here
Goal #2
  • Same as Goal #1 but with added version history
  • Including being able to install olders version (a rollback scenario)

zaterdag 2 januari 2016

AWS > First Steps


Task List
  1. Register yourdomain.com
  2. Set up an AWS Linux Server (server)
  3. Tell a/the Domain Name Server to associate yourdomain.com with the IP of the server
  4. Get a Git server running on the server
'Exploratory Testing' for the benefit of the tasks:
  • We will need to gather basic AWS knowledge before we can start to make real progress on the task list.
  • We start with AWS Getting Started:
    • http://docs.aws.amazon.com/gettingstarted/latest/swh/website-hosting-intro.html
  • Setting up to host a static website:
    • We need to sign up for AWS... check
    • Now we need to create an IAM (Identity and Access Management) user
    • AWS Management Console > IAM Management
      • Angry orange exclamation marks tell us that we need to increase the security of our AWS accounts. Let's look into that.
        • We are strongly advised to activate MFA (multi-factor authentication) on our AWS root account. We agree.
          • One angry orange exclamation mark has turned into a happy green box with a tick in it. One down one to go.
        • We set up a password policy for our IAM users and the last orange exclamation mark bites the dust. We are once more complaint. Happy days.
      • Next step: set up an IAM admin account so that we limit using the root account to a minimum... check
      • Now we can log on to the AWS Management Console via the link:
        • https://your_aws_account_id.signin.aws.amazon.com/console/
      • We customise the link so that it doesn't show the account ID and we can log on via the link
        • https://your_account_alias.signin.aws.amazon.com/console/
      • We add this link as a note in our password manager
      • We can also login directly via the password manager(!)
    • RESULT: 
      • We can now use the IAM admin account instead of the AWS root account for work on AWS.
    • God damned, not my password manager is having problems distinguishing between regular amazon login and AWS root account login. Gotta fix this.
      • Ok, fixed. We continue on.
    • Next we create the AWS buckets and set their settings per the tutorial's instruction:
      • yourdomain.com
      • www.yourdomain.com
      • logs.yourdomain.com
    • LEARNING MOMENT:
      • The tutorial is very clear on the fact that this type of S3-bucket-based hosting is for static websites only. For dynamic content (or something as a Git server) we will need to set up a virtual server.
    • Painful: we just wasted 30m trying to find the 'upload' action for one of the buttons. Turns out that the general S3 module starting page will show general actions only (who would've thought?), and that to get the bucket-specific actions you will first need to click one. Ouch.
    • Interesting: we can create a folder structure (with ditto content) inside the buckets to match file references inside the html document.
    • Continuing on with the 'Getting Started with AWS - Hosting a static website' guide we:
    • Configure the buckets
    • Deploy the website
    • Register the domain name via the AWS Route 53 module
    • Associate the domain name with the website
      • We create a 'hosted zone' (sounds fancy) for the domain
        • IMPORTANT:
          • By creating a hosted zone a number (4) of Name Servers were generated. We will need this list of name servers in the 'registered domain' section to link the registered domain to the hosted zone.
      • We create 'record sets' for the root domain and the subdomain)
      • We setup a DNS provider
        • This actually took me quite a while to understand
        • We need to "log into the domain name registrar used to register your domain"
          • This IS the Route 53 module of AWS
        • Then we need to 
          • Use the web interface provided by the registrar to set the name servers for your domain to the name server values displayed under Name Servers in the details for the hosted zone.
        • This is done by:
          • going to the 'Registered Domains' section and clicking on yourdomain.com
          • click Add/Edit Name Servers
            • enter the name servers that were created for the hosted zone in the window which pops up
      • It might take a while for these changes to propagate through the internet but essentially this is when you're done.
    • RECAP MOMENT:
      • We create buckets (in AWS S3) which correspond with a root domain and its subdomains respectively and contain the actual content of the website
      • We register domains (in AWS Route 53)
      • We create a hosted zone (in AWS Route 53) which acts as a in-between between the buckets and the registered domains
    • Also: Task 1... COMPLETED! :-)

woensdag 30 december 2015

Epic Story > Get a Git server running on an AWS hosted Linux server

New Year's resolution: git (see what I did there?) started on source control.

As a Test Automator
I want to have a Git server running on my own AWS hosted Linux server
So that I'll always have complete and up-to-date access to all my source code

C# > Code Smells


From Adaptive Code via C# by Gary McLean Hall

Code smells:
  • Static methods
  • Static classes (including singletons = classes which can only be instantiated by one object)
  • Object construction that uses new
  • Extension methods
Code perfumes:
  • Interfaces
  • Dependency injections
  • Inversion of control
  • Factories