Skip to content

Commit

Permalink
Merge branch 'Releases/Beta' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ambarkhan authored Sep 15, 2020
2 parents 2a9e97c + 743bffa commit ef9ed53
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 132 deletions.
9 changes: 6 additions & 3 deletions Ginger/GingerCore/Drivers/SeleniumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7658,12 +7658,15 @@ public bool CanStartAnotherINstance()
}

public bool CanStartAnotherInstance(out string errorMessage)

{

switch(mBrowserTpe)
{
case eBrowserType.IE:
errorMessage = "Internet Explorer Doen't Support Virtual Agents";
return false;


//TODO: filter on internetexplorer

default:
errorMessage = string.Empty;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public static void ClassInitialize(TestContext TC)

NewRepositorySerializer RS = new NewRepositorySerializer();
NewRepositorySerializer.AddClassesFromAssembly(typeof(MyRepositoryItem).Assembly);
mSolutionRepository.Open(TempRepositoryFolder);
mSolutionRepository.Open(TempRepositoryFolder);



}

private static void CreateTestSolution()
Expand Down
25 changes: 14 additions & 11 deletions Ginger/GingerCoreNET/AnalyzerLib/RunSetConfigAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,20 @@ public static List<AnalyzerItemBase> Analyze(RunSetConfig RSC)
Agents.Add(AA.Agent.Guid);
else
{
//create error
RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
AGR.ItemParent = GR.Name;
AGR.Description = "Same Agent was configured on more than one Runner";
AGR.Details = string.Format("The '{0}' Runner '{1}' Target Application is mapped to the '{2}' Agent which is already configured on another Runner", GR.Name, AA.AppName, AA.AgentName);
AGR.HowToFix = "Map the Target Application to different Agent";
AGR.CanAutoFix = AnalyzerItemBase.eCanFix.No;
AGR.IssueType = eType.Error;
AGR.Impact = "Execution will fail.";
AGR.Severity = eSeverity.Critical;
AGR.Selected = false;
if (!AA.Agent.SupportVirtualAgent())
{
//create error
RunSetConfigAnalyzer AGR = CreateNewIssue(IssuesList, RSC);
AGR.ItemParent = GR.Name;
AGR.Description = "Same Agent was configured on more than one Runner";
AGR.Details = string.Format("The '{0}' Runner '{1}' Target Application is mapped to the '{2}' Agent which is already configured on another Runner", GR.Name, AA.AppName, AA.AgentName);
AGR.HowToFix = "Map the Target Application to different Agent";
AGR.CanAutoFix = AnalyzerItemBase.eCanFix.No;
AGR.IssueType = eType.Error;
AGR.Impact = "Execution will fail.";
AGR.Severity = eSeverity.Critical;
AGR.Selected = false;
}
}
}
}
Expand Down
100 changes: 72 additions & 28 deletions Ginger/GingerCoreNET/Run/GingerRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public enum eRunLevel

public class GingerRunner : RepositoryItemBase
{


public enum eActionExecutorType
{
Expand Down Expand Up @@ -114,7 +114,7 @@ public Context Context


public PublishToALMConfig PublishToALMConfig = null;

public enum eResetStatus
{
All,
Expand All @@ -133,7 +133,7 @@ public enum eResetStatus
private bool mStopBusinessFlow = false;

private bool mCurrentActivityChanged = false;
private bool mErrorHandlerExecuted = false;
private bool mErrorHandlerExecuted = false;

BusinessFlow mExecutedBusinessFlowWhenStopped=null;
Activity mExecutedActivityWhenStopped=null;
Expand All @@ -156,9 +156,9 @@ public BusinessFlow CurrentBusinessFlow
mContext.BusinessFlow = mCurrentBusinessFlow;
mContext.Runner = this;
}
}
}
public bool AgentsRunning = false;
public ExecutionWatch RunnerExecutionWatch = new ExecutionWatch();
public ExecutionWatch RunnerExecutionWatch = new ExecutionWatch();
public eExecutedFrom ExecutedFrom;
public string CurrentGingerLogFolder = string.Empty;
public string CurrentHTMLReportFolder = string.Empty;
Expand Down Expand Up @@ -222,10 +222,10 @@ public eRunOptions RunOption
}

public ObservableList<Platform> Platforms = new ObservableList<Platform>();//TODO: delete me once projects moved to new Apps/Platform config, meanwhile enable to load old run set config, but ignore the value

