Forum Discussion

LAB's avatar
LAB
Contributor
6 years ago
Solved

Running test suites via distributed testing

Is there any way to remotely run large test suites with test execute? i.e. I can add any number of test items under my project and run them all at once.

 

I'm using distributed testing, but each task is associated with 1 test case, (and it won't allow multiple tasks under the same job with same host), so it seems like I'm stuck creating 40 jobs to run 40 test cases. (or pasting everything in to one case which is not ideal)

 

 

  • What is your reason for using distributed testing?  Is it simply to spread the test run across multiple machines?  If so, then you've found the only solution for that.

     

    However, if it's simply a matter of sending a full test run to a machine, we use Task Scheduler to do that... we simply have a VM that is set into console mode on our VMWare server that has a task set in Task Scheduler to execute a test run which includes the whole project.  You can have multiple test items per project and, when you indicate to run the project, all test items are run.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What is your reason for using distributed testing?  Is it simply to spread the test run across multiple machines?  If so, then you've found the only solution for that.

     

    However, if it's simply a matter of sending a full test run to a machine, we use Task Scheduler to do that... we simply have a VM that is set into console mode on our VMWare server that has a task set in Task Scheduler to execute a test run which includes the whole project.  You can have multiple test items per project and, when you indicate to run the project, all test items are run.

  • mjwatkins2's avatar
    mjwatkins2
    Occasional Contributor

    I got around this issue with a loop (below) that runs each task one at a time remotely, running a new task when a previous task completes. This lets you assign multiple tasks under the same job to the same host (I am distributing a couple hundred tests across a dozen hosts with this method). Sounds like what you need.

     

    The following code assumes you have already created a job with a long list of tasks, with multiple tasks assigned to the same host. You can do this programmatically.

     

     

    function RunJob(jobName)
    {
       // keep track of the Task row number for each host
       var runningHosts = new ActiveXObject("Scripting.Dictionary");
       
       // run through the list of tasks and begin the first one for each host
       var tasks = NetworkSuite.Jobs.ItemByName(jobName).Tasks;
       for (var i = 0; i < tasks.Count; i++)
       {
          var task = tasks.Items(i);
          var hostName = task.Host.Name;
          
          if (task.Active && !runningHosts.Exists(hostName))
          {
             runningHosts.Add(hostName, i);
             task.Run(false);
          }
       }
       
       // periodically check the list of tasks and see if one is finished
       var done = false;
       while (!done)
       {
          aqUtils.Delay(60000);
          var hostNames = runningHosts.Keys().toArray();
          for (var j = 0; j < runningHosts.Count; j++)
          {
             var hostName = hostNames[j];
             var lastTaskIndex = runningHosts.Item(hostName);
             var lastTask = tasks.Items(lastTaskIndex);
             if (lastTask.State == ns_Idle) // is the last task for this host finished?
             {
                // find the next task for this host and run it
                var i = lastTaskIndex + 1;
                for (; i < tasks.Count; i++)
                {
                   var task = tasks.Items(i);
                   var taskHostName = task.Host.Name;
                   if (task.Active && taskHostName == hostName)
                   {
                      runningHosts.Item(hostName) = i;
                      task.Run(false);
                      break;
                   }
                }
                // check if this host is finished with all tasks
                // if so, remove it from the dictionary
                if (i == tasks.Count)
                {
                   runningHosts.Remove(hostName);
                   if (runningHosts.Count == 0)
                      done = true;
                   break; // jumps back to the while loop
                }
             }
          }
       }
       
    }