engineyard-local 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/.gitignore +23 -0
  2. data/Gemfile +15 -0
  3. data/Gemfile.lock +62 -0
  4. data/README.md +115 -0
  5. data/Rakefile +15 -0
  6. data/bin/ey-local +4 -0
  7. data/config/dna.json +206 -0
  8. data/config/locales/en.yml +57 -0
  9. data/config/settings.yml +18 -0
  10. data/config/solo.rb +7 -0
  11. data/engineyard-local.gemspec +24 -0
  12. data/install/deb/README.md +72 -0
  13. data/install/deb/Rakefile +157 -0
  14. data/install/deb/Vagrantfile +10 -0
  15. data/install/deb/install.sh +32 -0
  16. data/install/osx/README.md +23 -0
  17. data/install/osx/Rakefile +39 -0
  18. data/install/osx/engineyard-local/engineyard-local.pkgproj +812 -0
  19. data/install/osx/images/eylocal_installer.png +0 -0
  20. data/install/osx/scripts/log.sh +3 -0
  21. data/install/osx/scripts/postinstall +57 -0
  22. data/install/osx/scripts/rvm_install.sh +34 -0
  23. data/lib/engineyard-local.rb +42 -0
  24. data/lib/engineyard-local/command.rb +65 -0
  25. data/lib/engineyard-local/command/base.rb +15 -0
  26. data/lib/engineyard-local/command/exec.rb +11 -0
  27. data/lib/engineyard-local/command/group.rb +86 -0
  28. data/lib/engineyard-local/command/helpers.rb +23 -0
  29. data/lib/engineyard-local/command/list.rb +29 -0
  30. data/lib/engineyard-local/command/rails.rb +19 -0
  31. data/lib/engineyard-local/command/up.rb +87 -0
  32. data/lib/engineyard-local/command/vagrant_action.rb +11 -0
  33. data/lib/engineyard-local/errors.rb +10 -0
  34. data/lib/engineyard-local/middleware.rb +28 -0
  35. data/lib/engineyard-local/middleware/bundle.rb +40 -0
  36. data/lib/engineyard-local/middleware/chef.rb +44 -0
  37. data/lib/engineyard-local/middleware/default_provisioner.rb +34 -0
  38. data/lib/engineyard-local/middleware/dna.rb +80 -0
  39. data/lib/engineyard-local/middleware/exec.rb +27 -0
  40. data/lib/engineyard-local/middleware/helpers.rb +4 -0
  41. data/lib/engineyard-local/middleware/helpers/executable.rb +27 -0
  42. data/lib/engineyard-local/middleware/helpers/network.rb +20 -0
  43. data/lib/engineyard-local/middleware/helpers/rvm.rb +37 -0
  44. data/lib/engineyard-local/middleware/helpers/uploadable.rb +14 -0
  45. data/lib/engineyard-local/middleware/network.rb +64 -0
  46. data/lib/engineyard-local/middleware/rails.rb +3 -0
  47. data/lib/engineyard-local/middleware/rails/command.rb +31 -0
  48. data/lib/engineyard-local/middleware/rails/db.rb +36 -0
  49. data/lib/engineyard-local/middleware/rails/install.rb +36 -0
  50. data/lib/engineyard-local/middleware/rails/new.rb +31 -0
  51. data/lib/engineyard-local/middleware/tag.rb +33 -0
  52. data/lib/engineyard-local/ui.rb +33 -0
  53. data/lib/engineyard-local/version.rb +5 -0
  54. data/lib/engineyard-local/virtualbox.rb +35 -0
  55. data/lib/vagrant_init.rb +1 -0
  56. data/test/engineyard-local/command/group_test.rb +34 -0
  57. data/test/engineyard-local/command/up_test.rb +70 -0
  58. data/test/engineyard-local/command_test.rb +40 -0
  59. data/test/engineyard-local/middelware/bundle_test.rb +32 -0
  60. data/test/engineyard-local/middelware/default_provisioner_test.rb +35 -0
  61. data/test/engineyard-local/middelware/exec_test.rb +19 -0
  62. data/test/engineyard-local/middelware/network_test.rb +94 -0
  63. data/test/engineyard-local/middelware/rails/command_test.rb +24 -0
  64. data/test/engineyard-local/middelware/rails/db_test.rb +23 -0
  65. data/test/engineyard-local/middelware/rails/install_test.rb +24 -0
  66. data/test/engineyard-local/ui_test.rb +22 -0
  67. data/test/engineyard-local/virtualbox_test.rb +34 -0
  68. data/test/integration/up_test.rb +28 -0
  69. data/test/test_helper.rb +78 -0
  70. metadata +178 -0
