vcloud-walker 3.2.2 → 3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/CHANGELOG.md +17 -0
- data/CONTRIBUTING.md +66 -0
- data/Gemfile +1 -1
- data/README.md +10 -0
- data/Rakefile +11 -6
- data/bin/vcloud-walk +1 -36
- data/jenkins.sh +1 -1
- data/jenkins_integration_tests.sh +1 -1
- data/lib/vcloud/walker/cli.rb +82 -0
- data/lib/vcloud/walker/fog_interface.rb +0 -1
- data/lib/vcloud/walker/resource/vapp.rb +12 -3
- data/lib/vcloud/walker/version.rb +1 -1
- data/lib/vcloud/walker.rb +6 -6
- data/spec/fog_interface_spec.rb +28 -33
- data/spec/integration/vcloud_walker_spec.rb +17 -17
- data/spec/spec_helper.rb +13 -15
- data/spec/stubs/stubs.rb +0 -1
- data/spec/vcloud/walker/cli_spec.rb +169 -0
- data/spec/vcloud/walker/resource/catalogs_spec.rb +38 -0
- data/spec/{walk → vcloud/walker/resource}/entity_spec.rb +17 -8
- data/spec/{walk → vcloud/walker/resource}/gateway_ipsec_vpn_service_spec.rb +0 -0
- data/spec/{walk → vcloud/walker/resource}/network_spec.rb +8 -18
- data/spec/vcloud/walker/resource/organization_spec.rb +66 -0
- data/spec/vcloud/walker/resource/vapp_spec.rb +89 -0
- data/spec/vcloud/walker/resource/vdcs_spec.rb +30 -0
- data/spec/{walk → vcloud/walker/resource}/vm_spec.rb +24 -24
- data/spec/vcloud/walker_spec.rb +12 -14
- data/vcloud-walker.gemspec +10 -8
- metadata +67 -65
- data/spec/walk/catalogs_spec.rb +0 -31
- data/spec/walk/organization_spec.rb +0 -53
- data/spec/walk/vapp_spec.rb +0 -24
- data/spec/walk/vdcs_spec.rb +0 -30
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 3.2.3 (2014-07-14)
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
|
5
|
+
- Prevent an "undefined method for nil:Nilclass" exception when
|
6
|
+
encountering a vApp that has no networks attached.
|
7
|
+
|
8
|
+
API changes:
|
9
|
+
|
10
|
+
- Vcloud::Walker::walk now returns an exception if provided an invalid
|
11
|
+
resource type instead of returning a `nil` object and printing the valid
|
12
|
+
options to STDOUT.
|
13
|
+
|
14
|
+
Bugfixes:
|
15
|
+
|
16
|
+
- Rename Rake integration test from 'integration_test' to 'integration' for consistency with other vCloud Tools
|
17
|
+
|
1
18
|
## 3.2.2 (2014-05-01)
|
2
19
|
|
3
20
|
- Use pessimistic version dependency for vcloud-core
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Contributing to vCloud Walker
|
2
|
+
|
3
|
+
We really welcome contributions.
|
4
|
+
|
5
|
+
## A quick guide on how to contribute
|
6
|
+
|
7
|
+
1. Clone the repo:
|
8
|
+
|
9
|
+
git clone git@github.com:gds-operations/vcloud-walker.git
|
10
|
+
|
11
|
+
2. Run `bundle` to get the required dependecies
|
12
|
+
|
13
|
+
3. Run the tests. Pull requests that add features must include unit tests,
|
14
|
+
so it is good to ensure you've got them passing to begin with.
|
15
|
+
|
16
|
+
bundle exec rake
|
17
|
+
|
18
|
+
If you have access to a live environment for testing, it would be great
|
19
|
+
if you could run the integration tests too - for more details on the
|
20
|
+
set-up for that, please see the [integration tests README]
|
21
|
+
(https://github.com/gds-operations/vcloud-walker/blob/master/spec/integration/README.md)
|
22
|
+
|
23
|
+
4. Add your functionality or bug fix and a test for your change. Only refactoring and
|
24
|
+
documentation changes do not require tests. If the functionality is at all complicated
|
25
|
+
then it is likely that more than one test will be required. If you would like help
|
26
|
+
with writing tests please do ask us.
|
27
|
+
|
28
|
+
5. Make sure all the tests pass, including the integration tests if possible.
|
29
|
+
|
30
|
+
6. Update the [CHANGELOG](https://github.com/gds-operations/vcloud-walker/blob/master/CHANGELOG.md)
|
31
|
+
with a short description of what the change is. This may be a feature, a bugfix, or an
|
32
|
+
API change. If your change is documenation or refactoring, you do not need to add a line
|
33
|
+
to the CHANGELOG.
|
34
|
+
|
35
|
+
7. Fork the repo, push to your fork, and submit a pull request.
|
36
|
+
|
37
|
+
## How soon will we respond?
|
38
|
+
|
39
|
+
We will comment on your pull request within two working days. However, we might not be able to review it immediately.
|
40
|
+
|
41
|
+
We may come back to you with comments and suggestions, and if we would like you to make changes, we will close the pull request as well as adding details of the changes we'd like you to make.
|
42
|
+
|
43
|
+
If you feel your pull request has been outstanding too long, please feel free to bump it by making a comment on it.
|
44
|
+
|
45
|
+
## Guidelines for making a pull request
|
46
|
+
|
47
|
+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
|
48
|
+
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
|
49
|
+
interpreted as described in RFC 2119.
|
50
|
+
|
51
|
+
## In order for a pull request to be accepted, it MUST
|
52
|
+
|
53
|
+
- Include at least one test (unless it is documentation or refactoring). If you have any questions about how to write tests, please ask us, we will be happy to help
|
54
|
+
- Follow our [Git style guide](https://github.com/alphagov/styleguides/blob/master/git.md)
|
55
|
+
- Include a clear summary in the pull request comments as to what the change is and why
|
56
|
+
you are making it
|
57
|
+
- Be readable - we might ask you to change unclear variable names or obscure syntactic sugar
|
58
|
+
- Have [good commit messages](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)
|
59
|
+
that explain the change being made in that commit. Don't be afraid to write a lot in the
|
60
|
+
detail.
|
61
|
+
|
62
|
+
## In order for a pull request to be accepted, it SHOULD
|
63
|
+
|
64
|
+
- Include a line in the CHANGELOG unless it is a refactoring or documentation change
|
65
|
+
- If it is code, follow our [Ruby style guide](https://github.com/alphagov/styleguides/blob/master/ruby.md)
|
66
|
+
- If it is documentation, follow the [GDS content style guide](https://www.gov.uk/design-principles/style-guide/style-points)
|
data/Gemfile
CHANGED
@@ -4,7 +4,7 @@ gemspec
|
|
4
4
|
|
5
5
|
if ENV['VCLOUD_WALKER_DEV_FOG_MASTER']
|
6
6
|
gem 'fog', :git => 'git@github.com:fog/fog.git', :branch => 'master'
|
7
|
-
gem 'vcloud-core', :git => 'git@github.com:
|
7
|
+
gem 'vcloud-core', :git => 'git@github.com:gds-operations/vcloud-core.git', :branch => 'master'
|
8
8
|
elsif ENV['VCLOUD_WALKER_DEV_FOG_LOCAL']
|
9
9
|
gem 'fog', :path => '../fog'
|
10
10
|
gem 'vcloud-core', :path => '../vcloud-core'
|
data/README.md
CHANGED
@@ -110,3 +110,13 @@ If you want to be sure you are pinning to 5.1, or use 5.5, you can set the API v
|
|
110
110
|
`export EXCON_DEBUG=true` - this will print out the API requests and responses.
|
111
111
|
|
112
112
|
`export DEBUG=true` - this will show you the stack trace when there is an exception instead of just the message.
|
113
|
+
|
114
|
+
## Testing
|
115
|
+
|
116
|
+
Run the default suite of tests (e.g. lint, unit, features):
|
117
|
+
|
118
|
+
bundle exec rake
|
119
|
+
|
120
|
+
Run the integration tests (slower and requires a real environment):
|
121
|
+
|
122
|
+
bundle exec rake integration
|
data/Rakefile
CHANGED
@@ -4,18 +4,23 @@ require 'rspec/core/rake_task'
|
|
4
4
|
require 'vcloud/walker/version'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
-
ENV['COVERAGE'] = 'true'
|
8
|
-
task.pattern = FileList['spec/**/*_spec.rb'] - FileList['spec/integration/*_spec.rb']
|
7
|
+
ENV['COVERAGE'] = 'true'
|
8
|
+
task.pattern = FileList['spec/**/*_spec.rb'] - FileList['spec/integration/*_spec.rb']
|
9
9
|
end
|
10
10
|
|
11
|
-
RSpec::Core::RakeTask.new(:
|
12
|
-
task.pattern = FileList['spec/integration/*_spec.rb']
|
11
|
+
RSpec::Core::RakeTask.new(:integration) do |task|
|
12
|
+
task.pattern = FileList['spec/integration/*_spec.rb']
|
13
13
|
end
|
14
14
|
|
15
|
-
task :default => :spec
|
15
|
+
task :default => [ :rubocop, :spec ]
|
16
16
|
|
17
17
|
require "gem_publisher"
|
18
|
-
task :publish_gem do
|
18
|
+
task :publish_gem do
|
19
19
|
gem = GemPublisher.publish_if_updated("vcloud-walker.gemspec", :rubygems)
|
20
20
|
puts "Published #{gem}" if gem
|
21
21
|
end
|
22
|
+
|
23
|
+
require 'rubocop/rake_task'
|
24
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
25
|
+
task.options = ['--lint']
|
26
|
+
end
|
data/bin/vcloud-walk
CHANGED
@@ -1,40 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'methadone'
|
5
|
-
|
6
|
-
require 'json'
|
7
3
|
require 'vcloud/walker'
|
8
4
|
|
9
|
-
|
10
|
-
include Methadone::Main
|
11
|
-
include Methadone::CLILogging
|
12
|
-
include Vcloud
|
13
|
-
|
14
|
-
main do |resource_to_walk|
|
15
|
-
walker_output = Vcloud::Walker.walk(resource_to_walk)
|
16
|
-
options[:yaml] ? print(walker_output.to_yaml) : print(JSON.pretty_generate walker_output)
|
17
|
-
end
|
18
|
-
|
19
|
-
on("--verbose", "Verbose output")
|
20
|
-
on("--debug", "Debugging output")
|
21
|
-
on("--yaml", "Yaml output")
|
22
|
-
|
23
|
-
arg :resource_to_walk
|
24
|
-
|
25
|
-
description '
|
26
|
-
Vcloud-walker is a command line tool, to describe different VMware vCloud Director 5.1 resources. It uses Fog under the hood.
|
27
|
-
|
28
|
-
Resources that can be walked using vcloud-walker are:
|
29
|
-
catalogs
|
30
|
-
vdcs
|
31
|
-
networks
|
32
|
-
edgegateways
|
33
|
-
organization
|
34
|
-
|
35
|
-
See https://github.com/alphagov/vcloud-walker for more info'
|
36
|
-
|
37
|
-
version Vcloud::Walker::VERSION
|
38
|
-
|
39
|
-
go!
|
40
|
-
end
|
5
|
+
Vcloud::Walker::Cli.new(ARGV).run
|
data/jenkins.sh
CHANGED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Vcloud
|
5
|
+
module Walker
|
6
|
+
class Cli
|
7
|
+
def initialize(argv_array)
|
8
|
+
@usage_text = nil
|
9
|
+
@resource_type = nil
|
10
|
+
@options = {
|
11
|
+
:yaml => false,
|
12
|
+
}
|
13
|
+
|
14
|
+
parse(argv_array)
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
begin
|
19
|
+
out = Vcloud::Walker.walk(@resource_type)
|
20
|
+
if @options[:yaml]
|
21
|
+
print(out.to_yaml)
|
22
|
+
else
|
23
|
+
print(JSON.pretty_generate(out))
|
24
|
+
end
|
25
|
+
rescue => e
|
26
|
+
$stderr.puts(e)
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def parse(args)
|
34
|
+
opt_parser = OptionParser.new do |opts|
|
35
|
+
opts.banner = <<-EOS
|
36
|
+
Usage: #{$0} [options] resource_type
|
37
|
+
Vcloud-walker is a command line tool, to describe different VMware vCloud Director 5.1 resources. It uses Fog under the hood.
|
38
|
+
|
39
|
+
Resources that can be walked using vcloud-walker are:
|
40
|
+
catalogs
|
41
|
+
vdcs
|
42
|
+
networks
|
43
|
+
edgegateways
|
44
|
+
organization
|
45
|
+
|
46
|
+
See https://github.com/gds-operations/vcloud-walker for more info
|
47
|
+
EOS
|
48
|
+
|
49
|
+
opts.on("--yaml", "Yaml output") do
|
50
|
+
@options[:yaml] = true
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on("-h", "--help", "Print usage and exit") do
|
54
|
+
$stderr.puts opts
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on("--version", "Display version and exit") do
|
59
|
+
puts Vcloud::Walker::VERSION
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
@usage_text = opt_parser.to_s
|
65
|
+
begin
|
66
|
+
opt_parser.parse!(args)
|
67
|
+
rescue OptionParser::InvalidOption => e
|
68
|
+
exit_error_usage(e)
|
69
|
+
end
|
70
|
+
|
71
|
+
exit_error_usage("must supply resource_type") unless args.size == 1
|
72
|
+
@resource_type = args.first
|
73
|
+
end
|
74
|
+
|
75
|
+
def exit_error_usage(error)
|
76
|
+
$stderr.puts "#{$0}: #{error}"
|
77
|
+
$stderr.puts @usage_text
|
78
|
+
exit 2
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -10,14 +10,18 @@ module Vcloud
|
|
10
10
|
@description = fog_vapp[:Description]
|
11
11
|
@deployed = fog_vapp[:deployed]
|
12
12
|
@id = extract_id(fog_vapp[:href])
|
13
|
-
@network_config = extract_network_config(fog_vapp
|
14
|
-
@network_section = fog_vapp
|
13
|
+
@network_config = extract_network_config(fog_vapp)
|
14
|
+
@network_section = extract_network_section(fog_vapp)
|
15
15
|
@vms = Resource::Vms.new(fog_vapp[:Children][:Vm])
|
16
16
|
@metadata = Vcloud::Core::Vapp.get_metadata(id)
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
|
-
def extract_network_config
|
20
|
+
def extract_network_config fog_vapp
|
21
|
+
return [] unless fog_vapp.key?(:NetworkConfigSection)
|
22
|
+
return [] unless fog_vapp[:NetworkConfigSection].key?(:NetworkConfig)
|
23
|
+
|
24
|
+
network_configs = fog_vapp[:NetworkConfigSection][:NetworkConfig]
|
21
25
|
(network_configs.is_a?(Hash) ? [network_configs] : network_configs).collect do |network_config|
|
22
26
|
{
|
23
27
|
network_name: network_config[:networkName],
|
@@ -31,6 +35,11 @@ module Vcloud
|
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
38
|
+
def extract_network_section fog_vapp
|
39
|
+
return {} unless fog_vapp.key?(:'ovf:NetworkSection')
|
40
|
+
|
41
|
+
fog_vapp[:'ovf:NetworkSection'].fetch(:'ovf:Network', {})
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
45
|
class VApps < Collection
|
data/lib/vcloud/walker.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'fog'
|
2
2
|
|
3
3
|
require 'vcloud/core'
|
4
|
+
require 'vcloud/walker/cli'
|
4
5
|
require 'vcloud/walker/vcloud_session'
|
5
6
|
require 'vcloud/walker/fog_interface'
|
6
7
|
require 'vcloud/walker/resource'
|
@@ -8,15 +9,14 @@ require 'vcloud/walker/version'
|
|
8
9
|
|
9
10
|
module Vcloud
|
10
11
|
module Walker
|
12
|
+
VALID_RESOURCES = %w{catalogs vdcs networks edgegateways organization}
|
11
13
|
|
12
14
|
def self.walk(resource_to_walk)
|
13
|
-
|
14
|
-
|
15
|
-
if valid_options.include? resource_to_walk
|
16
|
-
Vcloud::Walker::Resource::Organization.send(resource_to_walk)
|
17
|
-
else
|
18
|
-
puts "Possible options are '#{valid_options.join("','")}'."
|
15
|
+
unless VALID_RESOURCES.include?(resource_to_walk)
|
16
|
+
raise "Invalid resource '#{resource_to_walk}'. Possible options are '#{VALID_RESOURCES.join("','")}'."
|
19
17
|
end
|
18
|
+
|
19
|
+
Vcloud::Walker::Resource::Organization.send(resource_to_walk)
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
data/spec/fog_interface_spec.rb
CHANGED
@@ -8,51 +8,46 @@ describe Vcloud::Walker::FogInterface do
|
|
8
8
|
let(:session) { double(:fog_session, :org_name => 'org-123', :organizations => organizations) }
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
Vcloud::Walker::VcloudSession.
|
12
|
-
organizations.
|
11
|
+
expect(Vcloud::Walker::VcloudSession).to receive(:instance).with(any_args()).at_least(:once).and_return(session)
|
12
|
+
expect(organizations).to receive(:get_by_name).and_return(org)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should get catalogs for given org id" do
|
16
16
|
mock_catalogs = [double(:catalog1), double(:catalog2)]
|
17
|
-
org.
|
18
|
-
|
17
|
+
expect(org).to receive(:catalogs).and_return(double(:catalogs, :all => mock_catalogs))
|
19
18
|
catalogs = Vcloud::Walker::FogInterface.get_catalogs
|
20
|
-
|
21
|
-
catalogs.
|
22
|
-
catalogs.should == mock_catalogs
|
23
|
-
|
19
|
+
expect(catalogs.count).to eq(2)
|
20
|
+
expect(catalogs).to eq(mock_catalogs)
|
24
21
|
end
|
25
22
|
|
26
23
|
it "should get networks for given org id" do
|
27
24
|
mock_networks = [double(:network1), double(:network2)]
|
28
|
-
org.
|
29
|
-
|
25
|
+
expect(org).to receive(:networks).and_return(double(:networks, :all => mock_networks))
|
30
26
|
networks = Vcloud::Walker::FogInterface.get_networks
|
31
|
-
networks.count.
|
32
|
-
networks.
|
27
|
+
expect(networks.count).to eq(2)
|
28
|
+
expect(networks).to eq(mock_networks)
|
33
29
|
end
|
34
30
|
|
35
31
|
it "should get vdcs for given org id" do
|
36
32
|
mock_vdcs = [double(:vdc1), double(:vdc2), double(:vdc3)]
|
37
|
-
org.
|
38
|
-
|
33
|
+
expect(org).to receive(:vdcs).and_return(double(:vdcs, :all => mock_vdcs))
|
39
34
|
vdcs = Vcloud::Walker::FogInterface.get_vdcs
|
40
|
-
vdcs.count.
|
41
|
-
vdcs.
|
35
|
+
expect(vdcs.count).to eq(3)
|
36
|
+
expect(vdcs).to eq(mock_vdcs)
|
42
37
|
end
|
43
38
|
|
44
39
|
it "should get edge gateways for given org" do
|
45
40
|
mock_vdc1 = double(:vdc, :id => 1)
|
46
41
|
get_edge_gateway_result = double('Excon::Response', :body => {:EdgeGatewayRecord => {:href => '/sausage'}})
|
47
42
|
|
48
|
-
org.
|
49
|
-
session.
|
50
|
-
session.
|
43
|
+
expect(org).to receive(:vdcs).and_return(double(:vdcs, :all => [ mock_vdc1 ]))
|
44
|
+
expect(session).to receive(:get_org_vdc_gateways).with(1).and_return(get_edge_gateway_result)
|
45
|
+
expect(session).to receive(:get_edge_gateway).with('sausage').and_return(double(:eg, :body => :eg1))
|
51
46
|
|
52
47
|
edge_gateways = Vcloud::Walker::FogInterface.get_edge_gateways
|
53
48
|
|
54
|
-
edge_gateways.count.
|
55
|
-
edge_gateways.
|
49
|
+
expect(edge_gateways.count).to eq(1)
|
50
|
+
expect(edge_gateways).to eq([:eg1])
|
56
51
|
end
|
57
52
|
|
58
53
|
it "should get edge gateways for given org with complex set up of 2 vdcs and 3 edge gateways" do
|
@@ -61,18 +56,18 @@ describe Vcloud::Walker::FogInterface do
|
|
61
56
|
mock_vdc2 = double(:vdc, :id => 2)
|
62
57
|
get_edge_gateway_vdc_2_result = double('Excon::Response', :body => {:EdgeGatewayRecord => [{:href => '/beans'}, {:href => '/hashbrown'}]})
|
63
58
|
|
64
|
-
org.
|
59
|
+
expect(org).to receive(:vdcs).and_return(double(:vdcs, :all => [ mock_vdc1, mock_vdc2 ]))
|
65
60
|
|
66
|
-
session.
|
67
|
-
session.
|
68
|
-
session.
|
69
|
-
session.
|
70
|
-
session.
|
61
|
+
expect(session).to receive(:get_org_vdc_gateways).with(1).and_return(get_edge_gateway_vdc_1_result)
|
62
|
+
expect(session).to receive(:get_org_vdc_gateways).with(2).and_return(get_edge_gateway_vdc_2_result)
|
63
|
+
expect(session).to receive(:get_edge_gateway).with('sausage').and_return(double(:eg, :body => :eg1))
|
64
|
+
expect(session).to receive(:get_edge_gateway).with('beans').and_return(double(:eg, :body => :eg2))
|
65
|
+
expect(session).to receive(:get_edge_gateway).with('hashbrown').and_return(double(:eg, :body => :eg3))
|
71
66
|
|
72
67
|
edge_gateways = Vcloud::Walker::FogInterface.get_edge_gateways
|
73
68
|
|
74
|
-
edge_gateways.count.
|
75
|
-
edge_gateways.
|
69
|
+
expect(edge_gateways.count).to eq(3)
|
70
|
+
expect(edge_gateways).to eq([:eg1, :eg2, :eg3])
|
76
71
|
end
|
77
72
|
|
78
73
|
it "get_edge_gateways should be happy if there are no edge gateways" do
|
@@ -81,13 +76,13 @@ describe Vcloud::Walker::FogInterface do
|
|
81
76
|
# no edge gateways means no entries to find in the results, just some other noise
|
82
77
|
vdc_1_search_result = double('Excon::Response', :body => {:Link => {:href => 's'}})
|
83
78
|
|
84
|
-
org.
|
85
|
-
session.
|
79
|
+
expect(org).to receive(:vdcs).and_return(double(:vdcs, :all => [ mock_vdc1 ]))
|
80
|
+
expect(session).to receive(:get_org_vdc_gateways).with(1).and_return(vdc_1_search_result)
|
86
81
|
|
87
82
|
edge_gateways = Vcloud::Walker::FogInterface.get_edge_gateways
|
88
83
|
|
89
|
-
edge_gateways.count.
|
84
|
+
expect(edge_gateways.count).to eq(0)
|
90
85
|
end
|
91
86
|
|
92
87
|
end
|
93
|
-
end
|
88
|
+
end
|
@@ -31,11 +31,11 @@ describe Vcloud::Walker do
|
|
31
31
|
vdc_summaries = Vcloud::Walker.walk('vdcs').to_json
|
32
32
|
|
33
33
|
# assert that there are atleast one item and that includes the essencial sections
|
34
|
-
vdc_summaries.
|
35
|
-
vdc_summaries.
|
36
|
-
vdc_summaries.
|
37
|
-
vdc_summaries.
|
38
|
-
vdc_summaries.
|
34
|
+
expect(vdc_summaries).to have_json_path('0/id')
|
35
|
+
expect(vdc_summaries).to have_json_path('0/name')
|
36
|
+
expect(vdc_summaries).to have_json_path('0/vapps')
|
37
|
+
expect(vdc_summaries).to have_json_path('0/quotas')
|
38
|
+
expect(vdc_summaries).to have_json_path('0/compute_capacity')
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should integrate with fog to get networks" do
|
@@ -43,10 +43,10 @@ describe Vcloud::Walker do
|
|
43
43
|
network_summary = Vcloud::Walker.walk('networks').to_json
|
44
44
|
|
45
45
|
# assert that there are atleast one item and that includes the essencial sections
|
46
|
-
network_summary.
|
47
|
-
network_summary.
|
48
|
-
network_summary.
|
49
|
-
network_summary.
|
46
|
+
expect(network_summary).to have_json_path('0/id')
|
47
|
+
expect(network_summary).to have_json_path('0/name')
|
48
|
+
expect(network_summary).to have_json_path('0/ip_ranges')
|
49
|
+
expect(network_summary).to have_json_path('0/gateway')
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should integrate with fog to get catalogs" do
|
@@ -55,20 +55,20 @@ describe Vcloud::Walker do
|
|
55
55
|
catalog_summary = catalogs_summary.detect{|c| !c[:items].empty? }.to_json
|
56
56
|
|
57
57
|
# assert that there are atleast one item and that includes the essencial sections
|
58
|
-
catalog_summary.
|
59
|
-
catalog_summary.
|
60
|
-
catalog_summary.
|
61
|
-
catalog_summary.
|
58
|
+
expect(catalog_summary).to have_json_path('id')
|
59
|
+
expect(catalog_summary).to have_json_path('name')
|
60
|
+
expect(catalog_summary).to have_json_path('items')
|
61
|
+
expect(catalog_summary).to have_json_path('items/0/vapp_template_id')
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should integrate with fog to get edge gateway data" do
|
65
65
|
|
66
66
|
result = Vcloud::Walker.walk('edgegateways').to_json
|
67
67
|
# assert that there are atleast one item and that includes the essencial sections
|
68
|
-
result.
|
69
|
-
result.
|
70
|
-
result.
|
71
|
-
result.
|
68
|
+
expect(result).to have_json_path('0/Configuration/EdgeGatewayServiceConfiguration/FirewallService')
|
69
|
+
expect(result).to have_json_path('0/Configuration/EdgeGatewayServiceConfiguration/NatService')
|
70
|
+
expect(result).to have_json_path('0/Configuration/EdgeGatewayServiceConfiguration/LoadBalancerService')
|
71
|
+
expect(result).to have_json_path('0/Configuration/GatewayInterfaces/GatewayInterface')
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,22 @@
|
|
1
|
+
# SimpleCov must run _first_ according to its README
|
1
2
|
if ENV['COVERAGE']
|
2
3
|
require 'simplecov'
|
3
4
|
|
4
|
-
SimpleCov
|
5
|
+
# monkey-patch to prevent SimpleCov from reporting coverage percentage
|
6
|
+
class SimpleCov::Formatter::HTMLFormatter
|
7
|
+
def output_message(_message)
|
8
|
+
nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
SimpleCov.adapters.define 'gem' do
|
5
13
|
add_filter '/spec/'
|
6
|
-
add_filter '/features/'
|
7
14
|
add_filter '/vendor/'
|
8
15
|
|
9
16
|
add_group 'Libraries', '/lib/'
|
10
17
|
end
|
11
18
|
|
19
|
+
SimpleCov.minimum_coverage(99)
|
12
20
|
SimpleCov.start 'gem'
|
13
21
|
end
|
14
22
|
|
@@ -29,17 +37,7 @@ end
|
|
29
37
|
|
30
38
|
RSpec.configure do |config|
|
31
39
|
config.include JsonSpec::Helpers
|
32
|
-
|
33
|
-
|
34
|
-
if ENV['COVERAGE']
|
35
|
-
ACCEPTED_COVERAGE = 97
|
36
|
-
SimpleCov.at_exit do
|
37
|
-
SimpleCov.result.format!
|
38
|
-
# do not change the coverage percentage, instead add more unit tests to fix coverage failures.
|
39
|
-
if SimpleCov.result.covered_percent < ACCEPTED_COVERAGE
|
40
|
-
print "ERROR::BAD_CODE_COVERAGE\n"
|
41
|
-
print "Coverage is less than acceptable limit(#{ACCEPTED_COVERAGE}%). Please add more tests to improve the coverage"
|
42
|
-
exit(1)
|
43
|
-
end
|
40
|
+
config.expect_with :rspec do |c|
|
41
|
+
c.syntax = :expect
|
44
42
|
end
|
45
|
-
end
|
43
|
+
end
|