예제 #1
0
        private void Configure()
        {
            var properties = new JavaProperties(Properties);

            properties.Save(PropertiesFileName);
            Log.Info("Hercules process configured with properties:\n{properties}", properties);
        }
예제 #2
0
        public override void DocumentChanged()
        {
            // Clear the list.
            this.listView1.Items.Clear();

            if (manager.Opened)
            {
                //	Update main form heading.
                this.Text = Application.ProductName + " - " + manager.Document.Name;
                JavaProperties properties = ((JavaPropertiesDocument)manager.Document).Properties;

                //	Update the content window.
                foreach (String key in properties.Keys)
                {
                    ListViewItem item = new ListViewItem(key);
                    String       text = properties.GetProperty(key);
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, text));

                    this.listView1.Items.Add(item);
                }
            }
            else
            {
                //	Update main form heading.
                this.Text = Application.ProductName;
            }

            //	Force a display update.
            this.Refresh();
        }
        public void ReadPropertyFile_Test()
        {
            var file =
                "#Fri Jan 17 22:37:45 MYT 2014\r\n" +
                "! Comment\r\n" +
                "# Comment\r\n" +
                "!Comment\r\n" +
                "dbpassword=password\n" +
                "dbpassword2=he\\tjki\n" +
                "database=localhost\\u0394\n" +
                "Hong\\ Kong = Near China\n" +
                "a-key = a-value \\u2640 people\n" +
                "b\\u2126key : a-value\n" +
                "c-key=a-value\r\n" +
                "d-key a-value\r\n" +
                "a-longer-key-example = a really long value that is \\\r\n" +
                "    split over two lines.\r" +
                "dbuser=mkyong\r\n";

            var properties = JavaProperties.Read(file);

            Assert.AreEqual(10, properties.Count);
            Assert.AreEqual("password", properties["dbpassword"].Value);
            Assert.AreEqual("localhostΔ", properties["database"].Value);
            Assert.AreEqual("Hong Kong", properties["Hong Kong"].Key);
            Assert.AreEqual("bΩkey", properties["bΩkey"].Key);
            Assert.AreEqual("a really long value that is  split over two lines.", properties["a-longer-key-example"].Value);
        }
예제 #4
0
 public ExternalToolProperties(string filePath)
 {
     using (var fileStream = new FileStream(filePath, FileMode.Open))
     {
         _properties = new JavaProperties(PropertiesConstants.DEFAULTS);
         _properties.Load(fileStream);
     }
 }
예제 #5
0
 public T Deserialize <T>(Stream stream)
 {
     try {
         JavaProperties props = new JavaProperties();
         props.Load(stream);
         return((T)DeserializeFields(emptyPrefix, props, typeof(T)));
     } catch (IOException e) {
         throw new TeseReadException(e);
     }
 }
예제 #6
0
 public void Serialize(object obj, Stream writer)
 {
     try {
         JavaProperties props = new JavaProperties();
         SerializeFields(emptyPrefix, obj, props);
         props.Store(writer, null);
     } catch (IOException e) {
         throw new TeseWriteException(e);
     }
 }
 public void TestJavaPropertiesSaveAndLoad()
 {
     JavaProperties props = new JavaProperties();
     JavaProperties props1 = new JavaProperties();
     props.Add("a=", "b=\"''");
     props.Store("c:\\tempPropFileCsharp.txt", "comment1");
     props1.Load("c:\\tempPropFileCsharp.txt");
     File.Delete("c:\\tempPropFileCsharp.txt");
     Assert.AreEqual(props1["a="], props["a="]);
 }
예제 #8
0
        public void TestJavaPropertiesSaveAndLoad()
        {
            JavaProperties props  = new JavaProperties();
            JavaProperties props1 = new JavaProperties();

            props.Add("a=", "b=\"''");
            props.Store("c:\\tempPropFileCsharp.txt", "comment1");
            props1.Load("c:\\tempPropFileCsharp.txt");
            File.Delete("c:\\tempPropFileCsharp.txt");
            Assert.AreEqual(props1["a="], props["a="]);
        }
