dumbwaiter 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dumbwaiter.gemspec +1 -0
- data/lib/dumbwaiter/app.rb +8 -0
- data/lib/dumbwaiter/deployment.rb +17 -8
- data/lib/dumbwaiter/deployment_custom_json.rb +12 -8
- data/lib/dumbwaiter/mock.rb +84 -0
- data/lib/dumbwaiter/version.rb +1 -1
- data/lib/dumbwaiter.rb +1 -3
- data/spec/lib/dumbwaiter/app_spec.rb +26 -13
- data/spec/lib/dumbwaiter/cli_spec.rb +18 -25
- data/spec/lib/dumbwaiter/deployment_custom_json_spec.rb +3 -3
- data/spec/lib/dumbwaiter/deployment_spec.rb +34 -43
- data/spec/lib/dumbwaiter/instance_spec.rb +9 -10
- data/spec/lib/dumbwaiter/layer_spec.rb +14 -16
- data/spec/lib/dumbwaiter/stack_spec.rb +8 -16
- data/spec/spec_helper.rb +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94944ee58a46b0164e4f7937fcc3b066213f042c
|
4
|
+
data.tar.gz: 50cdfe19a328a832ff374dc68cbe50900e090b0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ca9bbc6e30aa1b6dee2a134d419c7180c5586979f83f7c633971de0800eb2f8e2966bb8252f13627b07e082ee5dcef1a95338b9f1359dff34adb90eea7ee9cd
|
7
|
+
data.tar.gz: fdedb2834345c6a697cf7ff8664473bfd494fc100a396afe13d8e4969c70f294da1269cd7965647da53a998146737e5faa44ff1271534061cba82a39123a2888
|
data/dumbwaiter.gemspec
CHANGED
data/lib/dumbwaiter/app.rb
CHANGED
@@ -35,6 +35,14 @@ class Dumbwaiter::App
|
|
35
35
|
opsworks_app.app_id
|
36
36
|
end
|
37
37
|
|
38
|
+
def url
|
39
|
+
opsworks_app.app_source.url
|
40
|
+
end
|
41
|
+
|
42
|
+
def revision
|
43
|
+
opsworks_app.app_source.revision || "master"
|
44
|
+
end
|
45
|
+
|
38
46
|
def deploy(revision = nil)
|
39
47
|
deployment = as_deployment("deploy", args: {migrate: ["true"]})
|
40
48
|
unless revision.nil?
|
@@ -2,13 +2,14 @@ require "dumbwaiter/deployment_custom_json"
|
|
2
2
|
require "dumbwaiter/user_profile"
|
3
3
|
|
4
4
|
class Dumbwaiter::Deployment
|
5
|
-
attr_reader :opsworks_deployment, :opsworks
|
5
|
+
attr_reader :stack, :opsworks_deployment, :opsworks
|
6
6
|
|
7
7
|
def self.all(stack, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
8
|
-
opsworks.describe_deployments(stack_id: stack.id).deployments.map { |d| new(d, opsworks) }
|
8
|
+
opsworks.describe_deployments(stack_id: stack.id).deployments.map { |d| new(stack, d, opsworks) }
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(opsworks_deployment, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
11
|
+
def initialize(stack, opsworks_deployment, opsworks = Aws::OpsWorks.new(region: "us-east-1"))
|
12
|
+
@stack = stack
|
12
13
|
@opsworks_deployment = opsworks_deployment
|
13
14
|
@opsworks = opsworks
|
14
15
|
end
|
@@ -30,23 +31,31 @@ class Dumbwaiter::Deployment
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def user_name
|
33
|
-
if opsworks_deployment.iam_user_arn.nil?
|
34
|
-
"
|
34
|
+
if opsworks_deployment.iam_user_arn.nil? || user_profile.nil?
|
35
|
+
"OpsWorks"
|
35
36
|
else
|
36
37
|
user_profile.name
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
def
|
41
|
-
deployment_custom_json.
|
41
|
+
def revision
|
42
|
+
deployment_custom_json.revision || "#{app.revision}@{#{created_at}}"
|
42
43
|
end
|
43
44
|
|
44
45
|
def to_log
|
45
|
-
|
46
|
+
if command_name == "deploy"
|
47
|
+
"#{created_at} - #{user_name} - #{command_name} - #{status} - #{revision}"
|
48
|
+
else
|
49
|
+
"#{created_at} - #{user_name} - #{command_name} - #{status}"
|
50
|
+
end
|
46
51
|
end
|
47
52
|
|
48
53
|
protected
|
49
54
|
|
55
|
+
def app
|
56
|
+
Dumbwaiter::App.find_by_id(stack, opsworks_deployment.app_id, opsworks)
|
57
|
+
end
|
58
|
+
|
50
59
|
def user_profile
|
51
60
|
Dumbwaiter::UserProfile.find(opsworks_deployment.iam_user_arn, opsworks)
|
52
61
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "hashie"
|
2
2
|
require "json"
|
3
3
|
|
4
|
-
class Dumbwaiter::DeploymentCustomJson
|
4
|
+
class Dumbwaiter::DeploymentCustomJson
|
5
5
|
def self.from_json(json_string)
|
6
6
|
new(JSON.parse(json_string))
|
7
7
|
end
|
@@ -10,15 +10,19 @@ class Dumbwaiter::DeploymentCustomJson < Hashie::Mash
|
|
10
10
|
{deploy: {name => {scm: {revision: ref}}}}
|
11
11
|
end
|
12
12
|
|
13
|
+
def initialize(params)
|
14
|
+
@params = params
|
15
|
+
end
|
16
|
+
|
17
|
+
def params
|
18
|
+
Hashie::Mash.new(@params)
|
19
|
+
end
|
20
|
+
|
13
21
|
def app_name
|
14
|
-
|
22
|
+
params.deploy.keys.first if params.deploy?
|
15
23
|
end
|
16
24
|
|
17
|
-
def
|
18
|
-
|
19
|
-
"HEAD"
|
20
|
-
else
|
21
|
-
self.deploy[self.app_name].scm.revision
|
22
|
-
end
|
25
|
+
def revision
|
26
|
+
params.deploy[app_name].scm.revision unless app_name.nil?
|
23
27
|
end
|
24
28
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "faker"
|
2
|
+
|
3
|
+
class Dumbwaiter::Mock
|
4
|
+
attr_reader :stacks, :deployments, :apps, :layers, :instances, :user_profiles
|
5
|
+
|
6
|
+
def opsworks; self; end
|
7
|
+
def describe_stacks(*_); OpenStruct.new(stacks: stacks); end
|
8
|
+
def describe_deployments(*_); OpenStruct.new(deployments: deployments); end
|
9
|
+
def describe_apps(*_); OpenStruct.new(apps: apps); end
|
10
|
+
def describe_layers(*_); OpenStruct.new(layers: layers); end
|
11
|
+
def describe_instances(*_); OpenStruct.new(instances: instances); end
|
12
|
+
def describe_user_profiles(*_); OpenStruct.new(user_profiles: user_profiles); end
|
13
|
+
|
14
|
+
def clear
|
15
|
+
@stacks = []
|
16
|
+
@deployments = []
|
17
|
+
@apps = []
|
18
|
+
@layers = []
|
19
|
+
@instances = []
|
20
|
+
@user_profiles = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
super
|
25
|
+
clear
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_stack(id = make_id, name = Faker::Name.first_name, color = make_color)
|
29
|
+
stack = OpenStruct.new(stack_id: id, name: name, attributes: {"Color" => color})
|
30
|
+
stacks << stack
|
31
|
+
stack
|
32
|
+
end
|
33
|
+
|
34
|
+
def make_app(stack = make_stack, id = make_id, name = Faker::Name.first_name, url = Faker::Internet.url, revision = make_revision)
|
35
|
+
app = OpenStruct.new(stack_id: stack.stack_id, app_id: id, name: name, app_source: make_app_source(url, revision))
|
36
|
+
apps << app
|
37
|
+
app
|
38
|
+
end
|
39
|
+
|
40
|
+
def make_layer(stack = make_stack, id = make_id, shortname = Faker::Name.first_name.downcase)
|
41
|
+
layer = OpenStruct.new(stack_id: stack.stack_id, layer_id: id, shortname: shortname)
|
42
|
+
layers << layer
|
43
|
+
layer
|
44
|
+
end
|
45
|
+
|
46
|
+
def make_deployment(stack = make_stack, app = make_app, id = make_id, command_name = Faker::Name.first_name.downcase, status = Faker::Name.first_name, custom_json = "{}", at = Time.now.to_s, arn = Faker::Name.first_name, comment = Faker::Company.bs)
|
47
|
+
command = OpenStruct.new(name: command_name)
|
48
|
+
deployment = OpenStruct.new(stack_id: stack.stack_id, app_id: app.app_id, deployment_id: id, command: command, created_at: at, status: status, comment: comment, iam_user_arn: arn, custom_json: custom_json)
|
49
|
+
deployments << deployment
|
50
|
+
deployment
|
51
|
+
end
|
52
|
+
|
53
|
+
def make_instance(stack = make_stack, layer = make_layer, id = make_id)
|
54
|
+
instance = OpenStruct.new(layer_id: layer.layer_id, stack_id: stack.stack_id, instance_id: id)
|
55
|
+
instances << instance
|
56
|
+
instance
|
57
|
+
end
|
58
|
+
|
59
|
+
def make_user_profile(id = Faker::Name.last_name.downcase, name = Faker::Name.first_name)
|
60
|
+
user_profile = OpenStruct.new(aws_iam_arn: id, name: name)
|
61
|
+
user_profiles << user_profile
|
62
|
+
user_profile
|
63
|
+
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
|
67
|
+
def make_app_source(url, revision)
|
68
|
+
OpenStruct.new(url: url, revision: revision)
|
69
|
+
end
|
70
|
+
|
71
|
+
def make_revision
|
72
|
+
"%06x" % (rand * 0xffffff)
|
73
|
+
end
|
74
|
+
|
75
|
+
def make_color
|
76
|
+
"rgb(#{rand(255)},#{rand(255)},#{rand(255)})"
|
77
|
+
end
|
78
|
+
|
79
|
+
def make_id
|
80
|
+
@id ||= 0
|
81
|
+
@id += 1
|
82
|
+
"taco-#{@id}"
|
83
|
+
end
|
84
|
+
end
|
data/lib/dumbwaiter/version.rb
CHANGED
data/lib/dumbwaiter.rb
CHANGED
@@ -1,17 +1,30 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Dumbwaiter::App do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:
|
4
|
+
let(:fake_opsworks) { Dumbwaiter::Mock.new }
|
5
|
+
let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
|
6
|
+
let!(:fake_app) { fake_opsworks.make_app(fake_stack, "amazing", "goose", "git@example.com:tacos/great.git") }
|
7
|
+
let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
|
8
8
|
|
9
|
-
subject(:app) { Dumbwaiter::App.new(
|
9
|
+
subject(:app) { Dumbwaiter::App.new(real_stack, fake_app, fake_opsworks) }
|
10
10
|
|
11
|
-
its(:stack) { should == fake_stack }
|
12
|
-
its(:opsworks_app) { should == fake_app }
|
13
11
|
its(:id) { should == "amazing" }
|
14
12
|
its(:name) { should == "goose" }
|
13
|
+
its(:url) { should == "git@example.com:tacos/great.git" }
|
14
|
+
|
15
|
+
describe "#revision" do
|
16
|
+
context "when there is no revision specified" do
|
17
|
+
let(:fake_app) { fake_opsworks.make_app(fake_stack, "amazing", "goose", "git@example.com:tacos/great.git", nil) }
|
18
|
+
|
19
|
+
its(:revision) { should == "master" }
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when a revision is specified" do
|
23
|
+
let(:fake_app) { fake_opsworks.make_app(fake_stack, "amazing", "goose", "git@example.com:tacos/great.git", "wat") }
|
24
|
+
|
25
|
+
its(:revision) { should == "wat" }
|
26
|
+
end
|
27
|
+
end
|
15
28
|
|
16
29
|
describe "#deploy" do
|
17
30
|
context "when no revision is specified" do
|
@@ -48,22 +61,22 @@ describe Dumbwaiter::App do
|
|
48
61
|
|
49
62
|
describe ".all" do
|
50
63
|
it "fetches all the apps" do
|
51
|
-
fake_opsworks.should_receive(:describe_apps).with(stack_id: "pancakes")
|
52
|
-
Dumbwaiter::App.all(
|
64
|
+
fake_opsworks.should_receive(:describe_apps).with(stack_id: "pancakes").and_call_original
|
65
|
+
Dumbwaiter::App.all(real_stack, fake_opsworks).should have(1).app
|
53
66
|
end
|
54
67
|
end
|
55
68
|
|
56
69
|
describe ".find" do
|
57
70
|
context "when the app exists" do
|
58
71
|
it "finds the app by name" do
|
59
|
-
Dumbwaiter::App.find(
|
72
|
+
Dumbwaiter::App.find(real_stack, "goose", fake_opsworks).id.should == "amazing"
|
60
73
|
end
|
61
74
|
end
|
62
75
|
|
63
76
|
context "when the app does not exist" do
|
64
77
|
it "blows up" do
|
65
78
|
expect {
|
66
|
-
Dumbwaiter::App.find(
|
79
|
+
Dumbwaiter::App.find(real_stack, "teeth", fake_opsworks)
|
67
80
|
}.to raise_error(Dumbwaiter::App::NotFound)
|
68
81
|
end
|
69
82
|
end
|
@@ -72,14 +85,14 @@ describe Dumbwaiter::App do
|
|
72
85
|
describe ".find" do
|
73
86
|
context "when the app exists" do
|
74
87
|
it "finds the app by id" do
|
75
|
-
Dumbwaiter::App.find_by_id(
|
88
|
+
Dumbwaiter::App.find_by_id(real_stack, "amazing", fake_opsworks).name.should == "goose"
|
76
89
|
end
|
77
90
|
end
|
78
91
|
|
79
92
|
context "when the app does not exist" do
|
80
93
|
it "blows up" do
|
81
94
|
expect {
|
82
|
-
Dumbwaiter::App.find_by_id(
|
95
|
+
Dumbwaiter::App.find_by_id(real_stack, "teeth", fake_opsworks)
|
83
96
|
}.to raise_error(Dumbwaiter::App::NotFound)
|
84
97
|
end
|
85
98
|
end
|
@@ -1,23 +1,20 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Dumbwaiter::Cli do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
4
|
+
let(:fake_opsworks) { Dumbwaiter::Mock.new }
|
5
|
+
let!(:fake_stack) { fake_opsworks.make_stack("amazing", "ducks") }
|
6
|
+
let!(:fake_layer) { fake_opsworks.make_layer(fake_stack, "mighty", "beans") }
|
7
|
+
let!(:fake_app) { fake_opsworks.make_app(fake_stack, "delightful", "reifel") }
|
7
8
|
|
8
9
|
subject(:cli) { Dumbwaiter::Cli.new }
|
9
10
|
|
10
|
-
before
|
11
|
-
Dumbwaiter::Stack.stub(all: [fake_stack])
|
12
|
-
Dumbwaiter::App.stub(all: [fake_app])
|
13
|
-
Dumbwaiter::Layer.stub(all: [fake_layer])
|
14
|
-
end
|
11
|
+
before { Aws::OpsWorks.stub(new: fake_opsworks) }
|
15
12
|
|
16
13
|
describe "#deploy" do
|
17
14
|
context "when the stack exists" do
|
18
15
|
context "when the app exists" do
|
19
16
|
it "deploys the stack with the resolved id" do
|
20
|
-
|
17
|
+
Dumbwaiter::App.any_instance.should_receive(:deploy).with("corn")
|
21
18
|
cli.deploy("ducks", "reifel", "corn")
|
22
19
|
end
|
23
20
|
end
|
@@ -40,7 +37,7 @@ describe Dumbwaiter::Cli do
|
|
40
37
|
context "when the stack exists" do
|
41
38
|
context "when the app exists" do
|
42
39
|
it "deploys the stack with the resolved id" do
|
43
|
-
|
40
|
+
Dumbwaiter::App.any_instance.should_receive(:rollback)
|
44
41
|
cli.rollback("ducks", "reifel")
|
45
42
|
end
|
46
43
|
end
|
@@ -61,40 +58,38 @@ describe Dumbwaiter::Cli do
|
|
61
58
|
|
62
59
|
describe "#list" do
|
63
60
|
context "when the stack exists" do
|
64
|
-
before { fake_stack.stub(deployments: [fake_deployment]) }
|
65
|
-
|
66
61
|
context "when the deployment is a rollback" do
|
67
|
-
|
62
|
+
before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "rollback") }
|
68
63
|
|
69
64
|
it "lists the deployment" do
|
70
|
-
Kernel.should_receive(:puts).
|
65
|
+
Kernel.should_receive(:puts) { |m| m.should =~ /rollback/ }
|
71
66
|
cli.list("ducks")
|
72
67
|
end
|
73
68
|
end
|
74
69
|
|
75
70
|
context "when the deployment is a deploy" do
|
76
|
-
|
71
|
+
before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy") }
|
77
72
|
|
78
73
|
it "lists the deployment" do
|
79
|
-
Kernel.should_receive(:puts).
|
74
|
+
Kernel.should_receive(:puts) { |m| m.should =~ /deploy/ }
|
80
75
|
cli.list("ducks")
|
81
76
|
end
|
82
77
|
end
|
83
78
|
|
84
79
|
context "when the deployment is a custom cookbook update" do
|
85
|
-
|
80
|
+
before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "update_custom_cookbooks") }
|
86
81
|
|
87
82
|
it "lists the deployment" do
|
88
|
-
Kernel.should_receive(:puts).
|
83
|
+
Kernel.should_receive(:puts) { |m| m.should =~ /update_custom_cookbooks/ }
|
89
84
|
cli.list("ducks")
|
90
85
|
end
|
91
86
|
end
|
92
87
|
|
93
88
|
context "when the deployment is a recipe execution" do
|
94
|
-
|
89
|
+
before { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "execute_recipes") }
|
95
90
|
|
96
91
|
it "lists the deployment" do
|
97
|
-
Kernel.should_receive(:puts).
|
92
|
+
Kernel.should_receive(:puts) { |m| m.should =~ /execute_recipes/ }
|
98
93
|
cli.list("ducks")
|
99
94
|
end
|
100
95
|
end
|
@@ -118,10 +113,8 @@ describe Dumbwaiter::Cli do
|
|
118
113
|
|
119
114
|
describe "#layers" do
|
120
115
|
context "when the stack exists" do
|
121
|
-
before { fake_stack.stub(layers: [fake_layer]) }
|
122
|
-
|
123
116
|
it "lists the layers" do
|
124
|
-
Kernel.should_receive(:puts).with(
|
117
|
+
Kernel.should_receive(:puts).with(fake_layer.shortname)
|
125
118
|
cli.layers("ducks")
|
126
119
|
end
|
127
120
|
end
|
@@ -136,7 +129,7 @@ describe Dumbwaiter::Cli do
|
|
136
129
|
describe "#rechef" do
|
137
130
|
context "when the stack exists" do
|
138
131
|
it "deploys the stack with the resolved id" do
|
139
|
-
|
132
|
+
Dumbwaiter::Stack.any_instance.should_receive(:rechef)
|
140
133
|
cli.rechef("ducks")
|
141
134
|
end
|
142
135
|
end
|
@@ -152,7 +145,7 @@ describe Dumbwaiter::Cli do
|
|
152
145
|
context "when the stack exists" do
|
153
146
|
context "when the layer exists" do
|
154
147
|
it "runs the recipe on the layer" do
|
155
|
-
|
148
|
+
Dumbwaiter::Layer.any_instance.should_receive(:run_recipe).with("meatballs")
|
156
149
|
cli.run_recipe("ducks", "beans", "meatballs")
|
157
150
|
end
|
158
151
|
end
|
@@ -7,14 +7,14 @@ describe Dumbwaiter::DeploymentCustomJson do
|
|
7
7
|
let(:custom_json) { {} }
|
8
8
|
|
9
9
|
its(:app_name) { should be_nil }
|
10
|
-
its(:
|
10
|
+
its(:revision) { should be_nil }
|
11
11
|
end
|
12
12
|
|
13
13
|
context "when the custom json contains a revision" do
|
14
14
|
let(:custom_json) { {deploy: {"reifel" => {scm: {revision: "corn"}}}} }
|
15
15
|
|
16
16
|
its(:app_name) { should == "reifel" }
|
17
|
-
its(:
|
17
|
+
its(:revision) { should == "corn" }
|
18
18
|
end
|
19
19
|
|
20
20
|
describe ".create" do
|
@@ -28,6 +28,6 @@ describe Dumbwaiter::DeploymentCustomJson do
|
|
28
28
|
subject(:json) { Dumbwaiter::DeploymentCustomJson.from_json(json_string) }
|
29
29
|
|
30
30
|
its(:app_name) { should == "toes" }
|
31
|
-
its(:
|
31
|
+
its(:revision) { should == "jam" }
|
32
32
|
end
|
33
33
|
end
|
@@ -1,67 +1,58 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Dumbwaiter::Deployment do
|
4
|
-
let(:
|
4
|
+
let(:fake_opsworks) { Dumbwaiter::Mock.new }
|
5
|
+
let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
|
6
|
+
let(:fake_app) { fake_opsworks.make_app(fake_stack, "yo") }
|
7
|
+
let!(:fake_user_profile) { fake_opsworks.make_user_profile("ie", "goose") }
|
5
8
|
let(:custom_json) { JSON.dump(deploy: {"hockey" => {scm: {revision: "eh-buddy"}}}) }
|
6
|
-
let(:fake_deployment)
|
7
|
-
|
8
|
-
created_at: "last Tuesday",
|
9
|
-
command: fake_command,
|
10
|
-
status: "badical",
|
11
|
-
custom_json: custom_json,
|
12
|
-
iam_user_arn: "ie",
|
13
|
-
comment: "i love sports"
|
14
|
-
)
|
15
|
-
end
|
16
|
-
let(:fake_deployments) { double(:deployments, deployments: [fake_deployment]) }
|
17
|
-
let(:fake_user_profile) { double(:user_profile, name: "goose") }
|
18
|
-
let(:fake_user_profiles) { double(:user_profiles, user_profiles: [fake_user_profile]) }
|
19
|
-
let(:fake_opsworks) { double(:opsworks, describe_deployments: fake_deployments, describe_user_profiles: fake_user_profiles) }
|
9
|
+
let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", custom_json, DateTime.parse("last Tuesday").to_s, "ie", "i love sports") }
|
10
|
+
let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
|
20
11
|
|
21
|
-
subject(:deployment) { Dumbwaiter::Deployment.new(fake_deployment, fake_opsworks) }
|
12
|
+
subject(:deployment) { Dumbwaiter::Deployment.new(real_stack, fake_deployment, fake_opsworks) }
|
22
13
|
|
23
|
-
its(:opsworks_deployment) { should == fake_deployment }
|
24
14
|
its(:created_at) { should == DateTime.parse("last Tuesday") }
|
25
|
-
its(:command_name) { should == "
|
15
|
+
its(:command_name) { should == "deploy" }
|
26
16
|
its(:status) { should == "badical" }
|
27
17
|
its(:comment) { should == "i love sports" }
|
28
|
-
its(:
|
29
|
-
its(:to_log) { should == "#{DateTime.parse("last Tuesday")} - goose - deplode - badical - eh-buddy" }
|
18
|
+
its(:revision) { should == "eh-buddy" }
|
30
19
|
its(:user_name) { should == "goose" }
|
31
20
|
|
21
|
+
context "when the command name is deploy" do
|
22
|
+
its(:to_log) { should == "#{DateTime.parse("last Tuesday")} - goose - deploy - badical - eh-buddy" }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when the command name is not deploy" do
|
26
|
+
let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "floss", "badical", custom_json, DateTime.parse("last Tuesday").to_s, "ie", "i love sports") }
|
27
|
+
|
28
|
+
its(:to_log) { should == "#{DateTime.parse("last Tuesday")} - goose - floss - badical" }
|
29
|
+
end
|
30
|
+
|
32
31
|
context "when the iam user arn is nil" do
|
33
|
-
let(:fake_deployment)
|
34
|
-
double(:deployment,
|
35
|
-
created_at: "last Tuesday",
|
36
|
-
command: fake_command,
|
37
|
-
status: "badical",
|
38
|
-
custom_json: custom_json,
|
39
|
-
iam_user_arn: nil
|
40
|
-
)
|
41
|
-
end
|
32
|
+
let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", custom_json, DateTime.parse("last Tuesday").to_s, nil, "i love sports") }
|
42
33
|
|
43
|
-
its(:user_name) { should == "
|
34
|
+
its(:user_name) { should == "OpsWorks" }
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when the iam user arn does not exist" do
|
38
|
+
let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", custom_json, DateTime.parse("last Tuesday").to_s, "wait which user is this", "i love sports") }
|
39
|
+
|
40
|
+
before { fake_opsworks.clear }
|
41
|
+
|
42
|
+
its(:user_name) { should == "OpsWorks" }
|
44
43
|
end
|
45
44
|
|
46
45
|
context "when custom_json is nil" do
|
47
|
-
let(:
|
48
|
-
|
49
|
-
created_at: "yo",
|
50
|
-
command: fake_command,
|
51
|
-
status: "badical",
|
52
|
-
custom_json: nil
|
53
|
-
)
|
54
|
-
end
|
46
|
+
let(:real_app) { Dumbwaiter::App.new(real_stack, fake_app, fake_opsworks) }
|
47
|
+
let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app, "jello", "deploy", "badical", nil, DateTime.parse("last Tuesday").to_s, "ie", "i love sports") }
|
55
48
|
|
56
|
-
its(:
|
49
|
+
its(:revision) { should == "#{real_app.revision}@{#{DateTime.parse("last Tuesday")}}" }
|
57
50
|
end
|
58
51
|
|
59
52
|
describe ".all" do
|
60
|
-
let(:fake_stack) { double(:stack, id: "pancakes") }
|
61
|
-
|
62
53
|
it "fetches all the deployments" do
|
63
|
-
fake_opsworks.should_receive(:describe_deployments).with(stack_id: "pancakes")
|
64
|
-
Dumbwaiter::Deployment.all(
|
54
|
+
fake_opsworks.should_receive(:describe_deployments).with(stack_id: "pancakes").and_call_original
|
55
|
+
Dumbwaiter::Deployment.all(real_stack, fake_opsworks).should have(1).deployment
|
65
56
|
end
|
66
57
|
end
|
67
58
|
end
|
@@ -1,22 +1,21 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Dumbwaiter::Instance do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
|
7
|
-
let(:fake_instance) {
|
8
|
-
let(:fake_instances) { double(:instances, instances: [fake_instance]) }
|
9
|
-
let(:fake_opsworks) { double(:opsworks, describe_instances: fake_instances) }
|
4
|
+
let(:fake_opsworks) { Dumbwaiter::Mock.new }
|
5
|
+
let(:fake_stack) { fake_opsworks.make_stack }
|
6
|
+
let(:fake_layer) { fake_opsworks.make_layer(fake_stack) }
|
7
|
+
let!(:fake_instance) { fake_opsworks.make_instance(fake_stack, fake_layer) }
|
10
8
|
|
11
9
|
subject(:instance) { Dumbwaiter::Instance.new(fake_layer, fake_instance, fake_opsworks) }
|
12
10
|
|
13
|
-
its(:
|
14
|
-
its(:id) { should == "dragons" }
|
11
|
+
its(:id) { should == fake_instance.instance_id }
|
15
12
|
|
16
13
|
describe ".all" do
|
14
|
+
let(:real_layer) { Dumbwaiter::Layer.new(fake_stack, fake_layer, fake_opsworks) }
|
15
|
+
|
17
16
|
it "fetches all the instances" do
|
18
|
-
fake_opsworks.should_receive(:describe_instances).with(layer_id:
|
19
|
-
Dumbwaiter::Instance.all(
|
17
|
+
fake_opsworks.should_receive(:describe_instances).with(layer_id: fake_layer.layer_id).and_call_original
|
18
|
+
Dumbwaiter::Instance.all(real_layer, fake_opsworks).should have(1).instance
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -1,43 +1,41 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Dumbwaiter::Layer do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:fake_instance) {
|
8
|
-
|
9
|
-
let(:
|
10
|
-
|
11
|
-
before do
|
12
|
-
Dumbwaiter::Instance.stub(all: [fake_instance])
|
13
|
-
end
|
4
|
+
let(:fake_opsworks) { Dumbwaiter::Mock.new }
|
5
|
+
let(:fake_stack) { fake_opsworks.make_stack("pancakes") }
|
6
|
+
let(:fake_layer) { fake_opsworks.make_layer(fake_stack, "pinto", "meaty") }
|
7
|
+
let!(:fake_instance) { fake_opsworks.make_instance(fake_layer, fake_stack, "dragons") }
|
8
|
+
|
9
|
+
let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
|
14
10
|
|
15
|
-
subject(:layer) { Dumbwaiter::Layer.new(
|
11
|
+
subject(:layer) { Dumbwaiter::Layer.new(real_stack, fake_layer, fake_opsworks) }
|
16
12
|
|
17
13
|
its(:opsworks_layer) { should == fake_layer }
|
18
14
|
its(:id) { should == "pinto" }
|
19
15
|
its(:shortname) { should == "meaty" }
|
20
16
|
|
21
|
-
|
17
|
+
it { should have(1).instances }
|
22
18
|
|
23
19
|
describe ".all" do
|
20
|
+
let(:real_stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
|
21
|
+
|
24
22
|
it "fetches all the deployments" do
|
25
|
-
fake_opsworks.should_receive(:describe_layers).with(stack_id: "pancakes")
|
26
|
-
Dumbwaiter::Layer.all(
|
23
|
+
fake_opsworks.should_receive(:describe_layers).with(stack_id: "pancakes").and_call_original
|
24
|
+
Dumbwaiter::Layer.all(real_stack, fake_opsworks).should have(1).layer
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
28
|
describe ".find" do
|
31
29
|
context "when the layer exists" do
|
32
30
|
it "finds the layer by name" do
|
33
|
-
Dumbwaiter::Layer.find(
|
31
|
+
Dumbwaiter::Layer.find(real_stack, "meaty", fake_opsworks).shortname.should == "meaty"
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
37
35
|
context "when the layer does not exist" do
|
38
36
|
it "blows up" do
|
39
37
|
expect {
|
40
|
-
Dumbwaiter::Layer.find(
|
38
|
+
Dumbwaiter::Layer.find(real_stack, "brick", fake_opsworks)
|
41
39
|
}.to raise_error(Dumbwaiter::Layer::NotFound)
|
42
40
|
end
|
43
41
|
end
|
@@ -1,30 +1,22 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Dumbwaiter::Stack do
|
4
|
-
let(:
|
5
|
-
let(:
|
6
|
-
let(:
|
7
|
-
let(:
|
8
|
-
let(:
|
9
|
-
let(:fake_layer) { double(:layer) }
|
4
|
+
let(:fake_opsworks) { Dumbwaiter::Mock.new }
|
5
|
+
let!(:fake_stack) { fake_opsworks.make_stack("cool", "ducks", "hot pink") }
|
6
|
+
let!(:fake_app) { fake_opsworks.make_app(fake_stack) }
|
7
|
+
let!(:fake_deployment) { fake_opsworks.make_deployment(fake_stack, fake_app) }
|
8
|
+
let!(:fake_layer) { fake_opsworks.make_layer(fake_stack) }
|
10
9
|
|
11
10
|
subject(:stack) { Dumbwaiter::Stack.new(fake_stack, fake_opsworks) }
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Dumbwaiter::Layer.stub(all: [fake_layer])
|
17
|
-
end
|
12
|
+
it { should have(1).apps }
|
13
|
+
it { should have(1).deployments }
|
14
|
+
it { should have(1).layers }
|
18
15
|
|
19
|
-
its(:opsworks_stack) { should == fake_stack }
|
20
16
|
its(:id) { should == "cool" }
|
21
17
|
its(:name) { should == "ducks" }
|
22
18
|
its(:color) { should == "hot pink" }
|
23
19
|
|
24
|
-
its(:apps) { should == [fake_app] }
|
25
|
-
its(:deployments) { should == [fake_deployment] }
|
26
|
-
its(:layers) { should == [fake_layer] }
|
27
|
-
|
28
20
|
describe ".all" do
|
29
21
|
it "fetches all the stacks" do
|
30
22
|
Dumbwaiter::Stack.all(fake_opsworks).should have(1).stack
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dumbwaiter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doc Ritezel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faker
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Hoist your code up to Opsworks
|
98
112
|
email:
|
99
113
|
- doc@ministryofvelocity.com
|
@@ -120,6 +134,7 @@ files:
|
|
120
134
|
- lib/dumbwaiter/deployment_custom_json.rb
|
121
135
|
- lib/dumbwaiter/instance.rb
|
122
136
|
- lib/dumbwaiter/layer.rb
|
137
|
+
- lib/dumbwaiter/mock.rb
|
123
138
|
- lib/dumbwaiter/stack.rb
|
124
139
|
- lib/dumbwaiter/user_profile.rb
|
125
140
|
- lib/dumbwaiter/version.rb
|