vcloud-tools-tester 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.3.0 (2014-10-06)
2
+
3
+ Features:
4
+
5
+ - Fixture creation (specifically networks at present) is now optional, based on
6
+ whether the 'network_1' or 'network_2' keys are required. Prevents unneccessary
7
+ pre-requisites for integration tests that do not require these fixtures, and should
8
+ be automatically enabled.
9
+
1
10
  ## 0.2.0 (2014-08-11)
2
11
 
3
12
  API changes:
@@ -4,9 +4,10 @@ module Vcloud
4
4
  class FixtureParameters
5
5
  attr_reader :fixture_params
6
6
 
7
- def initialize(user_params)
7
+ def initialize(user_params, expected_params)
8
8
  @vcloud_api = Vcloud::Core::ApiInterface.new
9
9
  @user_params = user_params
10
+ @expected_params = expected_params
10
11
  ensure_vcloud_fixtures
11
12
  extract_fixture_params
12
13
  end
@@ -14,58 +15,20 @@ module Vcloud
14
15
  private
15
16
 
16
17
  def ensure_vcloud_fixtures
17
- generate_fixtures_config
18
- correct_networks = ensure_networks_correct(@expected_fixtures_config[:networks])
19
- @fixtures = correct_networks
18
+ @fixtures = ensure_networks_correct(generate_fixtures_config[:networks])
20
19
  end
21
20
 
22
21
  def generate_fixtures_config