[IsSerializedForLocalRepository]
public ObservableList<IApplicationAgent> ApplicationAgents { get; set; } = new ObservableList<IApplicationAgent>();

[IsSerializedForLocalRepository]
public ObservableList<Guid> FilterExecutionTags = new ObservableList<Guid>();

Expand Down Expand Up @@ -324,21 +324,21 @@ public ProjEnvironment ProjEnvironment
mProjEnvironment = (ProjEnvironment)value;
//ExecutionLogger.ExecutionEnvironment = (ProjEnvironment)value;
mContext.Environment = mProjEnvironment;
NotifyEnvironmentChanged();
NotifyEnvironmentChanged();
}
}



public ObservableList<DataSourceBase> DSList {get; set;}


private bool mRunInSimulationMode;
[IsSerializedForLocalRepository]
public bool RunInSimulationMode
{
get
{
{
return mRunInSimulationMode;
}
set
Expand All @@ -363,7 +363,7 @@ public GingerRunner()
{
RunListeners.Add(new TelemetryRunListener());
}

}

public GingerRunner(Amdocs.Ginger.Common.eExecutedFrom executedFrom)
Expand Down Expand Up @@ -432,7 +432,7 @@ public Amdocs.Ginger.CoreNET.Execution.eRunStatus RunsetStatus
{
return eRunStatus.Skipped;
}
else if (((from x in BusinessFlows where (x.RunStatus == eRunStatus.Passed || x.RunStatus == eRunStatus.Skipped) select x).Count() == BusinessFlows.Count)&& BusinessFlows.Count>0)
else if (((from x in BusinessFlows where (x.RunStatus == eRunStatus.Passed || x.RunStatus == eRunStatus.Skipped) select x).Count() == BusinessFlows.Count) && BusinessFlows.Count > 0)
{
return eRunStatus.Passed;
}
Expand Down Expand Up @@ -463,7 +463,7 @@ public void UpdateBusinessFlowsRunList()
}
}
BFR.BusinessFlowRunDescription = bf.RunDescription;
BFR.BFFlowControls = bf.BFFlowControls ;
BFR.BFFlowControls = bf.BFFlowControls;
BusinessFlowsRunList.Add(BFR);
}
}
Expand All @@ -479,14 +479,15 @@ public async Task<int> RunRunnerAsync()
return result;
}




