azkaban_scheduler 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb696acb2c67ae0e468b3289302b4066dea786a9
4
- data.tar.gz: c9be59214ff6f278d726a8475143634c85fe4734
3
+ metadata.gz: 216f4849fc6fb0872518fad1ac43cf3e52664ea3
4
+ data.tar.gz: dc26f9aa61b535052274717ff53ae2def7e54920
5
5
  SHA512:
6
- metadata.gz: a700b32c8abb25fe772212a55f6a568deb46cb1399e7da86c5fc2a52bad57b712da93e249ae411abed96c9e14eed8a4cc0b14f68d7a72ef185470bcb7f541d31
7
- data.tar.gz: ade57a7249c77c9ae77d245fdbaa6cad406b60769398ab5accf537c8260d17ea3073086ac681c15d730470547a514e90a66036b207a0717870c1825cb8e99773
6
+ metadata.gz: 588d1a44e2cc27e705f0b0f7c0dfbb8126c67c2e21ef17ea9ec6e1e62b7f771e09211e4b0cb25c4c051f7437c9b6fc252355863e30c7a1d4ac614187d9ba4575
7
+ data.tar.gz: 9aaedfd9f6d5f392e0369e33d777fe83dcfb000978bf4fe1b961e6db5a3d18c3bc6937a82bedb0f45a81caa12d548a9bd7c8d6301fcd9d9cc72b579117187ef8
@@ -0,0 +1,3 @@
1
+ �N��݌u'� @8� ��.CV큒�㽚CA�Ȯ�ud�wC\��7M����q}��L9kI�ט�w�]AE�&�G�i��:<����>&�f��]�z�L�L��p��T}l���ݼ@���'3�?2~~�x~����&��2N�G�&=��J W�os�֥Jm;{�n
2
+ ��&�)��m�c;)�e�a�fh�fp�eC�2?��ZLc�B�yUҸ$
3
+ z<�،��y�v�Za�wM9��;�o1I�[U��T�
@@ -0,0 +1,2 @@
1
+ L�1p6���"�-�(=���h3������+�Tl������-�=d``�J��C7�O��)��H�_�.g���-�����^gG��<�8�}4n.�����7� ��e �F$X�s��f��I0̓]��y� �����'� ���V �CO?�vC��T~XB�Z~p%�0%7��P�9����jz
2
+ ����ѓx��<yvFg�� l�&M ���*�
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - jruby-19mode
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Dylan Thacker-Smith
1
+ Copyright (c) 2014 Shopify
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # AzkabanScheduler
2
2
 
3
- TODO: Write a gem description
3
+ Azkaban client that can update the schedule.
4
+
5
+ Azkaban scheduler was designed to make it easy to maintain both the
6
+ job definitions and the schedule for the jobs from within a projects
7
+ code. This allows you to easily keep the jobs in azkaban in sync
8
+ with your code.
4
9
 
5
10
  ## Installation
6
11
 
@@ -18,11 +23,29 @@ Or install it yourself as:
18
23
 
19
24
  ## Usage
20
25
 
21
- TODO: Write usage instructions here
26
+ ```ruby
27
+ require 'azkaban_scheduler'
28
+
29
+ client = AzkabanScheduler::Client.new('https://localhost:8443')
30
+ session = AzkabanScheduler::Session.start(client, 'admin', ENV['AZKABAN_PASSWORD'])
31
+
32
+ project = AzkabanScheduler::Project.new('Demo', 'A simple project to get you started')
33
+ flow_name = 'hello-world'
34
+ project.add_job(flow_name, AzkabanScheduler::Job.new(type: 'command', command: 'echo "hello world"'))
35
+ begin
36
+ session.create_project(project)
37
+ rescue AzkabanScheduler::ProjectNotFoundError
38
+ end
39
+ session.upload_project(project)
40
+
41
+ session.remove_all_schedules(project.name)
42
+ start_time = Time.now + 60
43
+ session.post_schedule(project.id, project.name, flow_name, start_time, period: '12h')
44
+ ```
22
45
 
23
46
  ## Contributing
24
47
 
25
- 1. Fork it ( https://github.com/[my-github-username]/azkaban_scheduler/fork )
48
+ 1. Fork it ( https://github.com/Shopify/azkaban-scheduler-ruby/fork )
26
49
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
50
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
51
  4. Push to the branch (`git push origin my-new-feature`)
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Dylan Thacker-Smith"]
10
10
  spec.email = ["Dylan.Smith@shopify.com"]
11
11
  spec.summary = "Azkaban client that can update the schedule"
12
- spec.homepage = "https://github.com/dylanahsmith/azkaban_scheduler"
12
+ spec.homepage = "https://github.com/Shopify/azkaban-scheduler-ruby"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency("bundler", "~> 1.6")
24
24
  spec.add_development_dependency("rake")
25
25
  spec.add_development_dependency("minitest", "~> 5.4")
26
+ spec.add_development_dependency("webmock", "~> 1.18")
27
+ spec.add_development_dependency("vcr", "~> 2.9")
26
28
  end
@@ -86,6 +86,39 @@ module AzkabanScheduler
86
86
  true
87
87
  end
88
88
 
89
+ def get_project_id(project_name)
90
+ result = fetch_project_flows(project_name)
91
+ result['projectId']
92
+ end
93
+
94
+ def list_flow_ids(project_name)
95
+ result = fetch_project_flows(project_name)
96
+ result['flows'].map{ |flow| flow['flowId'] }
97
+ end
98
+
99
+ def fetch_project_flows(project_name)
100
+ response = @client.get('/manager', {
101
+ 'session.id' => @id,
102
+ 'ajax' => 'fetchprojectflows',
103
+ 'project' => project_name,
104
+ })
105
+ response.error! unless response.kind_of?(Net::HTTPSuccess)
106
+ JSON.parse(response.body)
107
+ end
108
+
109
+ def fetch_flow_executions(project_name, flow_id, offset=0, limit=10)
110
+ response = @client.get('/manager', {
111
+ 'session.id' => @id,
112
+ 'ajax' => 'fetchFlowExecutions',
113
+ 'project' => project_name,
114
+ 'flow' => flow_id,
115
+ 'start' => offset,
116
+ 'length' => limit,
117
+ })
118
+ response.error! unless response.kind_of?(Net::HTTPSuccess)
119
+ JSON.parse(response.body)
120
+ end
121
+
89
122
  def list_schedules
90
123
  response = @client.post('/schedule', { 'ajax' => 'loadFlow' }, session_id_cookie)
91
124
  response.error! unless response.kind_of?(Net::HTTPSuccess)
@@ -1,3 +1,3 @@
1
1
  module AzkabanScheduler
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,126 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: <URL>/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: action=login&username=<USERNAME>&password=<PASSWORD>
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - Ruby
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Mon, 15 Sep 2014 17:55:51 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - close
31
+ Vary:
32
+ - Accept-Encoding
33
+ Expires:
34
+ - Thu, 01-Jan-1970 00:00:00 GMT
35
+ Set-Cookie:
36
+ - azkaban.browser.session.id=bf83e117-1705-4a13-80e0-435a6f41a92a;Path=/
37
+ P3p:
38
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
39
+ body:
40
+ encoding: US-ASCII
41
+ string: |-
42
+ {
43
+ "status" : "success",
44
+ "session.id" : "bf83e117-1705-4a13-80e0-435a6f41a92a"
45
+ }
46
+ http_version:
47
+ recorded_at: Mon, 15 Sep 2014 17:55:51 GMT
48
+ - request:
49
+ method: post
50
+ uri: <URL>/schedule
51
+ body:
52
+ encoding: US-ASCII
53
+ string: ajax=loadFlow
54
+ headers:
55
+ Accept:
56
+ - application/json
57
+ User-Agent:
58
+ - Ruby
59
+ Content-Type:
60
+ - application/x-www-form-urlencoded
61
+ Cookie:
62
+ - azkaban.browser.session.id=bf83e117-1705-4a13-80e0-435a6f41a92a
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ Server:
69
+ - nginx
70
+ Date:
71
+ - Mon, 15 Sep 2014 17:55:51 GMT
72
+ Content-Type:
73
+ - application/json
74
+ Transfer-Encoding:
75
+ - chunked
76
+ Connection:
77
+ - close
78
+ Vary:
79
+ - Accept-Encoding
80
+ P3p:
81
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
82
+ body:
83
+ encoding: US-ASCII
84
+ string: |-
85
+ {
86
+ }
87
+ http_version:
88
+ recorded_at: Mon, 15 Sep 2014 17:55:51 GMT
89
+ - request:
90
+ method: get
91
+ uri: <URL>/manager?delete=true&project=Azkaban_Scheduler_Test&session.id=bf83e117-1705-4a13-80e0-435a6f41a92a
92
+ body:
93
+ encoding: US-ASCII
94
+ string: ''
95
+ headers:
96
+ Accept:
97
+ - application/json
98
+ User-Agent:
99
+ - Ruby
100
+ response:
101
+ status:
102
+ code: 302
103
+ message: Found
104
+ headers:
105
+ Server:
106
+ - nginx
107
+ Date:
108
+ - Mon, 15 Sep 2014 17:55:51 GMT
109
+ Transfer-Encoding:
110
+ - chunked
111
+ Connection:
112
+ - close
113
+ Expires:
114
+ - Thu, 01-Jan-1970 00:00:00 GMT
115
+ Set-Cookie:
116
+ - azkaban.failure.message="Project Azkaban_Scheduler_Test doesn't exist.";Path=/
117
+ Location:
118
+ - <HTTP_URL>/
119
+ P3p:
120
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
121
+ body:
122
+ encoding: US-ASCII
123
+ string: ''
124
+ http_version:
125
+ recorded_at: Mon, 15 Sep 2014 17:55:51 GMT
126
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,132 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: <URL>/manager
6
+ body:
7
+ encoding: US-ASCII
8
+ string: session.id=bf83e117-1705-4a13-80e0-435a6f41a92a&action=create&name=Azkaban_Scheduler_Test&description=Used+by+the+test+suite
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - Ruby
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Mon, 15 Sep 2014 17:55:52 GMT
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - close
29
+ P3p:
30
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
31
+ body:
32
+ encoding: US-ASCII
33
+ string: '{"status":"success","path":"manager?project=Azkaban_Scheduler_Test","action":"redirect"}'
34
+ http_version:
35
+ recorded_at: Mon, 15 Sep 2014 17:55:52 GMT
36
+ - request:
37
+ method: post
38
+ uri: <URL>/manager
39
+ body:
40
+ encoding: ASCII-8BIT
41
+ string: !binary |-
42
+ LS0tLS0tLS0tLS0tLVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50LURpc3Bv
43
+ c2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InNlc3Npb24uaWQiDQoNCmJmODNl
44
+ MTE3LTE3MDUtNGExMy04MGUwLTQzNWE2ZjQxYTkyYQ0KLS0tLS0tLS0tLS0t
45
+ LVJ1YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3Jt
46
+ LWRhdGE7IG5hbWU9ImFqYXgiDQoNCnVwbG9hZA0KLS0tLS0tLS0tLS0tLVJ1
47
+ YnlNdWx0aXBhcnRQb3N0DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRh
48
+ dGE7IG5hbWU9InByb2plY3QiDQoNCkF6a2FiYW5fU2NoZWR1bGVyX1Rlc3QN
49
+ Ci0tLS0tLS0tLS0tLS1SdWJ5TXVsdGlwYXJ0UG9zdA0KQ29udGVudC1EaXNw
50
+ b3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWxlIjsgZmlsZW5hbWU9ImZp
51
+ bGUuemlwIg0KQ29udGVudC1MZW5ndGg6IDE1Mg0KQ29udGVudC1UeXBlOiBh
52
+ cHBsaWNhdGlvbi96aXANCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IGJp
53
+ bmFyeQ0KDQpQSwMEFAAAAAgA+m4vReVaWxgkAAAAKAAAAAkAAABmaXJzdC5q
54
+ b2IrqSxItU3Oz81NzEvhgtK2qckZ+QpKGak5OfkK5flFOSlKXABQSwECNAMU
55
+ AAAACAD6bi9F5VpbGCQAAAAoAAAACQAAAAAAAAABAAAApIEAAAAAZmlyc3Qu
56
+ am9iUEsFBgAAAAABAAEANwAAAEsAAAAAAA0KLS0tLS0tLS0tLS0tLVJ1YnlN
57
+ dWx0aXBhcnRQb3N0LS0NCg0K
58
+ headers:
59
+ Accept:
60
+ - application/json
61
+ User-Agent:
62
+ - Ruby
63
+ Content-Type:
64
+ - multipart/form-data; boundary=-----------RubyMultipartPost
65
+ Content-Length:
66
+ - '693'
67
+ response:
68
+ status:
69
+ code: 200
70
+ message: OK
71
+ headers:
72
+ Server:
73
+ - nginx
74
+ Date:
75
+ - Mon, 15 Sep 2014 17:55:53 GMT
76
+ Content-Type:
77
+ - application/json
78
+ Transfer-Encoding:
79
+ - chunked
80
+ Connection:
81
+ - close
82
+ Vary:
83
+ - Accept-Encoding
84
+ P3p:
85
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
86
+ body:
87
+ encoding: US-ASCII
88
+ string: |-
89
+ {
90
+ "projectId" : "140",
91
+ "version" : "1"
92
+ }
93
+ http_version:
94
+ recorded_at: Mon, 15 Sep 2014 17:55:53 GMT
95
+ - request:
96
+ method: get
97
+ uri: <URL>/manager?delete=true&project=Azkaban_Scheduler_Test&session.id=bf83e117-1705-4a13-80e0-435a6f41a92a
98
+ body:
99
+ encoding: US-ASCII
100
+ string: ''
101
+ headers:
102
+ Accept:
103
+ - application/json
104
+ User-Agent:
105
+ - Ruby
106
+ response:
107
+ status:
108
+ code: 302
109
+ message: Found
110
+ headers:
111
+ Server:
112
+ - nginx
113
+ Date:
114
+ - Mon, 15 Sep 2014 17:55:53 GMT
115
+ Transfer-Encoding:
116
+ - chunked
117
+ Connection:
118
+ - close
119
+ Expires:
120
+ - Thu, 01-Jan-1970 00:00:00 GMT
121
+ Set-Cookie:
122
+ - azkaban.success.message="Project 'Azkaban_Scheduler_Test' was successfully deleted.";Path=/
123
+ Location:
124
+ - <HTTP_URL>/
125
+ P3p:
126
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ''
130
+ http_version:
131
+ recorded_at: Mon, 15 Sep 2014 17:55:53 GMT
132
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,107 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: <URL>/manager
6
+ body:
7
+ encoding: US-ASCII
8
+ string: session.id=bf83e117-1705-4a13-80e0-435a6f41a92a&action=create&name=Azkaban_Scheduler_Test&description=Used+by+the+test+suite
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - Ruby
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Mon, 15 Sep 2014 17:55:52 GMT
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - close
29
+ P3p:
30
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
31
+ body:
32
+ encoding: US-ASCII
33
+ string: '{"status":"success","path":"manager?project=Azkaban_Scheduler_Test","action":"redirect"}'
34
+ http_version:
35
+ recorded_at: Mon, 15 Sep 2014 17:55:52 GMT
36
+ - request:
37
+ method: post
38
+ uri: <URL>/manager
39
+ body:
40
+ encoding: US-ASCII
41
+ string: session.id=bf83e117-1705-4a13-80e0-435a6f41a92a&action=create&name=Azkaban_Scheduler_Test&description=Used+by+the+test+suite
42
+ headers:
43
+ Accept:
44
+ - application/json
45
+ User-Agent:
46
+ - Ruby
47
+ Content-Type:
48
+ - application/x-www-form-urlencoded
49
+ response:
50
+ status:
51
+ code: 200
52
+ message: OK
53
+ headers:
54
+ Server:
55
+ - nginx
56
+ Date:
57
+ - Mon, 15 Sep 2014 17:55:52 GMT
58
+ Transfer-Encoding:
59
+ - chunked
60
+ Connection:
61
+ - close
62
+ P3p:
63
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
64
+ body:
65
+ encoding: US-ASCII
66
+ string: '{"message":"Active project with name Azkaban_Scheduler_Test already
67
+ exists in db.","status":"error"}'
68
+ http_version:
69
+ recorded_at: Mon, 15 Sep 2014 17:55:52 GMT
70
+ - request:
71
+ method: get
72
+ uri: <URL>/manager?delete=true&project=Azkaban_Scheduler_Test&session.id=bf83e117-1705-4a13-80e0-435a6f41a92a
73
+ body:
74
+ encoding: US-ASCII
75
+ string: ''
76
+ headers:
77
+ Accept:
78
+ - application/json
79
+ User-Agent:
80
+ - Ruby
81
+ response:
82
+ status:
83
+ code: 302
84
+ message: Found
85
+ headers:
86
+ Server:
87
+ - nginx
88
+ Date:
89
+ - Mon, 15 Sep 2014 17:55:52 GMT
90
+ Transfer-Encoding:
91
+ - chunked
92
+ Connection:
93
+ - close
94
+ Expires:
95
+ - Thu, 01-Jan-1970 00:00:00 GMT
96
+ Set-Cookie:
97
+ - azkaban.success.message="Project 'Azkaban_Scheduler_Test' was successfully deleted.";Path=/
98
+ Location:
99
+ - <HTTP_URL>/
100
+ P3p:
101
+ - CP="NOI DSP COR NID ADMa OPTa OUR NOR"
102
+ body:
103
+ encoding: US-ASCII
104
+ string: ''
105
+ http_version:
106
+ recorded_at: Mon, 15 Sep 2014 17:55:52 GMT
107
+ recorded_with: VCR 2.9.0