Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
from locust import HttpLocust, TaskSet, task
import logging, sys
from credentials import *
from locust import HttpUser, TaskSet, task, between

class LoginWithUniqueUsersSteps(TaskSet):
email = "NOT_FOUND"
password = "NOT_FOUND"

def on_start(self):
if len(USER_CREDENTIALS) > 0:
self.email, self.password = USER_CREDENTIALS.pop()
class QuickstartUser(HttpUser):
wait_time = between(1, 2)
host = "http://www.microsoft.com"

@task
def login(self):
self.client.post("/login", {
'email': self.email, 'passowrd': self.password
})
logging.info('Login with %s email and %s password', self.email, self.password)
def main_page(self):
self.client.get("/")
#print("task created.")

print("login by: ", self.email, " password: ", self.password )
self.stop()

class LoginWithUniqueUsersTest(HttpLocust):
task_set = LoginWithUniqueUsersSteps
host = "http://blazedemo.com"
sock = None

def __init__(self):
super(LoginWithUniqueUsersTest, self).__init__()
def on_start(self):
#print("Job started")
if len(USER_CREDENTIALS) > 0:
self.email, self.password = USER_CREDENTIALS.pop()
else:
self.email = "NO_MORE_USER"
self.password = "N/A"
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
from locust import HttpLocust, TaskSet, task
import time
import random
import logging, sys
import csv
from locust import HttpUser, TaskSet, task, between

# Global variable to load test data from csv
USER_CREDENTIALS = None

class LoginWithUniqueUsersSteps(TaskSet):
email = "NOT_FOUND"
password = "NOT_FOUND"

def on_start(self):
if len(USER_CREDENTIALS) > 0:
self.email, self.password = USER_CREDENTIALS.pop()
class QuickstartUser(HttpUser):
wait_time = between(1, 2)
host = "http://www.microsoft.com"

@task
def login(self):
self.client.post("/login", {
'email': self.email, 'passowrd': self.password
})
logging.info('Login with %s email and %s password', self.email, self.password)

class LoginWithUniqueUsersTest(HttpLocust):
task_set = LoginWithUniqueUsersSteps
host = "http://blazedemo.com"
sock = None
def main_page(self):
self.client.get("/")

# Check Mobile number to use for login
if (self.mobile == "NO_MORE_USER"):
print("NO MORE MOBILE")
else:
print("Mobile number: ", self.mobile, " otp: ", self.otp )
self.stop()

def __init__(self):
super(LoginWithUniqueUsersTest, self).__init__()
def on_start(self):
global USER_CREDENTIALS

# Load test data from csv file
if (USER_CREDENTIALS == None):
with open('credentials.csv', 'rb') as f:
print("open file")
with open('credentials.csv', 'r') as f:
reader = csv.reader(f)
USER_CREDENTIALS = list(reader)

# Load top record from dataset and mark for processed
if len(USER_CREDENTIALS) > 0:
self.mobile, self.otp = USER_CREDENTIALS.pop()
else:
self.mobile = "NO_MORE_MOBILE"
self.otp = "N/A"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LocustPerformanceUser5@gmail.com,5678901
LocustPerformanceUser4@gmail.com,456789
LocustPerformanceUser3@gmail.com,345678
LocustPerformanceUser2@gmail.com,234567
LocustPerformanceUser1@gmail.com,123456
081-xxx-2332,5678901
081-xxx-8767,456789
081-xxx-3412,345678
081-xxx-1122,234567
081-xxx-7383,123456