예제 #1
0
        public async Task DurationLoadTest()
        {
            var url = @"http://localhost:5000/api/Test/TestGet?numberOfResponses=20";

            var generator = new SimpleLoadTestGenerator();

            var durationOption = generator.Options.First(o => o.Description.Key == "Duration");

            durationOption.Value = "3"; // 3 seconds

            var urlOption = generator.Options.First(o => o.Description.Key == "Url");

            urlOption.Value = url;

            var requests = generator.Run();

            DateTime start = new DateTime(DateTime.Now.Ticks);

            foreach (var request in requests)
            {
                Assert.Equal(url, request.Url);
            }

            int duration = (DateTime.Now - start).Seconds;

            Assert.InRange(duration, 2, 4);
        }
예제 #2
0
        public async Task CountLoadTest()
        {
            var url = @"http://localhost:5000/api/Test/TestGet?numberOfResponses=20";

            var generator = new SimpleLoadTestGenerator();

            var countOption = generator.Options.First(o => o.Description.Key == "Count");

            countOption.Value = "10";

            var urlOption = generator.Options.First(o => o.Description.Key == "Url");

            urlOption.Value = url;

            var requests = generator.Run().ToList();

            Assert.Equal(10, requests.Count());
            Assert.True(requests[5].Url == url);
        }
예제 #3
0
        private static async Task <AgentResult> RunSimpleLoadTestAsync(Uri uri, int threads, TimeSpan duration, int count)
        {
            var generator = new SimpleLoadTestGenerator();

            var durationOption = generator.Options.First(o => o.Description.Key == "Duration");

            durationOption.Value = duration.Seconds.ToString();

            var countOption = generator.Options.First(o => o.Description.Key == "Count");

            countOption.Value = count.ToString();

            var urlOption = generator.Options.First(o => o.Description.Key == "Url");

            urlOption.Value = uri.AbsoluteUri;

            var tree = new HttpRequestTree()
            {
                Requests = generator.Run()
            };

            return(await RunRequestComparisonAsync(threads, tree, null));
        }