예제 #9
0
        public void saveSettings()
        {
            FileStream     stream   = new FileStream(pathSettings, FileMode.Create);
            JavaProperties settings = new JavaProperties();

            settings.SetProperty("pathSongs", pathSongs);
            settings.SetProperty("pathReplays", pathReplays);
            settings.SetProperty("pathOsuDB", pathOsuDB);
            JavaPropertyWriter writer = new JavaPropertyWriter(settings);

            writer.Write(stream, "osuReplayAnalyzer settings");
            stream.Close();
        }
        public void WritePropertyFile_Test()
        {
            var file = new JavaProperties();

            file.Add(new PropertyLine("dbpassword", "password"));
            file.Add(new PropertyLine("database", "localhost ♣ st"));
            file.Add(new PropertyLine("King Kong", "a really long value ioio"));

            var properties = JavaProperties.Read(file.ToString());

            Assert.AreEqual("password", properties["dbpassword"].Value);
            Assert.AreEqual("localhost ♣ st", properties["database"].Value);
            Assert.AreEqual("King Kong", properties["King Kong"].Key);
            Assert.AreEqual("a really long value ioio", properties["King Kong"].Value);
        }
        public void TestQcTestRunFromAPIRunner()
        {
            string file1 = "c:\\stam1.ini";
            JavaProperties props = new JavaProperties();
            props["TestSet1"] = "Aaron\\Amit";
            props["almServer"] = "http://vmsoa22:8080/qcbin";
            props["almUser"] = "******";
            props["almPassword"] = "";
            props["almDomain"] = "Default";
            props["almProject"] = "Aaron";
            props["almRunMode"] = "RUN_LOCAL";
            props["almTimeout"] = "-1";
            props["almRunHost"] = "";
            props.Save(file1, "");
            Launcher runner = new Launcher("false", file1, TestStorageType.Alm);

            runner.Run();
        }
예제 #12
0
        public void TestQcTestRunFromAPIRunner()
        {
            string         file1 = "c:\\stam1.ini";
            JavaProperties props = new JavaProperties();

            props["TestSet1"]    = "Aaron\\Amit";
            props["almServer"]   = "http://vmsoa22:8080/qcbin";
            props["almUser"]     = "******";
            props["almPassword"] = "";
            props["almDomain"]   = "Default";
            props["almProject"]  = "Aaron";
            props["almRunMode"]  = "RUN_LOCAL";
            props["almTimeout"]  = "-1";
            props["almRunHost"]  = "";
            props.Save(file1, "");
            Launcher runner = new Launcher("false", file1, TestStorageType.Alm);

            runner.Run();
        }
        public void PropertiesWriter_WorkdirPerModuleExplicitlySet()
        {
            // Tests that .sonar.working.directory is explicityl set per module

            // Arrange
            string projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten");
            string productProject = CreateEmptyFile(projectBaseDir, "MyProduct.csproj");

            string        productFile  = CreateEmptyFile(projectBaseDir, "File.cs");
            List <string> productFiles = new List <string>
            {
                productFile
            };
            string productFileListFilePath = Path.Combine(projectBaseDir, "productManagedFiles.txt");

            string      projectKey = "7B3B7244-5031-4D74-9BBD-3316E6B5E7D5";
            ProjectInfo product    = CreateProjectInfo("AnalysisSettingsTest.proj", projectKey, productProject, false, productFiles, productFileListFilePath, null, "language", "UTF-8");

            List <ProjectInfo> projects = new List <ProjectInfo>
            {
                product
            };

            AnalysisConfig config = new AnalysisConfig()
            {
                SonarOutputDir = @"C:\my_folder"
            };

            // Act
            PropertiesWriter writer = new PropertiesWriter(config);

            writer.WriteSettingsForProject(product, new string[] { productFile }, null);
            writer.WriteSonarProjectInfo("dummy basedir", new List <string>());
            string s = writer.Flush();

            var props = new JavaProperties();

            props.Load(GenerateStreamFromString(s));
            string key = projectKey + "." + SonarProperties.WorkingDirectory;

            Assert.IsTrue(props.ContainsKey(key));
        }
        public void PropertiesWriter_WorkdirPerModuleExplicitlySet()
        {
            // Tests that .sonar.working.directory is explicitly set per module

            // Arrange
            var projectBaseDir = TestUtils.CreateTestSpecificFolder(TestContext, "PropertiesWriterTest_AnalysisSettingsWritten");
            var productProject = CreateEmptyFile(projectBaseDir, "MyProduct.csproj");

            var productFile  = CreateEmptyFile(projectBaseDir, "File.cs");
            var productFiles = new List <FileInfo>
            {
                productFile
            };
            var productFileListFilePath = Path.Combine(projectBaseDir, "productManagedFiles.txt");

            var projectKey = "7B3B7244-5031-4D74-9BBD-3316E6B5E7D5";
            var product    = new ProjectData(CreateProjectInfo("AnalysisSettingsTest.proj", projectKey, productProject, false, productFiles, productFileListFilePath, null, "language", "UTF-8"));

            product.ReferencedFiles.Add(productFile);

            var config = new AnalysisConfig()
            {
                SonarOutputDir = @"C:\my_folder"
            };

            // Act
            var writer = new PropertiesWriter(config, new TestLogger());

            writer.WriteSettingsForProject(product);
            writer.WriteSonarProjectInfo(new DirectoryInfo("dummy basedir"));
            var s = writer.Flush();

            var props = new JavaProperties();

            props.Load(GenerateStreamFromString(s));
            var key = projectKey + "." + SonarProperties.WorkingDirectory;

#pragma warning disable DictionaryShouldContainKey // Simplify Assertion
            props.ContainsKey(key).Should().BeTrue();
#pragma warning restore DictionaryShouldContainKey // Simplify Assertion
        }
