Sha256: f4f8687439452a926df536fb7d8f5ac837f9ecc79f3df0cef6efe3d99de0b28f

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

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

require 'drbqs/task_client'

describe DRbQS::TaskClient do
  before(:all) do
    @node_id = 4
    @ts_queue = Rinda::TupleSpace.new
    @ts_result = Rinda::TupleSpace.new
    @task_client = DRbQS::TaskClient.new(@node_id, @ts_queue, @ts_result)
    @task_example = [[1, 2, 3], :size, []]
    @task_id = 10
  end

  it "should be empty" do
    @task_client.task_empty?.should be_true
    @task_client.result_empty?.should be_true
    @task_client.calculating_task.should be_nil
  end

  it "should queue a task" do
    @ts_queue.write([@task_id] + @task_example)
    @task_client.add_new_task
    @task_client.task_empty?.should_not be_true
    @task_client.result_empty?.should be_true
    @task_client.calculating_task.should == @task_id
    @ts_queue.read_all([nil, nil, nil, nil]).size.should == 0
    @ts_result.take([:accept, nil, nil], 0).should be_true
  end

  it "should dequeue a task" do
    ary = @task_client.dequeue_task
    ary.should == @task_example
    @task_client.task_empty?.should be_true
    @task_client.result_empty?.should be_true
    @task_client.calculating_task.should == @task_id
  end

  it "should queue result" do
    @task_client.queue_result(@task_example[0].__send__(@task_example[1], *@task_example[2]))
    @task_client.task_empty?.should be_true
    @task_client.result_empty?.should_not be_true
    @task_client.calculating_task.should == @task_id
  end

  it "should send result" do
    @task_client.send_result
    @task_client.task_empty?.should be_true
    @task_client.result_empty?.should be_true
    @task_client.calculating_task.should be_nil
    @ts_result.take([:result, nil, nil], 0).should be_true
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
drbqs-0.0.9 spec/task_client_spec.rb
drbqs-0.0.8 spec/task_client_spec.rb
drbqs-0.0.7 spec/task_client_spec.rb
drbqs-0.0.6 spec/task_client_spec.rb