Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c6ee326
Showing
9 changed files
with
1,224 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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()!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
Oops, something went wrong.