예제 #1
0
        public void WhenConvertTestcasesToTestResultObjectPreparedForJsonConverter()
        {            
            var testResultForwarder = new TestResultForwarder() { XMLResult = inputXML, Logger = TR.AppServer.Logging.Logger.Default };
            var testResult = new TestResult
            {
                Product = TestResultForwarder.ProductName,
                TimeStamp = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.000Z"),
                UUID = "dummy",
                InstallGuid = "00000000-0000-0000-0000-000000000000",
                MachineGUID = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":machineID")),
                Stats = testResultForwarder.GetTestCaseListFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":testCases//", TRRConstant.ElementPrefix, ":testCase"))
            };
            var product = TestResultForwarder.ProductName;
            var productName = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":product/@name"));            
            var productVersion = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":product/@version"));
            if (TestResultForwarder.IsEWM(productName, productVersion))
            {
                product = "ewm";
                testResultForwarder.MapStatCodeEWM(testResult);
            }
            var runningMode = testResultForwarder.GetValueFromXML(string.Concat("//", TRRConstant.ElementPrefix, ":runningMode"));
            var xnav = inputXML.CreateNavigator();
            var total = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase)", NamespaceMgr));
            var totalPass = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='pass'])", NamespaceMgr));
            var totalInfo = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='info'])", NamespaceMgr));
            var totalWarning = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='warning'])", NamespaceMgr));
            var totalAlert = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='alert'])", NamespaceMgr));
            var totalFail = Convert.ToInt32(testResultForwarder.GetXPathScalar(xnav, "count(/rst:rstResult/rst:testCases/rst:testCase[not(@shouldBeRerun!='false') and not(@ssiID!='') and rst:valid='fail'])", NamespaceMgr));
            var other = total - totalPass - totalInfo - totalWarning - totalAlert - totalFail;        

            testResult.Stats.Add(new TestCase { StatName = "runmode", StatVal = runningMode });
            testResult.Stats.Add(new TestCase { StatName = "total", StatVal = total.ToString() });
            testResult.Stats.Add(new TestCase { StatName = "pass", StatVal = totalPass.ToString() });
            testResult.Stats.Add(new TestCase { StatName = "info", StatVal = totalInfo.ToString() });
            testResultForwarder.AddValidationStat(xnav, testResult, "warn", totalWarning);
            testResultForwarder.AddValidationStat(xnav, testResult, "alert", totalAlert);
            testResultForwarder.AddValidationStat(xnav, testResult, "fail", totalFail);
            testResult.Stats.Add(new TestCase { StatName = "other", StatVal = other.ToString() });

            var compName = Environment.GetEnvironmentVariable("COMPUTERNAME") ?? "";
            var envName = Environment.GetEnvironmentVariable("AS_ENV") ?? "";

            testResult.Stats.Add(new TestCase { StatName = "servname", StatVal = compName });
            testResult.Stats.Add(new TestCase { StatName = "envname", StatVal = envName });
            //testResult.Stats.Add(new TestCase { StatName = "testID", StatVal = testID });
            testResult.Stats.Add(new TestCase { StatName = "product", StatVal = product });            

            ScenarioContext.Current.Set(testResult, "testResult");
        }
예제 #2
0
        internal static string SubmitTestResult(string rstResult, IAppServerServices services, bool isCompressed = true)
        {
            var uuid = services.UserContext.UUID;
            string testID = "";
            services.Logger.LogInfo("WebCallsImpl.SubmitTestResult(): [" + uuid + "] Started");
            try
            {
                if (isCompressed)
                {                    
                    rstResult = GzipDecompress(rstResult);
                }
                services.Logger.LogDebug("WebCallsImpl.SubmitTestResult(): [" + uuid + "] Decompressed");
                               
                inputXML = LoadStringToXmlDocument(rstResult);

                if (string.IsNullOrEmpty(XSLTString))
                {
                    using (var mStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ThomsonReuters.Eikon.SystemTest.MappingTestResult.xslt"))
                    {
                        using (var reader = new StreamReader(mStream))
                        {
                            mStream.Seek(0, SeekOrigin.Begin);
                            XSLTString = reader.ReadToEnd();
                        }
                    }
                }

                inputXML = FormatingTestResultByXslt(inputXML, XSLTString, services);
                //services.Logger.LogDebug("WebCallsImpl.SubmitTestResult(): [" + uuid + "] XSLT Loaded/Transformed");

                //Insert server detail into test result
                /*#region Insert server detail into the test result
                XmlNode userProfileNode = null;
                XmlNode refNode = inputXML.DocumentElement;
                XmlNode userProfileXml = CreateUserProfileXml(inputXML);
                if (userProfileXml != null)
                {
                    userProfileNode = inputXML.DocumentElement.InsertBefore(userProfileXml, refNode.FirstChild);
                }
                XmlNode serverVersionXml = CreateServerVersionXml(inputXML);
                if (serverVersionXml != null)
                {
                    inputXML.DocumentElement.InsertAfter(serverVersionXml, userProfileNode);
                }
                services.Logger.LogDebug("SubmitTestResult: [" + uuid + "] GetAAAservice");
                #endregion*/

                var forwarder = new TestResultForwarder { XMLResult = inputXML, Logger = services.Logger };
                
                if(!forwarder.ForwardTest(uuid, out testID))
                    SaveOfflineResult(inputXML, uuid);

                services.Logger.LogDebug("WebCallsImpl.SubmitTestResult(): [" + uuid + "] Forwarded");
            }
            catch (Exception ex)
            {
                SaveOfflineResult(inputXML, uuid);
                services.Logger.LogError("SubmitTestResult: [" + uuid + "], " + ex.Message);
                services.Logger.LogError("SubmitTestResult: [" + uuid + "], " + ex.StackTrace);
            }
            if (string.IsNullOrEmpty(testID))
            {               
                return TRR_RETURNMSG1 + uuid + TRR_RETURNMSG2;
            }
            else
            {
                return TRR_RETURNMSG1 + testID + TRR_RETURNMSG2;
            }
            
        }