How to distibute licenses.

Ranorex Studio, Spy, Recorder, and Driver.
User avatar
WilcoRakhorst
Posts: 6
Joined: Tue Nov 04, 2014 2:20 pm

How to distibute licenses.

Post by WilcoRakhorst » Tue Jan 15, 2019 10:17 am

I would like to be able to assign a specific number of licenses to two Jenkins installations.
For example:
* Jenkins server 1 (Final software tests) gets 10 licences to run at night
* Jenkins server 2 (Beta software tests) gets 8 licences to run at night

We use a floating licensing configuration. Can this be done?
A test employee does not break it. He only proves it was already broken.

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: How to distibute licenses.

Post by qwertzu » Tue Jan 15, 2019 10:44 am

Hi,

Generally, the machines on which the tests get executed, need access to your license server where the floating licenses are installed.
If you run one test after the other, you will only need one floating runtime license. If you want to execute multiple tests at the same time, each test needs its own floating runtime license.

You can simply download the license manager on one of your machines in your network and install all your floating licenses on this machine.
All machines in the same network will be able to lease licenses for running tests. As soon as a test ends, the license will be released.

regards, qwertzu

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

Re: How to distibute licenses.

Post by odklizec » Tue Jan 15, 2019 10:53 am

Hi,

Additionally, to what qwertzu suggested, I would suggest to implement WaitForValidLicense to all your projects. See this post:
web-license-manager-t10286.html#p41281
This will assure that the test will not fail (immediately) if there is currently no license available ;)
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

User avatar
WilcoRakhorst
Posts: 6
Joined: Tue Nov 04, 2014 2:20 pm

Re: How to distibute licenses.

Post by WilcoRakhorst » Tue Jan 15, 2019 11:06 am

Thank you both for replying.
We have 1 licensing server available. On this machine are all our licenses (RT + premium) installed. Our Jenkins configuration is running multiple scripts simultaneously. So when a script is executed it will wait if a license is available. And yes Odklizec, we have the WaitForValidLicense implemented, which is very useful!
What I would like to achieve is that each Jenkins configuration can only use 50% of the licences. I don't want a Jenkins configuration to use all the licenses during the night. If it does, I don't know my test results for the other Jenkins configuration in the morning.
We run our tests nightly on Final and Beta software. In the morning the test results are reviewed. And this is why I don't want a Jenkins configuration to take up all of the licenses. Because when it does, the other Jenkins configuration will not be ready in the morning.
For your information, each Jenkins configuration runs around 200 test scripts. We have this configured so it runs a lot of tests simultaneously, because we have multiple licenses for this.
I hope I made my case clear (enough).
A test employee does not break it. He only proves it was already broken.

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

Re: How to distibute licenses.

Post by odklizec » Tue Jan 15, 2019 11:18 am

Hi,

In my opinion, you will have to use two license servers and instruct each Jenkins machine to use one of them? I don't think there is a way to achieve what you want, with single license server.
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

User avatar
WilcoRakhorst
Posts: 6
Joined: Tue Nov 04, 2014 2:20 pm

Re: How to distibute licenses.

Post by WilcoRakhorst » Tue Jan 15, 2019 1:31 pm

odklizec wrote:
Tue Jan 15, 2019 11:18 am
Hi,

In my opinion, you will have to use two license servers and instruct each Jenkins machine to use one of them? I don't think there is a way to achieve what you want, with single license server.
I already thought it would come to that. Thanks for your advice!
A test employee does not break it. He only proves it was already broken.

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

Re: How to distibute licenses.

Post by Support Team » Thu Apr 04, 2019 8:48 am

Hi guys,

We recently faced an issue using the WaitForValidLicense() when triggering the test executable via CMD and the "/agent:" parameter. This causes the WaitForValidLicense() method to be called twice. Once before the actual deployment to your remote machine (agent) and once on the remote machine itself.

Here's the solution:
//You could use the following code to limit the license check to your agent machine:

