Beispiel #1
0
        public string InitializeTestSession(JObject arg)
        {
            var sessionInfo = SessionInfo.FromJson(arg);

            // New Changes:
            WithSeed(sessionInfo.schedulingSeed, sessionInfo.maxDecisions);

            var session = new TestingSession(sessionInfo);

            session.OnComplete += (sender, record) =>
            {
#if DEBUG
                Console.WriteLine("\n==========[ Test {0} {1} ]==========\n", record.sessionId, record.passed ? "PASSED" : "FAILED");

                if (record.reason != "")
                {
                    Console.WriteLine("  " + record.reason);
                }
#endif

                // Append Summary
                string summary = String.Join(",", new string[] {
                    sessionInfo.assemblyName,
                    sessionInfo.methodDeclaringClass,
                    sessionInfo.methodName,
                    session.Id,
                    sessionInfo.schedulingSeed.ToString(),
                    (record.passed ? "pass" : "fail"),
                    record.reason,
                    record.elapsedMs.ToString()
                });
                this.summaryFile.WriteLine(summary);
                this.summaryFile.Flush();

#if DEBUG
                Console.WriteLine("\n--------------------------------------------\n");
                Console.WriteLine("    Total Requests:\t{0}", record.numRequests);
                Console.WriteLine("    Avg Invoke Time:\t{0} ms", Math.Round((decimal)record.avgInvokeTime, 2));
                Console.WriteLine("    Total Time Taken:\t{0} ms", Math.Round((decimal)record.elapsedMs, 2));
                Console.WriteLine("\n===== END of {0} =====[ Results: {1}/{2} ]=====\n\n", session.Id, this.testSessions.Where(item => item.Value.LastRecord.passed == true).Count(), this.testSessions.Count);
#endif
            };

            lock (this.testSessions)
            {
                this.testSessions.Add(session.Id, session);
            }
#if DEBUG
            Console.WriteLine("\n\n===== BEGIN {0} ================================\n", session.Id);
            Console.WriteLine("  [{1}]\n  in {0}", sessionInfo.assemblyName, sessionInfo.methodDeclaringClass + "." + sessionInfo.methodName);
            Console.WriteLine("  Seed:\t\t{0}\n  Timeout:\t{1}\n  MaxDecisions:\t{2}\n", sessionInfo.schedulingSeed, sessionInfo.timeoutMs, sessionInfo.maxDecisions);
            Console.WriteLine("\nIndex\tThrd\t#Thrds\tCurTask\t#Tasks\t#Blckd\tPending\tStage\tMethod\tArgs");
#else
            Console.WriteLine("\nRun new session '{0}'\tseed = {1}", session.Id, sessionInfo.schedulingSeed);
#endif

            return(session.Id);
        }
Beispiel #2
0
        public SessionInfo ReplayTestSession(JToken arg)
        {
            string sessionId = arg.ToObject <string>();

            SessionInfo info = GetSessionInfo(sessionId);

            lock (this.testSessions)
            {
                TestingSession session = this.testSessions[sessionId];
                session.Reset();

#if DEBUG
                Console.WriteLine("\n\n===== BEGIN REPLAY {0} =========================\n", sessionId);
                Console.WriteLine("  [{1}]\n  in {0}\n", info.assemblyName, info.methodDeclaringClass + "." + info.methodName);
                Console.WriteLine("  Seed:\t\t{0}\n  Timeout:\t{1}\n  MaxDecisions:\t{2}\n", info.schedulingSeed, info.timeoutMs, info.maxDecisions);
#else
                Console.WriteLine("\n Replay session '{0}'\tseed = {1}", session.Id, session.Meta.schedulingSeed);
#endif
            }

            return(info);
        }