23
- @expected_fixtures_config = {
24
- :networks => {
25
- :network_1 => {
26
- :edge_gateway => @user_params["edge_gateway"],
27
- :vdc_name => @user_params["vdc_1_name"],
28
- :name => @user_params["network_1"],
29
- :type => 'application/vnd.vmware.vcloud.orgVdcNetwork+xml',
30
- :description => '',
31
- :is_inherited => 'false',
32
- :is_shared => 'true',
33
- :fence_mode => 'natRouted',
34
- :gateway => '192.168.1.1',
35
- :netmask => '255.255.255.0',
36
- :dns1 => nil,
37
- :dns2 => nil,
38
- :dns_suffix => nil,
39
- :ip_ranges => [
40
- {
41
- :start_address => "192.168.1.2",
42
- :end_address => "192.168.1.254"
43
- }
44
- ],
45
- },
46
- :network_2 => {
47
- :edge_gateway => @user_params["edge_gateway"],
48
- :vdc_name => @user_params["vdc_2_name"],
49
- :name => @user_params["network_2"],
50
- :type => 'application/vnd.vmware.vcloud.orgVdcNetwork+xml',
51
- :description => '',
52
- :is_inherited => 'false',
53
- :is_shared => 'true',
54
- :fence_mode => 'isolated',
55
- :gateway => '10.0.0.1',
56
- :netmask => '255.255.0.0',
57
- :dns1 => nil,
58
- :dns2 => nil,
59
- :dns_suffix => nil,
60
- :ip_ranges => [
61
- {
62
- :start_address => "10.0.0.2",
63
- :end_address => "10.0.255.254"
64
- }
65
- ],
66
- },
67
- },
22
+ expected_fixtures_config = {
23
+ :networks => {},
68
24
  }
25
+ if @expected_params.include?("network_1")
26
+ expected_fixtures_config[:networks][:network_1] = expected_network_1_config
27
+ end
28
+ if @expected_params.include?("network_2")
29
+ expected_fixtures_config[:networks][:network_2] = expected_network_2_config
30
+ end
31
+ expected_fixtures_config
69
32
  end
70
33
 
71
34
  def ensure_networks_correct(expected_network_config)
@@ -95,14 +58,13 @@ module Vcloud
95
58
  end
96
59
 
97
60
  def extract_fixture_params
98
- raise "No fixtures present" if @fixtures.empty?
99
61
 
100
62
  @fixture_params = {}
101
63
 
102
64
  @fixtures.each do |fixture|
103
65
  case fixture
104
66
  when ::Fog::Compute::VcloudDirector::Network, Vcloud::Core::OrgVdcNetwork
105
- @expected_fixtures_config[:networks].each do |network_ref, expected_network_config|
67
+ generate_fixtures_config[:networks].each do |network_ref, expected_network_config|
106
68
  if expected_network_config[:name] == fixture.name
107
69
  @fixture_params["#{network_ref}_id"] = fixture.id
108
70
  end
@@ -147,6 +109,55 @@ module Vcloud
147
109
 
148
110
  false
149
111
  end
112
+
113
+ def expected_network_1_config
114
+ {
115
+ :edge_gateway => @user_params["edge_gateway"],
116
+ :vdc_name => @user_params["vdc_1_name"],
117
+ :name => @user_params["network_1"],
118
+ :type => 'application/vnd.vmware.vcloud.orgVdcNetwork+xml',
119
+ :description => '',
120
+ :is_inherited => 'false',
121
+ :is_shared => 'true',
122
+ :fence_mode => 'natRouted',
123
+ :gateway => '192.168.1.1',
124
+ :netmask => '255.255.255.0',
125
+ :dns1 => nil,
126
+ :dns2 => nil,
127
+ :dns_suffix => nil,
128
+ :ip_ranges => [
129
+ {
130
+ :start_address => "192.168.1.2",
131
+ :end_address => "192.168.1.254"
132
+ }
133
+ ],
134
+ }
135
+ end
136
+
137
+ def expected_network_2_config
138
+ {
139
+ :edge_gateway => @user_params["edge_gateway"],
140
+ :vdc_name => @user_params["vdc_2_name"],
141
+ :name => @user_params["network_2"],
142
+ :type => 'application/vnd.vmware.vcloud.orgVdcNetwork+xml',
143
+ :description => '',
144
+ :is_inherited => 'false',
145
+ :is_shared => 'true',
146
+ :fence_mode => 'isolated',
147
+ :gateway => '10.0.0.1',
148
+ :netmask => '255.255.0.0',
149
+ :dns1 => nil,
150
+ :dns2 => nil,
151
+ :dns_suffix => nil,
152
+ :ip_ranges => [
153
+ {
154
+ :start_address => "10.0.0.2",
155
+ :end_address => "10.0.255.254"
156
+ }
157
+ ],
158
+ }
159
+ end
160
+
150
161
  end
151
162
  end
152
163
  end
@@ -6,7 +6,6 @@ module Vcloud
6
6
  class TestParameters
7
7
  def initialize(user_params, fixture_params)
8
8
  raise "No user parameters received" if user_params.empty?
9
- raise "No fixture parameters received" if fixture_params.empty?
10
9
 
11
10
  @user_params = user_params
12
11
  @fixture_params = fixture_params
@@ -6,9 +6,9 @@ module Vcloud
6
6
  class TestSetup
7
7
  attr_reader :test_params
8
8
 
9
- def initialize(config_file, expected_user_params)
10
- user_params = Vcloud::Tools::Tester::UserParameters.new(config_file, expected_user_params).user_params
11
- fixture_params = Vcloud::Tools::Tester::FixtureParameters.new(user_params).fixture_params
9
+ def initialize(config_file, expected_params)
10
+ user_params = Vcloud::Tools::Tester::UserParameters.new(config_file, expected_params).user_params
11
+ fixture_params = Vcloud::Tools::Tester::FixtureParameters.new(user_params, expected_params).fixture_params
12
12
 
13
13
  @test_params = Vcloud::Tools::Tester::TestParameters.new(user_params, fixture_params)
14
14
  end
@@ -6,9 +6,9 @@ module Vcloud
6
6
  class UserParameters
7
7
  attr_reader :user_params
8
8
 
9
- def initialize(config_file, expected_user_params)
9
+ def initialize(config_file, expected_params)
10
10
  @config_file = config_file
11
- @expected_user_params = expected_user_params || []
11
+ @expected_params = expected_params || []
12
12
 
13
13
  parse_config
14
14
  end
@@ -27,11 +27,11 @@ module Vcloud
27
27
  all_config = YAML::load_file(@config_file)
28
28
 
29
29
  @user_params = all_config.fetch(organization) do
30
- raise "Invalid FOG_CREDENTIAL environment variable value '#{organization}'"
30
+ raise "No matching organisation was found in #{@config_file} for FOG_CREDENTIAL value '#{organization}'"
31
31
  end
32
32
 
33
33
  defined_keys = @user_params.keys
34
- missing_params = @expected_user_params - defined_keys
34
+ missing_params = @expected_params - defined_keys
35
35
  if missing_params.any?
36
36
  raise "Required parameters not defined in #{@config_file}: " + missing_params.join(", ")
37
37
  end
@@ -1,7 +1,7 @@
1
1
  module Vcloud
2
2
  module Tools
3
3
  module Tester
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'vcloud/tools/tester'
3
3
 
4
4
  describe Vcloud::Tools::Tester::FixtureParameters do
5
- subject { Vcloud::Tools::Tester::FixtureParameters.new(user_params) }
5
+ subject { Vcloud::Tools::Tester::FixtureParameters.new(user_params, expected_params) }
6
6
 
7
7
  before(:each) do
8
8
  stub_const("Fog::Compute::VcloudDirector::Network", Object)
@@ -30,6 +30,16 @@ describe Vcloud::Tools::Tester::FixtureParameters do
30
30
  }
