landrush 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +10 -0
- data/examples/Vagrantfile +26 -0
- data/landrush.gemspec +35 -0
- data/lib/ext/rexec.rb +10 -0
- data/lib/landrush.rb +27 -0
- data/lib/landrush/action/redirect_dns.rb +35 -0
- data/lib/landrush/action/setup.rb +42 -0
- data/lib/landrush/action/teardown.rb +46 -0
- data/lib/landrush/command.rb +45 -0
- data/lib/landrush/config.rb +32 -0
- data/lib/landrush/dependent_vms.rb +40 -0
- data/lib/landrush/plugin.rb +32 -0
- data/lib/landrush/resolver_config.rb +53 -0
- data/lib/landrush/server.rb +69 -0
- data/lib/landrush/store.rb +49 -0
- data/lib/landrush/util.rb +25 -0
- data/lib/landrush/version.rb +3 -0
- data/test/landrush/action/setup_test.rb +73 -0
- data/test/landrush/action/teardown_test.rb +92 -0
- data/test/landrush/dependent_vms_test.rb +33 -0
- data/test/landrush/resolver_config_test.rb +20 -0
- data/test/landrush/server_test.rb +22 -0
- data/test/landrush/store_test.rb +55 -0
- data/test/support/clear_dependent_vms.rb +10 -0
- data/test/support/fake_resolver_config.rb +21 -0
- data/test/support/fake_ui.rb +4 -0
- data/test/support/fake_working_dir.rb +16 -0
- data/test/support/test_server_daemon.rb +40 -0
- data/test/test_helper.rb +54 -0
- metadata +156 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Landrush
|
4
|
+
describe DependentVMs do
|
5
|
+
describe "any?" do
|
6
|
+
it "reports false when nothing has happened" do
|
7
|
+
DependentVMs.any?.must_equal false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "reports true once a machine has been added" do
|
11
|
+
env = fake_environment_with_machine('recordme.example.dev', '1.2.3.4')
|
12
|
+
DependentVMs.add(env[:machine])
|
13
|
+
DependentVMs.any?.must_equal true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "reports false if a machine has been added then removed" do
|
17
|
+
env = fake_environment_with_machine('recordme.example.dev', '1.2.3.4')
|
18
|
+
DependentVMs.add(env[:machine])
|
19
|
+
DependentVMs.remove(env[:machine])
|
20
|
+
DependentVMs.any?.must_equal false
|
21
|
+
end
|
22
|
+
|
23
|
+
it "reports true if not all machines have been removed" do
|
24
|
+
first_env = fake_environment_with_machine('recordme.example.dev', '1.2.3.4')
|
25
|
+
second_env = fake_environment_with_machine('alsome.example.dev', '2.3.4.5')
|
26
|
+
DependentVMs.add(first_env[:machine])
|
27
|
+
DependentVMs.add(second_env[:machine])
|
28
|
+
DependentVMs.remove(first_env[:machine])
|
29
|
+
DependentVMs.any?.must_equal true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Landrush
|
4
|
+
describe ResolverConfig do
|
5
|
+
describe 'ensure_config_exists' do
|
6
|
+
it 'writes a resolver config on the host if one is not already there' do
|
7
|
+
ResolverConfig.config_file.exist?.must_equal false
|
8
|
+
hush {
|
9
|
+
ResolverConfig.ensure_config_exists
|
10
|
+
}
|
11
|
+
ResolverConfig.config_file.exist?.must_equal true
|
12
|
+
ResolverConfig.config_file.read.must_equal <<-EOF.gsub(/^ +/, '')
|
13
|
+
# Generated by landrush, a vagrant plugin
|
14
|
+
nameserver 127.0.0.1
|
15
|
+
port 10053
|
16
|
+
EOF
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Landrush
|
4
|
+
describe Server do
|
5
|
+
after {
|
6
|
+
if Server.running?
|
7
|
+
Server.stop
|
8
|
+
end
|
9
|
+
}
|
10
|
+
describe 'start/stop' do
|
11
|
+
it 'starts and stops a daemon' do
|
12
|
+
hush { Server.start }
|
13
|
+
|
14
|
+
Server.running?.must_equal true
|
15
|
+
|
16
|
+
hush { Server.stop }
|
17
|
+
|
18
|
+
Server.running?.must_equal false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Landrush
|
4
|
+
describe Store do
|
5
|
+
before {
|
6
|
+
@store = Store.new(Tempfile.new(%w[landrush_test_store .json]))
|
7
|
+
}
|
8
|
+
|
9
|
+
after {
|
10
|
+
@store.backing_file.unlink
|
11
|
+
}
|
12
|
+
|
13
|
+
describe "set" do
|
14
|
+
it "sets the key to the value and makes it available for getting" do
|
15
|
+
@store.set('foo', 'bar')
|
16
|
+
|
17
|
+
@store.get('foo').must_equal 'bar'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "allows updating keys that already exist" do
|
21
|
+
@store.set('foo', 'bar')
|
22
|
+
@store.set('foo', 'qux')
|
23
|
+
|
24
|
+
@store.get('foo').must_equal 'qux'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "get" do
|
29
|
+
it "returns nil for unset values" do
|
30
|
+
@store.get('notakey').must_equal nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns the latest set value (no caching)" do
|
34
|
+
@store.set('foo', 'first')
|
35
|
+
@store.get('foo').must_equal 'first'
|
36
|
+
@store.set('foo', 'second')
|
37
|
+
@store.get('foo').must_equal 'second'
|
38
|
+
@store.delete('foo')
|
39
|
+
@store.get('foo').must_equal nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "delete" do
|
44
|
+
it "removes the key from the store" do
|
45
|
+
@store.set('now', 'you see me')
|
46
|
+
|
47
|
+
@store.get('now').must_equal 'you see me'
|
48
|
+
|
49
|
+
@store.delete('now')
|
50
|
+
|
51
|
+
@store.get('now').must_equal nil # you don't!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FakeResolverConfigHooks
|
2
|
+
def setup
|
3
|
+
super
|
4
|
+
@test_resolver_config = Pathname('/tmp/vagrant_landrush_test_resolver_config')
|
5
|
+
Landrush::ResolverConfig.instance_variable_set(
|
6
|
+
"@config_file",
|
7
|
+
@test_resolver_config
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
super
|
13
|
+
if @test_resolver_config.exist?
|
14
|
+
@test_resolver_config.delete
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class MiniTest::Spec
|
20
|
+
include FakeResolverConfigHooks
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module FakeWorkingDirHooks
|
2
|
+
def setup
|
3
|
+
super
|
4
|
+
Landrush.working_dir = '/tmp/vagrant_landrush_test_working_dir'
|
5
|
+
end
|
6
|
+
|
7
|
+
def teardown
|
8
|
+
super
|
9
|
+
Landrush.working_dir.rmtree if Landrush.working_dir.directory?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class MiniTest::Spec
|
14
|
+
include FakeWorkingDirHooks
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Set test port so there's nothing colliding
|
2
|
+
Landrush::Server.port = 11153
|
3
|
+
|
4
|
+
module SilenceOutput
|
5
|
+
def silence
|
6
|
+
orig_out, orig_err = $stdout, $stderr
|
7
|
+
$stdout, $stderr = StringIO.new, StringIO.new
|
8
|
+
|
9
|
+
yield
|
10
|
+
ensure
|
11
|
+
$stdout = orig_out
|
12
|
+
$stderr = orig_err
|
13
|
+
end
|
14
|
+
|
15
|
+
def start
|
16
|
+
silence { super }
|
17
|
+
end
|
18
|
+
|
19
|
+
def stop
|
20
|
+
silence { super }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Landrush::Server
|
25
|
+
extend SilenceOutput
|
26
|
+
end
|
27
|
+
|
28
|
+
module TestServerHooks
|
29
|
+
def teardown
|
30
|
+
super
|
31
|
+
# Cleanup any stray server instances from tests
|
32
|
+
if Landrush::Server.running?
|
33
|
+
Landrush::Server.stop
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class MiniTest::Spec
|
39
|
+
include TestServerHooks
|
40
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
$:.push(File.expand_path('../../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'minitest/spec'
|
5
|
+
|
6
|
+
require 'landrush'
|
7
|
+
|
8
|
+
require 'minitest/autorun'
|
9
|
+
|
10
|
+
def fake_environment(extras={})
|
11
|
+
env = Vagrant::Environment.new
|
12
|
+
{ ui: FakeUI, global_config: env.config_global }.merge(extras)
|
13
|
+
end
|
14
|
+
|
15
|
+
def fake_environment_with_machine(hostname, ip)
|
16
|
+
provider_cls = Class.new do
|
17
|
+
def initialize(machine)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
env = Vagrant::Environment.new
|
22
|
+
|
23
|
+
machine = Vagrant::Machine.new(
|
24
|
+
'fake_machine',
|
25
|
+
'fake_provider',
|
26
|
+
provider_cls,
|
27
|
+
'provider_config',
|
28
|
+
env.config_global,
|
29
|
+
Pathname('data_dir'),
|
30
|
+
'box',
|
31
|
+
env
|
32
|
+
)
|
33
|
+
|
34
|
+
machine.config.landrush.enable
|
35
|
+
|
36
|
+
machine.config.vm.hostname = hostname
|
37
|
+
machine.config.vm.network :private_network, ip: ip
|
38
|
+
|
39
|
+
{ machine: machine, ui: FakeUI, global_config: env.config_global }
|
40
|
+
end
|
41
|
+
|
42
|
+
class MiniTest::Spec
|
43
|
+
alias_method :hush, :capture_io
|
44
|
+
end
|
45
|
+
|
46
|
+
# order is important on these
|
47
|
+
require 'support/clear_dependent_vms'
|
48
|
+
|
49
|
+
require 'support/fake_ui'
|
50
|
+
require 'support/test_server_daemon'
|
51
|
+
require 'support/fake_resolver_config'
|
52
|
+
|
53
|
+
# need to be last; don't want to delete dir out from servers before they clean up
|
54
|
+
require 'support/fake_working_dir'
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: landrush
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul Hinze
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rubydns
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: ! 'Even a Vagrant needs a place to settle down once in a while.
|
63
|
+
|
64
|
+
|
65
|
+
This Vagrant plugin spins up a lightweight DNS server and makes it visible
|
66
|
+
|
67
|
+
to your guests and your host, so that you can easily access all your
|
68
|
+
|
69
|
+
machines without having to fiddle with IP addresses.
|
70
|
+
|
71
|
+
|
72
|
+
DNS records are automatically added and removed as machines are brought up
|
73
|
+
|
74
|
+
and down, and you can configure static entries to be returned from the
|
75
|
+
|
76
|
+
server as well. See the README for more documentation.
|
77
|
+
|
78
|
+
'
|
79
|
+
email:
|
80
|
+
- paul.t.hinze@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- examples/Vagrantfile
|
91
|
+
- landrush.gemspec
|
92
|
+
- lib/ext/rexec.rb
|
93
|
+
- lib/landrush.rb
|
94
|
+
- lib/landrush/action/redirect_dns.rb
|
95
|
+
- lib/landrush/action/setup.rb
|
96
|
+
- lib/landrush/action/teardown.rb
|
97
|
+
- lib/landrush/command.rb
|
98
|
+
- lib/landrush/config.rb
|
99
|
+
- lib/landrush/dependent_vms.rb
|
100
|
+
- lib/landrush/plugin.rb
|
101
|
+
- lib/landrush/resolver_config.rb
|
102
|
+
- lib/landrush/server.rb
|
103
|
+
- lib/landrush/store.rb
|
104
|
+
- lib/landrush/util.rb
|
105
|
+
- lib/landrush/version.rb
|
106
|
+
- test/landrush/action/setup_test.rb
|
107
|
+
- test/landrush/action/teardown_test.rb
|
108
|
+
- test/landrush/dependent_vms_test.rb
|
109
|
+
- test/landrush/resolver_config_test.rb
|
110
|
+
- test/landrush/server_test.rb
|
111
|
+
- test/landrush/store_test.rb
|
112
|
+
- test/support/clear_dependent_vms.rb
|
113
|
+
- test/support/fake_resolver_config.rb
|
114
|
+
- test/support/fake_ui.rb
|
115
|
+
- test/support/fake_working_dir.rb
|
116
|
+
- test/support/test_server_daemon.rb
|
117
|
+
- test/test_helper.rb
|
118
|
+
homepage: https://github.com/phinze/landrush
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.8.23
|
140
|
+
signing_key:
|
141
|
+
specification_version: 3
|
142
|
+
summary: a vagrant plugin providing consistent DNS visible on host and guests
|
143
|
+
test_files:
|
144
|
+
- test/landrush/action/setup_test.rb
|
145
|
+
- test/landrush/action/teardown_test.rb
|
146
|
+
- test/landrush/dependent_vms_test.rb
|
147
|
+
- test/landrush/resolver_config_test.rb
|
148
|
+
- test/landrush/server_test.rb
|
149
|
+
- test/landrush/store_test.rb
|
150
|
+
- test/support/clear_dependent_vms.rb
|
151
|
+
- test/support/fake_resolver_config.rb
|
152
|
+
- test/support/fake_ui.rb
|
153
|
+
- test/support/fake_working_dir.rb
|
154
|
+
- test/support/test_server_daemon.rb
|
155
|
+
- test/test_helper.rb
|
156
|
+
has_rdoc:
|