public void RunRunner(bool doContinueRun = false)
{
bool runnerExecutionSkipped = false;
try
{

if (Active == false || BusinessFlows.Count == 0)
{
runnerExecutionSkipped = true;
Expand All @@ -505,6 +506,7 @@ public void RunRunner(bool doContinueRun = false)
Status = eRunStatus.Started;
IsRunning = true;
mStopRun = false;
SetupVirtualAgents();
if (doContinueRun == false)
{
RunnerExecutionWatch.StartRunWatch();
Expand All @@ -518,7 +520,7 @@ public void RunRunner(bool doContinueRun = false)
//do Validations

//Do execution preparations
if (doContinueRun == false && this.ExecutedFrom==eExecutedFrom.Automation)
if (doContinueRun == false && this.ExecutedFrom == eExecutedFrom.Automation)
{
UpdateApplicationAgents();
}
Expand All @@ -529,17 +531,17 @@ public void RunRunner(bool doContinueRun = false)
int startingBfIndx = 0;
if (doContinueRun == false)
{
startingBfIndx = 0;
startingBfIndx = 0;
}
else
{
startingBfIndx = BusinessFlows.IndexOf(CurrentBusinessFlow);//skip BFs which already executed
}

int? flowControlIndx = null;
int? flowControlIndx = null;
for (int bfIndx = startingBfIndx; bfIndx < BusinessFlows.Count; CalculateNextBFIndx(ref flowControlIndx, ref bfIndx))
{
BusinessFlow executedBusFlow =(BusinessFlow) BusinessFlows[bfIndx];
BusinessFlow executedBusFlow = (BusinessFlow)BusinessFlows[bfIndx];

//stop if needed before executing next BF
if (mStopRun)
Expand All @@ -559,20 +561,20 @@ public void RunRunner(bool doContinueRun = false)
//Run Bf
if (doContinueRun && bfIndx == startingBfIndx)//this is the BF to continue from
{
RunBusinessFlow(null,false,true);//Continue BF run
RunBusinessFlow(null, false, true);//Continue BF run
}
else
{
//Execute the Business Flow
RunBusinessFlow(executedBusFlow);// full BF run
}
//Do "During Execution" Run set Operations
if (PublishToALMConfig!=null)
if (PublishToALMConfig != null)
{
string result = string.Empty;
ObservableList<BusinessFlow> bfs = new ObservableList<BusinessFlow>();
bfs.Add(executedBusFlow);
RepositoryItemHelper.RepositoryItemFactory.ExportBusinessFlowsResultToALM(bfs, ref result, PublishToALMConfig, eALMConnectType.Silence);
RepositoryItemHelper.RepositoryItemFactory.ExportBusinessFlowsResultToALM(bfs, ref result, PublishToALMConfig, eALMConnectType.Silence);
}
//Call For Business Flow Control
flowControlIndx = DoBusinessFlowControl(executedBusFlow);
Expand All @@ -587,15 +589,15 @@ public void RunRunner(bool doContinueRun = false)

}
}
catch(Exception ec)
catch (Exception ec)
{

}
finally
{
//Post execution items to do
SetPendingBusinessFlowsSkippedStatus();

if (!runnerExecutionSkipped)
{
if (!mStopRun)//not on stop run
Expand All @@ -614,19 +616,61 @@ public void RunRunner(bool doContinueRun = false)

NotifyRunnerRunEnd(CurrentBusinessFlow.ExecutionFullLogFolder);

if(RunLevel == eRunLevel.Runner)
if (RunLevel == eRunLevel.Runner)
{
ExecutionLoggerManager.mExecutionLogger.EndRunSet();
RunLevel = eRunLevel.NA;
}
}
}
else
{
Status = RunsetStatus;
}
}
}

private void SetupVirtualAgents()
{
if (WorkSpace.Instance != null && WorkSpace.Instance.RunsetExecutor != null && WorkSpace.Instance.RunsetExecutor.RunSetConfig != null)
{

if (WorkSpace.Instance.RunsetExecutor.RunSetConfig.RunModeParallel)
{
RunSetConfig runSetConfig = WorkSpace.Instance.RunsetExecutor.RunSetConfig;
foreach (ApplicationAgent applicationAgent in this.ApplicationAgents)
{


if (applicationAgent.AgentName != null)
{
ObservableList<Agent> agents = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<Agent>();

var agent = (from a in agents where a.Name == applicationAgent.AgentName select a).FirstOrDefault();

//logic for if need to assign virtual agent
if (agent != null && agent.SupportVirtualAgent() && runSetConfig.ActiveAgentList.Where(y => y != null).Where(x => x.Guid == agent.Guid || (x.ParentGuid != null && x.ParentGuid == agent.Guid)).Count() > 0)
{

var virtualagent = agent.CreateCopy(true) as Agent;
virtualagent.ParentGuid = agent.Guid;
virtualagent.Name = agent.Name + " Virtual";
virtualagent.IsVirtual = true;
virtualagent.DriverClass = agent.DriverClass;
virtualagent.DriverType = agent.DriverType;
applicationAgent.Agent = virtualagent;
virtualagent.DriverConfiguration = agent.DriverConfiguration;


}

runSetConfig.ActiveAgentList.Add(applicationAgent.Agent);

}
}

}
}
}


//Calculate Next bfIndex for RunRunner Function
Expand Down Expand Up @@ -878,7 +922,7 @@ public void StopAgents()
}
AgentsRunning = false;
}

/*
public void StartAgents()
{
ObservableList<ApplicationAgent> ApplicationAgentsToStartLast = new ObservableList<ApplicationAgent>();
Expand Down Expand Up @@ -924,7 +968,7 @@ public void StartAgents()
}
AgentsRunning = true;
}

*/
public string GetAgentsNameToRun()
{
string agentsNames = string.Empty;
Expand Down
6 changes: 4 additions & 2 deletions Ginger/GingerCoreNET/Run/RunSetConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public string Name
}
}
}

public List<Agent> Agents = new List<Agent>();
/// <summary>
/// List of all the agents and the Virtual ones mapped during run
/// </summary>
public List<Agent> ActiveAgentList = new List<Agent>();
private bool mIsRunning;
public bool IsRunning
{
Expand Down
Loading

0 comments on commit ef9ed53

Please sign in to comment.