예제 #15
0
        public void LoadSettings()
        {
            FileStream stream = new FileStream(pathSettings, FileMode.Open);

            try
            {
                JavaProperties settings = new JavaProperties();
                settings.Load(stream);
                pathSongs   = settings.GetProperty("pathSongs");
                pathReplays = settings.GetProperty("pathReplays");
                pathOsuDB   = settings.GetProperty("pathOsuDB");
                Console.WriteLine(pathOsuDB);
                osuDbP = new OsuDbAPI.OsuDbFile(pathOsuDB);
            }
            catch (Exception exp)
            {
                Console.WriteLine("Error parsing settings:\n" + exp.ToString());
            }
            finally
            {
                stream.Close();
            }
        }
예제 #16
0
        public PropertiesFileConfigurationSource(PropertiesFileConfigurationSourceConfig config)
            : base(config)
        {
            _properties = new JavaProperties();

            try
            {
                using (Stream @is = new FileStream(config.FileName, FileMode.Open))
                {
                    if (@is == null)
                    {
                        Logger.Warn("file not found: {0}", config.FileName);
                        return;
                    }

                    _properties.Load(@is, new UTF8Encoding(false));
                }
            }
            catch (Exception e)
            {
                Logger.Warn(e, "failed to load properties file: " + config.FileName);
            }
        }
        /// <summary>
        /// creates the correct runner according to the given type
        /// </summary>
        /// <param name="runType"></param>
        /// <param name="ciParams"></param>
        IAssetRunner CreateRunner(TestStorageType runType, JavaProperties ciParams)
        {
            IAssetRunner runner = null;
            switch (runType)
            {
                case TestStorageType.Alm:
                    //check that all required parameters exist
                    foreach (string param1 in requiredParamsForQcRun)
                    {
                        if (!_ciParams.ContainsKey(param1))
                        {
                            ConsoleWriter.WriteLine(string.Format(Resources.LauncherParamRequired, param1));
                            return null;
                        }
                    }

                    //parse params that need parsing
                    double dblQcTimeout = int.MaxValue;
                    if (!double.TryParse(_ciParams["almTimeout"], out dblQcTimeout))
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherTimeoutNotNumeric);
                        dblQcTimeout = int.MaxValue;
                    }

                    ConsoleWriter.WriteLine(string.Format(Resources.LuancherDisplayTimout, dblQcTimeout));

                    QcRunMode enmQcRunMode = QcRunMode.RUN_LOCAL;
                    if (!Enum.TryParse<QcRunMode>(_ciParams["almRunMode"], true, out enmQcRunMode))
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherIncorrectRunmode);
                        enmQcRunMode = QcRunMode.RUN_LOCAL;
                    }
                    ConsoleWriter.WriteLine(string.Format(Resources.LauncherDisplayRunmode, enmQcRunMode.ToString()));

                    //go over testsets in the parameters, and collect them
                    List<string> sets = GetParamsWithPrefix("TestSet");

                    if (sets.Count == 0)
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherNoTests);
                        return null;
                    }

                    //create an Alm runner
                    runner = new AlmTestSetsRunner(_ciParams["almServerUrl"],
                                     _ciParams["almUserName"],
                                     Decrypt(_ciParams["almPassword"], secretkey),
                                     _ciParams["almDomain"],
                                     _ciParams["almProject"],
                                     dblQcTimeout,
                                     enmQcRunMode,
                                     _ciParams["almRunHost"],
                                     sets);
                    break;
                case TestStorageType.FileSystem:

                    //get the tests
                    IEnumerable<string> tests = GetParamsWithPrefix("Test");

                    IEnumerable<string> jenkinsEnvVariablesWithCommas = GetParamsWithPrefix("JenkinsEnv");
                    Dictionary<string, string> jenkinsEnvVariables = new Dictionary<string,string>();
                    foreach (string var in jenkinsEnvVariablesWithCommas)
                    { 
                        string[] nameVal = var.Split(",;".ToCharArray());
                        jenkinsEnvVariables.Add(nameVal[0], nameVal[1]);
                    }
                    //parse the timeout into a TimeSpan
                    TimeSpan timeout = TimeSpan.MaxValue;
                    if (_ciParams.ContainsKey("fsTimeout"))
                    {
                        string strTimoutInSeconds = _ciParams["fsTimeout"];
                        if (strTimoutInSeconds.Trim() != "-1")
                        {
                            int intTimoutInSeconds = 0;
                            int.TryParse(strTimoutInSeconds, out intTimoutInSeconds);
                            timeout = TimeSpan.FromSeconds(intTimoutInSeconds);
                        }
                    }
                    ConsoleWriter.WriteLine("Launcher timeout is " + timeout.ToString(@"dd\:\:hh\:mm\:ss"));

                    //LR specific values:
                    //default values are set by JAVA code, in com.hp.application.automation.tools.model.RunFromFileSystemModel.java

                    int pollingInterval = 30;
                    if (_ciParams.ContainsKey("controllerPollingInterval"))
                        pollingInterval = int.Parse(_ciParams["controllerPollingInterval"]);

                    TimeSpan perScenarioTimeOutMinutes = TimeSpan.MaxValue;
                    if (_ciParams.ContainsKey("PerScenarioTimeOut"))
                    {
                        string strTimoutInMinutes = _ciParams["PerScenarioTimeOut"];
                        ConsoleWriter.WriteLine("reading PerScenarioTimeout: "+strTimoutInMinutes);
                        if (strTimoutInMinutes.Trim() != "-1")
                        {
                            int intTimoutInMinutes = 0;
                            if (int.TryParse(strTimoutInMinutes, out intTimoutInMinutes))
                                perScenarioTimeOutMinutes = TimeSpan.FromMinutes(intTimoutInMinutes);
                            ConsoleWriter.WriteLine("PerScenarioTimeout: "+perScenarioTimeOutMinutes+" minutes");
                        }
                    }
                    ConsoleWriter.WriteLine("PerScenarioTimeout: " + perScenarioTimeOutMinutes.ToString(@"dd\:\:hh\:mm\:ss") + " minutes");

                    char[] delim = { '\n' };
                    List<string> ignoreErrorStrings = new List<string>();
                    if (_ciParams.ContainsKey("ignoreErrorStrings"))
                    {
                        ignoreErrorStrings.AddRange(_ciParams["ignoreErrorStrings"].Split(delim, StringSplitOptions.RemoveEmptyEntries));
                    }

                    
                    if (tests == null || tests.Count() == 0)
                    {
                        WriteToConsole(Resources.LauncherNoTestsFound);
                    }

                    List<string> validTests = Helper.ValidateFiles(tests);

                    if (tests != null && tests.Count() > 0 && validTests.Count == 0)
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherNoValidTests);
                        return null;
                    }

                    runner = new FileSystemTestsRunner(validTests, timeout, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables);

                    break;

                default:
                    runner = null;
                    break;
            }
            return runner;
        }
