Hello I wonder if you have ever tried to run a volume test on the aspnetzero solution? How many million users can I expect the solution to handle? :)
I tried to insert a loop that created users in the HostRoleAndUserCreator class, but if I use a loop greater than 100, the script or VS starts hanging. Maybe I have to create a stored procedure in Sql server?
2 Answer(s)
-
0
Show code for your loop.
-
0
<cite>aaron: </cite> Show code for your loop.
private void CreateVolumeTestUsers() { var userRoleForUser = _context.Roles.FirstOrDefault(r => r.TenantId == 1 && r.Name == StaticRoleNames.Tenants.User); if (userRoleForUser == null) { userRoleForUser = _context.Roles.Add(new Role(1, StaticRoleNames.Tenants.User, StaticRoleNames.Tenants.User) { IsStatic = true, IsDefault = true }).Entity; _context.SaveChanges(); }
int testUsers_NOR10000 = 10000; var testUserNOR1 = _context.Users.FirstOrDefault(u => u.TenantId == 1 && u.UserName == "[email protected]"); //var testUserNOR51 = _context.Users.FirstOrDefault(u => u.TenantId == null && u.UserName == "[email protected]"); if (testUserNOR1 == null) { for (int i = 1; i < testUsers_NOR10000; i++) { var testUserName = "TestuserNOR" + i + "@testuser.com"; var testUserNOR = _context.Users.FirstOrDefault(u => u.TenantId == null && u.UserName == testUserName); if (testUserNOR == null) { var testUser = new User { //UserId = Guid.NewGuid(), TenantId = 1, UserName = "TestuserNOR" + i + "@testuser.com", Name = "TestNOR" + i.ToString(), Surname = "UserNOR" + i.ToString(), CountryId = 3, AreaId = 53, SubAreaId = 425, CityId = 1, BirthYear = 1979, Gender = Model.Common.MySolutionEnums.GenderType.Woman, EmailAddress = "TestuserNOR" + i + "@testuser.com", IsEmailConfirmed = true, ShouldChangePasswordOnNextLogin = false, IsActive = true, Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe }; if (i % 2 == 0) { testUser.Gender = Model.Common.MySolutionEnums.GenderType.Man; testUser.BirthYear = 1972; } if (i % 4 == 0) { testUser.CityId = 2; testUser.BirthYear = 1988; } testUser.SetNormalizedNames(); testUserNOR = _context.Users.Add(testUser).Entity; _context.SaveChanges(); _context.UserRoles.Add(new UserRole(null, testUserNOR.Id, userRoleForUser.Id)); _context.SaveChanges(); //User account of test user _context.UserAccounts.Add(new UserAccount { TenantId = 1, UserId = testUserNOR.Id, UserName = testUserNOR.UserName, EmailAddress = testUserNOR.EmailAddress }); _context.SaveChanges(); } } } int testUsers_US = 2000; var testUserUS1 = _context.Users.FirstOrDefault(u => u.TenantId == 1 && u.UserName == "[email protected]"); if (testUserUS1 == null) { for (int i = 1; i < testUsers_US; i++) { var testUserName = "TestuserUS" + i + "@testuser.com"; var testUserUS = _context.Users.FirstOrDefault(u => u.TenantId == null && u.UserName == testUserName); if (testUserUS == null) { var testUser = new User { //UserId = Guid.NewGuid(), TenantId = 1, UserName = "TestuserUS" + i + "@testuser.com", Name = "TestUS" + i.ToString(), Surname = "UserUS" + i.ToString(), EmailAddress = "TestuserUS" + i + "@testuser.com", CountryId = 1, AreaId = 32, CityId = 15, BirthYear = 1979, Gender = Model.Common.MySolutionEnums.GenderType.Woman, IsEmailConfirmed = true, ShouldChangePasswordOnNextLogin = false, IsActive = true, Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe }; if (i % 2 == 0) { testUser.Gender = Model.Common.MySolutionEnums.GenderType.Man; testUser.BirthYear = 1982; } if (i % 6 == 0) { testUser.CityId = 16; testUser.AreaId = 5; testUser.BirthYear = 1967; } testUser.SetNormalizedNames(); testUserUS = _context.Users.Add(testUser).Entity; _context.SaveChanges(); //User account of test user _context.UserAccounts.Add(new UserAccount { TenantId = 1, UserId = testUserUS.Id, UserName = testUserUS.UserName, EmailAddress = testUserUS.EmailAddress }); _context.SaveChanges(); } } } var userRoleForCustomer = _context.Roles.FirstOrDefault(r => r.TenantId == 1 && r.Name == StaticRoleNames.Tenants.CustomerContact); if (userRoleForCustomer == null) { userRoleForCustomer = _context.Roles.Add(new Role(1, StaticRoleNames.Tenants.CustomerContact, StaticRoleNames.Tenants.CustomerContact) { IsStatic = true, IsDefault = false }).Entity; _context.SaveChanges(); } }