public void TestConnections() { var p = new PasswordAuthProvider(new Uri("http://localhost:9001/")); var adminToken = p.Login(new PasswordAuthRequest <PasswordAuthData>() { RequestData = new PasswordAuthData() { Password = "******", Usename = "admin" } }).Result; var connectionsList = new PasswordOAuthContext[10000]; for (int conn = 0; conn < 10000; conn++) { try { var registerRes = Register(adminToken, conn).Result; } catch (Exception ex) { Debug.Write(ex.Message); } connectionsList[conn] = PostAuth(conn).Result; } Array.ForEach(new[] { 1, 10, 100, 1000, 10000 }, connectionsNumber => { Debug.WriteLine("Connections number: {0}", connectionsNumber); var sw = Stopwatch.StartNew(); for (int i = 0; i < connectionsNumber; i++) { var x = GetData(connectionsList[i]).Result; } Debug.WriteLine("Single: {0}", sw.Elapsed); Debug.WriteLine(""); }); Array.ForEach(new[] { 1, 10, 100, 1000, 10000 }, connectionsNumber => { Debug.WriteLine("Connections number: {0}", connectionsNumber); var sw = Stopwatch.StartNew(); List <Task> taskList = new List <Task>(); for (var i = 0; i < connectionsNumber; ++i) { taskList.Add(GetData(connectionsList[i])); } Task.WhenAll(taskList); Debug.WriteLine("Parallel: {0}", sw.Elapsed); Debug.WriteLine(""); }); }
private async static Task <PasswordOAuthContext> PostAuth(int index) { var p = new PasswordAuthProvider(new Uri("http://localhost:9001/")); return(await p.Login(new PasswordAuthRequest <PasswordAuthData>() { RequestData = new PasswordAuthData() { Password = "******", Usename = "userok" + index } })); }
public static async Task <Tuple <PasswordOAuthContext, string> > UserLogin(string[] serversList, int port, string userName, string password) { var serverInfoUrl = GetApiServerUri(serversList, userName, port); var p = new PasswordAuthProvider(serverInfoUrl); var res = await p.Login(new PasswordAuthRequest <PasswordAuthData>() { RequestData = new PasswordAuthData() { Password = password, Usename = userName } }); return(new Tuple <PasswordOAuthContext, string>(res, userName)); }
public Task <Tuple <PerformanceCounter, ClientConnectionInfo> > Login(string login, string password) { var serverUri = GetApiServerUri(_serviceUriList, login); var p = new PasswordAuthProvider(serverUri, _logger); return(DoPerformanceMeasureAction(async() => { var token = await p.Login(new PasswordAuthRequest <PasswordAuthData>() { RequestData = new PasswordAuthData() { Password = password, Usename = login } }); return new ClientConnectionInfo { Login = login, Context = token }; }, serverUri.ToString())); }