Permalink
Browse files

added stacks support, tests,docs

  • Loading branch information...
1 parent ab90668 commit bb579319c447a404a139dd28c2290d89005adaae @rkononov rkononov committed Mar 7, 2014
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- iron_worker_ng (1.3.0)
+ iron_worker_ng (1.3.1)
bundler
iron_core (>= 1.0.0)
rubyzip (= 0.9.9)
View
@@ -411,6 +411,25 @@ for as many tasks as you want.
client.tasks.create('MyWorker', {:client => 'Joe'})
```
+# Stacks
+Stack is a docker image based on ubuntu + some custom software(ruby/python/mono/java...)
+You can use different stacks to launch your tasks.
+To get list of available stacks you could do:
+
+```ruby
+client.stacks_list
+```
+And to specify stack add following line in your .worker file
+
+```ruby
+# define the runtime language, this can be ruby, java, node, php, go, etc.
+runtime 'binary'
+stack 'java-1.7'
+exec 'java.sh'
+```
+
+
+
# The Rest of the IronWorker API
## IronWorker::Client
@@ -30,6 +30,10 @@ def base_url
super + @api_version.to_s + '/'
end
+ def stacks_list
+ parse_response(get("stacks"))
+ end
+
def codes_list(options = {})
parse_response(get("projects/#{@project_id}/codes", options))
end
@@ -53,6 +53,11 @@ def method_missing(name, *args, &block)
end
end
+ def stacks_list
+ @api.stacks_list
+ end
+
+
def codes_list(options = {})
IronCore::Logger.debug 'IronWorkerNG', "Calling codes.list with options='#{options.to_s}'"
View
@@ -22,7 +22,7 @@ Rake::TestTask.new do |t|
t.libs << "lib"
- files = FileList['test/**/test_**.rb']
+ files = FileList['test/**/test_stacks.rb']
t.test_files = files.keep_if do |f|
f =~ Regexp.new(ENV['TESTP'] || '') and
not ( r = ENV['EXCLP'] and
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'java-1.7'
+exec 'java.sh'
@@ -0,0 +1 @@
+java -version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'mono-2.10'
+exec 'mono.sh'
@@ -0,0 +1 @@
+mono --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'mono-3.0'
+exec 'mono3.sh'
@@ -0,0 +1 @@
+mono --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'node-0.10'
+exec 'node.sh'
@@ -0,0 +1 @@
+node --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'php-5.4'
+exec 'php.sh'
@@ -0,0 +1 @@
+php --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'python-2.7'
+exec 'python2.sh'
@@ -0,0 +1 @@
+python --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'python-3.2'
+exec 'python3.sh'
@@ -0,0 +1 @@
+python3 --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'ruby-1.9'
+exec 'ruby1.9.sh'
@@ -0,0 +1 @@
+ruby --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'ruby-2.1'
+exec 'ruby2.1.sh'
@@ -0,0 +1 @@
+ruby --version
@@ -0,0 +1,3 @@
+runtime 'binary'
+stack 'scala-2.9'
+exec 'scala.sh'
@@ -0,0 +1,2 @@
+scala -version
+printenv
View
@@ -0,0 +1,29 @@
+require_relative 'helpers'
+
+class CodeCreateTest < IWNGTest
+
+ def test_create
+ stacks_list = client.stacks_list
+ assert stacks_list.is_a? Array
+ assert stacks_list.count > 0
+ assert stacks_list.include? 'python-2.7'
+ end
+
+ def test_wrong_stack
+ code = code_bundle(:exec => 'test/hello.rb',:name => 'sample')
+ code.stack('none')
+ assert_raise Rest::Wrappers::RestClientExceptionWrapper do
+ client.codes_create code
+ end
+ end
+
+ def test_stacks
+ client.stacks_list.each do |stack|
+ client.codes.create(IronWorkerNG::Code::Base.new("test/stacks/#{stack}/#{stack}"))
+ id = client.tasks.create(stack).id
+ task = client.tasks.wait_for(id)
+ assert_equal 'complete', task.status
+ end
+ end
+
+end

0 comments on commit bb57931

Please sign in to comment.