Exemple #1
0
        //HACK: DiscoverableActionSequencer is meant to be stateless, and should not be accessing TestDefinition object.
        //These settings should be loaded via Stress State initialization.
        public DiscoverableActionSequencer()
        {
            ContentPropertyBag testParameters = DriverState.DriverParameters;
            string             standardRecursionLimitString = testParameters["StandardRecursionLimit"];

            if (!String.IsNullOrEmpty(standardRecursionLimitString))
            {
                standardRecursionLimit = Int32.Parse(standardRecursionLimitString);
                Trace.WriteLine("[DiscoverableActionSequencer] standardRecursionLimit: " + standardRecursionLimit);
            }

            string absoluteRecursionLimitString = testParameters["AbsoluteRecursionLimit"];

            if (!String.IsNullOrEmpty(absoluteRecursionLimitString))
            {
                absoluteRecursionLimit = Int32.Parse(absoluteRecursionLimitString);
                Trace.WriteLine("[DiscoverableActionSequencer] absoluteRecursionLimit: " + absoluteRecursionLimit);
            }

            if (standardRecursionLimit > absoluteRecursionLimit)
            {
                throw new InvalidOperationException("AbsoluteRecursionLimit must be greater than StandardRecursionLimit");
            }
            if (standardRecursionLimit <= 0)
            {
                throw new InvalidOperationException("Recursion Limits must exceed 0");
            }
        }
        private string GetAttributeValue(ContentPropertyBag stateData, string attributeName, bool throwIfNotDefined)
        {
            string attributeValue = stateData[attributeName];

            if (String.IsNullOrEmpty(attributeValue) && throwIfNotDefined)
            {
                throw new InvalidDataException(String.Format("{0} attribute requested in StateArguments.", attributeName));
            }
            return(attributeValue);
        }
Exemple #3
0
        //HACK: This TestDefinition/ObjectSerializer/XmlDocument business is a nightmare. We need to move to a simple dictionary based model
        //This is quite a disapointing solution, but expedient. To fix this up would be expensive, with no functional/external gain.
        //I would like to switch the pipeline to be CLD/CLP based to streamline the design however.
        private IStatePayload PopulateStateArgs(Type stateType, ContentPropertyBag bag)
        {
            IStatePayload payload = null;

            if (stateType == typeof(ConvenienceStressState))
            {
                ConvenienceStressStatePayload csp = new ConvenienceStressStatePayload();
                csp.Initialize(bag);
                payload = csp;
            }
            return(payload);
        }
Exemple #4
0
        internal static ContentPropertyBag ToDriverParameters(Assembly testAssembly, TestVariation variation)
        {
            ContentPropertyBag driverParams = new ContentPropertyBag();

            // Use assembly partial name because we will be loading assembly from the
            // local directory, not the GAC.
            driverParams[targetAssemblyKey] = testAssembly.GetName().Name;
            driverParams[suiteKey]          = variation.TestCase.Suite.GetType().FullName;
            driverParams[testIdKey]         = variation.TestCase.Id;
            driverParams[commandLineKey]    = string.Join(" ", variation.Parameters);
            return(driverParams);
        }
Exemple #5
0
        // This comes from the AnnotationsTestSettings class that used to be in the adaptor file.
        //private ContentPropertyBag ToDriverParameters(Assembly testAssembly, TestVariation variation)
        private ContentPropertyBag ToDriverParameters(Assembly testAssembly, object variation)
        {
            ContentPropertyBag driverParams = new ContentPropertyBag();

            // Use assembly partial name because we will be loading assembly from the
            // local directory, not the GAC.
            driverParams[targetAssemblyKey] = testAssembly.GetName().Name;
            //driverParams[suiteKey] = variation.TestCase.Suite.GetType().FullName;
            driverParams[suiteKey] = HackyGetProperty(HackyGetProperty(variation, "TestCase"), "Suite").GetType().FullName;
            //driverParams[testIdKey] = variation.TestCase.Id;
            driverParams[testIdKey] = (string)HackyGetProperty(HackyGetProperty(variation, "TestCase"), "Id");
            //driverParams[commandLineKey] = string.Join(" ", variation.Parameters);
            driverParams[commandLineKey] = string.Join(" ", ((string[])HackyGetProperty(variation, "Parameters")));
            return(driverParams);
        }
        /// <summary>
        /// Converts XmlInput and initializes the payload object
        /// with explicit property values which can be serialized
        /// </summary>
        /// <param name="arguments"></param>
        public void Initialize(ContentPropertyBag bag)
        {
            // Required attributes
            FactoriesPath = GetAttributeValue(bag, "FactoriesPath", true);
            ActionsPath   = GetAttributeValue(bag, "ActionsPath", true);

            // Optional attributes
            WindowXamlPaths      = GetAttributeValue(bag, "WindowXamlPaths", false);
            ContentXamlPath      = GetAttributeValue(bag, "ContentXamlPath", false);
            ConstraintsTablePath = GetAttributeValue(bag, "ConstraintsTablePath", false);

            if (bag["MemoryLimit"] != null)
            {
                MemoryLimit = int.Parse((string)bag["MemoryLimit"]);
            }
            else
            {
                MemoryLimit = 100000000;
            }
        }
