Page 1 of 1

How to distibute licenses.

Posted: Tue Jan 15, 2019 10:17 am
by WilcoRakhorst
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?

Re: How to distibute licenses.

Posted: Tue Jan 15, 2019 10:44 am
by qwertzu
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

Re: How to distibute licenses.

Posted: Tue Jan 15, 2019 10:53 am
by odklizec
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 ;)

Re: How to distibute licenses.

Posted: Tue Jan 15, 2019 11:06 am
by WilcoRakhorst
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).

Re: How to distibute licenses.

Posted: Tue Jan 15, 2019 11:18 am
by odklizec
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.

Re: How to distibute licenses.

Posted: Tue Jan 15, 2019 1:31 pm
by WilcoRakhorst
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!

Re: How to distibute licenses.

Posted: Thu Apr 04, 2019 8:48 am
by Support Team
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

Re: How to distibute licenses.

Posted: Mon May 13, 2019 9:15 am
by Johann
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.

Re: How to distibute licenses.

Posted: Mon May 13, 2019 9:46 am
by odklizec
Hi,

So have you tried the workaround code posted by Robert? This code should fix the problem with license check, while using /agent parameter.

Re: How to distibute licenses.

Posted: Mon May 13, 2019 10:36 am
by Johann
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...");  
	}  
}
....

Re: How to distibute licenses.

Posted: Tue May 14, 2019 8:23 am
by Johann
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();     
                 }
            }    
    }
}

Re: How to distibute licenses.

Posted: Tue May 14, 2019 11:18 am
by Support Team
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

Re: How to distibute licenses.

Posted: Wed May 15, 2019 12:24 pm
by Johann
It helped, thank you Robert.