all tests run at trace log level with a null log output; new tests for watchdog,...
[scpubgit/Object-Remote.git] / t / watchdog.t
diff --git a/t/watchdog.t b/t/watchdog.t
new file mode 100644 (file)
index 0000000..c7e2c1f
--- /dev/null
@@ -0,0 +1,45 @@
+use strictures 1;
+use Test::More;
+
+require 't/logsetup.pl';
+
+use Object::Remote::Connection;
+use Object::Remote::FromData; 
+
+$SIG{ALRM} = sub {  fail("Watchdog killed remote process in time"); die "test failed" };
+
+my $conn = Object::Remote::Connection->conn_from_spec("-", watchdog_timeout => 1)->connect;
+
+my $remote = HangClass->new::on($conn);
+
+isa_ok($remote, 'Object::Remote::Proxy');
+is($remote->alive, 1, "Hanging test object is running");
+
+alarm(3);
+
+eval { $remote->hang };
+
+like($@, qr/^Object::Remote connection lost: eof/, "Correct error message"); 
+
+done_testing; 
+
+__DATA__
+
+package HangClass;
+
+use Moo;
+
+sub alive {
+    return 1; 
+}
+
+sub hang {
+    while(1) {
+        sleep(1); 
+    }
+}
+
+
+
+
+