Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
vivin committed May 25, 2011
0 parents commit c6ee326
Show file tree
Hide file tree
Showing 9 changed files with 1,224 additions and 0 deletions.
675 changes: 675 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README
@@ -0,0 +1,2 @@
Torqueo is a framework for Grinder that makes performance testing easier by facilitating the creation of reusable tasks and scenarios.
Torqueo is distributed under the GPLv3 license.
Empty file added torqueo/__init__.py
Empty file.
Empty file added torqueo/test/__init__.py
Empty file.
63 changes: 63 additions & 0 deletions torqueo/test/framework/Scenario.py
@@ -0,0 +1,63 @@
# Scenario.py: Scenario class in the torqueo framework.
# Copyright (C) 2009 Vivin Suresh Paliath
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import warnings

class Scenario:
def __init__(self, description, urlDict):
if(len(urlDict.keys()) == 0):
raise Exception("Cannot set " + self.__class__.__name__ + ".urlDict to an empty dictionary.")
else:
self.description = description
self.urlDict = urlDict
self.tasks = []

def addTask(self, task):
if(hasattr(task, "setUrlDict")):
task.setUrlDict(self.urlDict)
else:
raise Exception(task.__class__.__name__ + " does not implement setUrlDict()!")

if(hasattr(task, "initializeTask")):
task.initializeTask()
else:
raise Exception(task.__class__.__name__ + " does not implement initializeTask()!")

if(hasattr(task, "run")):
self.tasks.append(task)
else:
raise Exception(task.__class__.__name__ + " does not implement run()!")

def setUrlDict(self, url):
warnings.warn("Scenario.urlDict is a read-only property that can only be initialized in the constructor.")

def getUrlDict(self):
return self.urlDict

def setUrl(self, key, value):
warnings.warn("Cannot modify Scenario.urlDict because it is a read-only property")

def getUrl(self, key):
return self.urlDict[key]

urlDict = property(getUrlDict, setUrlDict)

def run(self):
for task in self.tasks:
if(hasattr(task, "run")):
task.run()
else:
raise Exception(task.__class__.__name__ + " does not implement run()!")
63 changes: 63 additions & 0 deletions torqueo/test/framework/Task.py
@@ -0,0 +1,63 @@
# Task.py: Base class for all Tasks
# Copyright (C) 2009 Vivin Suresh Paliath
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Base class for all Tasks.

class Task:

numberOfTasks = 0;

def __init__(self):
"""Initialize properties of class"""
self.urlDict = {}
self.parameterizingMethods = {}
Task.numberOfTasks += 1

def setUrlDict(self, urlDict):
"""Setter for urlDict property"""
self.urlDict = urlDict

def getUrlDict(self, urlDict):
"""Getter for urlDict property"""
return self.urlDict

def setUrl(self, key, value):
"""Sets value to 'value' of particular url in URL dict identified by key 'key'"""
self.urlDict[key] = value

def getUrl(self, key):
"""Returns value of particular url in URL dict identified by key 'key'"""
return self.urlDict[key]

def callParameterizingMethodFor(self, key):
"""Calls parameterizing method associated with page identified by key 'key'"""
if(self.parameterizingMethods.has_key(key)):
self.parameterizingMethods[key]()

def setParameterizingMethodFor(self, key, value):
"""Sets parameterizing method associated with page identified by key 'key' to method in 'value'"""
self.parameterizingMethods[key] = value

def getParameterizingMethodFor(self, key):
"""Returns the parameterizing method associated with page identified by key 'key'"""
return self.parameterizingMethods[key]

def instrumentMethod(self, test, method_name):
"""Instrument a method with the given Test."""
unadorned = getattr(self.__class__, method_name)
import new
method = new.instancemethod(test.wrap(unadorned), None, self.__class__)
setattr(self.__class__, method_name, method)
Empty file.
Empty file added torqueo/test/tasks/__init__.py
Empty file.

0 comments on commit c6ee326

Please sign in to comment.