Sha256: 2eda238b4e97619ab42f726f708094d28d2faafa87e545b8e98211a400d57375

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

# -*- encoding : utf-8 -*-
require File.dirname(__FILE__) + '/../spec_helper'

describe "#update_config" do
  before :each do
    @cfg = C.p3.merge(:checks => join(C.check_mem, C.check_cpu), :monitor_children => {})    
    start_ok_process(@cfg)
    sleep 6
  end

  after :each do
    @process.stop if @process
  end

  it "update only env" do
    @process.watchers.keys.should == [:check_alive, :check_childs, :check_memory, :check_cpu]
    @process.childs.keys.size.should == 3
    child_pids = @process.childs.keys
    @process[:environment].should == {"ENV1" => "SUPER"}

    @process.update_config(@cfg.merge(:environment => {"ENV2" => "SUPER"}))
    sleep 5

    @process.state_name.should == :up
    @process.watchers.keys.should == [:check_alive, :check_childs, :check_memory, :check_cpu]
    @process.childs.keys.size.should == 3
    @process.childs.keys.should == child_pids
    @process[:environment].should == {"ENV2" => "SUPER"}
    @process.pid.should == @pid
  end

  it "update watchers" do
    @process.watchers.keys.should == [:check_alive, :check_childs, :check_memory, :check_cpu]
    @process.childs.keys.size.should == 3
    child_pids = @process.childs.keys

    @process.update_config(@cfg.merge(:checks => C.check_mem))
    sleep 5

    @process.state_name.should == :up
    @process.watchers.keys.should == [:check_alive, :check_childs, :check_memory]
    @process.childs.keys.size.should == 3
    @process.childs.keys.should == child_pids
    @process.pid.should == @pid
  end

  it "when disable monitor_children they should remove" do
    @process.watchers.keys.should == [:check_alive, :check_childs, :check_memory, :check_cpu]
    @process.childs.keys.size.should == 3
    child_pids = @process.childs.keys

    @process.update_config(@cfg.merge(:monitor_children => nil))
    sleep 5

    @process.state_name.should == :up
    @process.watchers.keys.should == [:check_alive, :check_memory, :check_cpu]
    @process.childs.keys.size.should == 0
    @process.pid.should == @pid
  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eye-0.1.11 spec/process/update_config_spec.rb