Exemple #7
0
        public StabilityTestDefinition(ContentPropertyBag payload)
        {
            string schedulerTypename = payload["SchedulerType"];

            SchedulerType = Type.GetType(schedulerTypename);
            if (SchedulerType == null)
            {
                throw new ArgumentException(string.Format("Requested SchedulerType '{0}' does not exist in assembly '{1}'.", schedulerTypename, Assembly.GetExecutingAssembly().FullName));
            }

            RandomSeed       = int.Parse(payload["Seed"]);
            NumWorkerThreads = int.Parse(payload["NumWorkerThreads"]);

            IsolateThreadsInAppdomains = bool.Parse(payload["IsolateThreadsInAppdomains"]);

            ExecutionContext                     = new ExecutionContextMetadata();
            ExecutionContext.StateType           = InitType(payload["StateAssembly"], payload["StateType"]);
            ExecutionContext.ActionSequencerType = InitType(payload["ActionAssembly"], payload["SequenceType"]);
            ExecutionContext.StateArguments      = PopulateStateArgs(ExecutionContext.StateType, payload);

            int timeInMinutes;

            if (!int.TryParse(payload["DurationInMinutes"], out timeInMinutes))
            {
                timeInMinutes = 900;
            }
            ExecutionTime = TimeSpan.FromMinutes(timeInMinutes);

            int idleDuration;

            if (!int.TryParse(payload["IdleDuration"], out idleDuration))
            {
                idleDuration = 200;
            }
            IdleDuration = TimeSpan.FromMilliseconds(idleDuration);
        }
Exemple #8
0
        /// <summary>
        /// Discover DRTs from drt manifest.
        /// </summary>
        /// <param name="testManifestPath">Should be path to rundrtlist.txt</param>
        /// <param name="defaultTestInfo"></param>
        /// <returns>TestInfos for drts.</returns>
        //List<TestInfo> Discover(string testBinRootPath, string targetFilename, TestInfo defaultTestInfo)
        public override IEnumerable <TestInfo> Discover(FileInfo testManifestPath, TestInfo defaultTestInfo)
        {
            string targetFilename = testManifestPath.FullName;

            if (!File.Exists(targetFilename))
            {
                throw new FileNotFoundException(Path.GetFullPath(targetFilename));
            }

            // Deserialize Drt manifest file into a list of Drt objects.
            XmlTextReader reader         = new XmlTextReader(targetFilename);
            List <Drt>    drtDefinitions = (List <Drt>)ObjectSerializer.Deserialize(reader, typeof(List <Drt>), null);

            // Convert each Drt object into a TestInfo.
            List <TestInfo> drts = new List <TestInfo>();

            foreach (Drt drtDef in drtDefinitions)
            {
                // Initialize TestInfo.
                TestInfo drtTestInfo = defaultTestInfo.Clone();

                ContentPropertyBag driverArgs = drtTestInfo.DriverParameters;
                // Store Executable, Owner, and Args in the property bag for DrtDriver to consume.
                driverArgs["exe"] = drtDef.Executable;
                if (!String.IsNullOrEmpty(drtDef.Args))
                {
                    driverArgs["args"] = drtDef.Args;
                }
                driverArgs["owner"] = drtDef.Owner;

                string exeFileNameWithoutExtension = Path.GetFileNameWithoutExtension(driverArgs["exe"]);

                drtTestInfo.Name             = exeFileNameWithoutExtension + "(" + drtDef.Args + ")";
                drtTestInfo.DriverParameters = driverArgs;
                drtTestInfo.Area             = drtDef.Team;

                if (drtDef.Timeout > 0)
                {
                    drtTestInfo.Timeout = TimeSpan.FromSeconds(drtDef.Timeout);
                }

                SelectConfiguration(drtTestInfo, drtDef);

                // Convert drt support files to a source/destination pair for TestInfo.
                foreach (string file in drtDef.SupportFiles)
                {
                    //The path may be to a directory or a file.  If we think the path is to a directory
                    //then the destination and the source are the same
                    //otherwise the destination is the containing directory of the source file
                    //We assume people are not specifying files that have no extention
                    //and that * is used only in filenames
                    TestSupportFile supportFile = new TestSupportFile();
                    supportFile.Source      = Path.Combine("DRT", file);
                    supportFile.Destination = string.IsNullOrEmpty(Path.GetExtension(supportFile.Source)) && !supportFile.Source.Contains("*") ? file : Path.GetDirectoryName(file);
                    drtTestInfo.SupportFiles.Add(supportFile);
                }

                // Add all needed build output files
                List <string> buildOutputFilePaths =
                    new List <string>()
                {
                    Path.Combine("DRT", driverArgs["exe"]),
                };

                // In .NET Core we need to add all outputs that are prefixed with the exe name
                buildOutputFilePaths.AddRange(Directory.GetFiles("DRT", exeFileNameWithoutExtension + ".*"));

                foreach (var path in buildOutputFilePaths)
                {
                    if (!drtTestInfo.SupportFiles.Select(s => s.Source).Contains(path))
                    {
                        drtTestInfo.SupportFiles.Add(new TestSupportFile()
                        {
                            Source = path
                        });
                    }
                }

                // Append relative path to all deployments.
                foreach (string deployment in drtDef.Deployments)
                {
                    drtTestInfo.Deployments.Add(Path.Combine("DRT", deployment));
                }

                drts.Add(drtTestInfo);
            }
            return(drts);
        }