schemata-dea 0.0.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/lib/schemata/common/error.rb +12 -0
  2. data/lib/schemata/common/msgbase.rb +281 -0
  3. data/lib/schemata/common/msgtypebase.rb +144 -0
  4. data/lib/schemata/common/parsed_msg.rb +43 -0
  5. data/lib/schemata/dea/advertise_message/advertise_message_v1.rb +40 -0
  6. data/lib/schemata/dea/advertise_message.rb +13 -0
  7. data/lib/schemata/dea/dea_status_response/dea_status_response_v1.rb +48 -0
  8. data/lib/schemata/dea/dea_status_response.rb +13 -0
  9. data/lib/schemata/dea/discover_request/discover_request_v1.rb +93 -0
  10. data/lib/schemata/dea/discover_request.rb +13 -0
  11. data/lib/schemata/dea/droplet_status_response/droplet_status_response_v1.rb +38 -0
  12. data/lib/schemata/dea/droplet_status_response.rb +13 -0
  13. data/lib/schemata/dea/exit_message/exit_message_v1.rb +48 -0
  14. data/lib/schemata/dea/exit_message.rb +13 -0
  15. data/lib/schemata/dea/find_droplet_request/find_droplet_request_v1.rb +52 -0
  16. data/lib/schemata/dea/find_droplet_request.rb +13 -0
  17. data/lib/schemata/dea/find_droplet_response/find_droplet_response_v1.rb +107 -0
  18. data/lib/schemata/dea/find_droplet_response.rb +13 -0
  19. data/lib/schemata/dea/heartbeat_response/heartbeat_response_v1.rb +58 -0
  20. data/lib/schemata/dea/heartbeat_response.rb +13 -0
  21. data/lib/schemata/dea/hello_message/hello_message_v1.rb +40 -0
  22. data/lib/schemata/dea/hello_message.rb +13 -0
  23. data/lib/schemata/dea/start_request/start_request_v1.rb +141 -0
  24. data/lib/schemata/dea/start_request.rb +13 -0
  25. data/lib/schemata/dea/stop_request/stop_request_v1.rb +39 -0
  26. data/lib/schemata/dea/stop_request.rb +13 -0
  27. data/lib/schemata/dea/update_request/update_request_v1.rb +33 -0
  28. data/lib/schemata/dea/update_request.rb +13 -0
  29. data/lib/schemata/dea/version.rb +5 -0
  30. data/lib/schemata/dea.rb +64 -0
  31. data/lib/schemata/helpers/hash_copy.rb +28 -0
  32. data/lib/schemata/helpers/stringify.rb +26 -0
  33. data/spec/cloud_controller/cc_bar_spec.rb +140 -0
  34. data/spec/common/helpers_spec.rb +115 -0
  35. data/spec/common/parsed_msg_spec.rb +46 -0
  36. data/spec/component/aux_data_spec.rb +37 -0
  37. data/spec/component/component_bar_spec.rb +140 -0
  38. data/spec/component/component_foo_spec.rb +630 -0
  39. data/spec/component/foo_spec.rb +214 -0
  40. data/spec/dea/advertise_message_spec.rb +10 -0
  41. data/spec/dea/dea_spec.rb +6 -0
  42. data/spec/dea/dea_status_response_spec.rb +10 -0
  43. data/spec/dea/discover_request_spec.rb +10 -0
  44. data/spec/dea/droplet_status_response_spec.rb +10 -0
  45. data/spec/dea/exit_message_spec.rb +10 -0
  46. data/spec/dea/find_droplet_request_spec.rb +27 -0
  47. data/spec/dea/find_droplet_response_spec.rb +10 -0
  48. data/spec/dea/heartbeat_response_spec.rb +10 -0
  49. data/spec/dea/hello_message_spec.rb +10 -0
  50. data/spec/dea/start_request_spec.rb +10 -0
  51. data/spec/dea/stop_request_spec.rb +10 -0
  52. data/spec/dea/update_request_spec.rb +0 -0
  53. data/spec/router/register_request_spec.rb +10 -0
  54. data/spec/router/router_spec.rb +6 -0
  55. data/spec/router/start_message_spec.rb +10 -0
  56. data/spec/spec_helper.rb +1 -0
  57. data/spec/staging/staging_message_spec.rb +14 -0
  58. data/spec/staging/staging_spec.rb +6 -0
  59. data/spec/support/component_helpers.rb +51 -0
  60. data/spec/support/helpers.rb +54 -0
  61. data/spec/support/message_helpers.rb +138 -0
  62. data/spec/support/message_type_helpers.rb +171 -0
  63. metadata +234 -0
