inception-server 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.chef/knife.rb +4 -0
  2. data/.gitignore +21 -0
  3. data/.kitchen.yml +47 -0
  4. data/.rspec +3 -0
  5. data/.travis.yml +18 -0
  6. data/Berksfile +8 -0
  7. data/Berksfile.lock +9 -0
  8. data/ChangeLog.md +20 -0
  9. data/Gemfile +27 -0
  10. data/Guardfile +6 -0
  11. data/LICENSE.txt +22 -0
  12. data/README.md +126 -0
  13. data/Rakefile +66 -0
  14. data/TODO.md +25 -0
  15. data/bin/inception +8 -0
  16. data/bin/inception-server +8 -0
  17. data/config/ssh/kitchen-aws +23 -0
  18. data/cookbooks/bosh_inception/README.md +15 -0
  19. data/cookbooks/bosh_inception/attributes/default.rb +25 -0
  20. data/cookbooks/bosh_inception/files/default/Gemfile.cf +5 -0
  21. data/cookbooks/bosh_inception/files/default/Gemfile.micro +5 -0
  22. data/cookbooks/bosh_inception/metadata.rb +32 -0
  23. data/cookbooks/bosh_inception/recipes/default.rb +16 -0
  24. data/cookbooks/bosh_inception/recipes/install_bosh.rb +37 -0
  25. data/cookbooks/bosh_inception/recipes/install_ruby.rb +10 -0
  26. data/cookbooks/bosh_inception/recipes/mount_store_volume.rb +24 -0
  27. data/cookbooks/bosh_inception/recipes/packages.rb +23 -0
  28. data/cookbooks/bosh_inception/recipes/setup_dotfog.rb +29 -0
  29. data/cookbooks/bosh_inception/recipes/setup_git.rb +34 -0
  30. data/cookbooks/bosh_inception/recipes/useful_dirs.rb +13 -0
  31. data/inception-server.gemspec +43 -0
  32. data/lib/inception/cli.rb +141 -0
  33. data/lib/inception/cli_helpers/display.rb +26 -0
  34. data/lib/inception/cli_helpers/interactions.rb +15 -0
  35. data/lib/inception/cli_helpers/prepare_deploy_settings.rb +89 -0
  36. data/lib/inception/cli_helpers/provider.rb +14 -0
  37. data/lib/inception/cli_helpers/settings.rb +53 -0
  38. data/lib/inception/inception_server.rb +304 -0
  39. data/lib/inception/inception_server_cookbook.rb +90 -0
  40. data/lib/inception/next_deploy_actions.rb +20 -0
  41. data/lib/inception/providers/README.md +5 -0
  42. data/lib/inception/providers/clients/aws_provider_client.rb +144 -0
  43. data/lib/inception/providers/clients/fog_provider_client.rb +185 -0
  44. data/lib/inception/providers/clients/openstack_provider_client.rb +84 -0
  45. data/lib/inception/providers/constants/aws_constants.rb +25 -0
  46. data/lib/inception/providers/constants/openstack_constants.rb +12 -0
  47. data/lib/inception/providers.rb +28 -0
  48. data/lib/inception/version.rb +3 -0
  49. data/lib/inception.rb +9 -0
  50. data/nodes/.gitkeep +0 -0
  51. data/spec/assets/.gitkeep +0 -0
  52. data/spec/assets/gitconfig +5 -0
  53. data/spec/assets/settings/aws-before-server.yml +14 -0
  54. data/spec/assets/settings/aws-created-server.yml +31 -0
  55. data/spec/integration/.gitkeep +0 -0
  56. data/spec/integration/aws/aws_basic_spec.rb +38 -0
  57. data/spec/spec_helper.rb +50 -0
  58. data/spec/support/aws/aws_helpers.rb +73 -0
  59. data/spec/support/settings_helper.rb +20 -0
  60. data/spec/support/stdout_capture.rb +17 -0
  61. data/spec/unit/.gitkeep +0 -0
  62. data/spec/unit/cli_delete_spec.rb +39 -0
  63. data/spec/unit/cli_deploy_aws_spec.rb +83 -0
  64. data/spec/unit/cli_ssh_spec.rb +80 -0
  65. data/spec/unit/inception_server_cookbook_spec.rb +62 -0
  66. data/spec/unit/inception_server_spec.rb +58 -0
  67. data/spec/unit/providers/aws_spec.rb +198 -0
  68. data/test/integration/default/bats/discover_user.bash +2 -0
  69. data/test/integration/default/bats/dotfog.bats +11 -0
  70. data/test/integration/default/bats/install_ruby.bats +8 -0
  71. data/test/integration/default/bats/useful_dirs.bats +8 -0
  72. data/test/integration/default/bats/user.bats +9 -0
  73. data/test/integration/default/bats/verify_bosh.bats +18 -0
  74. data/test/integration/default/bats/verify_git.bats +18 -0
  75. metadata +361 -0