31
31
  end
32
32
 
33
+ let(:expected_params) do
34
+ [
35
+ "edge_gateway",
36
+ "vdc_1_name",
37
+ "vdc_2_name",
38
+ "network_1",
39
+ "network_2",
40
+ ]
41
+ end
42
+
33
43
  let(:mock_found_vdcs) do
34
44
  [
35
45
  mock_vdc_1,
@@ -158,4 +168,23 @@ describe Vcloud::Tools::Tester::FixtureParameters do
158
168
  expect(subject.fixture_params.values).to eq(mock_fixture_uuids)
159
169
  end
160
170
  end
171
+
172
+ context "when none of the network fixtures are needed" do
173
+
174
+ let(:networkless_expected_params) {
175
+ [
176
+ "edge_gateway",
177
+ "vdc_1_name",
178
+ "vdc_2_name",
179
+ ]
180
+ }
181
+
182
+ subject { Vcloud::Tools::Tester::FixtureParameters.new(user_params, networkless_expected_params) }
183
+
184
+ it "returns an empty fixture_params hash" do
185
+ expect(subject.fixture_params).to eq({})
186
+ end
187
+
188
+ end
189
+
161
190
  end
@@ -47,12 +47,5 @@ describe Vcloud::Tools::Tester::TestParameters do
47
47
  expect{ parameters }.to raise_error("No user parameters received")
48
48
  end
49
49
  end
50
-
51
- context "no fixture parameters passed in" do
52
- let(:fixture_params) {{}}
53
- it "raises an error if it receives no fixture parameters" do
54
- expect{ parameters }.to raise_error("No fixture parameters received")
55
- end
56
- end
57
50
  end
58
51
  end
@@ -9,7 +9,7 @@ describe Vcloud::Tools::Tester::TestSetup do
9
9
  end
10
10
 
11
11
  let(:example_filename) { "example_filename.yaml" }
12
- let(:expected_user_params) { [] }
12
+ let(:expected_params) { [] }
13
13
 
14
14
  let(:mock_user_parameters) do
15
15
  double(:user_parameters, :user_params => {})
@@ -24,7 +24,7 @@ describe Vcloud::Tools::Tester::TestSetup do
24
24
  end
25
25
 
26
26
  subject do
27
- Vcloud::Tools::Tester::TestSetup.new(example_filename, expected_user_params)
27
+ Vcloud::Tools::Tester::TestSetup.new(example_filename, expected_params)
28
28
  end
29
29
 
30
30
  it "responds with test parameters" do
@@ -32,8 +32,8 @@ describe Vcloud::Tools::Tester::TestSetup do
32
32
  end
33
33
 
34
34
  it "calls the appropriate methods" do
35
- expect(Vcloud::Tools::Tester::UserParameters).to receive(:new).with(example_filename, expected_user_params)
36
- expect(Vcloud::Tools::Tester::FixtureParameters).to receive(:new).with({})
35
+ expect(Vcloud::Tools::Tester::UserParameters).to receive(:new).with(example_filename, expected_params)
36
+ expect(Vcloud::Tools::Tester::FixtureParameters).to receive(:new).with({}, expected_params)
37
37
  expect(Vcloud::Tools::Tester::TestParameters).to receive(:new).with({}, {})
38
38
 
39
39
  subject.test_params
@@ -3,7 +3,7 @@ require 'vcloud/tools/tester'
3
3
 
4
4
  describe Vcloud::Tools::Tester::UserParameters do
5
5
  subject(:parameters) do
6
- Vcloud::Tools::Tester::UserParameters.new(config_file, expected_user_params).user_params
6
+ Vcloud::Tools::Tester::UserParameters.new(config_file, expected_params).user_params
7
7
  end
8
8
 
9
9
  before(:each) do
@@ -18,7 +18,7 @@ describe Vcloud::Tools::Tester::UserParameters do
18
18
  "#{data_dir}/test_config.yaml"
19
19
  end
20
20
 
21
- let(:expected_user_params) {[]}
21
+ let(:expected_params) {[]}
22
22
  context "loading standard config file" do
23
23
  it "loads input yaml when intialized" do
24
24
  test_vdc = parameters["vdc_1_name"]
@@ -33,12 +33,12 @@ describe Vcloud::Tools::Tester::UserParameters do
33
33
 
34
34
  it "gives a useful error when the FOG_CREDENTIAL is missing from the config" do
35
35
  stub_const('ENV', {'FOG_CREDENTIAL' => 'bogus-fog-credential'})
36
- expect { parameters }.to raise_error(RuntimeError, /Invalid FOG_CREDENTIAL environment variable value/)
36
+ expect { parameters }.to raise_error(RuntimeError, /No matching organisation was found in/)
37
37
  end
38
38
  end
39
39
 
40
40
  context "when an expected user-defined parameter is missing from the config file" do
41
- let(:expected_user_params) { [ "vdc_1_name", "bar" ] }
41
+ let(:expected_params) { [ "vdc_1_name", "bar" ] }
42
42
 
43
43
  it "raises an error if an expected user-defined parameter is not present" do
44
44
  expect{ parameters }.to raise_error(RuntimeError, "Required parameters not defined in #{config_file}: bar")
@@ -47,7 +47,7 @@ describe Vcloud::Tools::Tester::UserParameters do
47
47
 
48
48
  context "loading minimal config file" do
49
49
  subject(:parameters) do
50
- Vcloud::Tools::Tester::UserParameters.new("#{data_dir}/test_minimal_config.yaml", expected_user_params).user_params
50
+ Vcloud::Tools::Tester::UserParameters.new("#{data_dir}/test_minimal_config.yaml", expected_params).user_params
51
51
  end
52
52
 
53
53
  it "input yaml file can be changed" do
@@ -64,7 +64,7 @@ describe Vcloud::Tools::Tester::UserParameters do
64
64
 
65
65
  context "loading non-existent config file" do
66
66
  subject(:parameters) do
67
- Vcloud::Tools::Tester::UserParameters.new("#{data_dir}/nonexistent_config_file.yaml", expected_user_params).user_params
67
+ Vcloud::Tools::Tester::UserParameters.new("#{data_dir}/nonexistent_config_file.yaml", expected_params).user_params
68
68
  end
69
69
 
70
70
  it "gives a useful error when there is no config file" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcloud-tools-tester
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,27 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-11 00:00:00.000000000 Z
12
+ date: 2014-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gem_publisher
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &7024540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - '='
19
+ - - =
20
20
  - !ruby/object:Gem::Version
21
21
  version: 1.2.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - '='
28
- - !ruby/object:Gem::Version
29
- version: 1.2.0
24
+ version_requirements: *7024540
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: pry
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &7023740 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: '0'
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *7023740
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: rake
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &7023000 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ! '>='
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: '0'
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
46
+ version_requirements: *7023000
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: rspec
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &7021480 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ~>
@@ -69,15 +54,10 @@ dependencies:
69
54
  version: 2.14.1
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 2.14.1
57
+ version_requirements: *7021480
78
58
  - !ruby/object:Gem::Dependency
79
59
  name: rubocop
80
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &7018860 !ruby/object:Gem::Requirement
81
61
  none: false
82
62
  requirements:
83
63
  - - ~>
@@ -85,15 +65,10 @@ dependencies:
85
65
  version: 0.23.0
86
66
  type: :development
87
67
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: 0.23.0
68
+ version_requirements: *7018860
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: simplecov
96
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &7046520 !ruby/object:Gem::Requirement
97
72
  none: false
98
73
  requirements:
99
74
  - - ~>
@@ -101,15 +76,10 @@ dependencies:
101
76
  version: 0.7.1
102
77
  type: :development
103
78
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: 0.7.1
79
+ version_requirements: *7046520
110
80
  - !ruby/object:Gem::Dependency
111
81
  name: vcloud-core
112
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &7044820 !ruby/object:Gem::Requirement
113
83
  none: false
114
84
  requirements:
115
85
  - - ~>
@@ -117,12 +87,7 @@ dependencies:
117
87
  version: '0.9'
118
88
  type: :runtime
119
89
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ~>
124
- - !ruby/object:Gem::Version
125
- version: '0.9'
90
+ version_requirements: *7044820
126
91
  description: Tool to facilitate testing of vCloud Tools
127
92
  email:
128
93
  - anna.shipman@digital.cabinet-office.gov.uk
@@ -175,10 +140,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
140
  version: '0'
176
141
  segments:
177
142
  - 0
178
- hash: 3686057879377265780
143
+ hash: 2091558975490885511
179
144
  requirements: []
180
145
  rubyforge_project:
181
- rubygems_version: 1.8.23
146
+ rubygems_version: 1.8.11
182
147
  signing_key:
183
148
  specification_version: 3
184
149
  summary: vCloud Tools integration tests require secret parameters. This helps you