Ejemplo n.º 1
0
        public void GenerateSuite(int seed, string suiteName, string outputPath, string[] testPaths, string[] searchPatterns, string[] hintPaths, LoadSuiteConfig config)
        {
            int suiteTestCount = 0;

            _unitTestSelector = new UnitTestSelector();

            _unitTestSelector.Initialize(seed, testPaths, searchPatterns, hintPaths);

            foreach (var loadTestConfig in config.LoadTestConfigs)
            {
                for (int i = 0; i < loadTestConfig.TestCount; i++)
                {
                    var loadTestInfo = new LoadTestInfo()
                    {
                        TestName = suiteName + "_" + suiteTestCount.ToString("X4"),
                        Duration = loadTestConfig.Duration,
                        LoadPatternType = Type.GetType(loadTestConfig.LoadPattern),
                        TestPatternType = Type.GetType(loadTestConfig.TestPattern),
                        WorkerStrategyType = Type.GetType(loadTestConfig.WorkerStrategy),
                        WorkerCount = loadTestConfig.NumWorkers,
                        EnvironmentVariables = loadTestConfig.EnvironmentVariables,
                        SuiteConfig = config,
                    };

                    loadTestInfo.SourceDirectory = Path.Combine(outputPath, loadTestInfo.TestName);
                    loadTestInfo.UnitTests = _unitTestSelector.NextUnitTests(loadTestConfig.NumTests).ToArray();

                    this.GenerateTestSources(loadTestInfo);
                    CodeGenOutput.Info($"Generated Load Test: {loadTestInfo.TestName}");
                    suiteTestCount++;
                }
            }
        }
Ejemplo n.º 2
0
        public static LoadSuiteConfig Deserialize(string path)
        {
            LoadSuiteConfig config = null;

            // Deserialize the RunConfiguration
            JsonSerializer serializer = JsonSerializer.CreateDefault();

            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(fs))
                {
                    JsonTextReader jReader = new JsonTextReader(reader);

                    // Call the Deserialize method to restore the object's state.
                    config = serializer.Deserialize <LoadSuiteConfig>(jReader);
                }
            }

            return(config);
        }
Ejemplo n.º 3
0
        public void GenerateSuite(int seed, string suiteName, string outputPath, string[] testPaths, string[] searchPatterns, string[] hintPaths, LoadSuiteConfig config, string cachePath = null, bool legacyProject = false, string globalPackageConfig = null)
        {
            Random rand = new Random(seed);

            int suiteTestCount = 0;

            _unitTestSelector = new UnitTestSelector();

            _unitTestSelector.Initialize(seed, testPaths, searchPatterns, hintPaths, cachePath);

            for (int iConfig = 0; iConfig < config.LoadTestConfigs.Count; iConfig++)
            {
                var loadTestConfig = config.LoadTestConfigs[iConfig];

                for (int i = 0; i < loadTestConfig.TestCount; i++)
                {
                    var loadTestInfo = new LoadTestInfo(globalPackageConfig)
                    {
                        TestName             = suiteName + "_" + suiteTestCount.ToString("X4"),
                        Duration             = loadTestConfig.Duration,
                        LoadPatternType      = typeof(StaticLoadPattern),                     //Type.GetType(loadTestConfig.LoadPattern),
                        TestPatternType      = typeof(RandomTestPattern),                     //Type.GetType(loadTestConfig.TestPattern),
                        WorkerStrategyType   = typeof(DedicatedThreadWorkerStrategy),         //Type.GetType(loadTestConfig.WorkerStrategy),
                        WorkerCount          = loadTestConfig.NumWorkers,
                        SelfDestruct         = loadTestConfig.SelfDestruct,
                        EnvironmentVariables = loadTestConfig.EnvironmentVariables,
                        SuiteConfig          = config,
                        Seed = rand.Next(),
                    };

                    loadTestInfo.SourceDirectory = Path.Combine(outputPath, iConfig.ToString("00") + "_" + loadTestInfo.Duration.TotalHours.ToString("00.##") + "hr", loadTestInfo.TestName);
                    loadTestInfo.UnitTests       = _unitTestSelector.NextUnitTests(loadTestConfig.NumTests).ToArray();

                    //build a list of all the sources files to generate for the load test
                    var generators = new List <ISourceFileGenerator>()
                    {
                        new LoadTestSourceFileGenerator(),
                        new ProgramSourceFileGenerator(),
                        new ExecutionFileGeneratorWindows(),
                        new ExecutionFileGeneratorLinux(),
                    };

                    //if we want to generate a legacy project file (i.e. ToF project file) use HelixToFProjectFileGenerator otherwise use LoadTestProjectFileGenerator
                    var projectFileGenerator = legacyProject ? (ISourceFileGenerator) new HelixToFProjectFileGenerator() : (ISourceFileGenerator) new LoadTestProjectFileGenerator();

                    if (!legacyProject)
                    {
                        generators.Add(new LoadTestProjectJsonFileGenerator());
                    }

                    //I believe the project file generator must be last, becuase it depends on discovering all the other source files
                    //however the ordering beyond that should not matter
                    generators.Add(projectFileGenerator);

                    this.GenerateTestSources(loadTestInfo, generators);
                    CodeGenOutput.Info($"Generated Load Test: {loadTestInfo.TestName}");
                    suiteTestCount++;
                }
            }
        }
Ejemplo n.º 4
0
 private LoadSuiteConfig GetSuiteConfig()
 {
     return(LoadSuiteConfig.Deserialize(this.ConfigPath));
 }
Ejemplo n.º 5
0
        public void GenerateSuite(int seed, string suiteName, string outputPath, string[] testPaths, string[] searchPatterns, string[] hintPaths, LoadSuiteConfig config, string cachePath = null)
        {
            int suiteTestCount = 0;

            _unitTestSelector = new UnitTestSelector();

            _unitTestSelector.Initialize(seed, testPaths, searchPatterns, hintPaths, cachePath);

            for (int iConfig = 0; iConfig < config.LoadTestConfigs.Count; iConfig++)
            {
                var loadTestConfig = config.LoadTestConfigs[iConfig];

                for (int i = 0; i < loadTestConfig.TestCount; i++)
                {
                    var loadTestInfo = new LoadTestInfo()
                    {
                        TestName             = suiteName + "_" + suiteTestCount.ToString("X4"),
                        Duration             = loadTestConfig.Duration,
                        LoadPatternType      = typeof(StaticLoadPattern),                     //Type.GetType(loadTestConfig.LoadPattern),
                        TestPatternType      = typeof(RandomTestPattern),                     //Type.GetType(loadTestConfig.TestPattern),
                        WorkerStrategyType   = typeof(DedicatedThreadWorkerStrategy),         //Type.GetType(loadTestConfig.WorkerStrategy),
                        WorkerCount          = loadTestConfig.NumWorkers,
                        EnvironmentVariables = loadTestConfig.EnvironmentVariables,
                        SuiteConfig          = config,
                    };

                    loadTestInfo.SourceDirectory = Path.Combine(outputPath, iConfig.ToString("00") + "_" + loadTestInfo.Duration.TotalHours.ToString("00.##") + "hr", loadTestInfo.TestName);
                    loadTestInfo.UnitTests       = _unitTestSelector.NextUnitTests(loadTestConfig.NumTests).ToArray();

                    this.GenerateTestSources(loadTestInfo);
                    CodeGenOutput.Info($"Generated Load Test: {loadTestInfo.TestName}");
                    suiteTestCount++;
                }
            }
        }