@@ -0,0 +1,19 @@
1
+ require "test_helper"
2
+
3
+ class ExecMiddlewareTest < Test::Unit::TestCase
4
+ include Vagrant::TestHelpers
5
+ include Engineyard::Local::TestHelpers
6
+
7
+ context "bundle" do
8
+ setup do
9
+ @app, @env = action_env
10
+ @middleware = Engineyard::Local::Middleware::Exec.new(@app, @env)
11
+ end
12
+
13
+ should "pass through the commands on the env" do
14
+ @env["eylocal.exec.command_args"] = [ "foo" , "bar", "baz" ]
15
+
16
+ @middleware.commands.include?( "foo bar baz" )
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,94 @@
1
+ require "test_helper"
2
+
3
+ class NetworkTest < Test::Unit::TestCase
4
+ include Vagrant::TestHelpers
5
+ include Engineyard::Local::TestHelpers
6
+
7
+ context "network" do
8
+ setup do
9
+ @app, @env = action_env
10
+ @middleware = Engineyard::Local::Middleware::Network.new(@app, @env, {})
11
+ @middleware.stubs(:check_with_user)
12
+
13
+ @vbox = Engineyard::Local::Virtualbox
14
+ @driver = mock( "vbox_driver")
15
+ @vbox.stubs(:vbox).returns(@driver)
16
+ @driver.stubs(:execute).returns("")
17
+
18
+ @config = Engineyard::Local.config
19
+
20
+ @vb_vm = mock("vb_vm")
21
+ @env[:vm] = @vb_vm
22
+ end
23
+
24
+ should "skip any action when the vm is the current one " do
25
+ @vbox.expects(:uuid_map).returns("foo" => "foo")
26
+ @env[:vm].expects(:uuid).returns("foo")
27
+ @first_vm.expects(:extra_data).never
28
+
29
+ @middleware.call(@env)
30
+ end
31
+
32
+ should "call the next middleware if none of the ips match" do
33
+ common_expectations
34
+
35
+ # make sure the proposed ip is
36
+ @middleware.expects(:proposed_ip).returns("2")
37
+
38
+ @app.expects(:call)
39
+
40
+ # make sure that use is never prompted
41
+ @middleware.expects(:check_with_user).never
42
+
43
+ @middleware.call(@env)
44
+ end
45
+
46
+ should "prompt the user when there is an ip match" do
47
+ common_expectations
48
+
49
+ # make sure the proposed ip is
50
+ @middleware.expects(:proposed_ip).returns("1")
51
+
52
+ # when the ip matches the user should be prompted
53
+ @middleware.expects(:check_with_user).returns("Y")
54
+
55
+ @middleware.call(@env)
56
+ end
57
+
58
+ should "not prompt the user when silent option is provided" do
59
+ @middleware = Engineyard::Local::Middleware::Network.new(@app, @env, {:silent => true})
60
+ common_expectations
61
+
62
+ @middleware.expects(:proposed_ip).never
63
+ @middleware.expects(:check_with_user).never
64
+ @middleware.call(@env)
65
+ end
66
+
67
+ should "raise an exception when the user responds no" do
68
+ common_expectations
69
+
70
+ # make sure the proposed ip is
71
+ @middleware.expects(:proposed_ip).twice.returns("1")
72
+
73
+ # when the ip matches the user should be prompted and in this case respond
74
+ # that they don't want to keep the process going
75
+ @middleware.expects(:check_with_user).returns("N")
76
+
77
+ assert_raise Engineyard::Local::Errors::PossibleIPCollision do
78
+ @middleware.call(@env)
79
+ end
80
+ end
81
+
82
+ def common_expectations(vm_uuid = "baz")
83
+ @vbox.expects(:uuid_map).returns( "foo" => "foo_name" )
84
+
85
+ # make sure that it appears as a different vm from the first mock one
86
+ @env[:vm].expects(:uuid).returns(vm_uuid)
87
+
88
+ # return the ip tagged onto the mock vm
89
+ @vbox.expects(:extra_data).returns("1")
90
+
91
+ @middleware.stubs(:check_with_user).returns("N")
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,24 @@
1
+ require "test_helper"
2
+
3
+ class RailsCommandTest < Test::Unit::TestCase
4
+ include Vagrant::TestHelpers
5
+ include Engineyard::Local::TestHelpers
6
+
7
+ context "rails command" do
8
+ setup do
9
+ @app, @env = action_env
10
+ @env.merge!( "eylocal.rails.command_args" => ["foo"] )
11
+ @klass = Engineyard::Local::Middleware::Rails::Command
12
+ @middleware = @klass.new(@app, @env)
13
+ end
14
+
15
+ should "pass through command args to the rails bin" do
16
+ assert(joined_commands.include?("rails foo"))
17
+ end
18
+
19
+ should "pass through many arguments to the rails bin" do
20
+ @middleware = @klass.new(@app, @env.merge("eylocal.rails.command_args" => ["foo", "bar", "baz:bing:bang"]))
21
+ assert(joined_commands.include?("rails foo bar baz:bing:bang"))
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ require "test_helper"
2
+
3
+ class DBTest < Test::Unit::TestCase
4
+ include Vagrant::TestHelpers
5
+ include Engineyard::Local::TestHelpers
6
+
7
+ context "bundle" do
8
+ setup do
9
+ @app, @env = action_env
10
+ @middleware = Engineyard::Local::Middleware::Rails::DB.new(@app, @env)
11
+ end
12
+
13
+ should "run both db create and migrate" do
14
+ assert(joined_commands.include?("rake db:migrate"))
15
+ assert(joined_commands.include?("rake db:create"))
16
+ end
17
+
18
+ should "execute the commands necessary setup a rails db" do
19
+ mock_ssh_channel(@env).expects(:execute).with(joined_commands)
20
+ @middleware.call(@env)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require "test_helper"
2
+
3
+ class RailsInstallTest < Test::Unit::TestCase
4
+ include Vagrant::TestHelpers
5
+ include Engineyard::Local::TestHelpers
6
+
7
+ context "rails install" do
8
+ setup do
9
+ @app, @env = action_env
10
+ @klass = Engineyard::Local::Middleware::Rails::Install
11
+ @middleware = @klass.new(@app, @env)
12
+ end
13
+
14
+ should "force the version provided" do
15
+ @env.merge!( "eylocal.rails.version" => "foo" )
16
+ assert(joined_commands.include?("gem install rails --version=foo"))
17
+ end
18
+
19
+ should "not include the version flag when none is provided" do
20
+ @middleware = @klass.new(@app, @env)
21
+ assert(!joined_commands.include?("--version"))
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ require "test_helper"
2
+
3
+ class UITest < Test::Unit::TestCase
4
+ context "color" do
5
+ setup do
6
+ @instance = Engineyard::Local::UI::Colored.new("foo")
7
+ end
8
+
9
+ should "replace instances of Vagrant" do
10
+ assert(@instance.ey_localize("Vagrant"), "ey-local")
11
+ end
12
+
13
+ should "replace instances of 'a Vagrant'" do
14
+ assert(@instance.ey_localize("a Vagrant"), "an ey-local")
15
+ assert(@instance.ey_localize("a `vagrant foo`"), "an `ey-local foo`")
16
+ end
17
+
18
+ should "not replace instances of Vagrantfile" do
19
+ assert(@instance.ey_localize("Vagrantfile"), "Vagrantfile")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ require "test_helper"
2
+
3
+ class VirtualboxTest < Test::Unit::TestCase
4
+ context "Virtualbox" do
5
+ setup do
6
+ @klass = Engineyard::Local::Virtualbox
7
+ @vbox = mock("vbox")
8
+ @klass.stubs(:vbox).returns(@vbox)
9
+ end
10
+
11
+ should "return only the key for extra data responses" do
12
+ @vbox.expects(:execute).with("getextradata", "foo", "bar").returns("Value: baz")
13
+
14
+ assert(@klass.extra_data("foo", "bar") == "baz")
15
+ end
16
+
17
+ should "return nil for keys that don't exist" do
18
+ @vbox.expects(:execute).with("getextradata", "foo", "bar").returns("No value set!")
19
+
20
+ assert(!@klass.extra_data("foo", "bar"))
21
+ end
22
+
23
+ should "provide a hash for names and uuids for all vms" do
24
+ @vbox.expects(:execute).with("list", "vms").returns(<<-stdout)
25
+ "Foo" {123}
26
+ "Bar" {1234}
27
+ stdout
28
+
29
+ map = @klass.uuid_map
30
+ assert(map["Foo"] == "123")
31
+ assert(map["Bar"] == "1234")
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ require "test_helper"
2
+
3
+ module Integration
4
+ class UpTest < Test::Unit::TestCase
5
+ include Engineyard::Local::TestHelpers::Integration
6
+
7
+ def setup
8
+ Dir.chdir(ensure_test_directory)
9
+ clear_init
10
+ fail_on_stderr
11
+ end
12
+
13
+ # TODO break these out or rename the test set
14
+ context "up command" do
15
+ should "complete the creation of the vm without prompting" do
16
+ assert_cmd("ey-local up --silent")
17
+ end
18
+
19
+ should "list the vm that was created" do
20
+ assert(`ey-local list` != "", "the output should not be empty")
21
+ end
22
+
23
+ should "destroy the vm that was created" do
24
+ assert_cmd("ey-local destroy -f")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,78 @@
1
+ require "test/unit"
2
+ require "vagrant"
3
+ require "engineyard-local"
4
+ require "shoulda-context"
5
+ require "mocha"
6
+ require "fileutils"
7
+
8
+ # load ruby debug for developer work where present
9
+ begin
10
+ require 'ruby-debug'
11
+ rescue LoadError
12
+ end
13
+
14
+ module Engineyard
15
+ module Local
16
+ module TestHelpers
17
+ def joined_commands
18
+ @middleware.commands.join(";\n")
19
+ end
20
+
21
+ def mock_ssh_channel(env)
22
+ mock_channel = mock("ssh channel")
23
+ env[:vm].expects(:channel).returns(mock_channel)
24
+
25
+ mock_channel
26
+ end
27
+
28
+ module Integration
29
+ def self.included(base)
30
+ puts "If prompted, authenticate for `sudo` to prevent required NFS intervention."
31
+ Kernel.system("sudo true")
32
+ end
33
+
34
+ def clear_init
35
+ vagrantfile = File.join(@test_dir, "Vagrantfile")
36
+ if(File.exists?(vagrantfile))
37
+ FileUtils.rm(vagrantfile)
38
+ end
39
+ end
40
+
41
+ def ensure_test_directory
42
+ @test_dir ||= begin
43
+ tmp_dir = File.join(File.expand_path('.', File.dirname(__FILE__)), "tmp")
44
+ FileUtils.mkdir_p(tmp_dir)
45
+
46
+ test_dir = File.join(tmp_dir, "project")
47
+ if !File.exists?(test_dir)
48
+ # TODO test config option
49
+ `git clone https://github.com/engineyard/todo.git #{test_dir}`
50
+ end
51
+
52
+ test_dir
53
+ end
54
+ end
55
+
56
+ def fail_on_stderr
57
+ UI::Colored.class_eval do
58
+ def error; raise "output to stderr"; end
59
+ end
60
+
61
+ UI::Basic.class_eval do
62
+ def error; raise "output to stderr"; end
63
+ end
64
+ end
65
+
66
+ def assert_cmd(cmd)
67
+ assert(system_call(cmd), "#{cmd}")
68
+ end
69
+
70
+ def system_call(cmd)
71
+ # when debugging is turned on prevent output swallow
72
+ # TODO xplatform
73
+ Kernel.system(cmd + (ENV["DEBUG"] ? "" : " > /dev/null 2>&1"))
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: engineyard-local
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 1
10
+ version: 0.2.1
11
+ platform: ruby
12
+ authors:
13
+ - John Bender
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: vagrant
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - "="
27
+ - !ruby/object:Gem::Version
28
+ hash: 21
29
+ segments:
30
+ - 1
31
+ - 0
32
+ - 1
33
+ version: 1.0.1
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: thor
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 43
45
+ segments:
46
+ - 0
47
+ - 14
48
+ - 6
49
+ version: 0.14.6
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ description: A plugin to streamline ruby web application development with Vagrant
53
+ email:
54
+ - john.m.bender@gmail.com
55
+ executables:
56
+ - ey-local
57
+ extensions: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - README.md
66
+ - Rakefile
67
+ - bin/ey-local
68
+ - config/dna.json
69
+ - config/locales/en.yml
70
+ - config/settings.yml
71
+ - config/solo.rb
72
+ - engineyard-local.gemspec
73
+ - install/deb/README.md
74
+ - install/deb/Rakefile
75
+ - install/deb/Vagrantfile
76
+ - install/deb/install.sh
77
+ - install/osx/README.md
78
+ - install/osx/Rakefile
79
+ - install/osx/engineyard-local/engineyard-local.pkgproj
80
+ - install/osx/images/eylocal_installer.png
81
+ - install/osx/scripts/log.sh
82
+ - install/osx/scripts/postinstall
83
+ - install/osx/scripts/rvm_install.sh
84
+ - lib/engineyard-local.rb
85
+ - lib/engineyard-local/command.rb
86
+ - lib/engineyard-local/command/base.rb
87
+ - lib/engineyard-local/command/exec.rb
88
+ - lib/engineyard-local/command/group.rb
89
+ - lib/engineyard-local/command/helpers.rb
90
+ - lib/engineyard-local/command/list.rb
91
+ - lib/engineyard-local/command/rails.rb
92
+ - lib/engineyard-local/command/up.rb
93
+ - lib/engineyard-local/command/vagrant_action.rb
94
+ - lib/engineyard-local/errors.rb
95
+ - lib/engineyard-local/middleware.rb
96
+ - lib/engineyard-local/middleware/bundle.rb
97
+ - lib/engineyard-local/middleware/chef.rb
98
+ - lib/engineyard-local/middleware/default_provisioner.rb
99
+ - lib/engineyard-local/middleware/dna.rb
100
+ - lib/engineyard-local/middleware/exec.rb
101
+ - lib/engineyard-local/middleware/helpers.rb
102
+ - lib/engineyard-local/middleware/helpers/executable.rb
103
+ - lib/engineyard-local/middleware/helpers/network.rb
104
+ - lib/engineyard-local/middleware/helpers/rvm.rb
105
+ - lib/engineyard-local/middleware/helpers/uploadable.rb
106
+ - lib/engineyard-local/middleware/network.rb
107
+ - lib/engineyard-local/middleware/rails.rb
108
+ - lib/engineyard-local/middleware/rails/command.rb
109
+ - lib/engineyard-local/middleware/rails/db.rb
110
+ - lib/engineyard-local/middleware/rails/install.rb
111
+ - lib/engineyard-local/middleware/rails/new.rb
112
+ - lib/engineyard-local/middleware/tag.rb
113
+ - lib/engineyard-local/ui.rb
114
+ - lib/engineyard-local/version.rb
115
+ - lib/engineyard-local/virtualbox.rb
116
+ - lib/vagrant_init.rb
117
+ - test/engineyard-local/command/group_test.rb
118
+ - test/engineyard-local/command/up_test.rb
119
+ - test/engineyard-local/command_test.rb
120
+ - test/engineyard-local/middelware/bundle_test.rb
121
+ - test/engineyard-local/middelware/default_provisioner_test.rb
122
+ - test/engineyard-local/middelware/exec_test.rb
123
+ - test/engineyard-local/middelware/network_test.rb
124
+ - test/engineyard-local/middelware/rails/command_test.rb
125
+ - test/engineyard-local/middelware/rails/db_test.rb
126
+ - test/engineyard-local/middelware/rails/install_test.rb
127
+ - test/engineyard-local/ui_test.rb
128
+ - test/engineyard-local/virtualbox_test.rb
129
+ - test/integration/up_test.rb
130
+ - test/test_helper.rb
131
+ homepage: ""
132
+ licenses: []
133
+
134
+ post_install_message:
135
+ rdoc_options: []
136
+
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ hash: 3
145
+ segments:
146
+ - 0
147
+ version: "0"
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ hash: 3
154
+ segments:
155
+ - 0
156
+ version: "0"
157
+ requirements: []
158
+
159
+ rubyforge_project: engineyard-local
160
+ rubygems_version: 1.8.21
161
+ signing_key:
162
+ specification_version: 3
163
+ summary: A plugin to streamline ruby web application development with Vagrant
164
+ test_files:
165
+ - test/engineyard-local/command/group_test.rb
166
+ - test/engineyard-local/command/up_test.rb
167
+ - test/engineyard-local/command_test.rb
168
+ - test/engineyard-local/middelware/bundle_test.rb
169
+ - test/engineyard-local/middelware/default_provisioner_test.rb
170
+ - test/engineyard-local/middelware/exec_test.rb
171
+ - test/engineyard-local/middelware/network_test.rb
172
+ - test/engineyard-local/middelware/rails/command_test.rb
173
+ - test/engineyard-local/middelware/rails/db_test.rb
174
+ - test/engineyard-local/middelware/rails/install_test.rb
175
+ - test/engineyard-local/ui_test.rb
176
+ - test/engineyard-local/virtualbox_test.rb
177
+ - test/integration/up_test.rb
178
+ - test/test_helper.rb