private int HanldeGridOption(GridOptions gridOptions) { SetVerboseLevel(gridOptions.VerboseLevel); Reporter.ToLog(eLogLevel.INFO, "Starting Ginger Grid at port: " + gridOptions.Port); GingerGrid gingerGrid = new GingerGrid(gridOptions.Port); gingerGrid.Start(); if (gridOptions.Tracker) { ServiceGridTracker serviceGridTracker = new ServiceGridTracker(gingerGrid); } Console.WriteLine(); Console.WriteLine("---------------------------------------------------"); Console.WriteLine("- Press 'q' exit -"); Console.WriteLine("---------------------------------------------------"); if (!Console.IsInputRedirected && !WorkSpace.Instance.RunningFromUnitTest) // for example unit test redirect input, or we can run without input like from Jenkins { ConsoleKey consoleKey = ConsoleKey.A; while (consoleKey != ConsoleKey.Q) { ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(); consoleKey = consoleKeyInfo.Key; } } return(0); }
private static GingerNodeInfo GetGingerNode(string ServiceId) { // TODO: create round robin algorithm or something smarter // Menahwile we can the first ready node with least amount of actions so balance across same service GingerGrid gingerGrid = WorkSpace.Instance.LocalGingerGrid; Console.WriteLine("Number of Nodes found in GingerGrid:" + gingerGrid.NodeList.Count); foreach (GingerNodeInfo gingerNodeInfo in gingerGrid.NodeList) { Console.WriteLine("Name:" + gingerNodeInfo.Name); Console.WriteLine("ServiceId:" + gingerNodeInfo.ServiceId); Console.WriteLine("Status:" + gingerNodeInfo.Status); Console.WriteLine("Host:" + gingerNodeInfo.Host); Console.WriteLine("IP:" + gingerNodeInfo.IP); } Console.WriteLine("Searching for ServiceID=" + ServiceId); GingerNodeInfo GNI = (from x in gingerGrid.NodeList where x.ServiceId == ServiceId && x.Status == GingerNodeInfo.eStatus.Ready orderby x.ActionCount select x).FirstOrDefault(); if (GNI is null) { Console.WriteLine("GNI is null"); } return(GNI); }
public static void ClassInitialize(TestContext TestContext) { // We start a Ginger grid int HubPort = SocketHelper.GetOpenPort(); GG = new GingerGrid(HubPort); GG.Start(); // Add 2 Ginger Nodes with Dummy Driver DummyDriver DummyDriver1 = new DummyDriver(); Task.Factory.StartNew(() => { GingerNodeStarter gingerNodeStarter = new GingerNodeStarter(); gingerNodeStarter.StartNode("N1", new DummyDriver(), SocketHelper.GetLocalHostIP(), HubPort); gingerNodeStarter.StartNode("N2", new DummyDriver(), SocketHelper.GetLocalHostIP(), HubPort); gingerNodeStarter.Listen(); }); Stopwatch stopwatch = Stopwatch.StartNew(); while (GG.NodeList.Count < 2 && stopwatch.ElapsedMilliseconds < 5000) // max 5 seconds { Thread.Sleep(50); } }
public static void ClassInitialize(TestContext TestContext) { // We start a Ginger grid int HubPort = SocketHelper.GetOpenPort(); GG = new GingerGrid(HubPort); GG.Start(); // Add 2 Ginger Nodes with Dummy Driver // TODO: check how to externalize // make it NodeInfo and drivers capabilities DummyDriver DummyDriver1 = new DummyDriver(); //DriverCapabilities DC = new DriverCapabilities(); //DC.OS = "Windows"; //TODO: use const //DC.Platform = "Web"; //TODO: use const //GingerNode GN = new GingerNode(DC, DummyDriver1); //GN.StartGingerNode("N1", HubIP: SocketHelper.GetLocalHostIP(), HubPort: HubPort); GingerNodeStarter gingerNodeStarter = new GingerNodeStarter(); gingerNodeStarter.StartNode("N1", new DummyDriver()); gingerNodeStarter.StartNode("N2", new DummyDriver()); // DummyDriver DummyDriver2 = new DummyDriver(); //DriverCapabilities DC2 = new DriverCapabilities(); //DC2.OS = "Mac"; //DC2.Platform = "Java"; //GingerNode GingerNode2 = new GingerNode(DC2, DummyDriver2); //GingerNode2.StartGingerNode("N2", HubIP: SocketHelper.GetLocalHostIP(), HubPort: HubPort); }
public static void ClassInitialize(TestContext TestContext) { mTestHelper.ClassInitialize(TestContext); // Create temp solution SolutionRepository solutionRepository; string path = Path.Combine(TestResources.GetTestTempFolder(@"Solutions" + Path.DirectorySeparatorChar + "AgentTestSolution")); if (Directory.Exists(path)) { Directory.Delete(path, true); } solutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository(); solutionRepository.CreateRepository(path); WorkSpace.Instance.SolutionRepository = solutionRepository; // add Example4 Plugin to solution string pluginPath = Path.Combine(TestResources.GetTestResourcesFolder(@"Plugins" + Path.DirectorySeparatorChar + "PluginDriverExample4")); WorkSpace.Instance.PlugInsManager.Init(solutionRepository); WorkSpace.Instance.PlugInsManager.AddPluginPackage(pluginPath); mGingerGrid = WorkSpace.Instance.LocalGingerGrid; }
public void Execute(string PluginId, string ServiceId, NewPayLoad payLoad) { GingerGrid gingerGrid = WorkSpace.Instance.LocalGingerGrid; // string PID = GA.InputParams["PluginID"].GetValueAsString(); PluginPackage p = (from x in mPluginPackages where x.PluginID == PluginId select x).SingleOrDefault(); if (p == null) { throw new Exception("Plugin id not found: " + PluginId); // GA.AddError("Execute", "Plugin id not found: " + PID); // return; } //TODO: use nameof after ActPlugin move to common // string serviceID = GA.InputParams["PluginActionID"].GetValueAsString(); GingerNodeInfo GNI = (from x in gingerGrid.NodeList where x.Name == p.PluginID select x).FirstOrDefault(); //run script only if service is not up if (GNI == null) { string script = CommandProcessor.CreateLoadPluginScript(p.Folder); // hard coded!!!!!!!!!! - use ServiceId script += CommandProcessor.CreateStartServiceScript("PACTService", p.PluginID, SocketHelper.GetLocalHostIP(), gingerGrid.Port); // script += CommandProcessor.CreateStartServiceScript("ExcelService", p.PluginID, SocketHelper.GetLocalHostIP(), gingerGrid.Port); Task t = new Task(() => { // GingerConsoleHelper.Execute(script); // keep it for regular service dll load string StarterDLL = Path.Combine(p.Folder, "GingerPACTPluginConsole.dll"); StartService(StarterDLL); }); t.Start(); } int counter = 0; while (GNI == null && counter < 30) { Thread.Sleep(1000); GNI = (from x in gingerGrid.NodeList where x.Name == "PACT" select x).FirstOrDefault(); counter++; } if (GNI == null) { // GA.AddError("Execute", "Cannot execute action beacuse Service was not found or was not abale to start: " + p.PluginID); } GingerNodeProxy GNA = new GingerNodeProxy(GNI); GNA.Reserve(); GNA.GingerGrid = gingerGrid; //GNA.RunAction(GA); }
public GingerGridPage(GingerGrid GingerGrid) { InitializeComponent(); mGingerGrid = GingerGrid; StatusLabel.BindControl(GingerGrid, nameof(GingerGrid.Status)); mGingerGrid.NodeList.CollectionChanged += NodeList_CollectionChanged; ShowNodes(); }
void StartGrid() { Console.WriteLine("Starting Ginger Grid Hub"); mGingerGrid = new GingerGrid(SocketHelper.GetOpenPort()); mGingerGrid.Start(); Console.WriteLine("Ginger Grid started - " + mGingerGrid.Status); Console.WriteLine("Port: " + mGingerGrid.Port); }
public static void ClassInitialize(TestContext TestContext) { // We start a Ginger grid int HubPort = SocketHelper.GetOpenPort(); mGingerGrid = new GingerGrid(HubPort); mGingerGrid.Start(); }
public GingerGridPage(GingerGrid GingerGrid) { InitializeComponent(); mGingerGrid = GingerGrid; StatusLabel.BindControl(GingerGrid, nameof(GingerGrid.Status)); mGingerGrid.NodeList.CollectionChanged += NodeList_CollectionChanged; ShowNodes(); WorkSpace.Instance.PlugInsManager.PluginProcesses.CollectionChanged += PluginProcesses_CollectionChanged; ShowProcesses(); }
Agent prep() { mGingerGrid = WorkSpace.Instance.LocalGingerGrid; // Start one DummyDriver - in process, so we can test whats going on everywhere mDummyDriver = new DummyDriver(); GingerNode gingerNode = new GingerNode(mDummyDriver); gingerNode.StartGingerNode("N1", HubIP: SocketHelper.GetLocalHostIP(), HubPort: mGingerGrid.Port); // Wait for the Grid to be up and the node connected // max 30 seconds Stopwatch st = Stopwatch.StartNew(); while (!gingerNode.Connected && st.ElapsedMilliseconds < 30000) { Thread.Sleep(100); } if (!gingerNode.Connected) { throw new Exception(">>>>>>>>>>>>>>>> GingerNode didn't connect to grid <<<<<<<<<<<<<<<<<<<<< " + mPluginId + "." + mServiceId); } st.Restart(); while (mGingerGrid.NodeList.Count == 0 && st.ElapsedMilliseconds < 30000) { Thread.Sleep(100); } if (mGingerGrid.NodeList.Count == 0) { throw new Exception(">>>>>>>>>>>>>>>> NodeList count =0, no node connected <<<<<<<<<<<<<<<<<<<<< " + mPluginId + "." + mServiceId); } WorkSpace.Instance.PlugInsManager.PluginServiceIsSeesionDictionary.Add(mPluginId + "." + mServiceId, true); //TODO: handle no GG node found Agent agent = new Agent(); agent.Name = "agent 1"; agent.AgentType = Agent.eAgentType.Service; agent.PluginId = mPluginId; agent.ServiceId = mServiceId; mGingerRunner = new GingerRunner(); mGingerRunner.ApplicationAgents.Add(new ApplicationAgent() { AppName = cWebApp, Agent = agent }); return(agent); }
private void InitLocalGrid() { try { mLocalGingerGrid = new GingerGrid(); mLocalGingerGrid.Start(); } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, "Failed to start Ginger Grid", e); } }
public void Execute(GingerAction GA) { GingerGrid gingerGrid = WorkSpace.Instance.LocalGingerGrid; string PID = GA.InputParams["PluginID"].GetValueAsString(); PluginPackage p = (from x in mPluginPackages where x.PluginID == PID select x).SingleOrDefault(); if (p == null) { GA.AddError("Execute", "Plugin id not found: " + PID); return; } //TODO: use nameof after ActPlugin move to common string serviceID = GA.InputParams["PluginActionID"].GetValueAsString(); GingerNodeInfo GNI = (from x in gingerGrid.NodeList where x.Name == p.PluginID select x).FirstOrDefault(); //run script only if service is not up if (GNI == null) { string script = CommandProcessor.CreateLoadPluginScript(p.Folder); // hard coded!!!!!!!!!! script += CommandProcessor.CreateStartServiceScript("ExcelService", p.PluginID, SocketHelper.GetLocalHostIP(), gingerGrid.Port); Task t = new Task(() => { GingerConsoleHelper.Execute(script); }); t.Start(); } int counter = 0; while (GNI == null && counter < 30) { Thread.Sleep(1000); GNI = (from x in gingerGrid.NodeList where x.Name == p.PluginID select x).FirstOrDefault(); counter++; } GingerNodeProxy GNA = new GingerNodeProxy(GNI); GNA.Reserve(); GNA.GingerGrid = gingerGrid; GNA.RunAction(GA); }
public static void ClassInitialize(TestContext TestContext) { mTestHelper.ClassInitialize(TestContext); mTestHelper.Log("Creating temp solution"); // Init workspace string solutionFolder = TestResources.GetTempFolder("WebPlatformPluginTest"); WorkspaceHelper.CreateWorkspaceWithTempSolution(solutionFolder); // To debug SeleniumPlugin start the plugin from VS to register to LocalGrid string pluginFolder = TestResources.GetTestResourcesFolder("Plugins" + Path.DirectorySeparatorChar + "SeleniumPlugin"); WorkSpace.Instance.PlugInsManager.Init(WorkSpace.Instance.SolutionRepository); mTestHelper.Log("Adding SeleniumPlugin from: " + pluginFolder); WorkSpace.Instance.PlugInsManager.AddPluginPackage(pluginFolder); // Start Agent agent = new Agent(); agent.AgentType = Agent.eAgentType.Service; agent.PluginId = "SeleniumPlugin"; agent.ServiceId = "SeleniumChromeService"; mTestHelper.Log("StartDriver SeleniumPlugin SeleniumChromeService"); agent.AgentOperations.StartDriver(); GingerGrid GG = WorkSpace.Instance.LocalGingerGrid; Stopwatch stopwatch = Stopwatch.StartNew(); mTestHelper.Log("Waiting for node to connect"); while (GG.NodeList.Count == 0 && stopwatch.ElapsedMilliseconds < 10000) // wait max 10 seconds { mTestHelper.Log("GG.NodeList.Count == 0"); Thread.Sleep(100); } if (GG.NodeList.Count == 0) { throw new Exception("GG.NodeList.Count == 0"); } mTestHelper.Log("Done Waiting"); }
public static void ClassInitialize(TestContext TestContext) { // We start a Ginger grid on open port int GingerHubPort = SocketHelper.GetOpenPort(); GG = new GingerGrid(GingerHubPort); GG.Start(); // Add 2 Ginger Nodes with Dummy Driver DummyDriver DummyDriver1 = new DummyDriver(); GingerNode GN = new GingerNode(DummyDriver1); GN.StartGingerNode("N1", HubIP: SocketHelper.GetLocalHostIP(), HubPort: GingerHubPort); DummyDriver DummyDriver2 = new DummyDriver(); GingerNode GingerNode2 = new GingerNode(DummyDriver2); GingerNode2.StartGingerNode("N2", HubIP: SocketHelper.GetLocalHostIP(), HubPort: GingerHubPort); }
private void HandleArg(string param, string value) { // TODO: get all classes impl ICLI and check Identifier then set switch (param) { case "--version": Console.WriteLine(string.Format("{0} Version: {1}", ApplicationInfo.ApplicationName, ApplicationInfo.ApplicationVersionWithInfo)); break; case "--help": case "-h": ShowCLIHelp(); break; case "ConfigFile": case "--configfile": mCLIHelper.CLIType = eCLIType.Config; Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with ConfigFile= '{0}'", value)); mCLIHandler = new CLIConfigFile(); PerformLoadAndExecution(ReadFile(value)); break; case "Script": case "--scriptfile": mCLIHelper.CLIType = eCLIType.Script; Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with ScriptFile= '{0}'", value)); mCLIHandler = new CLIScriptFile(); PerformLoadAndExecution(ReadFile(value)); break; case "--dynamicfile": case "Dynamic": mCLIHelper.CLIType = eCLIType.Dynamic; Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with DynamicXML= '{0}'", value)); mCLIHandler = new CLIDynamicXML(); PerformLoadAndExecution(ReadFile(value)); break; case "--args": mCLIHelper.CLIType = eCLIType.Arguments; Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with Command Args= '{0}'", value)); mCLIHandler = new CLIArgs(); PerformLoadAndExecution(value); break; case "--excel": Reporter.ToLog(eLogLevel.DEBUG, string.Format("Running with CLI Excel= '{0}'", value)); mCLIHandler = new CLIExcel(); PerformLoadAndExecution(value); break; case "--servicegrid": int port = 15555; Console.WriteLine("Starting Ginger Grid at port: " + port); GingerGrid gingerGrid = new GingerGrid(15555); // TODO: get port from CLI arg gingerGrid.Start(); ServiceGridTracker serviceGridTracker = new ServiceGridTracker(gingerGrid); Console.ReadKey(); break; } }
public static void ClassInit(TestContext context) { Reporter.WorkSpaceReporter = new UnitTestWorkspaceReporter(); int port = SocketHelper.GetOpenPort(); // gingerGrid = WorkSpace.Instance.LocalGingerGrid; // new GingerGrid(port); gingerGrid = new GingerGrid(port); gingerGrid.Start(); // WorkSpace.Instance.LocalGingerGrid = gingerGrid; webPlatform = new WebPlatformServiceFake(); gingerNode = new GingerNode(webPlatform); gingerNode.StartGingerNode("WebPlatformServiceFake 1", SocketHelper.GetLocalHostIP(), port); // Wait for node to be connected. gingerNodeProxy = new GingerNodeProxy(gingerGrid.NodeList[0]); gingerNodeProxy.GingerGrid = gingerGrid; // GingerRunner gingerRunner = new GingerRunner(); agent = new Agent(); agent.GingerNodeProxy = gingerNodeProxy; agent.Platform = GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib.ePlatformType.Service; // agent.PluginId = "aa"; agent.ServiceId = "WebPlatformServiceFake"; agent.AgentType = Agent.eAgentType.Service; agent.DriverConfiguration = new Amdocs.Ginger.Common.ObservableList <DriverConfigParam>(); //agent.st // agent.StartDriver(); gingerNodeProxy.StartDriver(agent.DriverConfiguration); mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Java Driver"; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "TestApp" }); Activity activity = new Activity(); activity.TargetApplication = "JavaTestApp"; mBF.Activities.Add(activity); mBF.CurrentActivity = activity; mGR.CurrentBusinessFlow = mBF; ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "JavaTestApp"; AA.Agent = agent; mGR.ApplicationAgents.Add(AA); mGR.SetCurrentActivityAgent(); }
private void InitLocalGrid() { mLocalGingerGrid = new GingerGrid(); mLocalGingerGrid.Start(); }