alias :pputs :puts def puts(*x) if "#{x}"=~/.*NoMethod.*/ raise "MUH" end pputs *x end alias :ppp :pp def pp(*x) if "#{x}"=~/.*NoMethod.*/ raise "MUH" end ppp *x end describe "UDP Network" do it "should offer itself over network discovery" do b=TestBed.new ["NetworkDiscovery","NetworkDiscoveryUdp","UdpNetwork"].each{|n|b.run(n)} sleep 2 dis=b.getApp(:networkDiscovery) pp dis.get dis.get.should == [b.getApp(:fullNetworkNode).me] b.stop end it "should connect to another node" do b1=TestBed.new b2=TestBed.new ["UdpNetwork"].each{|n| b1.run(n) b2.run(n) } n1=b1.getApp(:fullNetworkNode) n2=b2.getApp(:fullNetworkNode) sleep 5 pp b1.getApp(:networkDiscovery).get pp b2.getApp(:networkDiscovery).get b2.getApp(:networkDiscovery).get.sort.should == [n1.me,n2.me].sort b1.getApp(:networkDiscovery).get.sort.should == [n1.me,n2.me].sort b1.stop b2.stop end it "should provide some functions for spreading udp-node-information" do b1=TestBed.new b2=TestBed.new b3=TestBed.new [b1,b2,b3].each{|b| b.run("NetworkDiscovery",{:discovery=>[:networkDiscoveryLocalstore]}) } n1=b1.run("UdpNetwork") n2=b2.run("UdpNetwork") n3=b3.run("UdpNetwork") store=b2.getApp(:networkDiscoveryLocalstore) store.add(n1.me) store.add(n3.me) sleep UdpNetworkApp::SPREADING_INTERVAL*2 all=[n1,n2,n3].map{|n|n.me}.sort n2.knownNodes.sort.should == all n1.knownNodes.sort.should == all n3.knownNodes.sort.should == all end it "should provide a framework for running remote apps" do b1=TestBed.new b2=TestBed.new ["NodeBroadcast","NetworkDiscoveryUdp","NetworkDiscovery","UdpNetwork"].each{|n| b1.run(n) b2.run(n) } sleep 3 n1=b1.getApp(:fullNetworkNode).api n2=b2.getApp(:fullNetworkNode).api service1=n1.hook("test1"){|arg| arg.should == "test1Arg" "testRet" } service2=n2.hook("test1"){|arg| arg.should == "test1Arg" "testRet2" } measureTime { n2.send(n1.me,"test1","test1Arg").wait.should == "testRet" } measureTime { service1.send(n2.me,"test1Arg").wait.should == "testRet2" } b1.stop b2.stop end end