@@ -0,0 +1,83 @@
1
+ require File.expand_path("../../support/aws/aws_helpers", __FILE__)
2
+
3
+ require "fog"
4
+
5
+ describe "AWS deployment" do
6
+ include FileUtils
7
+ include StdoutCapture
8
+ include SettingsHelper
9
+ include AwsHelpers
10
+
11
+ before do
12
+ setup_home_dir
13
+ Fog.mock!
14
+ @cmd = Inception::Cli.new
15
+ @cmd.stub(:converge_cookbooks)
16
+ @credentials = {aws_access_key_id: "ACCESS", aws_secret_access_key: "SECRET"}
17
+ @fog_credentials = @credentials.merge(provider: "AWS")
18
+ end
19
+
20
+ describe "with simple manifest" do
21
+ before do
22
+ create_manifest(credentials: @credentials)
23
+ capture_stdout { cmd.deploy }
24
+ # cmd.deploy
25
+ end
26
+
27
+ it "populates settings with git.name & git.email from ~/.gitconfig" do
28
+ settings.git.name.should == "Dr Nic Williams"
29
+ settings.git.email.should == "drnicwilliams@gmail.com"
30
+ end
31
+
32
+ it "creates an elastic IP automatically and assigns to settings.inception.provisioned.ip_address" do
33
+ settings.inception.provisioned.ip_address.should_not be_nil
34
+ end
35
+
36
+ it "creates AWS key pair and assigns to inception.key_pair.name / private_key" do
37
+ settings.inception.key_pair.name.should == "inception"
38
+ settings.inception.key_pair.private_key.should_not be_nil
39
+ end
40
+
41
+ it "stores private key in local file" do
42
+ local_private_key = File.expand_path("~/.inception_server/ssh/inception")
43
+ File.should be_exist(local_private_key)
44
+ File.read(local_private_key).should == settings.inception.key_pair.private_key
45
+ end
46
+
47
+ it "provisions inception server" do
48
+ settings.inception.flavor.should == "m1.small"
49
+ settings.inception.disk_size.should == 16
50
+ settings.inception.image_id.should == "ami-bf1d8a8f" # us-west-2 13.04 AMI
51
+ settings.inception.security_groups.should == ["ssh"]
52
+
53
+ settings.inception.provisioned.username.should == "ubuntu"
54
+ settings.inception.provisioned.host.should_not be_nil
55
+ settings.inception.provisioned.server_id.should_not be_nil
56
+
57
+ settings.inception.provisioned.disk_device.volume_id.should_not be_nil
58
+ settings.inception.provisioned.disk_device.external.should == "/dev/sdf"
59
+ settings.inception.provisioned.disk_device.internal.should == "/dev/xvdf"
60
+ end
61
+
62
+ end
63
+
64
+ describe "converge inception server if it fails midway" do
65
+ it "use local git config even if already allocated" do
66
+ create_manifest(credentials: @credentials, "git.name" => "Mystery", "git.email" => "mystery@gmail.com")
67
+ capture_stdout { cmd.deploy }
68
+ settings.git.email.should == "drnicwilliams@gmail.com"
69
+ end
70
+
71
+ it "does not provision another IP address if already allocated" do
72
+ create_manifest(credentials: @credentials, "inception.provisioned.ip_address" => "1.2.3.4")
73
+ capture_stdout { cmd.deploy }
74
+ settings.inception.provisioned.ip_address.should == "1.2.3.4"
75
+ end
76
+
77
+ it "provisions another server if server_id id unknown" do
78
+ create_manifest(credentials: @credentials, "inception.provisioned.server_id" => "i-UNKNOWN")
79
+ capture_stdout { cmd.deploy }
80
+ settings.inception.provisioned.server_id.should_not == "i-UNKNOWN"
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,80 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ # Specs for 'ssh' related behavior. Includes CLI commands:
4
+ # * ssh
5
+ # * tmux
6
+ # * mosh
7
+ describe Inception do
8
+ include FileUtils
9
+ include SettingsHelper
10
+
11
+ before do
12
+ setup_home_dir
13
+ @cmd = Inception::Cli.new
14
+ setting "provider.name", "aws"
15
+ setting "provider.credentials.aws_access_key_id", "aws_access_key_id"
16
+ setting "provider.credentials.aws_secret_access_key", "aws_secret_access_key"
17
+ setting "provider.region", "us-west-2"
18
+ setting "inception.key_pair.name", "inception"
19
+ setting "inception.key_pair.private_key", "PRIVATE"
20
+ setting "inception.provisioned.host", "5.5.5.5"
21
+ setting "inception.provisioned.username", "vcap"
22
+ end
23
+
24
+ describe "ssh" do
25
+ let(:private_key_path) { home_file(".inception_server/ssh/inception") }
26
+
27
+ describe "normal" do
28
+ it "launches ssh session" do
29
+ @cmd.should_receive(:exit)
30
+ @cmd.should_receive(:system).
31
+ with("ssh -i #{private_key_path} vcap@5.5.5.5")
32
+ @cmd.ssh
33
+ end
34
+ it "runs ssh command" do
35
+ @cmd.should_receive(:exit)
36
+ @cmd.should_receive(:system).
37
+ with("ssh -i #{private_key_path} vcap@5.5.5.5 'some command'")
38
+ @cmd.ssh("some command")
39
+ end
40
+ end
41
+
42
+ describe "tmux" do
43
+ it "launches ssh session" do
44
+ @cmd.should_receive(:exit)
45
+ @cmd.should_receive(:system).
46
+ with("ssh -i #{private_key_path} vcap@5.5.5.5 -t 'tmux attach || tmux new-session'")
47
+ @cmd.tmux
48
+ end
49
+ end
50
+
51
+ describe "mosh" do
52
+ before { Fog.mock! }
53
+ after { Fog.unmock! }
54
+ xit "should check whether mosh is installed" do
55
+ @cmd.should_receive(:system).
56
+ with("mosh --version")
57
+ @cmd.stub!(:exit)
58
+ @cmd.ensure_mosh_installed
59
+ end
60
+ xit "launches mosh session" do
61
+ @cmd.stub!(:ensure_mosh_installed).and_return(true)
62
+ @cmd.should_receive(:exit)
63
+ @cmd.should_receive(:system).
64
+ with("mosh --ssh 'ssh -i #{@private_key_path}' vcap@5.5.5.5")
65
+ @cmd.mosh
66
+ end
67
+ xit "should ensure that the mosh ports are opened" do
68
+ expected_ports = {
69
+ mosh: {
70
+ protocol: "udp",
71
+ ports: (60000..60050)
72
+ }
73
+ }
74
+ @cmd.provider.stub!(:create_security_group)
75
+ .with('default','not used', expected_ports)
76
+ @cmd.ensure_security_group_allows_mosh
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,62 @@
1
+ describe Inception::InceptionServerCookbook do
2
+ include FileUtils
3
+ include StdoutCapture
4
+ include SettingsHelper
5
+
6
+ before do
7
+ setup_home_dir
8
+ Fog.mock!
9
+ setting "provider.name", "aws"
10
+ setting "provider.credentials.aws_access_key_id", "aws_access_key_id"
11
+ setting "provider.credentials.aws_secret_access_key", "aws_secret_access_key"
12
+ setting "provider.region", "us-west-2"
13
+ setting "git.name", "Dr Nic Williams"
14
+ setting "git.email", "drnicwilliams@gmail.com"
15
+ setting "inception.host", "host"
16
+ setting "inception.provisioned.username", "user"
17
+ setting "inception.provisioned.disk_device.internal", "/dev/abc"
18
+ end
19
+
20
+ let(:settings_dir) { File.expand_path("~/.inception_server") }
21
+ let(:inception_server) { mock(user_host: "user@host", private_key_path: "path/to/key") }
22
+ subject { Inception::InceptionServerCookbook.new(inception_server, settings, settings_dir) }
23
+
24
+ describe "in prepared settings dir" do
25
+ before do
26
+ attributes = '{"disk":{"mounted":true,"device":"/dev/abc"},"git":{"name":"Dr Nic Williams","email":"drnicwilliams@gmail.com"},"user":{"username":"user"},"fog":{"aws_access_key_id":"aws_access_key_id","aws_secret_access_key":"aws_secret_access_key"}}'
27
+ cmd_arguments = "user@host -i path/to/key -j '#{attributes}' -r 'bosh_inception'"
28
+ subject.should_receive(:sh).with("knife solo prepare #{cmd_arguments}")
29
+ subject.prepare
30
+
31
+ subject.should_receive(:sh).with("knife solo cook #{cmd_arguments}")
32
+ subject.converge
33
+ end
34
+
35
+ it "creates Berksfile" do
36
+ FileUtils.chdir(settings_dir) do
37
+ File.should be_exists("Berksfile")
38
+ end
39
+ end
40
+
41
+ it "copies in cookbook" do
42
+ FileUtils.chdir(settings_dir) do
43
+ File.should be_exists("cookbooks/bosh_inception/recipes/default.rb")
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "after initial converge" do
49
+ it "does not prepare/install chef again" do
50
+ setting "cookbook.prepared", true
51
+ cookbook = Inception::InceptionServerCookbook.new(inception_server, settings, settings_dir)
52
+
53
+ attributes = '{"disk":{"mounted":true,"device":"/dev/abc"},"git":{"name":"Dr Nic Williams","email":"drnicwilliams@gmail.com"},"user":{"username":"user"},"fog":{"aws_access_key_id":"aws_access_key_id","aws_secret_access_key":"aws_secret_access_key"}}'
54
+ cmd_arguments = "user@host -i path/to/key -j '#{attributes}' -r 'bosh_inception'"
55
+
56
+ subject.should_receive(:sh).with("knife solo cook #{cmd_arguments}") # just to stub :sh
57
+ subject.prepare
58
+ subject.converge
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,58 @@
1
+ describe Inception::InceptionServer do
2
+ include StdoutCapture
3
+
4
+ describe "new AWS server" do
5
+ let(:provider_attributes) do
6
+ {
7
+ "name" => "aws",
8
+ "region" => "us-west-2",
9
+ "credentials" => {
10
+ "aws_access_key_id" => 'MOCK_AWS_ACCESS_KEY_ID',
11
+ "aws_secret_access_key" => 'MOCK_AWS_SECRET_ACCESS_KEY'
12
+ }
13
+ }
14
+ end
15
+ let(:attributes) do
16
+ {
17
+ "provisioned" => {
18
+ "ip_address" => "54.214.15.178"
19
+ },
20
+ "key_pair" => {
21
+ "name" => "inception",
22
+ "private_key" => "private_key",
23
+ "public_key" => "public_key"
24
+ }
25
+ }
26
+ end
27
+ let(:provider_client) { Inception::Providers.provider_client(provider_attributes) }
28
+ let(:ssh_dir) { "~/.inception_server/ssh" }
29
+ subject { Inception::InceptionServer.new(provider_client, attributes, ssh_dir) }
30
+ let(:fog_compute) { subject.fog_compute }
31
+
32
+ before do
33
+ Fog.mock!
34
+ Fog::Mock.reset
35
+ capture_stdout do
36
+ provider_client.create_key_pair("inception")
37
+ subject.create
38
+ end
39
+ end
40
+
41
+ it "has default security groups" do
42
+ subject.security_groups.should == ["ssh"]
43
+ fog_compute.security_groups.get("ssh").should_not be_nil
44
+ end
45
+
46
+ it "has default flavor" do
47
+ subject.flavor.should == "m1.small"
48
+ end
49
+
50
+ it "has default disk size" do
51
+ subject.disk_size.should == 16
52
+ end
53
+
54
+ xit "is created" do
55
+ fog_compute.servers.size.should == 1
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,198 @@
1
+ # Copyright (c) 2012-2013 Stark & Wayne, LLC
2
+
3
+ require "fog"
4
+
5
+ # Specs for the aws provider
6
+ describe Inception::Providers do
7
+ include FileUtils
8
+ include StdoutCapture
9
+
10
+ describe "AWS" do
11
+ before { Fog.mock! }
12
+ let(:provider_attributes) do
13
+ {
14
+ "name" => "aws",
15
+ "region" => "us-west-2",
16
+ "credentials" => {
17
+ "aws_access_key_id" => 'MOCK_AWS_ACCESS_KEY_ID',
18
+ "aws_secret_access_key" => 'MOCK_AWS_SECRET_ACCESS_KEY'
19
+ }
20
+ }
21
+ end
22
+ subject { Inception::Providers.provider_client(provider_attributes) }
23
+ let(:fog_compute) { subject.fog_compute }
24
+
25
+ describe "create security group" do
26
+ it "should open a single TCP port on a security group" do
27
+ capture_stdout do
28
+ ports = { ssh: 22 }
29
+ subject.create_security_group("sg1-name", "sg1-desc", ports)
30
+ created_sg = fog_compute.security_groups.get("sg1-name")
31
+ created_sg.name.should == "sg1-name"
32
+ created_sg.description.should == "sg1-desc"
33
+ created_sg.ip_permissions.should == [
34
+ {
35
+ "ipProtocol"=>"tcp",
36
+ "fromPort"=>22,
37
+ "toPort"=>22,
38
+ "groups"=>[],
39
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
40
+ }
41
+ ]
42
+ end
43
+ end
44
+ it "should open a range of TCP ports" do
45
+ capture_stdout do
46
+ ports = { ssh: (22..30) }
47
+ subject.create_security_group("sg-range-name", "sg-range-desc", ports)
48
+ created_sg = fog_compute.security_groups.get("sg-range-name")
49
+ created_sg.ip_permissions.should == [
50
+ {
51
+ "ipProtocol"=>"tcp",
52
+ "fromPort"=>22,
53
+ "toPort"=>30,
54
+ "groups"=>[],
55
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
56
+ }
57
+ ]
58
+ end
59
+ end
60
+ it "should open a range of UDP ports" do
61
+ capture_stdout do
62
+ ports = { ssh: { protocol: "udp", ports: (60000..600050) } }
63
+ subject.create_security_group("sg-range-udp-name", "sg-range-udp-name", ports)
64
+ created_sg = fog_compute.security_groups.get("sg-range-udp-name")
65
+ created_sg.ip_permissions.should == [
66
+ {
67
+ "ipProtocol"=>"udp",
68
+ "fromPort"=>60000,
69
+ "toPort"=>600050,
70
+ "groups"=>[],
71
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
72
+ }
73
+ ]
74
+ end
75
+ end
76
+ it "should open a range of ICMP ports" do
77
+ capture_stdout do
78
+ ports = { ping: { protocol: "icmp", ports: (3..4) } }
79
+ subject.create_security_group("sg-range-icmp-name", "sg-range-icmp-name", ports)
80
+ created_sg = fog_compute.security_groups.get("sg-range-icmp-name")
81
+ created_sg.ip_permissions.should == [
82
+ {
83
+ "ipProtocol"=>"icmp",
84
+ "fromPort"=>3,
85
+ "toPort"=>4,
86
+ "groups"=>[],
87
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
88
+ }
89
+ ]
90
+ end
91
+ end
92
+ it "should open not open ports if they are already open" do
93
+ capture_stdout do
94
+ subject.create_security_group("sg2", "", { ssh: { protocol: "udp", ports: (60000..600050) } })
95
+ subject.create_security_group("sg2", "", { ssh: { protocol: "udp", ports: (60010..600040) } })
96
+ subject.create_security_group("sg2", "", { ssh: { protocol: "udp", ports: (60000..600050) } })
97
+ created_sg = fog_compute.security_groups.get("sg2")
98
+ created_sg.ip_permissions.should == [
99
+ {
100
+ "ipProtocol"=>"udp",
101
+ "fromPort"=>60000,
102
+ "toPort"=>600050,
103
+ "groups"=>[],
104
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
105
+ }
106
+ ]
107
+ end
108
+ end
109
+ xit "should open ports even if they are already open for a different protocol" do
110
+ capture_stdout do
111
+ subject.create_security_group("sg3", "", { ssh: { protocol: "udp", ports: (60000..600050) } })
112
+ subject.create_security_group("sg3", "", { ssh: { protocol: "tcp", ports: (60000..600050) } })
113
+ created_sg = fog_compute.security_groups.get("sg3")
114
+ created_sg.ip_permissions.should == [
115
+ {
116
+ "ipProtocol"=>"udp",
117
+ "fromPort"=>60000,
118
+ "toPort"=>600050,
119
+ "groups"=>[],
120
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
121
+ },
122
+ {
123
+ "ipProtocol"=>"tcp",
124
+ "fromPort"=>60000,
125
+ "toPort"=>600050,
126
+ "groups"=>[],
127
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
128
+ }
129
+ ]
130
+ end
131
+ end
132
+ xit "should open ports even if they are already open for a different ip_range" do
133
+ capture_stdout do
134
+ default_ports = {
135
+ all_internal_tcp: { protocol: "tcp", ip_range: "1.1.1.1/32", ports: (0..65535) }
136
+ }
137
+ subject.create_security_group("sg6", "sg6", default_ports)
138
+ subject.create_security_group("sg6", "sg6", { mosh: { protocol: "tcp", ports: (15..30) } })
139
+ created_sg = fog_compute.security_groups.get("sg6")
140
+ created_sg.ip_permissions.should == [
141
+ {
142
+ "ipProtocol"=>"tcp",
143
+ "fromPort"=>0,
144
+ "toPort"=>65535,
145
+ "groups"=>[],
146
+ "ipRanges"=>[ { "cidrIp"=>"1.1.1.1/32" } ]
147
+ },
148
+ {
149
+ "ipProtocol"=>"tcp",
150
+ "fromPort"=>15,
151
+ "toPort"=>30,
152
+ "groups"=>[],
153
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
154
+ }
155
+ ]
156
+ end
157
+ end
158
+ xit "should open ports on the default sg" do
159
+ capture_stdout do
160
+ subject.create_security_group("default", "default", { mosh: { protocol: "tcp", ports: (15..30) } })
161
+ created_sg = fog_compute.security_groups.get("default")
162
+ expected_rule = {
163
+ "ipProtocol"=>"tcp",
164
+ "fromPort"=>15,
165
+ "toPort"=>30,
166
+ "groups"=>[],
167
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
168
+ }
169
+ created_sg.ip_permissions.should include expected_rule
170
+ end
171
+ end
172
+ #AWS allows overlapping port ranges, and it makes it easier to see the separate "rules" that were added
173
+ xit "should create overlapping port ranges" do
174
+ capture_stdout do
175
+ subject.create_security_group("sg4", "", { ssh: { protocol: "udp", ports: (10..20) } })
176
+ subject.create_security_group("sg4", "", { ssh: { protocol: "udp", ports: (15..30) } })
177
+ created_sg = fog_compute.security_groups.get("sg4")
178
+ created_sg.ip_permissions.should == [
179
+ {
180
+ "ipProtocol"=>"udp",
181
+ "fromPort"=>10,
182
+ "toPort"=>20,
183
+ "groups"=>[],
184
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
185
+ },
186
+ {
187
+ "ipProtocol"=>"udp",
188
+ "fromPort"=>15,
189
+ "toPort"=>30,
190
+ "groups"=>[],
191
+ "ipRanges"=>[ { "cidrIp"=>"0.0.0.0/0" } ]
192
+ }
193
+ ]
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,2 @@
1
+ export TEST_USER=$(users | head -n1 | awk '{print $1}')
2
+ export TEST_USER_HOME="/home/$TEST_USER"
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load discover_user
4
+
5
+ @test "~/.fog contains default.aws_access_key_id" {
6
+ run su - $TEST_USER -c "cat $TEST_USER_HOME/.fog"
7
+ [ "${lines[0]}" = "---" ]
8
+ [ "${lines[1]}" = ":default:" ]
9
+ [ "${lines[2]}" = " :aws_access_key_id: PERSONAL_ACCESS_KEY" ]
10
+ [ "${lines[3]}" = " :aws_secret_access_key: PERSONAL_SECRET" ]
11
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load discover_user
4
+
5
+ @test "ruby 1.9.3p392 is default" {
6
+ run su - $TEST_USER -c "ruby -v"
7
+ [ "$(echo ${lines[0]} | awk '{print $2}')" = "1.9.3p392" ]
8
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bats
2
+
3
+ @test "use file dirs created" {
4
+ for dir in microboshes/deployments deployments releases repos stemcells systems tmp bosh_cache
5
+ do
6
+ [ -d /var/vcap/store/$dir ]
7
+ done
8
+ }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load discover_user
4
+
5
+ @test "~/.bosh_cache symlink" {
6
+ run su - $TEST_USER -c "readlink ~/.bosh_cache"
7
+ [ "${lines[0]}" = "/var/vcap/store/bosh_cache" ]
8
+ }
9
+
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load discover_user
4
+
5
+ @test "bosh micro installed" {
6
+ run su - $TEST_USER -c "cd /var/vcap/store/microboshes; bundle exec bosh micro"
7
+ [ "$status" -eq 0 ]
8
+ }
9
+
10
+ @test "bosh-bootstrap installed" {
11
+ run su - $TEST_USER -c "cd /var/vcap/store/systems; bundle exec bosh-bootstrap"
12
+ [ "$status" -eq 0 ]
13
+ }
14
+
15
+ @test "bosh-cloudfoundry installed" {
16
+ run su - $TEST_USER -c "cd /var/vcap/store/systems; bundle exec bosh cf"
17
+ [ "$status" -eq 0 ]
18
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bats
2
+
3
+ load discover_user
4
+
5
+ @test "git config name is set" {
6
+ run git config -f $TEST_USER_HOME/.gitconfig user.name
7
+ [ "${lines[0]}" = "Nobody" ]
8
+ }
9
+
10
+ @test "git config email is set" {
11
+ run git config -f $TEST_USER_HOME/.gitconfig user.email
12
+ [ "${lines[0]}" = "nobody@in-the-house.com" ]
13
+ }
14
+
15
+ @test "hub installed" {
16
+ run hub
17
+ [ "$status" -eq 0 ]
18
+ }