Sha256: 1bc5e18d19fbed957807c095677f0775c2f9c19f7d21a8f1495279f6b3af65d2

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

require 'drbqs/task/task'
require_relative 'definition/task_obj_definition.rb'

describe DRbQS do
  before(:all) do
    @dir = 'test_pid_dir'
    FileUtils.mkdir(@dir) unless File.exist?(@dir)
    @number_of_task = 10
    @tasks = @number_of_task.times.map do |i|
      DRbQS::Task.new(TestPID.new, :save, args: [@dir])
    end
    @process_number = 3
    @process_id, @uri = drbqs_fork_server(14120, :task => @tasks)
    @node = DRbQS::Node.new(@uri, :log_file => $stdout, :process => @process_number)
  end

  it "should calculate" do
    @node.connect
    lambda do
      @node.calculate
    end.should_not raise_error
    paths = Dir.glob(File.join(@dir, '*')).select do |file|
      /^\d+$/ =~ File.basename(file)
    end
    paths.uniq.should have(@process_number).items
    n = 0
    paths.each do |path|
      n += File.read(path).to_i
    end
    n.should == @number_of_task
  end

  after(:all) do
    TestCount.clear
    lambda do
      drbqs_wait_kill_server(@process_id)
    end.should_not raise_error
    FileUtils.rm_r(@dir) if File.exist?(@dir)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
drbqs-0.1.1 spec/integration_test/12_multiple_workers_spec.rb
drbqs-0.1.0 spec/integration_test/12_multiple_workers_spec.rb
drbqs-0.0.19 spec/integration_test/12_multiple_workers_spec.rb