public static int Main(string[] args)
        {
            bool licenseAvailable = false;
            
            var commandParams = CommandLine.EnvironmentCommandLine.Parameters;
            
            if (!commandParams.ContainsKey("a") && !commandParams.ContainsKey("agent"))
            {
                Console.WriteLine("License check ...");
                licenseAvailable = ElementEngine.WaitForValidLicense(new Duration((int)600E+3), new Duration((int)5E+3));
                
                if(licenseAvailable)
                {
                    Console.WriteLine("License available...");
                }
            }

Sincerely,
Robert

Johann
Posts: 23
Joined: Fri May 03, 2019 8:55 am

Re: How to distibute licenses.

Post by Johann » Mon May 13, 2019 9:15 am

I believe that I have exactly the problem described above.
Here are some key data:
- I got one Floating License
- Ranorex Version: 9.0.1

I've tried to add the license check with "WaitForValidLicense(), until i found this post. Then i tried to implement the solution from above, but that doesn't work... maybe I'm doing something wrong.
I can run the test on my VM development machine using a batch script , but I can't run a test with an Agent on my test VM mashine.
And I can run the tests on the VM test mashine with a batch script too.

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

Re: How to distibute licenses.

Post by odklizec » Mon May 13, 2019 9:46 am

Hi,

So have you tried the workaround code posted by Robert? This code should fix the problem with license check, while using /agent parameter.
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

Johann
Posts: 23
Joined: Fri May 03, 2019 8:55 am

Re: How to distibute licenses.

Post by Johann » Mon May 13, 2019 10:36 am

Yes, I tried.
I am not an expert on coding, I've tried this Code to add :

Code: Select all

[STAThread]
 public static int Main(string[] args)
{  
bool licenseAvailable = false;  
              
var commandParams = CommandLine.EnvironmentCommandLine.Parameters;  
              
 if (!commandParams.ContainsKey("a") && !commandParams.ContainsKey("agent"))  
 {  
	Console.WriteLine("License check ...");  
	licenseAvailable = ElementEngine.WaitForValidLicense(new Duration((int)600E+3), new Duration((int)5E+3));  
                  
	if(licenseAvailable)  
	{  
		Console.WriteLine("License available...");  
	}  
}
....

Johann
Posts: 23
Joined: Fri May 03, 2019 8:55 am

Re: How to distibute licenses.

Post by Johann » Tue May 14, 2019 8:23 am

I found the problem. It's my Popupwatcher, if i uncomment Popupwatcher, my Tests works...
can someone please check it?

Code: Select all

namespace TEST
{
    class Program
    {
        // repository
        public static TEST.TESTRepository repo = TEST.TESTRepository.Instance;
        
        [STAThread]
        public static int Main(string[] args)
        {
            // License check
            bool licenseAvailable = false;
            var commandParams = CommandLine.EnvironmentCommandLine.Parameters;
            if (!commandParams.ContainsKey("a") && !commandParams.ContainsKey("agent"))
            {
                Console.WriteLine("License check ...");
                licenseAvailable = ElementEngine.WaitForValidLicense(new Duration((int)600E+3), new Duration((int)5E+3));
                
                if(licenseAvailable)
                {
                    Console.WriteLine("License available...");
                }
            }
            
            // PopupWatcher
            PopupWatcher myPopupWatcher = new PopupWatcher();
  
            myPopupWatcher.Watch(repo.Main.Titlebar.MaximierenInfo, PopupHandler);
            myPopupWatcher.Watch(repo.Main.VorhandenInfo, PopupHandler);
            myPopupWatcher.Watch(repo.Main.BankInfo, PopupHandler);
            myPopupWatcher.Watch(repo.Main.TitleMeldungInfo, PopupHandler);
            
            myPopupWatcher.Start();
            
            Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
            int error = 0;
            
            try
            {
                error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
            }
            catch (Exception e)
            {
                Report.Error("Unexpected exception occurred: " + e.ToString());
                error = -1;
            }
            return error;
        }
            /// <summary>
            /// Popupwatcher 
            /// </summary>
            /// <param name="myInfo"></param>
            /// <param name="myElement"></param>
            public static void PopupHandler(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)
            {
                if(myInfo == repo.Main.Titlebar.MaximierenInfo)
                {
                    repo.Main.Titlebar.Maximieren.MoveTo();
                    Delay.Duration(100);
                    repo.Main.Titlebar.Maximieren.Click();
                }
                else if(myInfo == repo.Main.VorhandenInfo)
                {
                    repo.Main.ButtonOK.MoveTo();
                    Delay.Duration(100);
                    repo.Main.ButtonOK.Click();    
                }
                 else if(myInfo == repo.Main.BankverbindungInfo)
                {   
                    repo.Main.ButtonOK.MoveTo();
                    Delay.Duration(100);
                    repo.Main.ButtonOK.Click();  
                }
                 else if (myInfo == repo.Main.TitleMeldungInfo)
                 {
                    repo.Main.ButtonOK.MoveTo();
                    Delay.Duration(100);
                    repo.Main.ButtonOK.Click();     
                 }
            }    
    }
}

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

Re: How to distibute licenses.

Post by Support Team » Tue May 14, 2019 11:18 am

Hi Johann,

I would recommend to start the popup watcher as part of your test suite.
Simply add a code module to your SETUP region within your test suite and add the code there.

Sincerely,
Robert

Johann
Posts: 23
Joined: Fri May 03, 2019 8:55 am

Re: How to distibute licenses.

Post by Johann » Wed May 15, 2019 12:24 pm

It helped, thank you Robert.