예제 #1
0
        public void SimpleLoad(CancellationToken cancelToken)
        {
            var unitTests = new UnitTest[] { new UnitTest(this.Foo), new UnitTest(this.Bar), new UnitTest(this.Shz), new UnitTest(this.Nit) };

            var testPattern = new RandomTestPattern();

            testPattern.Initialize(0, unitTests);

            var workerStrategy = new DedicatedThreadWorkerStrategy();

            var loadPattern = new StaticLoadPattern()
            {
                WorkerCount = 24
            };

            Task t = loadPattern.ExecuteAsync(testPattern, workerStrategy, cancelToken);

            Task.Delay(3000).GetAwaiter().GetResult();

            var rootLoadPattern = new StaticLoadPattern()
            {
                WorkerCount = 500
            };

            //add a burst of execution
            rootLoadPattern.Execute(new UnitTest(Root), workerStrategy, new CancellationTokenSource(10000).Token);

            //wait for original workers to complete
            t.GetAwaiter().GetResult();
        }
예제 #2
0
        public static void ExecuteTestMix()
        {
            Console.WriteLine($"executing stress test mix (duration={s_duration} workercount={s_workerCount} seed={s_seed})");

            CancellationTokenSource completeSource = new CancellationTokenSource(s_duration);

            var unitTests = new StressTestsAssemblyTestEnumerator().ToArray();

            var testPattern = new RandomTestPattern();

            testPattern.Initialize(s_seed, unitTests);

            DedicatedThreadWorkerStrategy workerStrategy = new DedicatedThreadWorkerStrategy();

            StaticLoadPattern loadPattern = new StaticLoadPattern()
            {
                WorkerCount = s_workerCount
            };

            loadPattern.Execute(testPattern, workerStrategy, completeSource.Token);
        }