Sha256: e16a54f8add28c1544140a32423d87d9f057bdf729997d5bff244e02fdd1fe1a

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'test/unit'
require 'yaml'
require File.join(File.dirname(__FILE__), '../lib/simple_worker')

class SimpleWorkerTests < Test::Unit::TestCase

    def setup
        @config = YAML::load(File.open(File.expand_path("~/.test-configs/simple_worker.yml")))
        #puts @config.inspect
        @access_key = @config['simple_worker']['access_key']
        @secret_key = @config['simple_worker']['secret_key']
    end

    def teardown

    end

    def test_queue

        worker = SimpleWorker::Service.new(@access_key, @secret_key)

        # Upload latest runner code
        worker.upload(File.join(File.dirname(__FILE__), "./test_runner.rb"), "TestRunner")

        # Add something to queue, get task ID back
        # Single task
        response_hash = worker.queue("TestRunner", {"s3_key"=>"single runner", "times"=>10})
        # task set
        response_hash = worker.queue("TestRunner", [{"id"=>"local_id", "s3_key"=>"some key", "times"=>4}, {"s3_key"=>"some key2", "times"=>3}, {"s3_key"=>"some key", "times"=>2}])

        # Check status
        tasks = response_hash["tasks"]
        while tasks.size > 0
            tasks.each do |t|
                status_response = worker.status(t["task_id"])
                puts 'status for ' + t["task_id"] + ' = ' + status_response["status"]
                if status_response["status"] == "complete"
                    tasks.delete(t)
                end
            end
        end


    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_worker-0.0.13 test/simple_worker_tests.rb