aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/availability/actionplayers.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios/availability/actionplayers.py')
-rw-r--r--yardstick/benchmark/scenarios/availability/actionplayers.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/yardstick/benchmark/scenarios/availability/actionplayers.py b/yardstick/benchmark/scenarios/availability/actionplayers.py
new file mode 100644
index 000000000..420626413
--- /dev/null
+++ b/yardstick/benchmark/scenarios/availability/actionplayers.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2016 Juan Qiu and others
+# juan_ qiu@tongji.edu.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+class ActionPlayer(object):
+ """
+ Abstract the action functions of attacker,
+ monitor, operation, resultchecker and mybe others in future
+ """
+
+ def action(self):
+ pass
+
+
+class AttackerPlayer(ActionPlayer):
+
+ def __init__(self, attacker):
+ self.underlyingAttacker = attacker
+
+ def action(self):
+ self.underlyingAttacker.inject_fault()
+
+
+class OperationPlayer(ActionPlayer):
+
+ def __init__(self, operation):
+ self.underlyingOperation = operation
+
+ def action(self):
+ self.underlyingOperation.run()
+
+
+class MonitorPlayer(ActionPlayer):
+
+ def __init__(self, monitor):
+ self.underlyingmonitor = monitor
+
+ def action(self):
+ self.underlyingmonitor.start_monitor()
+
+
+class ResultCheckerPlayer(ActionPlayer):
+
+ def __init__(self, resultChecker):
+ self.underlyingresultChecker = resultChecker
+
+ def action(self):
+ self.underlyingresultChecker.verify()