Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add failure detector specs

From node-gossip
  • Loading branch information...
commit 17e1aa5088777a794785eb30ec7f50cdb85c30b5 1 parent f749de8
Grant Rodgers authored
35  spec/dcell-gossip/failure_detector_spec.rb
... ...
@@ -0,0 +1,35 @@
  1
+require 'spec_helper'
  2
+
  3
+describe DCell::Gossip::FailureDetector do
  4
+  it 'should have a low phi value after only a second' do
  5
+    time = 0
  6
+    0.upto(100) do |i|
  7
+      time += 1000
  8
+      subject.add(time)
  9
+    end
  10
+
  11
+    subject.phi(time + 1000).should be < 0.5
  12
+  end
  13
+
  14
+  it 'should have a high phi value after ten seconds' do
  15
+    time = 0
  16
+    0.upto(100) do |i|
  17
+      time += 1000
  18
+      subject.add(time)
  19
+    end
  20
+
  21
+    subject.phi(time + 10000).should be > 4
  22
+
  23
+  end
  24
+
  25
+  it 'should only keep last 1000 values' do
  26
+    time = 0
  27
+    0.upto(2000) do |i|
  28
+      time += 1000
  29
+      subject.add(time)
  30
+    end
  31
+
  32
+    subject.intervals.size.should == 1000
  33
+  end
  34
+
  35
+end

0 notes on commit 17e1aa5

Please sign in to comment.
Something went wrong with that request. Please try again.