diff --git a/Bench/README.md b/Bench/README.md new file mode 100644 index 0000000..9f7d313 --- /dev/null +++ b/Bench/README.md @@ -0,0 +1,2 @@ += Bench = +Bench utilisant funkload : http://funkload.nuxeo.org/ diff --git a/Bench/bench.conf b/Bench/bench.conf new file mode 100644 index 0000000..6fbd9ce --- /dev/null +++ b/Bench/bench.conf @@ -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 diff --git a/Bench/bench.py b/Bench/bench.py new file mode 100644 index 0000000..60994a5 --- /dev/null +++ b/Bench/bench.py @@ -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()