Bench Funckload

This commit is contained in:
Quentin Rouland 2016-12-11 01:10:26 +01:00
parent b36df03f9a
commit ec212b3ab9
3 changed files with 116 additions and 0 deletions

2
Bench/README.md Normal file
View File

@ -0,0 +1,2 @@
= Bench =
Bench utilisant funkload : http://funkload.nuxeo.org/

55
Bench/bench.conf Normal file
View File

@ -0,0 +1,55 @@
# main section for the test case
[main]
title=Bench MovieRecommender
description=Bench MovieRecommender
url=http://localhost:8080/MovieRecommender
# a section for each test
[test_movies]
description=Access to movies
id_user_start=1
id_user_end=1000
[test_ratings]
description=Access to ratings
id_user_start=1
id_user_end=1000
[test_ratings_update]
description=Update ratings
id_user=23
id_movies_rating_start=100
id_movies_rating_end=1000
[test_recommendations_v1]
description=Access to test_recommendations_v1
id_user_start=0
id_user_end=100
[test_recommendations_v2]
description=Access to test_recommendations_v2
id_user_start=0
id_user_end=100
[test_recommendations_v3]
description=Access to test_recommendations_v3
id_user_start=0
id_user_end=100
# a section to configure the test mode
[ftest]
log_to = console file
log_path = log/bench.log
result_path = result/bench.xml
sleep_time_min = 0
sleep_time_max = 0
# a section to configure the bench mode
[bench]
cycles = 10:20:40:60
duration = 10
startup_delay = 0.01
sleep_time = 0.01
cycle_time = 1
sleep_time_min = 0
sleep_time_max = 0.5

59
Bench/bench.py Normal file
View File

@ -0,0 +1,59 @@
import unittest
from random import randint
from funkload.FunkLoadTestCase import FunkLoadTestCase
class bench(FunkLoadTestCase):
def setUp(self):
self.server_url = self.conf_get('main', 'url')
def test_movies(self):
server_url = self.server_url
id_user_start = self.conf_getInt('test_movies', 'id_user_start')
id_user_end = self.conf_getInt('test_movies', 'id_user_end')
for i in range(id_user_start,id_user_end+1):
self.get(server_url+"/recommendations?user_id="+str(i), description='Get Movies')
def test_ratings(self):
server_url = self.server_url
id_user_start = self.conf_getInt('test_ratings', 'id_user_start')
id_user_end = self.conf_getInt('test_ratings', 'id_user_end')
for i in range(id_user_start,id_user_end+1):
self.get(server_url+"/movieratings?user_id="+str(i), description='Get Rating')
def test_ratings_update(self):
server_url = self.server_url
id_user = self.conf_getInt('test_ratings_update', 'id_user')
id_movies_rating_start = self.conf_getInt('test_ratings_update', 'id_movies_rating_start')
id_movies_rating_stop = self.conf_getInt('test_ratings_update', 'id_movies_rating_stop')
for i in range(id_movies_rating_start,id_movies_rating_stop+1):
self.post(server_url+"/movieratings?user_id="+str(id_user),
params=[
['score', str(randint(0,5))],
],
description='Update Rating')
def test_recommendations_v1(self):
server_url = self.server_url
id_user_start = self.conf_getInt('test_recommendations_v1', 'id_user_start')
id_user_end = self.conf_getInt('test_recommendations_v1', 'id_user_end')
for i in range(id_user_start,id_user_end+1):
self.get(server_url+"/recommendations?user_id="+str(i)+"&?processing_mode=1", description='Get Recommendations v1')
def test_recommendations_v2(self):
server_url = self.server_url
id_user_start = self.conf_getInt('test_recommendations_v2', 'id_user_start')
id_user_end = self.conf_getInt('test_recommendations_v2', 'id_user_end')
for i in range(id_user_start,id_user_end+1):
self.get(server_url+"/recommendations?user_id="+str(i)+"&?processing_mode=2", description='Get Recommendations v2')
def test_recommendations_v3(self):
server_url = self.server_url
id_user_start = self.conf_getInt('test_recommendations_v3', 'id_user_start')
id_user_end = self.conf_getInt('test_recommendations_v3', 'id_user_end')
for i in range(id_user_start,id_user_end+1):
self.get(server_url+"/recommendations?user_id="+str(i)+"&?processing_mode=3", description='Get Recommendations v3')
if __name__ in ('main', '__main__'):
unittest.main()