WaitForValidLicense returns true even if all lic. are in use

Class library usage, coding and language questions.
Posts: 19
Joined: Wed Mar 14, 2012 9:20 am

WaitForValidLicense returns true even if all lic. are in use

Post by sauer-peters » Mon May 13, 2013 1:58 pm

Hi Ranorex Users and Support Team,
in our continuous integration and nightly test automation setup we need an easy way to check if a Ranorex floating license is available (or wait for a free floating license) before we start scripts to run the tests. I found WaitForValidLicense() API method http://www.ranorex.de/Documentation/Ran ... ense_1.htm which looks promising. I used VS2012 to built a console application which takes timeout and checkInterval in seconds as command line arguments and returns an exit code 0 if a license is available and exit code 1 if no license is available. But unfortunately the thing is not working as I expected but is returning 'true' even if all licenses are in use by running Ranorex tests.
I did the following tests:
I started my console application to wait for a license to become available. Then I was connecting to the license server holding the floating licenses. As soon as the connection to the server was estabished my console app returned 0 (Ranorex API method returned 'true'). When the timeout was over while the connection was still not established my app returned 1 (Ranorex API method returned 'false'). So far so good!
After this I started so many running Ranorex test suites that all my foating licenses were in use. No more test suite could be sarted. Then again I started my console application and it immediatly returned 0 (Ranorex API method returned 'true' = license available).
And that's NOT what I want!
If all floating licenses are in use by running test suites then WaitForValidLicense(timeout, checkInterval) should wait and if the the timeout has run out it should return 'false' (in stead of 'true').
Am I getting something wrong here :?:
Is this method just checking the connection to the Ranorex floating license server?

This is a snippet from my code of the console application:

Code: Select all

    bool licenseAvailable = Ranorex.Core.ElementEngine.WaitForValidLicense(new Ranorex.Duration(timeout * 1000), new Ranorex.Duration(checkInterval * 1000));

                if (licenseAvailable)
                    System.Console.WriteLine("Yeah... license avaliable!");
                    return (int)ExitCode.Success;
                    System.Console.WriteLine("Doh... no license avaliable.");
                    return (int)ExitCode.NoLicenseAvailable;

User avatar
Support Team
Site Admin
Site Admin
Posts: 12169
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: WaitForValidLicense returns true even if all lic. are in use

Post by Support Team » Tue May 14, 2013 3:52 pm

Hello Sebastian,

Thanks for the detailed explanation!
Could it be that a node locked license is also installed on the machine where you execute the console application?
Are you able to execute your Ranorex tests on the machine where your console application returned true?