Wait for license in Devops pipeline- Floating license

Best practices, code snippets for common functionality, examples, and guidelines.
vishalkulkarni
Posts: 7
Joined: Fri Aug 14, 2020 8:59 am

Wait for license in Devops pipeline- Floating license

Post by vishalkulkarni » Thu Sep 17, 2020 10:43 am

https://ranorex.com/forum/floating-lice ... t1970.html

Currently in Ranorex studio 9.2 we see this feature.
When there are license in use, the test suite waits till license availability and then begins execution.

However when running test suite exes using command line in pipeline, the execution fails stating license not available.
How to ensure similar behavior to be done for command line execution.

Wait for license to be available and then execute the suite.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6180
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Wait for license in Devops pipeline- Floating license

Post by odklizec » Thu Sep 17, 2020 11:06 am

Hi,

What you need is to implement WaitForAvailableLicense method in Program.cs, as described for example here...
running-tests-on-numerous-machines-t8803.html#p35582
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

vishalkulkarni
Posts: 7
Joined: Fri Aug 14, 2020 8:59 am

Re: Wait for license in Devops pipeline- Floating license

Post by vishalkulkarni » Thu Sep 17, 2020 12:11 pm

Hi ,

Thank you so much, will try this.

vishalkulkarni
Posts: 7
Joined: Fri Aug 14, 2020 8:59 am

Re: Wait for license in Devops pipeline- Floating license

Post by vishalkulkarni » Thu Sep 17, 2020 1:50 pm

So I tried this.
I removed the license server configuration from where license was being fetched.

I created a console exe which contains the code snippet

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;
                }
                else
                {
                    System.Console.WriteLine("Doh... no license avaliable.");
                    return (int)ExitCode.NoLicenseAvailable;
                    }
Now i run the exe it returns license available.

However when I run Ranorex studio, it pops up the dialog to configure license or activate trial license.

After this again if i run the exe it still says license is available.

I see similar problem here
waitforvalidlicense-returns-true-even-i ... t4653.html

Can you help.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6180
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Wait for license in Devops pipeline- Floating license

Post by odklizec » Thu Sep 17, 2020 1:59 pm

Hi,

So are you using floating license? And the machine where you run the test is properly configured to reach the license server? Ideally, install whole Ranorex Studio on the target machine and configure the license via license manager.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

vishalkulkarni
Posts: 7
Joined: Fri Aug 14, 2020 8:59 am

Re: Wait for license in Devops pipeline- Floating license

Post by vishalkulkarni » Thu Sep 17, 2020 7:33 pm

Yes, My problem is following.
I am running suites on virtual machines configured as azure devops pipeline agents
All of them are configured to connect to license server.
I have more vm's than licenses.

Most of times tests pass as they get license

Sporadically few suites fail stating they were not able to get license as all licenses were being used.


Hence I thought I could use this snippet to make a vm wait for license, get the license and then start executing test cases.

However the code snippet never reports that there is no license. Even though there is no license with which test suite could progress successfully.