Exemplo n.º 1
0
        private bool PerformAttachGingerAgent()
        {
            string command      = string.Empty;
            string javaExecuter = string.Empty;

            try
            {
                if (WaitForAppWindowTitle() == false)
                {
                    Error = "Failed to find the Java application with title '" + mWaitForWindowTitle_Calc + "' after " + mWaitForWindowTitleMaxTime_Calc + " seconds.";
                    return(false);
                }

                //If Auto detect port then we get available port just before doing attach
                //So for parallel execution 2 runners won't get same Port
                ePortConfigType portConfigType = (ePortConfigType)GetInputParamValue <ePortConfigType>(Fields.PortConfigParam);
                if (portConfigType == ePortConfigType.AutoDetect)
                {
                    mPort_Calc = Fields.DynamicPortPlaceHolder;
                }

                //choosing executer
                javaExecuter = Path.Combine(mJavaWSEXEPath_Calc, "java.exe");

                //arrange java application command params
                string commandParams_OneLine = string.Empty;
                commandParams_OneLine += "\"" + "AgentJarPath=" + Path.Combine(mJavaAgentPath_Calc, "GingerAgent.jar") + "\"";
                commandParams_OneLine += " \"" + "PID=" + mProcessIDForAttach.ToString() + "\"";
                commandParams_OneLine += " \"" + "ShowGingerAgentConsole=" + ShowAgent.ToString() + "\"";
                commandParams_OneLine += " \"" + "Port=" + mPort_Calc + "\"";

                //command
                command = "-jar " + "\"" + Path.Combine(mJavaAgentPath_Calc, "GingerAgentStarter.jar") + "\" " + commandParams_OneLine;

                //run commnad
                ExecuteCommandAsync(new List <string> {
                    javaExecuter, command
                });

                if (String.IsNullOrEmpty(Error) != true)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Error = "Failed to attach the Ginger Agent with the command '" + javaExecuter + " " + command + "'";
                Reporter.ToLog(eLogLevel.ERROR, ex.StackTrace);
                return(false);
            }
        }
Exemplo n.º 2
0
        private void CalculatePortValue()
        {
            //Action created with old version do not have this parameter.
            //If running the action without opening the edit page, the param will be null
            //So we add the default value to param
            if(GetInputParamValue(Fields.PortConfigParam)==null)
            {
                AddOrUpdateInputParamValue(Fields.PortConfigParam, ePortConfigType.Manual.ToString());
            }

            ePortConfigType portConfigType = (ePortConfigType)GetInputParamValue<ePortConfigType>(Fields.PortConfigParam);
            if (portConfigType == ePortConfigType.Manual)
            {
                mPort_Calc = CalculateValue(mPort);
            }
            else
            {
                mPort_Calc= SocketHelper.GetOpenPort().ToString();
            }
        }
Exemplo n.º 3
0
        private void CalculatePortValue()
        {
            //Action created with old version do not have this parameter.
            //If running the action without opening the edit page, the param will be null
            //So we add the default value to param
            if (GetInputParamValue(Fields.PortConfigParam) == null)
            {
                AddOrUpdateInputParamValue(Fields.PortConfigParam, ePortConfigType.Manual.ToString());
            }

            ePortConfigType portConfigType = (ePortConfigType)GetInputParamValue <ePortConfigType>(Fields.PortConfigParam);

            if (portConfigType == ePortConfigType.Manual)
            {
                mPort_Calc = CalculateValue(mPort);
            }
            else
            {
                //If port calculation is auto detect then we initialize autoreset event for it
                mPortValueAutoResetEvent = new AutoResetEvent(false);
            }
        }
Exemplo n.º 4
0
        private bool ValidateArguments()
        {
            try
            {
                if (mLaunchJavaApplication == false && mLaunchWithAgent == false)
                {
                    Error = "No action to perform was selected.";
                    return(false);
                }

                if (Directory.Exists(mJavaWSEXEPath_Calc) == false || File.Exists(Path.Combine(mJavaWSEXEPath_Calc, "java.exe")) == false || File.Exists(Path.Combine(mJavaWSEXEPath_Calc, "javaws.exe")) == false)
                {
                    Error = "The Java path folder '" + mJavaWSEXEPath_Calc + "' is not valid, please select the Java Bin folder.";
                    return(false);
                }

                if (mLaunchJavaApplication == true)
                {
                    bool isValidURL = SetURLExtensionType(mURL_Calc);
                    if (!isValidURL)
                    {
                        Error = "The provided Java application path '" + mURL_Calc + "' is not valid, please select .Jar or .Jnlp file or .Exe file";
                        return(false);
                    }
                }

                if ((mLaunchJavaApplication == true && WaitForWindowWhenDoingLaunch == true) || mLaunchWithAgent == true)
                {
                    if (string.IsNullOrEmpty(mWaitForWindowTitle_Calc))
                    {
                        Error = "Missing valid Java application Window title to search for.";
                        return(false);
                    }

                    if (string.IsNullOrEmpty(mWaitForWindowTitleMaxTime_Calc) || int.TryParse(mWaitForWindowTitleMaxTime_Calc, out mWaitForWindowTitleMaxTime_Calc_int) == false)
                    {
                        Error = "Max waiting time for java application window is not valid.";
                        return(false);
                    }
                }

                if (mLaunchWithAgent == true)
                {
                    if (string.IsNullOrEmpty(mAttachAgentProcessSyncTime_Calc) || int.TryParse(mAttachAgentProcessSyncTime_Calc, out mAttachAgentProcessSyncTime_Calc_int) == false)
                    {
                        Error = "Process sync time for attach agent is not valid.";
                        return(false);
                    }

                    if (Directory.Exists(mJavaAgentPath_Calc) == false || File.Exists(Path.Combine(mJavaAgentPath_Calc, "GingerAgent.jar")) == false || File.Exists(Path.Combine(mJavaAgentPath_Calc, "GingerAgentStarter.jar")) == false)
                    {
                        Error = "The Ginger Agent path folder '" + mJavaAgentPath_Calc + "' is not valid, please select the folder which contains the 'GingerAgent.jar' &  'GingerAgentStarter.jar' files.";
                        return(false);
                    }

                    ePortConfigType portConfigType = (ePortConfigType)GetInputParamValue <ePortConfigType>(Fields.PortConfigParam);
                    if (portConfigType == ePortConfigType.Manual)
                    {
                        return(ValidatePort());
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Error = "Error occurred while validating the action arguments. Error=" + ex.Message;
                return(false);
            }
        }