From 8136d05331d3c66590fbfeb46bea9077fb5d6416 Mon Sep 17 00:00:00 2001 From: Christina Date: Tue, 26 Mar 2024 14:22:30 +0100 Subject: [PATCH] min_followers spec --- spec/replication_spec.cr | 41 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/spec/replication_spec.cr b/spec/replication_spec.cr index 1bb2cd4522..d11c90d635 100644 --- a/spec/replication_spec.cr +++ b/spec/replication_spec.cr @@ -82,7 +82,20 @@ describe LavinMQ::Replication::Server do LavinMQ::Config.instance.min_followers = 0 end - it "+min_followers" do + it "should publish when min_followers is fulfilled" do + q = Server.vhosts["/"].queues["repli"].as(LavinMQ::Queue) + repli = LavinMQ::Replication::Client.new(data_dir) + spawn do + repli.follow("127.0.0.1", LavinMQ::Config.instance.replication_port) + end + with_channel do |ch| + ch.basic_publish "hello world", "", "repli" + end + q.basic_get(true) { }.should be_true + repli.close + end + + it "should not publish when min_followers is not fulfilled" do done = Channel(Nil).new client : AMQP::Client::Connection? = nil spawn do @@ -95,34 +108,10 @@ describe LavinMQ::Replication::Server do end select when done.receive - fail "should not receive message" + fail "Should not receive message" when timeout(0.1.seconds) - pp "timeout" client.try &.close(no_wait: true) Server.close end - - # q = Server.vhosts["/"].queues["repli"].as(LavinMQ::Queue) - # q.basic_get(true) { }.should be_false - - # repli = LavinMQ::Replication::Client.new(data_dir) - # spawn do - # repli.follow("127.0.0.1", LavinMQ::Config.instance.replication_port) - # end - # with_channel do |ch| - # ch.basic_publish "hello world", "", "repli" - # end - # q = Server.vhosts["/"].queues["repli"].as(LavinMQ::Queue) - # q.basic_get(true) { }.should be_true - - # repli.close - end - - it "-min_followers" do - end - - it "+max_lag" do - end - it "-max_lag" do end end