vmc 0.4.0.beta.93 → 0.4.0.beta.94
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.
- data/vmc-ng/Rakefile +21 -30
- data/vmc-ng/lib/vmc.rb +4 -3
- data/vmc-ng/lib/vmc/cli.rb +10 -9
- data/vmc-ng/lib/vmc/cli/app/app.rb +45 -0
- data/vmc-ng/lib/vmc/cli/app/apps.rb +97 -0
- data/vmc-ng/lib/vmc/cli/app/base.rb +82 -0
- data/vmc-ng/lib/vmc/cli/app/crashes.rb +41 -0
- data/vmc-ng/lib/vmc/cli/app/delete.rb +90 -0
- data/vmc-ng/lib/vmc/cli/app/deprecated.rb +11 -0
- data/vmc-ng/lib/vmc/cli/app/env.rb +86 -0
- data/vmc-ng/lib/vmc/cli/app/files.rb +85 -0
- data/vmc-ng/lib/vmc/cli/app/health.rb +27 -0
- data/vmc-ng/lib/vmc/cli/app/instances.rb +49 -0
- data/vmc-ng/lib/vmc/cli/app/logs.rb +80 -0
- data/vmc-ng/lib/vmc/cli/app/push.rb +336 -0
- data/vmc-ng/lib/vmc/cli/app/rename.rb +31 -0
- data/vmc-ng/lib/vmc/cli/app/restart.rb +23 -0
- data/vmc-ng/lib/vmc/cli/app/routes.rb +97 -0
- data/vmc-ng/lib/vmc/cli/app/scale.rb +67 -0
- data/vmc-ng/lib/vmc/cli/app/start.rb +96 -0
- data/vmc-ng/lib/vmc/cli/app/stats.rb +68 -0
- data/vmc-ng/lib/vmc/cli/app/stop.rb +29 -0
- data/vmc-ng/lib/vmc/cli/domain/add_domain.rb +27 -0
- data/vmc-ng/lib/vmc/cli/domain/base.rb +12 -0
- data/vmc-ng/lib/vmc/cli/domain/create_domain.rb +31 -0
- data/vmc-ng/lib/vmc/cli/domain/delete_domain.rb +51 -0
- data/vmc-ng/lib/vmc/cli/domain/domains.rb +43 -0
- data/vmc-ng/lib/vmc/cli/domain/remove_domain.rb +26 -0
- data/vmc-ng/lib/vmc/cli/help.rb +0 -1
- data/vmc-ng/lib/vmc/cli/interactive.rb +4 -0
- data/vmc-ng/lib/vmc/cli/route/base.rb +12 -0
- data/vmc-ng/lib/vmc/cli/route/create_route.rb +42 -0
- data/vmc-ng/lib/vmc/cli/route/delete_route.rb +42 -0
- data/vmc-ng/lib/vmc/cli/route/routes.rb +26 -0
- data/vmc-ng/lib/vmc/detect.rb +2 -2
- data/vmc-ng/lib/vmc/spec_helper.rb +1 -0
- data/vmc-ng/lib/vmc/version.rb +1 -1
- data/vmc-ng/spec/cli/app/push_spec.rb +34 -0
- data/vmc-ng/spec/cli/app/rename_spec.rb +108 -0
- data/vmc-ng/spec/cli/route/delete_route_spec.rb +160 -0
- data/vmc-ng/spec/detect_spec.rb +54 -0
- data/vmc-ng/spec/factories/app_factory.rb +9 -0
- data/vmc-ng/spec/factories/client_factory.rb +16 -0
- data/vmc-ng/spec/factories/domain_factory.rb +9 -0
- data/vmc-ng/spec/factories/factory.rb +3 -0
- data/vmc-ng/spec/factories/framework_factory.rb +9 -0
- data/vmc-ng/spec/factories/route_factory.rb +10 -0
- data/vmc-ng/spec/spec_helper.rb +17 -0
- data/vmc-ng/spec/support/interact_helpers.rb +23 -0
- metadata +135 -62
- data/vmc-ng/lib/vmc/cli/app.rb +0 -1333
- data/vmc-ng/lib/vmc/cli/domain.rb +0 -164
- data/vmc-ng/lib/vmc/cli/route.rb +0 -106
- data/vmc-ng/lib/vmc/spec_helpers.rb +0 -431
- data/vmc-ng/lib/vmc/spec_helpers/eventlog.rb +0 -277
- data/vmc-ng/lib/vmc/spec_helpers/patches.rb +0 -94
- data/vmc-ng/spec/Rakefile +0 -13
- data/vmc-ng/spec/app/app_spec.rb +0 -19
- data/vmc-ng/spec/app/apps_spec.rb +0 -79
- data/vmc-ng/spec/app/push_spec.rb +0 -74
- data/vmc-ng/spec/assets/hello-sinatra/Gemfile +0 -2
- data/vmc-ng/spec/assets/hello-sinatra/main.rb +0 -5
- data/vmc-ng/spec/assets/hello-sinatra/manifest.yml +0 -9
- data/vmc-ng/spec/helpers.rb +0 -7
- data/vmc-ng/spec/start/target_spec.rb +0 -60
@@ -1,164 +0,0 @@
|
|
1
|
-
require "vmc/cli"
|
2
|
-
|
3
|
-
module VMC
|
4
|
-
class Domain < CLI
|
5
|
-
def precondition
|
6
|
-
super
|
7
|
-
fail "This command is v2-only." unless v2?
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
desc "List domains in a space"
|
12
|
-
group :domains
|
13
|
-
input :space, :argument => :optional,
|
14
|
-
:default => proc { client.current_space },
|
15
|
-
:from_given => by_name("space"),
|
16
|
-
:desc => "Space to list the domains from"
|
17
|
-
input :all, :type => :boolean, :default => false,
|
18
|
-
:desc => "List all domains"
|
19
|
-
def domains
|
20
|
-
space = input[:space]
|
21
|
-
|
22
|
-
domains =
|
23
|
-
if input[:all]
|
24
|
-
with_progress("Getting all domains") do
|
25
|
-
client.domains
|
26
|
-
end
|
27
|
-
else
|
28
|
-
with_progress("Getting domains in #{c(space.name, :name)}") do
|
29
|
-
space.domains
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
line unless quiet?
|
34
|
-
|
35
|
-
table(
|
36
|
-
%w{name owner},
|
37
|
-
domains.sort_by(&:name).collect { |r|
|
38
|
-
[ c(r.name, :name),
|
39
|
-
if org = r.owning_organization
|
40
|
-
c(org.name, :name)
|
41
|
-
else
|
42
|
-
d("none")
|
43
|
-
end
|
44
|
-
]
|
45
|
-
})
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
desc "Delete a domain"
|
50
|
-
group :domains
|
51
|
-
input(:domain, :argument => :optional,
|
52
|
-
:from_given => find_by_name("domain"),
|
53
|
-
:desc => "URL to map to the application") { |domains|
|
54
|
-
fail "No domains." if domains.empty?
|
55
|
-
|
56
|
-
ask "Which domain?", :choices => domains.sort_by(&:name),
|
57
|
-
:display => proc(&:name)
|
58
|
-
}
|
59
|
-
input :organization, :aliases => ["--org", "-o"],
|
60
|
-
:from_given => by_name("organization"),
|
61
|
-
:desc => "Organization to delete the domain from"
|
62
|
-
input(:really, :type => :boolean, :forget => true,
|
63
|
-
:default => proc { force? || interact }) { |name, color|
|
64
|
-
ask("Really delete #{c(name, color)}?", :default => false)
|
65
|
-
}
|
66
|
-
input :all, :type => :boolean, :default => false,
|
67
|
-
:desc => "Delete all domains"
|
68
|
-
def delete_domain
|
69
|
-
target = input[:organization] || client
|
70
|
-
|
71
|
-
if input[:all]
|
72
|
-
return unless input[:really, "ALL DOMAINS", :bad]
|
73
|
-
|
74
|
-
target.domains.each do |r|
|
75
|
-
begin
|
76
|
-
invoke :delete_domain, :domain => r, :really => true
|
77
|
-
rescue CFoundry::APIError => e
|
78
|
-
err "#{e.class}: #{e.message}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
return
|
83
|
-
end
|
84
|
-
|
85
|
-
domain = input[:domain, target.domains]
|
86
|
-
|
87
|
-
return unless input[:really, domain.name, :name]
|
88
|
-
|
89
|
-
with_progress("Deleting domain #{c(domain.name, :name)}") do
|
90
|
-
domain.delete!
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
desc "Create a domain"
|
96
|
-
group :domains
|
97
|
-
input :name, :argument => :required,
|
98
|
-
:desc => "Domain name to create"
|
99
|
-
input :organization, :aliases => ["--org", "-o"],
|
100
|
-
:from_given => by_name("organization"),
|
101
|
-
:default => proc { client.current_organization },
|
102
|
-
:desc => "Organization to add the domain to"
|
103
|
-
input :shared, :type => :boolean, :default => false,
|
104
|
-
:desc => "Create a shared domain (admin-only)"
|
105
|
-
def create_domain
|
106
|
-
org = input[:organization]
|
107
|
-
name = input[:name].sub(/^\*\./, "")
|
108
|
-
|
109
|
-
domain = client.domain
|
110
|
-
domain.name = name
|
111
|
-
domain.owning_organization = org unless input[:shared]
|
112
|
-
|
113
|
-
with_progress("Creating domain #{c(name, :name)}") do
|
114
|
-
domain.create!
|
115
|
-
end
|
116
|
-
|
117
|
-
domain
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
desc "Add a domain to a space"
|
122
|
-
group :domains
|
123
|
-
input :name, :argument => :required,
|
124
|
-
:desc => "Domain to add"
|
125
|
-
input :space, :from_given => by_name("space"),
|
126
|
-
:default => proc { client.current_space },
|
127
|
-
:desc => "Space to add the domain to"
|
128
|
-
def add_domain
|
129
|
-
space = input[:space]
|
130
|
-
name = input[:name].sub(/^\*\./, "")
|
131
|
-
|
132
|
-
org = space.organization
|
133
|
-
|
134
|
-
domain =
|
135
|
-
org.domains.find { |d| d.name == name } ||
|
136
|
-
invoke(:create_domain, :org => org, :name => name)
|
137
|
-
|
138
|
-
with_progress("Adding #{c(domain.name, :name)} to #{c(space.name, :name)}") do
|
139
|
-
space.add_domain(domain)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
|
144
|
-
desc "Remove a domain from a space"
|
145
|
-
group :domains
|
146
|
-
input(:domain, :argument => :optional,
|
147
|
-
:from_given => by_name("domain"),
|
148
|
-
:desc => "Domain to add") { |space|
|
149
|
-
ask "Which domain?", :choices => space.domains,
|
150
|
-
:display => proc(&:name)
|
151
|
-
}
|
152
|
-
input :space, :from_given => by_name("space"),
|
153
|
-
:default => proc { client.current_space },
|
154
|
-
:desc => "Space to add the domain to"
|
155
|
-
def remove_domain
|
156
|
-
space = input[:space]
|
157
|
-
domain = input[:domain, space]
|
158
|
-
|
159
|
-
with_progress("Removing #{c(domain.name, :name)} from #{c(space.name, :name)}") do
|
160
|
-
space.remove_domain(domain)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
data/vmc-ng/lib/vmc/cli/route.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
require "vmc/cli"
|
2
|
-
|
3
|
-
module VMC
|
4
|
-
class Route < CLI
|
5
|
-
def precondition
|
6
|
-
super
|
7
|
-
fail "This command is v2-only." unless v2?
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
desc "List routes in a space"
|
12
|
-
group :routes
|
13
|
-
def routes
|
14
|
-
# TODO: scope to space once space.routes is possible
|
15
|
-
routes =
|
16
|
-
with_progress("Getting routes") do
|
17
|
-
client.routes
|
18
|
-
end
|
19
|
-
|
20
|
-
line unless quiet?
|
21
|
-
|
22
|
-
table(
|
23
|
-
%w{host domain},
|
24
|
-
routes.sort_by { |r| "#{r.domain.name} #{r.host}" }.collect { |r|
|
25
|
-
[ c(r.host, :name),
|
26
|
-
r.domain.name
|
27
|
-
]
|
28
|
-
})
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
desc "Delete a route"
|
33
|
-
group :routes
|
34
|
-
input(:route, :argument => :optional,
|
35
|
-
:from_given => find_by_name("route"),
|
36
|
-
:desc => "URL to map to the application") { |routes|
|
37
|
-
ask "Which route?", :choices => routes.sort_by(&:name),
|
38
|
-
:display => proc(&:name)
|
39
|
-
}
|
40
|
-
input(:really, :type => :boolean, :forget => true,
|
41
|
-
:default => proc { force? || interact }) { |name, color|
|
42
|
-
ask("Really delete #{c(name, color)}?", :default => false)
|
43
|
-
}
|
44
|
-
input :all, :type => :boolean, :default => false,
|
45
|
-
:desc => "Delete all routes"
|
46
|
-
def delete_route
|
47
|
-
if input[:all]
|
48
|
-
return unless input[:really, "ALL ROUTES", :bad]
|
49
|
-
|
50
|
-
client.routes.each do |r|
|
51
|
-
invoke :delete_route, :route => r, :really => true
|
52
|
-
end
|
53
|
-
|
54
|
-
return
|
55
|
-
end
|
56
|
-
|
57
|
-
routes = client.routes
|
58
|
-
fail "No routes." if routes.empty?
|
59
|
-
|
60
|
-
route = input[:route, client.routes]
|
61
|
-
|
62
|
-
return unless input[:really, route.name, :name]
|
63
|
-
|
64
|
-
with_progress("Deleting route #{c(route.name, :name)}") do
|
65
|
-
route.delete!
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
desc "Create a route"
|
71
|
-
group :routes
|
72
|
-
input :url, :argument => :optional,
|
73
|
-
:desc => "Full route in URL form"
|
74
|
-
input(:host, :desc => "Host name") {
|
75
|
-
ask "Host name?"
|
76
|
-
}
|
77
|
-
input(:domain, :desc => "Domain to add the route to",
|
78
|
-
:from_given => find_by_name("domain")) { |domains|
|
79
|
-
ask "Which domain?", :choices => domains,
|
80
|
-
:display => proc(&:name)
|
81
|
-
}
|
82
|
-
def create_route
|
83
|
-
if url = input[:url]
|
84
|
-
host, domain_name = url.split(".", 2)
|
85
|
-
return invoke :create_route, {}, :host => host, :domain => domain_name
|
86
|
-
end
|
87
|
-
|
88
|
-
domain = input[:domain, client.current_organization.domains]
|
89
|
-
host = input[:host]
|
90
|
-
|
91
|
-
route = client.route
|
92
|
-
route.host = host
|
93
|
-
route.domain = domain
|
94
|
-
route.space = client.current_space
|
95
|
-
|
96
|
-
with_progress("Creating route #{c("#{host}.#{domain.name}", :name)}") do
|
97
|
-
route.create!
|
98
|
-
end
|
99
|
-
rescue CFoundry::RouteHostTaken => e
|
100
|
-
line c(e.description, :error)
|
101
|
-
line
|
102
|
-
input.forget(:host)
|
103
|
-
retry
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1,431 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
|
3
|
-
require "cfoundry"
|
4
|
-
require "vmc"
|
5
|
-
|
6
|
-
require "vmc/spec_helpers/eventlog"
|
7
|
-
require "vmc/spec_helpers/patches"
|
8
|
-
|
9
|
-
|
10
|
-
module VMCHelpers
|
11
|
-
TARGET = ENV["VMC_TEST_TARGET"] || "http://localhost:8181"
|
12
|
-
USER = ENV["VMC_TEST_USER"] || "sre@vmware.com"
|
13
|
-
PASSWORD = ENV["VMC_TEST_PASSWORD"] || "test"
|
14
|
-
|
15
|
-
def random_str
|
16
|
-
format("%x", rand(1000000))
|
17
|
-
end
|
18
|
-
|
19
|
-
def client
|
20
|
-
VMC::CLI.client
|
21
|
-
end
|
22
|
-
|
23
|
-
# invoke a block while logged out
|
24
|
-
def without_auth
|
25
|
-
proxy = client.proxy
|
26
|
-
client.logout
|
27
|
-
client.proxy = nil
|
28
|
-
yield
|
29
|
-
ensure
|
30
|
-
client.login(USER, PASSWORD)
|
31
|
-
client.proxy = proxy
|
32
|
-
end
|
33
|
-
|
34
|
-
# same as Ruby 1.9's Array#sample
|
35
|
-
def sample(ary)
|
36
|
-
ary[rand(ary.size)]
|
37
|
-
end
|
38
|
-
|
39
|
-
# cache frameworks for app generation
|
40
|
-
def frameworks
|
41
|
-
@@frameworks ||= client.frameworks(:depth => 0)
|
42
|
-
end
|
43
|
-
|
44
|
-
# cache runtimes for app generation
|
45
|
-
def runtimes
|
46
|
-
@@runtimes ||= client.runtimes(:depth => 0)
|
47
|
-
end
|
48
|
-
|
49
|
-
def with_random_app(space = client.current_space)
|
50
|
-
with_random_apps(space, 1) do |apps|
|
51
|
-
yield apps.first
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# create 2-5 random apps, call the block, and then delete them
|
56
|
-
def with_random_apps(space = client.current_space, num = rand(3) + 2)
|
57
|
-
apps = []
|
58
|
-
|
59
|
-
num.times do |n|
|
60
|
-
app = client.app
|
61
|
-
app.name = "app-#{n + 1}-#{random_str}"
|
62
|
-
app.space = space
|
63
|
-
app.instances = rand(2)
|
64
|
-
|
65
|
-
app.framework = sample(frameworks)
|
66
|
-
app.runtime = sample(runtimes)
|
67
|
-
app.memory = sample([64, 128, 256, 512])
|
68
|
-
app.create!
|
69
|
-
|
70
|
-
apps << app
|
71
|
-
end
|
72
|
-
|
73
|
-
yield apps
|
74
|
-
ensure
|
75
|
-
apps.each(&:delete!)
|
76
|
-
end
|
77
|
-
|
78
|
-
def with_new_space(org = client.current_organization)
|
79
|
-
space = client.space
|
80
|
-
space.name = "space-#{random_str}"
|
81
|
-
space.organization = org
|
82
|
-
space.create!
|
83
|
-
|
84
|
-
yield space
|
85
|
-
ensure
|
86
|
-
space.delete!
|
87
|
-
end
|
88
|
-
|
89
|
-
def running(command, inputs = {}, given = {})
|
90
|
-
VMC::CLI.new.exit_status 0
|
91
|
-
|
92
|
-
before_in = $stdin
|
93
|
-
before_out = $stdout
|
94
|
-
before_err = $stderr
|
95
|
-
before_event = $vmc_event
|
96
|
-
|
97
|
-
tty = FakeTTY.new
|
98
|
-
|
99
|
-
$vmc_event = EventLog.new(tty)
|
100
|
-
|
101
|
-
$stdin = tty
|
102
|
-
$stdout = StringIO.new
|
103
|
-
$stderr = StringIO.new
|
104
|
-
|
105
|
-
main = Thread.current
|
106
|
-
|
107
|
-
thd_group = ThreadGroup.new
|
108
|
-
thd = Thread.new do
|
109
|
-
begin
|
110
|
-
VMC::CLI.new.invoke(command, inputs, given, :quiet => true)
|
111
|
-
rescue SystemExit => e
|
112
|
-
unless e.status == 0
|
113
|
-
raise <<EOF
|
114
|
-
execution failed with status #{e.status}!
|
115
|
-
|
116
|
-
stdout:
|
117
|
-
#{$stdout.string}
|
118
|
-
|
119
|
-
stderr:
|
120
|
-
#{$stderr.string}
|
121
|
-
EOF
|
122
|
-
end
|
123
|
-
rescue => e
|
124
|
-
$vmc_event.raised(e)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
thd_group.add(thd)
|
129
|
-
|
130
|
-
begin
|
131
|
-
$vmc_event.process = thd
|
132
|
-
|
133
|
-
yield $vmc_event
|
134
|
-
|
135
|
-
$vmc_event.should complete
|
136
|
-
ensure
|
137
|
-
thd_group.list.each(&:kill)
|
138
|
-
end
|
139
|
-
ensure
|
140
|
-
$stdin = before_in
|
141
|
-
$stdout = before_out
|
142
|
-
$stderr = before_err
|
143
|
-
$vmc_event = before_event
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
module VMCMatchers
|
148
|
-
class Contain
|
149
|
-
def initialize(content)
|
150
|
-
@content = content
|
151
|
-
end
|
152
|
-
|
153
|
-
def matches?(actual)
|
154
|
-
@actual = actual
|
155
|
-
true
|
156
|
-
end
|
157
|
-
|
158
|
-
def failure_message
|
159
|
-
"expected '#@content' to be in the output"
|
160
|
-
end
|
161
|
-
|
162
|
-
def negative_failure_message
|
163
|
-
"expected '#@content' to NOT be in the output"
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def contain(content)
|
168
|
-
Contain.new(content)
|
169
|
-
end
|
170
|
-
|
171
|
-
class Ask
|
172
|
-
def initialize(message)
|
173
|
-
@message = message
|
174
|
-
end
|
175
|
-
|
176
|
-
def matches?(log)
|
177
|
-
ev = log.wait_for_event(EventLog::Asked)
|
178
|
-
|
179
|
-
@actual = ev.message
|
180
|
-
@actual == @message
|
181
|
-
end
|
182
|
-
|
183
|
-
def failure_message
|
184
|
-
"expected to be asked '#@message', got '#@actual'"
|
185
|
-
end
|
186
|
-
|
187
|
-
def negative_failure_message
|
188
|
-
"expected to NOT be asked for #@message"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def ask(message)
|
193
|
-
Ask.new(message)
|
194
|
-
end
|
195
|
-
|
196
|
-
class HaveInput
|
197
|
-
def initialize(name, value = nil)
|
198
|
-
@name = name
|
199
|
-
@expected = value
|
200
|
-
end
|
201
|
-
|
202
|
-
def matches?(log)
|
203
|
-
input = log.wait_for_event(EventLog::GotInput)
|
204
|
-
until input.name == @name
|
205
|
-
input = log.wait_for_event(EventLog::GotInput)
|
206
|
-
end
|
207
|
-
|
208
|
-
@actual = input.value
|
209
|
-
@actual == @expected
|
210
|
-
end
|
211
|
-
|
212
|
-
def failure_message
|
213
|
-
"expected to have input '#@name' as '#@expected', but got '#@actual'"
|
214
|
-
end
|
215
|
-
|
216
|
-
def negative_failure_message
|
217
|
-
"expected not to have input '#@name', but had it as '#@actual'"
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
def have_input(name, value = nil)
|
222
|
-
HaveInput.new(name, value)
|
223
|
-
end
|
224
|
-
|
225
|
-
class Output
|
226
|
-
def initialize(line)
|
227
|
-
@expected = line
|
228
|
-
end
|
229
|
-
|
230
|
-
def matches?(log)
|
231
|
-
@actual = log.wait_for_event(EventLog::Printed).line
|
232
|
-
@actual == @expected
|
233
|
-
end
|
234
|
-
|
235
|
-
def failure_message
|
236
|
-
"expected '#@expected' to be in the output, but got '#@actual'"
|
237
|
-
end
|
238
|
-
|
239
|
-
def negative_failure_message
|
240
|
-
"expected '#@expected' NOT to be in the output, but it was"
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
def output(line)
|
245
|
-
Output.new(line)
|
246
|
-
end
|
247
|
-
|
248
|
-
class Complete
|
249
|
-
def matches?(log)
|
250
|
-
@log = log
|
251
|
-
|
252
|
-
log.process.join(1)
|
253
|
-
|
254
|
-
log.process.status == false
|
255
|
-
end
|
256
|
-
|
257
|
-
def failure_message
|
258
|
-
pending = @log.pending_events
|
259
|
-
|
260
|
-
if @exception
|
261
|
-
"process existed with an exception: #@exception"
|
262
|
-
elsif !pending.empty?
|
263
|
-
"expected process to complete, but it's pending events #{pending}"
|
264
|
-
else
|
265
|
-
"process is blocked; status: #{@log.process.status}"
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
def negative_failure_message
|
270
|
-
"expected process to still be running, but it's completed"
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
def complete
|
275
|
-
Complete.new
|
276
|
-
end
|
277
|
-
|
278
|
-
|
279
|
-
class FailWith
|
280
|
-
def initialize(exception, predicate = nil)
|
281
|
-
@expected = exception
|
282
|
-
@predicate = predicate
|
283
|
-
end
|
284
|
-
|
285
|
-
def matches?(log)
|
286
|
-
@actual = log.wait_for_event(EventLog::Raised).exception
|
287
|
-
|
288
|
-
return false unless @actual.is_a?(@expected)
|
289
|
-
|
290
|
-
@predicate.call(@actual) if @predicate
|
291
|
-
|
292
|
-
true
|
293
|
-
end
|
294
|
-
|
295
|
-
def failure_message
|
296
|
-
"expected #@expected to be raised, but got #{@actual.class}: '#@actual'"
|
297
|
-
end
|
298
|
-
|
299
|
-
def negative_failure_message
|
300
|
-
"expected #@expected to NOT be raised, but it was"
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
def fail_with(exception, &blk)
|
305
|
-
FailWith.new(exception, blk)
|
306
|
-
end
|
307
|
-
|
308
|
-
|
309
|
-
class ProgressExpectation
|
310
|
-
def matches?(log)
|
311
|
-
@actual = log.wait_for_event(EventLog::Progress)
|
312
|
-
@actual == @expected
|
313
|
-
end
|
314
|
-
|
315
|
-
def failure_message
|
316
|
-
"expected to #{@expected.report}, but #{@actual.report_past} instead"
|
317
|
-
end
|
318
|
-
|
319
|
-
def negative_failure_message
|
320
|
-
"expected not to #{@expected.report}"
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
class Successfully < ProgressExpectation
|
325
|
-
def initialize(message)
|
326
|
-
@expected = EventLog::Did.new(message)
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
class Skip < ProgressExpectation
|
331
|
-
def initialize(message)
|
332
|
-
@expected = EventLog::Skipped.new(message)
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
class FailTo < ProgressExpectation
|
337
|
-
def initialize(message)
|
338
|
-
@expected = EventLog::FailedTo.new(message)
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
class GiveUp < ProgressExpectation
|
343
|
-
def initialize(message)
|
344
|
-
@expected = EventLog::GaveUp.new(message)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
|
-
def successfully(message)
|
349
|
-
Successfully.new(message)
|
350
|
-
end
|
351
|
-
|
352
|
-
def skip(message)
|
353
|
-
Skip.new(message)
|
354
|
-
end
|
355
|
-
|
356
|
-
def fail_to(message)
|
357
|
-
FailTo.new(message)
|
358
|
-
end
|
359
|
-
|
360
|
-
def give_up(message)
|
361
|
-
GiveUp.new(message)
|
362
|
-
end
|
363
|
-
|
364
|
-
|
365
|
-
def asks(what)
|
366
|
-
$vmc_event.should ask(what)
|
367
|
-
end
|
368
|
-
|
369
|
-
def given(what)
|
370
|
-
$vmc_event.provide("#{what}\n")
|
371
|
-
end
|
372
|
-
|
373
|
-
def has_input(name, value = nil)
|
374
|
-
$vmc_event.should have_input(name, value)
|
375
|
-
end
|
376
|
-
|
377
|
-
def raises(exception, &blk)
|
378
|
-
$vmc_event.should fail_with(exception, &blk)
|
379
|
-
end
|
380
|
-
|
381
|
-
def finish
|
382
|
-
$vmc_event.should complete
|
383
|
-
end
|
384
|
-
|
385
|
-
def outputs(what)
|
386
|
-
$vmc_event.should output(what)
|
387
|
-
end
|
388
|
-
|
389
|
-
def does(what)
|
390
|
-
$vmc_event.should successfully(what)
|
391
|
-
end
|
392
|
-
|
393
|
-
def skips(what)
|
394
|
-
$vmc_event.should skip(what)
|
395
|
-
end
|
396
|
-
|
397
|
-
def fails_to(what)
|
398
|
-
$vmc_event.should fail_to(what)
|
399
|
-
end
|
400
|
-
|
401
|
-
def gives_up(what)
|
402
|
-
$vmc_event.should give_up(what)
|
403
|
-
end
|
404
|
-
|
405
|
-
def kill
|
406
|
-
$vmc_event.kill_process
|
407
|
-
end
|
408
|
-
|
409
|
-
def with_output
|
410
|
-
yield $vmc_event.wait_for_event(EventLog::Printed).line
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
|
-
RSpec.configure do |c|
|
415
|
-
c.include VMCHelpers
|
416
|
-
c.include VMCMatchers
|
417
|
-
|
418
|
-
c.before(:all) do
|
419
|
-
VMC::CLI.client = CFoundry::Client.new(VMCHelpers::TARGET)
|
420
|
-
|
421
|
-
client.login(
|
422
|
-
:username => VMCHelpers::USER,
|
423
|
-
:password => VMCHelpers::PASSWORD)
|
424
|
-
|
425
|
-
unless client.is_a? CFoundry::V1::Client
|
426
|
-
client.current_organization = client.organizations.first
|
427
|
-
client.current_space = client.current_organization.spaces.first
|
428
|
-
end
|
429
|
-
end
|
430
|
-
end
|
431
|
-
|