예제 #18
0
 public ExternalToolProperties(FileStream fileStream)
 {
     _properties = new JavaProperties(PropertiesConstants.DEFAULTS);
     _properties.Load(fileStream);
 }
        static void Main(string[] args)
        {
            try
            {
                if (args == null || args.Length == 0)
                {
                    Console.Out.WriteLine("Usage: HpToolsAborter paramfile");
                    return;
                }

                if (!File.Exists(args[0]))
                {
                    Console.Out.WriteLine("File {0} is missing", args[0]);
                    return;
                }

                string paramfile;

                using (FileStream fs = File.Open(args[0], FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        paramfile = sr.ReadToEnd();
                    }
                }

                Console.Out.WriteLine("============================================================================");
                Console.Out.WriteLine("Aborting testing tool related processes");

                JavaProperties _ciParams = new JavaProperties();

                _ciParams.Load(args[0]);
                string timeout = _ciParams["timeout"];

                if (!string.IsNullOrEmpty(timeout))
                {
                    int timeoutInSeconds = Int32.Parse(timeout);
                    System.Threading.Thread.Sleep(timeoutInSeconds * 1000);
                }

                string runType = _ciParams["runType"];

                if (string.IsNullOrEmpty(runType))
                {
                    Console.Out.WriteLine("Unable to find runType in " + args[0]);
                    return;
                }

                if (runType == "FileSystem")
                {
                    KillQtpAutomationProcess();
                    KillLoadRunnerAutomationProcess();
                }

                if (runType == "Alm")
                {
                    string almRunMode = _ciParams["almRunMode"];
                    if (almRunMode == "RUN_LOCAL")
                    {
                        KillQtpAutomationFromAlm();
                        KillServiceTestFromAlm();
                    }
                    else if (almRunMode == "RUN_REMOTE")
                    {
                        Console.Out.WriteLine(string.Format("Stopping a test in a remote machine is not supported. Test in {0} should be stopped manually", _ciParams["almRunHost"]));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(string.Format("Error in HpToolsAborter: {0} ", ex.Message));
            }
        }
        /// <summary>
        /// creates the correct runner according to the given type
        /// </summary>
        /// <param name="runType"></param>
        /// <param name="ciParams"></param>
        IAssetRunner CreateRunner(TestStorageType runType, JavaProperties ciParams)
        {
            IAssetRunner runner = null;
            switch (runType)
            {
                case TestStorageType.Alm:
                    //check that all required parameters exist
                    foreach (string param1 in requiredParamsForQcRun)
                    {
                        if (!_ciParams.ContainsKey(param1))
                        {
                            ConsoleWriter.WriteLine(string.Format(Resources.LauncherParamRequired, param1));
                            return null;
                        }
                    }

                    //parse params that need parsing
                    double dblQcTimeout = int.MaxValue;
                    if (!double.TryParse(_ciParams["almTimeout"], out dblQcTimeout))
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherTimeoutNotNumeric);
                        dblQcTimeout = int.MaxValue;
                    }

                    ConsoleWriter.WriteLine(string.Format(Resources.LuancherDisplayTimout, dblQcTimeout));

                    QcRunMode enmQcRunMode = QcRunMode.RUN_LOCAL;
                    if (!Enum.TryParse<QcRunMode>(_ciParams["almRunMode"], true, out enmQcRunMode))
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherIncorrectRunmode);
                        enmQcRunMode = QcRunMode.RUN_LOCAL;
                    }
                    ConsoleWriter.WriteLine(string.Format(Resources.LauncherDisplayRunmode, enmQcRunMode.ToString()));

                    //go over testsets in the parameters, and collect them
                    List<string> sets = GetParamsWithPrefix("TestSet");

                    if (sets.Count == 0)
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherNoTests);
                        return null;
                    }

                    //create an Alm runner
                    runner = new AlmTestSetsRunner(_ciParams["almServerUrl"],
                                     _ciParams["almUserName"],
                                     Decrypt(_ciParams["almPassword"], secretkey),
                                     _ciParams["almDomain"],
                                     _ciParams["almProject"],
                                     dblQcTimeout,
                                     enmQcRunMode,
                                     _ciParams["almRunHost"],
                                     sets);
                    break;
                case TestStorageType.FileSystem:

                    //get the tests
                    IEnumerable<string> tests = GetParamsWithPrefix("Test");

                    IEnumerable<string> jenkinsEnvVariablesWithCommas = GetParamsWithPrefix("JenkinsEnv");
                    Dictionary<string, string> jenkinsEnvVariables = new Dictionary<string,string>();
                    foreach (string var in jenkinsEnvVariablesWithCommas)
                    {
                        string[] nameVal = var.Split(",;".ToCharArray());
                        jenkinsEnvVariables.Add(nameVal[0], nameVal[1]);
                    }
                    //parse the timeout into a TimeSpan
                    TimeSpan timeout = TimeSpan.MaxValue;
                    if (_ciParams.ContainsKey("fsTimeout"))
                    {
                        string strTimoutInSeconds = _ciParams["fsTimeout"];
                        if (strTimoutInSeconds.Trim() != "-1")
                        {
                            int intTimoutInSeconds = 0;
                            int.TryParse(strTimoutInSeconds, out intTimoutInSeconds);
                            timeout = TimeSpan.FromSeconds(intTimoutInSeconds);
                        }
                    }
                    ConsoleWriter.WriteLine("Launcher timeout is " + timeout.ToString(@"dd\:\:hh\:mm\:ss"));

                    //LR specific values:
                    //default values are set by JAVA code, in com.hp.application.automation.tools.model.RunFromFileSystemModel.java

                    int pollingInterval = 30;
                    if (_ciParams.ContainsKey("controllerPollingInterval"))
                        pollingInterval = int.Parse(_ciParams["controllerPollingInterval"]);

                    TimeSpan perScenarioTimeOutMinutes = TimeSpan.MaxValue;
                    if (_ciParams.ContainsKey("PerScenarioTimeOut"))
                    {
                        string strTimoutInMinutes = _ciParams["PerScenarioTimeOut"];
                        ConsoleWriter.WriteLine("reading PerScenarioTimeout: "+strTimoutInMinutes);
                        if (strTimoutInMinutes.Trim() != "-1")
                        {
                            int intTimoutInMinutes = 0;
                            if (int.TryParse(strTimoutInMinutes, out intTimoutInMinutes))
                                perScenarioTimeOutMinutes = TimeSpan.FromMinutes(intTimoutInMinutes);
                            ConsoleWriter.WriteLine("PerScenarioTimeout: "+perScenarioTimeOutMinutes+" minutes");
                        }
                    }
                    ConsoleWriter.WriteLine("PerScenarioTimeout: " + perScenarioTimeOutMinutes.ToString(@"dd\:\:hh\:mm\:ss") + " minutes");

                    char[] delim = { '\n' };
                    List<string> ignoreErrorStrings = new List<string>();
                    if (_ciParams.ContainsKey("ignoreErrorStrings"))
                    {
                        ignoreErrorStrings.AddRange(_ciParams["ignoreErrorStrings"].Split(delim, StringSplitOptions.RemoveEmptyEntries));
                    }

                    if (tests == null || tests.Count() == 0)
                    {
                        WriteToConsole(Resources.LauncherNoTestsFound);
                    }

                    List<string> validTests = Helper.ValidateFiles(tests);

                    if (tests != null && tests.Count() > 0 && validTests.Count == 0)
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherNoValidTests);
                        return null;
                    }

                    //--MC connection info
                    McConnectionInfo mcConnectionInfo = new McConnectionInfo();
                    if (_ciParams.ContainsKey("MobileHostAddress"))
                    {
                        string mcServerUrl = _ciParams["MobileHostAddress"];

                        if (!string.IsNullOrEmpty(mcServerUrl) )
                        {
                            //url is something like http://xxx.xxx.xxx.xxx:8080
                            string[] strArray = mcServerUrl.Split(new Char[] { ':' });
                            if (strArray.Length == 3)
                            {
                                mcConnectionInfo.MobileHostAddress = strArray[1].Replace("/", "");
                                mcConnectionInfo.MobileHostPort = strArray[2];
                            }

                            //mc username
                            if (_ciParams.ContainsKey("MobileUserName"))
                            {
                                string mcUsername = _ciParams["MobileUserName"];
                                if (!string.IsNullOrEmpty(mcUsername))
                                {
                                    mcConnectionInfo.MobileUserName = mcUsername;
                                }
                            }

                            //mc password
                            if (_ciParams.ContainsKey("MobilePassword"))
                            {
                                string mcPassword = _ciParams["MobilePassword"];
                                if (!string.IsNullOrEmpty(mcPassword))
                                {
                                    mcConnectionInfo.MobilePassword = Decrypt(mcPassword, secretkey);
                                }
                            }

                            //ssl
                            if (_ciParams.ContainsKey("MobileUseSSL"))
                            {
                                string mcUseSSL = _ciParams["MobileUseSSL"];
                                if (!string.IsNullOrEmpty(mcUseSSL))
                                {
                                    mcConnectionInfo.MobileUseSSL = int.Parse(mcUseSSL);
                                }
                            }

                            //Proxy enabled flag
                            if (_ciParams.ContainsKey("MobileUseProxy"))
                            {
                                string useProxy = _ciParams["MobileUseProxy"];
                                if (!string.IsNullOrEmpty(useProxy))
                                {
                                    mcConnectionInfo.MobileUseProxy = int.Parse(useProxy);
                                }
                            }

                            //Proxy type
                            if (_ciParams.ContainsKey("MobileProxyType"))
                            {
                                string proxyType = _ciParams["MobileProxyType"];
                                if (!string.IsNullOrEmpty(proxyType))
                                {
                                    mcConnectionInfo.MobileProxyType = int.Parse(proxyType);
                                }
                            }

                            //proxy address
                            if (_ciParams.ContainsKey("MobileProxySetting_Address"))
                            {
                                string proxyAddress = _ciParams["MobileProxySetting_Address"];
                                if (!string.IsNullOrEmpty(proxyAddress))
                                {
                                    // data is something like "16.105.9.23:8080"
                                    string[] strArray4ProxyAddr = proxyAddress.Split(new Char[] { ':' });
                                    if (strArray.Length == 2)
                                    {
                                        mcConnectionInfo.MobileProxySetting_Address = strArray4ProxyAddr[0];
                                        mcConnectionInfo.MobileProxySetting_Port = int.Parse(strArray4ProxyAddr[1]);
                                    }
                                }
                            }

                            //Proxy authentication
                            if (_ciParams.ContainsKey("MobileProxySetting_Authentication"))
                            {
                                string proxyAuthentication = _ciParams["MobileProxySetting_Authentication"];
                                if (!string.IsNullOrEmpty(proxyAuthentication))
                                {
                                    mcConnectionInfo.MobileProxySetting_Authentication = int.Parse(proxyAuthentication);
                                }
                            }

                            //Proxy username
                            if (_ciParams.ContainsKey("MobileProxySetting_UserName"))
                            {
                                string proxyUsername = _ciParams["MobileProxySetting_UserName"];
                                if (!string.IsNullOrEmpty(proxyUsername))
                                {
                                    mcConnectionInfo.MobileProxySetting_UserName = proxyUsername;
                                }
                            }

                            //Proxy password
                            if (_ciParams.ContainsKey("MobileProxySetting_Password"))
                            {
                                string proxyPassword = _ciParams["MobileProxySetting_Password"];
                                if (!string.IsNullOrEmpty(proxyPassword))
                                {
                                    mcConnectionInfo.MobileProxySetting_Password = Decrypt(proxyPassword, secretkey);
                                }
                            }

                        }
                    }

                    // other mobile info
                    string mobileinfo = "";
                    if (_ciParams.ContainsKey("mobileinfo"))
                    {
                        mobileinfo = _ciParams["mobileinfo"];
                    }

                    runner = new FileSystemTestsRunner(validTests, timeout, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo);

                    break;

                default:
                    runner = null;
                    break;
            }
            return runner;
        }
        static void Main(string[] args)
        {
            try
            {
                if (args == null)
                {
                    Console.Out.WriteLine("Usage: HpToolsAborter paramfile");
                    return;
                }

                if (!File.Exists(args[0]))
                {
                    Console.Out.WriteLine("File {0} is missing", args[0]);
                    return;
                }

                string paramfile;

                using (FileStream fs = File.Open(args[0], FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        paramfile = sr.ReadToEnd();
                    }
                }

                Console.Out.WriteLine("============================================================================");
                Console.Out.WriteLine("Aborting testing tool related processes!");

               JavaProperties _ciParams = new JavaProperties();

                _ciParams.Load(args[0]);

               string runType = _ciParams["runType"];

                if (string.IsNullOrEmpty(runType))
                {
                    Console.Out.WriteLine("Unable to find runType in " + args[0]);
                    return;
                }

                if (runType=="FileSystem")
                {
                    KillQtpAutomationProcess();
                    KillLoadRunnerAutomationProcess();
                }

                if (runType=="Alm")
                {
                     string almRunMode = _ciParams["almRunMode"];
                    if (almRunMode=="RUN_LOCAL")
                    {
                        Console.Out.WriteLine("begin to kill processed (Alm)" );
                        KillQtpAutomationFromAlm();
                        KillServiceTestFromAlm();
                    }
                    else if (almRunMode == "RUN_REMOTE")
                    {
                        Console.Out.WriteLine(string.Format("Stopping a test in a remote machine is not supported. Test in {0} should be stopped manually",_ciParams["almRunHost"]));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(string.Format("Error in HpToolsAborter: {0} ",ex.Message));
            }
        }
예제 #22
0
        static void Main(string[] args)
        {
            try
            {
                if (args == null || args.Length == 0)
                {
                    ShowHelp();
                    return;
                }

                if (args[0] == "-v" || args[0] == "-version" || args[0] == "/v")
                {
                    Console.Out.WriteLine(Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    Environment.Exit(0);
                    return;
                }

                if (!File.Exists(args[0]))
                {
                    Console.Out.WriteLine("File '{0}' is missing", args[0]);
                    Environment.Exit(1);
                    return;
                }

                string paramfile;

                using (FileStream fs = File.Open(args[0], FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        paramfile = sr.ReadToEnd();
                    }
                }

                Console.Out.WriteLine("============================================================================");
                Console.Out.WriteLine("Aborting testing tool related processes");

                JavaProperties _ciParams = new JavaProperties();

                _ciParams.Load(args[0]);

                string runType = _ciParams["runType"];

                if (string.IsNullOrEmpty(runType))
                {
                    Console.Out.WriteLine("Unable to find runType in " + args[0]);
                    return;
                }

                if (runType == "FileSystem")
                {
                    KillQtpAutomationProcess();
                    KillLoadRunnerAutomationProcess();
                    KillParallelRunnerAutomationProcesses();
                }

                if (runType == "Alm")
                {
                    string almRunMode = _ciParams["almRunMode"];
                    if (almRunMode == "RUN_LOCAL")
                    {
                        KillQtpAutomationFromAlm();
                        KillServiceTestFromAlm();
                    }
                    else if (almRunMode == "RUN_REMOTE")
                    {
                        Console.Out.WriteLine(string.Format("Stopping a test in a remote machine is not supported. Test in {0} should be stopped manually", _ciParams["almRunHost"]));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(string.Format("Error in HpToolsAborter: {0} ", ex.Message));
            }
        }
        bool IsInstalled(AndroidToolchainComponent component, string path, out bool missing)
        {
            missing = true;
            if (!Directory.Exists(path))
            {
                Log.DebugLine($"Component '{component.Name}' directory does not exist: {path}");
                return(false);
            }

            // This is just a cursory check, we might want to check versions
            string propsFile = Path.Combine(path, "source.properties");

            if (!File.Exists(propsFile))
            {
                Log.DebugLine($"Component '{component.Name}' properties file does not exist: {propsFile}");
                return(false);
            }

            missing = false;
            if ((RefreshSdk && !IsNdk(component)) || (RefreshNdk && IsNdk(component)))
            {
                Log.DebugLine($"A reinstall has been requested for component '{component.Name}'");
                return(false);
            }

            if (String.IsNullOrEmpty(component.PkgRevision))
            {
                Log.DebugLine($"Component '{component.Name}' does not specify required Pkg.Revision, assuming it's valid");
                return(true);
            }

            Log.DebugLine($"Component '{component.Name}' requires Pkg.Revision to be '{component.PkgRevision}', verifying");
            var props = new JavaProperties();

            try {
                using (var fs = File.OpenRead(propsFile)) {
                    props.Load(fs);
                }
            } catch (Exception ex) {
                Log.DebugLine($"Failed to read '{component.Name}' source.properties. Assuming invalid version, component will be reinstalled.");
                Log.DebugLine(ex.ToString());
                return(false);
            }

            string pkgRevision = props.GetProperty("Pkg.Revision", String.Empty);

            if (String.IsNullOrEmpty(pkgRevision))
            {
                Log.DebugLine($"Component '{component.Name}' does not have Pkg.Revision in its source.properties file, it will be reinstalled.");
                return(false);
            }

            if (!ParseVersion(pkgRevision, out Version pkgVer))
            {
                Log.DebugLine($"Failed to parse a valid version from Pkg.Revision ({pkgRevision}) for component '{component.Name}'. Component will be reinstalled.");
                return(false);
            }

            if (!ParseVersion(component.PkgRevision, out Version expectedPkgVer))
            {
                throw new InvalidOperationException($"Invalid expected package version for component '{component.Name}': {component.PkgRevision}");
            }

            bool equal = pkgVer == expectedPkgVer;

            if (!equal)
            {
                Log.DebugLine($"Installed version of '{component.Name}' ({pkgVer}) is different than the required one ({expectedPkgVer})");
            }

            return(equal);
        }