save the observer logs to /tmp when test framework runs
diff --git a/xos/tosca/tests/observerComputeTest.py b/xos/tosca/tests/observerComputeTest.py
index 144f8cb..0a803be 100644
--- a/xos/tosca/tests/observerComputeTest.py
+++ b/xos/tosca/tests/observerComputeTest.py
@@ -29,17 +29,17 @@
instance = self.assert_obj(Instance, "test_compute1")
assert(instance.flavor.name == "m1.small")
- self.run_model_policy()
+ self.run_model_policy(save_output="/tmp/instancetest:create_instance:model_policy")
# first observer pass should make any necessary networks or ports
- self.run_observer()
+ self.run_observer(save_output="/tmp/instancetest:create_instance:observer_first")
# reset the exponential backoff
instance = self.assert_obj(Instance, "test_compute1")
instance.backend_register="{}"
# second observer pass should instantiate the instance
- self.run_observer()
+ self.run_observer(save_output="/tmp/instancetest:create_instance:observer_second")
instance = self.assert_obj(Instance, "test_compute1")
diff --git a/xos/tosca/tests/observerImageTest.py b/xos/tosca/tests/observerImageTest.py
index 65b2c69..3588b04 100644
--- a/xos/tosca/tests/observerImageTest.py
+++ b/xos/tosca/tests/observerImageTest.py
@@ -25,14 +25,14 @@
props={"path": "/tmp/testimg"}))
image = self.assert_obj(Image, "testimg")
- self.run_model_policy()
+ self.run_model_policy(save_output="/tmp/imagetest:create_image:model_policy")
# make sure a ControllerImages object was created
cims = ControllerImages.objects.filter(image=image)
assert(len(cims) == 1)
# first observer pass should make any necessary networks or ports
- self.run_observer()
+ self.run_observer(save_output="/tmp/imagetest:create_image:observer")
# reset the exponential backoff
image = self.assert_obj(Image, "testimg")
diff --git a/xos/tosca/tests/observertest.py b/xos/tosca/tests/observertest.py
index 687a9db..f714045 100644
--- a/xos/tosca/tests/observertest.py
+++ b/xos/tosca/tests/observertest.py
@@ -57,10 +57,14 @@
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
- #if not self.hide_observer_output:
- print self.logStream.getvalue()
+ if not self.hide_observer_output:
+ print self.logStream.getvalue()
- def run_model_policy(self):
+ def save_output(self, what, fn):
+ file(fn,"w").write(self.logStream.getvalue())
+ print >> sys.__stdout__," (%s log saved to %s)" % (what, fn)
+
+ def run_model_policy(self, save_output=None):
self.ensure_observer_not_running()
self.hide_output()
@@ -68,10 +72,12 @@
print ">>>>> run model_policies"
run_policy_once()
print ">>>>> done model_policies"
+ if save_output:
+ self.save_output("model_policy",save_output)
finally:
self.restore_output()
- def run_observer(self):
+ def run_observer(self, save_output=None):
self.ensure_observer_not_running()
self.log_to_memory()
@@ -81,6 +87,8 @@
observer = XOSObserver()
observer.run_once()
print ">>>>> done observer"
+ if save_output:
+ self.save_output("observer",save_output)
finally:
self.restore_output()