mortar-api-ruby 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -1
- data/lib/mortar/api/jobs.rb +7 -3
- data/lib/mortar/api/version.rb +1 -1
- data/spec/mortar/api/jobs_spec.rb +37 -11
- metadata +4 -4
data/.travis.yml
CHANGED
data/lib/mortar/api/jobs.rb
CHANGED
@@ -46,6 +46,10 @@ module Mortar
|
|
46
46
|
STATUS_EXECUTION_ERROR,
|
47
47
|
STATUS_SERVICE_ERROR,
|
48
48
|
STATUS_STOPPED])
|
49
|
+
|
50
|
+
CLUSTER_TYPE__SINGLE_JOB = 'single_job'
|
51
|
+
CLUSTER_TYPE__PERSISTENT = 'persistent'
|
52
|
+
CLUSTER_TYPE__PERMANENT = 'permanent'
|
49
53
|
end
|
50
54
|
|
51
55
|
|
@@ -78,15 +82,15 @@ module Mortar
|
|
78
82
|
|
79
83
|
# POST /vX/jobs
|
80
84
|
def post_job_new_cluster(project_name, script_name, git_ref, cluster_size, options={})
|
81
|
-
|
85
|
+
cluster_type = options[:cluster_type].nil? ? Jobs::CLUSTER_TYPE__PERSISTENT : options[:cluster_type]
|
82
86
|
notify_on_job_finish = options[:notify_on_job_finish].nil? ? true : options[:notify_on_job_finish]
|
83
87
|
parameters = options[:parameters] || {}
|
84
88
|
is_control_script = options[:is_control_script] || false
|
85
|
-
|
89
|
+
|
86
90
|
body = { "project_name" => project_name,
|
87
91
|
"git_ref" => git_ref,
|
88
92
|
"cluster_size" => cluster_size,
|
89
|
-
"
|
93
|
+
"cluster_type" => cluster_type,
|
90
94
|
"parameters" => parameters,
|
91
95
|
"notify_on_job_finish" => notify_on_job_finish
|
92
96
|
}
|
data/lib/mortar/api/version.rb
CHANGED
@@ -28,7 +28,7 @@ describe Mortar::API do
|
|
28
28
|
after(:each) do
|
29
29
|
Excon.stubs.clear
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
context "jobs" do
|
33
33
|
it "posts a job for an existing cluster" do
|
34
34
|
job_id = "7b93e4d3ab034188a0c2be418d3d24ed"
|
@@ -51,16 +51,17 @@ describe Mortar::API do
|
|
51
51
|
response.body['job_id'].should == job_id
|
52
52
|
end
|
53
53
|
|
54
|
-
it "posts a job for a new cluster, defaulting to
|
54
|
+
it "posts a job for a new cluster, defaulting cluster_type to persistent" do
|
55
55
|
job_id = "7b93e4d3ab034188a0c2be418d3d24ed"
|
56
56
|
project_name = "my_project"
|
57
57
|
pigscript_name = "my_pigscript"
|
58
58
|
git_ref = "e20395b8b06fbf52e86665b0660209673f311d1a"
|
59
59
|
cluster_size = 5
|
60
|
+
cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__PERSISTENT
|
60
61
|
body = Mortar::API::OkJson.encode({"project_name" => project_name,
|
61
62
|
"git_ref" => git_ref,
|
62
63
|
"cluster_size" => cluster_size,
|
63
|
-
"
|
64
|
+
"cluster_type" => cluster_type,
|
64
65
|
"parameters" => {},
|
65
66
|
"notify_on_job_finish" => true,
|
66
67
|
"pigscript_name" => pigscript_name
|
@@ -78,10 +79,11 @@ describe Mortar::API do
|
|
78
79
|
pigscript_name = "my_pigscript"
|
79
80
|
git_ref = "e20395b8b06fbf52e86665b0660209673f311d1a"
|
80
81
|
cluster_size = 5
|
82
|
+
cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__PERSISTENT
|
81
83
|
body = Mortar::API::OkJson.encode({"project_name" => project_name,
|
82
84
|
"git_ref" => git_ref,
|
83
85
|
"cluster_size" => cluster_size,
|
84
|
-
"
|
86
|
+
"cluster_type" => cluster_type,
|
85
87
|
"parameters" => {},
|
86
88
|
"notify_on_job_finish" => true,
|
87
89
|
"pigscript_name" => pigscript_name
|
@@ -99,10 +101,11 @@ describe Mortar::API do
|
|
99
101
|
pigscript_name = "my_pigscript"
|
100
102
|
git_ref = "e20395b8b06fbf52e86665b0660209673f311d1a"
|
101
103
|
cluster_size = 5
|
104
|
+
cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__SINGLE_JOB
|
102
105
|
body = Mortar::API::OkJson.encode({"project_name" => project_name,
|
103
106
|
"git_ref" => git_ref,
|
104
107
|
"cluster_size" => cluster_size,
|
105
|
-
"
|
108
|
+
"cluster_type" => cluster_type,
|
106
109
|
"parameters" => {},
|
107
110
|
"notify_on_job_finish" => false,
|
108
111
|
"pigscript_name" => pigscript_name
|
@@ -110,31 +113,54 @@ describe Mortar::API do
|
|
110
113
|
Excon.stub({:method => :post, :path => "/v2/jobs", :body => body}) do |params|
|
111
114
|
{:body => Mortar::API::OkJson.encode({'job_id' => job_id}), :status => 200}
|
112
115
|
end
|
113
|
-
response = @api.post_job_new_cluster(project_name, pigscript_name, git_ref, cluster_size, :
|
116
|
+
response = @api.post_job_new_cluster(project_name, pigscript_name, git_ref, cluster_size, :cluster_type => cluster_type, :notify_on_job_finish => false)
|
114
117
|
response.body['job_id'].should == job_id
|
115
118
|
end
|
116
119
|
|
117
|
-
it "accepts
|
120
|
+
it "accepts cluster_type of single_job" do
|
118
121
|
job_id = "7b93e4d3ab034188a0c2be418d3d24ed"
|
119
122
|
project_name = "my_project"
|
120
123
|
pigscript_name = "my_pigscript"
|
121
124
|
git_ref = "e20395b8b06fbf52e86665b0660209673f311d1a"
|
122
125
|
cluster_size = 5
|
126
|
+
cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__SINGLE_JOB
|
123
127
|
body = Mortar::API::OkJson.encode({"project_name" => project_name,
|
124
128
|
"git_ref" => git_ref,
|
125
129
|
"cluster_size" => cluster_size,
|
126
|
-
"
|
130
|
+
"cluster_type" => cluster_type,
|
127
131
|
"parameters" => {},
|
128
132
|
"notify_on_job_finish" => true,
|
129
133
|
"pigscript_name" => pigscript_name
|
130
|
-
})
|
134
|
+
})
|
131
135
|
Excon.stub({:method => :post, :path => "/v2/jobs", :body => body}) do |params|
|
132
136
|
{:body => Mortar::API::OkJson.encode({'job_id' => job_id}), :status => 200}
|
133
137
|
end
|
134
|
-
response = @api.post_job_new_cluster(project_name, pigscript_name, git_ref, cluster_size, :
|
138
|
+
response = @api.post_job_new_cluster(project_name, pigscript_name, git_ref, cluster_size, :cluster_type => cluster_type)
|
135
139
|
response.body['job_id'].should == job_id
|
136
140
|
end
|
137
|
-
|
141
|
+
|
142
|
+
it "accepts cluster_type of permanent" do
|
143
|
+
job_id = "7b93e4d3ab034188a0c2be418d3d24ed"
|
144
|
+
project_name = "my_project"
|
145
|
+
pigscript_name = "my_pigscript"
|
146
|
+
git_ref = "e20395b8b06fbf52e86665b0660209673f311d1a"
|
147
|
+
cluster_size = 5
|
148
|
+
cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__PERMANENT
|
149
|
+
body = Mortar::API::OkJson.encode({"project_name" => project_name,
|
150
|
+
"git_ref" => git_ref,
|
151
|
+
"cluster_size" => cluster_size,
|
152
|
+
"cluster_type" => cluster_type,
|
153
|
+
"parameters" => {},
|
154
|
+
"notify_on_job_finish" => true,
|
155
|
+
"pigscript_name" => pigscript_name
|
156
|
+
})
|
157
|
+
Excon.stub({:method => :post, :path => "/v2/jobs", :body => body}) do |params|
|
158
|
+
{:body => Mortar::API::OkJson.encode({'job_id' => job_id}), :status => 200}
|
159
|
+
end
|
160
|
+
response = @api.post_job_new_cluster(project_name, pigscript_name, git_ref, cluster_size, :cluster_type => cluster_type)
|
161
|
+
response.body['job_id'].should == job_id
|
162
|
+
end
|
163
|
+
|
138
164
|
it "gets a job" do
|
139
165
|
job_id = "7b93e4d3ab034188a0c2be418d3d24ed"
|
140
166
|
status = Mortar::API::Jobs::STATUS_RUNNING
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortar-api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mortar Data
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-03-
|
18
|
+
date: 2013-03-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: excon
|