@@ -0,0 +1,13 @@
1
+ require 'schemata/common/msgtypebase'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module DiscoverRequest
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/discover_request/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,38 @@
1
+ require 'membrane'
2
+ require 'schemata/helpers/hash_copy'
3
+ require 'schemata/common/msgtypebase'
4
+ require 'vcap/common'
5
+
6
+ module Schemata
7
+ module DEA
8
+ module DropletStatusResponse
9
+ version 1 do
10
+ include_preschemata
11
+
12
+ define_schema do
13
+ {
14
+ "name" => String,
15
+ "uris" => [String],
16
+ }
17
+ end
18
+
19
+ define_min_version 1
20
+
21
+ define_upvert do |old_data|
22
+ raise NotImplementedError.new
23
+ end
24
+
25
+ define_generate_old_fields do |msg_obj|
26
+ raise NotImplementedError.new
27
+ end
28
+
29
+ define_mock_values do
30
+ {
31
+ "name" => "foo",
32
+ "uris" => ['foo.com', 'bar.com'],
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ require 'schemata/common/msgtypebase'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module DropletStatusResponse
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/droplet_status_response/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,48 @@
1
+ require 'schemata/common/msgtypebase'
2
+ require 'vcap/common'
3
+
4
+ module Schemata
5
+ module DEA
6
+ module ExitMessage
7
+ version 1 do
8
+ include_preschemata
9
+
10
+ define_schema do
11
+ {
12
+ "cc_partition" => String,
13
+ "droplet" => String,
14
+ "version" => String,
15
+ "instance" => String,
16
+ "index" => Integer,
17
+ "reason" => String,
18
+
19
+ "crash_timestamp" => Integer,
20
+ }
21
+ end
22
+
23
+ define_min_version 1
24
+
25
+ define_upvert do |old_data|
26
+ raise NotImplementedError.new
27
+ end
28
+
29
+ define_generate_old_fields do |msg_obj|
30
+ raise NotImplementedError.new
31
+ end
32
+
33
+ define_mock_values do
34
+ {
35
+ "cc_partition" => "default",
36
+ "droplet" => proc { VCAP.secure_uuid },
37
+ "version" => "0.1.0",
38
+ "instance" => proc { VCAP.secure_uuid },
39
+ "index" => Random.rand(100),
40
+ "reason" => "STOPPED",
41
+
42
+ "crash_timestamp" => Time.now.to_i,
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,13 @@
1
+ require 'schemata/common/msgtypebase'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module ExitMessage
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/exit_message/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,52 @@
1
+ require 'schemata/common/msgtypebase'
2
+ require 'vcap/common'
3
+
4
+ module Schemata
5
+ module DEA
6
+ module FindDropletRequest
7
+ version 1 do
8
+ include_preschemata
9
+
10
+ define_schema do
11
+ {
12
+ "droplet" => String,
13
+ "states" => [String],
14
+ "version" => String,
15
+
16
+ optional("path") => String,
17
+ optional("instance_ids") => [String],
18
+ optional("indices") => [Integer],
19
+ optional("include_stats") => bool,
20
+ }
21
+ end
22
+
23
+ define_min_version 1
24
+
25
+ define_upvert do |old_data|
26
+ raise NotImplementedError.new
27
+ end
28
+
29
+ define_generate_old_fields do |msg_obj|
30
+ raise NotImplementedError.new
31
+ end
32
+
33
+ define_generate_old_fields do |msg_obj|
34
+
35
+ end
36
+
37
+ define_mock_values do
38
+ {
39
+ "droplet" => proc { VCAP.secure_uuid },
40
+ "states" => ["RUNNING"],
41
+ "version" => "0.1.0",
42
+
43
+ "path" => "logs/staging.log",
44
+ "instance_ids" => proc { [VCAP.secure_uuid] },
45
+ "indices" => [0],
46
+ "include_stats" => false,
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ require 'schemata/common/msgtypebase'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module FindDropletRequest
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/find_droplet_request/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,107 @@
1
+ require 'membrane'
2
+ require 'schemata/helpers/hash_copy'
3
+ require 'schemata/common/msgtypebase'
4
+ require 'vcap/common'
5
+
6
+ module Schemata
7
+ module DEA
8
+ module FindDropletResponse
9
+ version 1 do
10
+ include_preschemata
11
+
12
+ define_schema do
13
+ {
14
+ "dea" => String,
15
+ "droplet" => String,
16
+ "version" => String,
17
+ "instance" => String,
18
+ "index" => Integer,
19
+ "state" => String,
20
+ "state_timestamp" => Float,
21
+ "file_uri" => String,
22
+ "credentials" => [String],
23
+ "staged" => String,
24
+
25
+ optional("file_uri_v2") => String,
26
+
27
+ optional("debug_ip") => String,
28
+ optional("debug_port") => Integer,
29
+
30
+ optional("console_ip") => String,
31
+ optional("console_port") => Integer,
32
+
33
+ optional("stats") => {
34
+ "name" => String,
35
+ "uris" => [String],
36
+ "host" => String,
37
+ "port" => Integer,
38
+ "uptime" => Integer,
39
+ "mem_quota" => Integer,
40
+ "disk_quota" => Integer,
41
+ "fds_quota" => Integer,
42
+ "usage" => {
43
+ "time" => String,
44
+ "cpu" => Integer,
45
+ "mem" => Integer,
46
+ "disk" => Integer,
47
+ },
48
+ },
49
+ }
50
+ end
51
+
52
+ define_min_version 1
53
+
54
+ define_upvert do |old_data|
55
+ raise NotImplementedError.new
56
+ end
57
+
58
+ define_generate_old_fields do |msg_obj|
59
+ raise NotImplmentedError.new
60
+ end
61
+
62
+ define_mock_values do
63
+ instance_id = VCAP.secure_uuid
64
+
65
+ {
66
+ "dea" => VCAP.secure_uuid,
67
+ "droplet" => "#{Random.rand(1000)}",
68
+ "version" => VCAP.secure_uuid,
69
+ "instance" => instance_id,
70
+ "index" => 0,
71
+ "state" => "RUNNING",
72
+ "state_timestamp" => Time.now.to_f,
73
+ "file_uri" => "http://172.20.208.11:80/instances",
74
+ "credentials" => [VCAP.secure_uuid, VCAP.secure_uuid],
75
+ "staged" => "/#{instance_id}",
76
+
77
+ "file_uri_v2" => "http://#{VCAP.secure_uuid}.vcap.me/instance_paths/#{instance_id}/\
78
+ ?timestamp=#{Time.now.to_i}&hmac=cfa11450527aeb&path=",
79
+
80
+ "debug_ip" => "127.0.0.1",
81
+ "debug_port" => 80,
82
+
83
+ "console_ip" => "127.0.0.1",
84
+ "console_port" => 80,
85
+
86
+ "stats" => {
87
+ "name" => "foo",
88
+ "uris" => ["foo.com", "bar.com"],
89
+ "host" => "127.0.0.1",
90
+ "port" => 80,
91
+ "uptime" => 1,
92
+ "mem_quota" => 5,
93
+ "disk_quota" => 10,
94
+ "fds_quota" => 15,
95
+ "usage" => {
96
+ "time" => Time.now.to_s,
97
+ "cpu" => 0,
98
+ "mem" => 0,
99
+ "disk" => 0,
100
+ },
101
+ },
102
+ }
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,13 @@
1
+ require "schemata/common/msgtypebase"
2
+
3
+ module Schemata
4
+ module DEA
5
+ module FindDropletResponse
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/find_droplet_response/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,58 @@
1
+ require 'membrane'
2
+ require 'schemata/helpers/hash_copy'
3
+ require 'schemata/common/msgtypebase'
4
+ require 'vcap/common'
5
+
6
+ module Schemata
7
+ module DEA
8
+ module HeartbeatResponse
9
+
10
+ version 1 do
11
+ include_preschemata
12
+
13
+ define_schema do
14
+ {
15
+ "droplets" => [{
16
+ optional("cc_partition") => String,
17
+ "droplet" => String,
18
+ "version" => String,
19
+ "instance" => String,
20
+ "index" => Integer,
21
+ "state" => String,
22
+ "state_timestamp" => Float,
23
+ }],
24
+ "dea" => String,
25
+ "prod" => bool,
26
+ }
27
+ end
28
+
29
+ define_min_version 1
30
+
31
+ define_upvert do |old_data|
32
+ raise NotImplementedError.new
33
+ end
34
+
35
+ define_generate_old_fields do |msg_obj|
36
+ raise NotImplementedError.new
37
+ end
38
+
39
+ define_mock_values do
40
+ {
41
+ "droplets" => [{
42
+ "cc_partition" => "default",
43
+ "droplet" => "#{Random.rand(1000)}",
44
+ "version" => VCAP.secure_uuid,
45
+ "instance" => VCAP.secure_uuid,
46
+ "index" => 0,
47
+ "state" => "RUNNING",
48
+ "state_timestamp" => Time.now.to_f
49
+ }],
50
+ "dea" => VCAP.secure_uuid,
51
+ "prod" => false,
52
+ }
53
+ end
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,13 @@
1
+ require "schemata/common/msgtypebase"
2
+
3
+ module Schemata
4
+ module DEA
5
+ module HeartbeatResponse
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/heartbeat_response/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,40 @@
1
+ require 'schemata/common/msgtypebase'
2
+ require 'vcap/common'
3
+
4
+ module Schemata
5
+ module DEA
6
+ module HelloMessage
7
+ version 1 do
8
+ include_preschemata
9
+
10
+ define_schema do
11
+ {
12
+ "id" => String,
13
+ "ip" => String,
14
+ "port" => Integer,
15
+ "version" => String,
16
+ }
17
+ end
18
+
19
+ define_min_version 1
20
+
21
+ define_upvert do |old_data|
22
+ raise NotImplementedError.new
23
+ end
24
+
25
+ define_generate_old_fields do |msg_obj|
26
+ raise NotImplementedError.new
27
+ end
28
+
29
+ define_mock_values do
30
+ {
31
+ "id" => proc { VCAP.secure_uuid },
32
+ "ip" => '127.0.0.1',
33
+ "port" => 80,
34
+ "version" => '0.1.0',
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,13 @@
1
+ require 'schemata/common/msgtypebase'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module HelloMessage
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/hello_message/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,141 @@
1
+ require 'schemata/common/msgtypebase'
2
+ require 'vcap/common'
3
+
4
+ module Schemata
5
+ module DEA
6
+ module StartRequest
7
+ version 1 do
8
+ include_preschemata
9
+
10
+ define_schema do
11
+ {
12
+ "droplet" => String,
13
+ "name" => String,
14
+ "uris" => [String],
15
+ "runtime" => String,
16
+ "runtime_info" => {
17
+ "description" => String,
18
+ "version" => String,
19
+ "executable" => String,
20
+ "staging" => String,
21
+ "version_output" => String,
22
+ "version_flag" => String,
23
+ "additional_checks" => String,
24
+ "environment" => {
25
+ "LD_LIBRARY_PATH" => String,
26
+ "BUNDLE_GEMFILE" => enum(String, NilClass),
27
+ "PATH" => String,
28
+ "GEM_PATH" => String
29
+ },
30
+ "status" => {
31
+ "name" => String
32
+ },
33
+ "series" => String,
34
+ "category" => String,
35
+ "name" => String
36
+ },
37
+ "framework" => String,
38
+ "prod" => bool,
39
+ "sha1" => String,
40
+ "executableFile" => String,
41
+ "executableUri" => String,
42
+ "version" => String,
43
+ "services" => [{
44
+ "label" => String,
45
+ "tags" => [String],
46
+ "name" => String,
47
+ "credentials" => {
48
+ "hostname" => String,
49
+ "host" => String,
50
+ "port" => Integer,
51
+ "username" => String,
52
+ "password" => String,
53
+ "name" => String,
54
+ optional("db") => String,
55
+ optional("url") => String,
56
+ optional("vhost") => String,
57
+ optional("user") => String,
58
+ optional("pass") => String,
59
+ },
60
+ "options" => any,
61
+ "plan" => String,
62
+ "plan_option" => enum(String, NilClass),
63
+ "type" => String,
64
+ "version" => String,
65
+ "vendor" => String
66
+ }],
67
+ "limits" => {
68
+ "mem" => Integer,
69
+ "disk" => Integer,
70
+ "fds" => Integer
71
+ },
72
+ "env" => [String],
73
+ "users" => [String],
74
+ "cc_partition" => String,
75
+ "debug" => any,
76
+ "console" => any,
77
+ "index" => Integer
78
+ }
79
+ end
80
+
81
+ define_min_version 1
82
+
83
+ define_upvert do |old_data|
84
+ raise NotImplementedError.new
85
+ end
86
+
87
+ define_generate_old_fields do |msg_obj|
88
+ raise NotImplementedError.new
89
+ end
90
+
91
+ define_mock_values do
92
+ {
93
+ "droplet" => proc { VCAP.secure_uuid },
94
+ "name" => "foo",
95
+ "uris" => ["foo.vcap.me"],
96
+ "runtime" => "ruby18",
97
+ "runtime_info" => {
98
+ "description" => "Ruby 1.8",
99
+ "version" => "1.8.7p357",
100
+ "executable" => "/var/vcap/packages/dea_ruby18/bin/ruby",
101
+ "staging" => "/var/vcap/packages/ruby/bin/ruby stage",
102
+ "version_output" => "1.8.7",
103
+ "version_flag" => "-e 'puts RUBY_VERSION'",
104
+ "additional_checks" => "-e 'puts RUBY_PATCHLEVEL == 357'",
105
+ "environment" => {
106
+ "LD_LIBRARY_PATH" => "/var/vcap/packages/mysqlclient/lib/mysql:/var/vcap/packages/sqlite/lib:/var/vcap/packages/libpq/lib:/var/vcap/packages/imagemagick/lib:$LD_LIBRARY_PATH",
107
+ "BUNDLE_GEMFILE" => nil,
108
+ "PATH" => "/var/vcap/packages/imagemagick/bin:/var/vcap/packages/dea_transition/rubygems/1.8/bin:/var/vcap/packages/dea_ruby18/bin:/var/vcap/packages/dea_node08/bin:$PATH",
109
+ "GEM_PATH" => "/var/vcap/packages/dea_transition/rubygems/1.8:$GEM_PATH"
110
+ },
111
+ "status" => {
112
+ "name" => "current"
113
+ },
114
+ "series" => "ruby18",
115
+ "category" => "ruby",
116
+ "name" => "ruby18"
117
+ },
118
+ "framework" => "rails3",
119
+ "prod" => false,
120
+ "sha1" => "1487604bbdd3e29351a6f13570628a703dc032a4",
121
+ "executableFile" => "/var/vcap/shared/droplets/droplet_123",
122
+ "executableUri" => "http://172.20.208.195:9022/staged_droplets/123/1487604bbdd3e29351a6f13570628a703dc032a4",
123
+ "version" => "1487604bbdd3e29351a6f13570628a703dc032a4-1",
124
+ "services"=> [],
125
+ "limits" => {
126
+ "mem" => 256,
127
+ "disk" => 2048,
128
+ "fds" => 256
129
+ },
130
+ "env" => [],
131
+ "users" => ["user@rbcon.com"],
132
+ "cc_partition" => "default",
133
+ "debug" => nil,
134
+ "console" => nil,
135
+ "index" => 0
136
+ }
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,13 @@
1
+ require 'schemata/common/msgtypebase'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module StartRequest
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/start_request/*.rb'].each do |file|
12
+ require file
13
+ end
@@ -0,0 +1,39 @@
1
+ require 'vcap/common'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module StopRequest
6
+ version 1 do
7
+ include_preschemata
8
+
9
+ define_schema do
10
+ {
11
+ "droplet" => String,
12
+ optional("version") => String,
13
+ optional("instances") => [String],
14
+ optional("indices") => [Integer]
15
+ }
16
+ end
17
+
18
+ define_min_version 1
19
+
20
+ define_upvert do |old_message|
21
+ raise NotImplementedError.new
22
+ end
23
+
24
+ define_generate_old_fields do
25
+ raise NotImplementedError.new
26
+ end
27
+
28
+ define_mock_values do
29
+ {
30
+ "droplet" => proc { VCAP.secure_uuid },
31
+ "version" => proc { VCAP.secure_uuid },
32
+ "instances" => proc { [VCAP.secure_uuid] },
33
+ "indices" => [0, 1, 2],
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ require 'schemata/common/msgtypebase'
2
+
3
+ module Schemata
4
+ module DEA
5
+ module StopRequest
6
+ extend Schemata::MessageTypeBase
7
+ end
8
+ end
9
+ end
10
+
11
+ Dir[File.dirname(__FILE__) + '/stop_request/*.rb'].each do |file|
12
+ require file
13
+ end