tengine_resource 0.5.15 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -27
- data/Gemfile.lock +60 -73
- data/README.rdoc +2 -2
- data/bin/create_indexes_for_tengine_resource +18 -0
- data/lib/tengine/resource/config/resource.rb +0 -3
- data/lib/tengine/resource/credential.rb +16 -17
- data/lib/tengine/resource/net_ssh.rb +22 -10
- data/lib/tengine/resource/physical_server.rb +8 -0
- data/lib/tengine/resource/provider.rb +206 -35
- data/lib/tengine/resource/server.rb +3 -3
- data/lib/tengine/resource/virtual_server.rb +1 -1
- data/lib/tengine/resource/virtual_server_image.rb +8 -8
- data/lib/tengine/resource/virtual_server_type.rb +2 -2
- data/lib/tengine/resource/watcher.rb +39 -9
- data/tmp/.gitkeep +0 -0
- metadata +92 -141
- data/.document +0 -5
- data/.rspec +0 -1
- data/Rakefile +0 -42
- data/VERSION +0 -1
- data/config/.gitignore +0 -2
- data/lib/tengine/resource/credential/ec2.rb +0 -5
- data/lib/tengine/resource/credential/ec2/dummy.rb +0 -148
- data/lib/tengine/resource/credential/ec2/launch_options.rb +0 -179
- data/lib/tengine/resource/provider/ec2.rb +0 -187
- data/lib/tengine/resource/provider/wakame.rb +0 -638
- data/spec/fixtures/goku_at_ec2_ap_northeast.rb +0 -177
- data/spec/mongoid.yml +0 -35
- data/spec/mongoid_en.yml +0 -48
- data/spec/spec_helper.rb +0 -43
- data/spec/support/ec2.rb +0 -129
- data/spec/support/mongo_index_key_log.rb +0 -91
- data/spec/tengine/resource/bugfix/watcher_for_wakame_spec.rb +0 -232
- data/spec/tengine/resource/credential_spec.rb +0 -205
- data/spec/tengine/resource/drivers/resource_control_driver_spec.rb +0 -84
- data/spec/tengine/resource/net_ssh_spec.rb +0 -148
- data/spec/tengine/resource/physical_server_spec.rb +0 -47
- data/spec/tengine/resource/provider/ec2_spec.rb +0 -473
- data/spec/tengine/resource/provider/test_files/describe_host_nodes.json +0 -22
- data/spec/tengine/resource/provider/test_files/describe_images.json +0 -23
- data/spec/tengine/resource/provider/test_files/describe_instance_specs.json +0 -23
- data/spec/tengine/resource/provider/test_files/describe_instances.json +0 -56
- data/spec/tengine/resource/provider/test_files/run_instances.json +0 -30
- data/spec/tengine/resource/provider/test_files/terminate_instances.json +0 -3
- data/spec/tengine/resource/provider/wakame/00_describe_host_nodes_0_physical_servers.json +0 -8
- data/spec/tengine/resource/provider/wakame/01_describe_host_nodes_10_physical_servers.json +0 -139
- data/spec/tengine/resource/provider/wakame/02_describe_host_nodes_60_physical_servers.json +0 -795
- data/spec/tengine/resource/provider/wakame/10_describe_instances_0_virtual_servers.json +0 -8
- data/spec/tengine/resource/provider/wakame/11_describe_instances_10_virtual_servers.json +0 -469
- data/spec/tengine/resource/provider/wakame/12_describe_instances_after_run_instances.json +0 -280
- data/spec/tengine/resource/provider/wakame/13_describe_instances_after_terminate_instances.json +0 -279
- data/spec/tengine/resource/provider/wakame/20_describe_images_0_virtual_server_images.json +0 -8
- data/spec/tengine/resource/provider/wakame/21_describe_images_5_virtual_server_images.json +0 -84
- data/spec/tengine/resource/provider/wakame/22_describe_images_60_virtual_server_images.json +0 -856
- data/spec/tengine/resource/provider/wakame/30_describe_instance_specs_0_virtual_server_specs.json +0 -8
- data/spec/tengine/resource/provider/wakame/31_describe_instance_specs_4_virtual_server_specs.json +0 -66
- data/spec/tengine/resource/provider/wakame/40_run_instances_0_virtual_servers.json +0 -1
- data/spec/tengine/resource/provider/wakame/41_run_instances_1_virtual_servers.json +0 -22
- data/spec/tengine/resource/provider/wakame/42_run_instances_5_virtual_servers.json +0 -106
- data/spec/tengine/resource/provider/wakame/50_terminate_instances_0_virtual_servers.json +0 -1
- data/spec/tengine/resource/provider/wakame/51_terminate_instances_3_virtual_servers.json +0 -5
- data/spec/tengine/resource/provider/wakame/sync_physical_servers_spec.rb +0 -114
- data/spec/tengine/resource/provider/wakame/sync_virtual_server_images_spec.rb +0 -116
- data/spec/tengine/resource/provider/wakame/sync_virtual_server_types_spec.rb +0 -116
- data/spec/tengine/resource/provider/wakame/sync_virtual_servers_spec.rb +0 -216
- data/spec/tengine/resource/provider/wakame_api_spec.rb +0 -319
- data/spec/tengine/resource/provider/wakame_spec.rb +0 -339
- data/spec/tengine/resource/provider_spec.rb +0 -252
- data/spec/tengine/resource/server_spec.rb +0 -195
- data/spec/tengine/resource/test_files/.gitignore +0 -6
- data/spec/tengine/resource/test_files/00_describe_host_nodes_0_physical_servers.json +0 -8
- data/spec/tengine/resource/test_files/01_describe_host_nodes_10_physical_servers.json +0 -139
- data/spec/tengine/resource/test_files/02_describe_host_nodes_60_physical_servers.json +0 -795
- data/spec/tengine/resource/test_files/10_describe_instances_0_virtual_servers.json +0 -8
- data/spec/tengine/resource/test_files/11_describe_instances_10_virtual_servers.json +0 -469
- data/spec/tengine/resource/test_files/12_describe_instances_after_run_instances.json +0 -280
- data/spec/tengine/resource/test_files/13_describe_instances_after_terminate_instances.json +0 -279
- data/spec/tengine/resource/test_files/14_describe_instances_after_run_1_instance.json +0 -55
- data/spec/tengine/resource/test_files/20_describe_images_0_virtual_server_images.json +0 -8
- data/spec/tengine/resource/test_files/21_describe_images_5_virtual_server_images.json +0 -84
- data/spec/tengine/resource/test_files/22_describe_images_60_virtual_server_images.json +0 -856
- data/spec/tengine/resource/test_files/30_describe_instance_specs_0_virtual_server_specs.json +0 -8
- data/spec/tengine/resource/test_files/31_describe_instance_specs_4_virtual_server_specs.json +0 -66
- data/spec/tengine/resource/test_files/40_run_instances_0_virtual_servers.json +0 -1
- data/spec/tengine/resource/test_files/41_run_instances_1_virtual_servers.json +0 -22
- data/spec/tengine/resource/test_files/42_run_instances_5_virtual_servers.json +0 -106
- data/spec/tengine/resource/test_files/43_run_instances_1_virtual_servers_without_aws_availability_zone.json +0 -22
- data/spec/tengine/resource/test_files/50_terminate_instances_0_virtual_servers.json +0 -1
- data/spec/tengine/resource/test_files/51_terminate_instances_3_virtual_servers.json +0 -5
- data/spec/tengine/resource/virtual_server_image_spec.rb +0 -94
- data/spec/tengine/resource/virtual_server_spec.rb +0 -116
- data/spec/tengine/resource/virtual_server_type_spec.rb +0 -4
- data/spec/tengine/resource/watcher_spec.rb +0 -1027
- data/spec/tengine_resource_spec.rb +0 -5
- data/tengine_resource.gemspec +0 -172
- data/tmp/log/.gitignore +0 -1
data/spec/tengine/resource/test_files/31_describe_instance_specs_4_virtual_server_specs.json
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"owner_total": 2,
|
4
|
-
"start": 0,
|
5
|
-
"results": [
|
6
|
-
{
|
7
|
-
"id": "virtual_server_spec_uuid_01",
|
8
|
-
"uuid": "virtual_server_spec_uuid_01",
|
9
|
-
"cpu_cores": 1,
|
10
|
-
"memory_size": 256,
|
11
|
-
"arch": "x86_64",
|
12
|
-
"hypervisor": "kvm",
|
13
|
-
"updated_at": "2011-10-28T02:58:57Z",
|
14
|
-
"account_id": "a-shpoolxx",
|
15
|
-
"vifs": "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
16
|
-
"quota_weight": 1.0,
|
17
|
-
"created_at": "2011-10-28T02:58:57Z",
|
18
|
-
"drives": "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n"
|
19
|
-
},
|
20
|
-
{
|
21
|
-
"id": "virtual_server_spec_uuid_02",
|
22
|
-
"uuid": "virtual_server_spec_uuid_02",
|
23
|
-
"cpu_cores": 2,
|
24
|
-
"memory_size": 512,
|
25
|
-
"arch": "x86_64",
|
26
|
-
"hypervisor": "kvm",
|
27
|
-
"updated_at": "2011-10-28T02:58:57Z",
|
28
|
-
"account_id": "a-shpoolxx",
|
29
|
-
"vifs": "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
30
|
-
"quota_weight": 1.0,
|
31
|
-
"created_at": "2011-10-28T02:58:57Z",
|
32
|
-
"drives": "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n"
|
33
|
-
},
|
34
|
-
{
|
35
|
-
"id": "virtual_server_spec_uuid_03",
|
36
|
-
"uuid": "virtual_server_spec_uuid_03",
|
37
|
-
"cpu_cores": 5,
|
38
|
-
"memory_size": 1,
|
39
|
-
"arch": "x86_64",
|
40
|
-
"hypervisor": "kvm",
|
41
|
-
"updated_at": "2011-10-28T02:58:57Z",
|
42
|
-
"account_id": "a-shpoolxx",
|
43
|
-
"vifs": "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
44
|
-
"quota_weight": 1.0,
|
45
|
-
"created_at": "2011-10-28T02:58:57Z",
|
46
|
-
"drives": "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n"
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"id": "virtual_server_spec_uuid_04",
|
50
|
-
"uuid": "virtual_server_spec_uuid_04",
|
51
|
-
"cpu_cores": 1,
|
52
|
-
"memory_size": 1500,
|
53
|
-
"arch": "x86_64",
|
54
|
-
"hypervisor": "kvm",
|
55
|
-
"updated_at": "2011-10-28T02:58:57Z",
|
56
|
-
"account_id": "a-shpoolxx",
|
57
|
-
"vifs": "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
58
|
-
"quota_weight": 1.0,
|
59
|
-
"created_at": "2011-10-28T02:58:57Z",
|
60
|
-
"drives": "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n"
|
61
|
-
}
|
62
|
-
|
63
|
-
],
|
64
|
-
"limit": null
|
65
|
-
}
|
66
|
-
]
|
@@ -1 +0,0 @@
|
|
1
|
-
[]
|
@@ -1,22 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"id": "virtual_server_uuid_91",
|
4
|
-
"state": "scheduling",
|
5
|
-
"image_id": "vertual_server_image_uuid_01",
|
6
|
-
"hostname": "physical_server_uuid_01",
|
7
|
-
"instance_spec_id": "virtual_server_spec_uuid_01",
|
8
|
-
"vif": [],
|
9
|
-
"status": "init",
|
10
|
-
"memory_size": 256,
|
11
|
-
"ha_enabled": 0,
|
12
|
-
"network": [],
|
13
|
-
"arch": "x86_64",
|
14
|
-
"host_node": "physical_server_uuid_01",
|
15
|
-
"created_at": "2011-10-18T06:48:47Z",
|
16
|
-
"netfilter_group_id": ["ng-demofgr"],
|
17
|
-
"ssh_key_pair": null,
|
18
|
-
"volume": [],
|
19
|
-
"netfilter_group": ["default"],
|
20
|
-
"cpu_cores": 1
|
21
|
-
}
|
22
|
-
]
|
@@ -1,106 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"id": "virtual_server_uuid_92",
|
4
|
-
"state": "scheduling",
|
5
|
-
"image_id": "vertual_server_image_uuid_01",
|
6
|
-
"hostname": "physical_server_uuid_01",
|
7
|
-
"instance_spec_id": "virtual_server_spec_uuid_01",
|
8
|
-
"vif": [],
|
9
|
-
"status": "init",
|
10
|
-
"memory_size": 256,
|
11
|
-
"ha_enabled": 0,
|
12
|
-
"network": [],
|
13
|
-
"arch": "x86_64",
|
14
|
-
"host_node": null,
|
15
|
-
"created_at": "2011-10-18T06:48:47Z",
|
16
|
-
"netfilter_group_id": ["ng-demofgr"],
|
17
|
-
"ssh_key_pair": null,
|
18
|
-
"volume": [],
|
19
|
-
"netfilter_group": ["default"],
|
20
|
-
"cpu_cores": 1
|
21
|
-
},
|
22
|
-
|
23
|
-
{
|
24
|
-
"id": "virtual_server_uuid_93",
|
25
|
-
"state": "scheduling",
|
26
|
-
"image_id": "vertual_server_image_uuid_01",
|
27
|
-
"hostname": "physical_server_uuid_01",
|
28
|
-
"instance_spec_id": "virtual_server_spec_uuid_01",
|
29
|
-
"vif": [],
|
30
|
-
"status": "init",
|
31
|
-
"memory_size": 256,
|
32
|
-
"ha_enabled": 0,
|
33
|
-
"network": [],
|
34
|
-
"arch": "x86_64",
|
35
|
-
"host_node": null,
|
36
|
-
"created_at": "2011-10-18T06:48:47Z",
|
37
|
-
"netfilter_group_id": ["ng-demofgr"],
|
38
|
-
"ssh_key_pair": null,
|
39
|
-
"volume": [],
|
40
|
-
"netfilter_group": ["default"],
|
41
|
-
"cpu_cores": 1
|
42
|
-
},
|
43
|
-
|
44
|
-
{
|
45
|
-
"id": "virtual_server_uuid_94",
|
46
|
-
"state": "scheduling",
|
47
|
-
"image_id": "vertual_server_image_uuid_01",
|
48
|
-
"hostname": "physical_server_uuid_01",
|
49
|
-
"instance_spec_id": "virtual_server_spec_uuid_01",
|
50
|
-
"vif": [],
|
51
|
-
"status": "init",
|
52
|
-
"memory_size": 256,
|
53
|
-
"ha_enabled": 0,
|
54
|
-
"network": [],
|
55
|
-
"arch": "x86_64",
|
56
|
-
"host_node": null,
|
57
|
-
"created_at": "2011-10-18T06:48:47Z",
|
58
|
-
"netfilter_group_id": ["ng-demofgr"],
|
59
|
-
"ssh_key_pair": null,
|
60
|
-
"volume": [],
|
61
|
-
"netfilter_group": ["default"],
|
62
|
-
"cpu_cores": 1
|
63
|
-
},
|
64
|
-
|
65
|
-
{
|
66
|
-
"id": "virtual_server_uuid_95",
|
67
|
-
"state": "scheduling",
|
68
|
-
"image_id": "vertual_server_image_uuid_01",
|
69
|
-
"hostname": "physical_server_uuid_01",
|
70
|
-
"instance_spec_id": "virtual_server_spec_uuid_01",
|
71
|
-
"vif": [],
|
72
|
-
"status": "init",
|
73
|
-
"memory_size": 256,
|
74
|
-
"ha_enabled": 0,
|
75
|
-
"network": [],
|
76
|
-
"arch": "x86_64",
|
77
|
-
"host_node": null,
|
78
|
-
"created_at": "2011-10-18T06:48:47Z",
|
79
|
-
"netfilter_group_id": ["ng-demofgr"],
|
80
|
-
"ssh_key_pair": null,
|
81
|
-
"volume": [],
|
82
|
-
"netfilter_group": ["default"],
|
83
|
-
"cpu_cores": 1
|
84
|
-
},
|
85
|
-
|
86
|
-
{
|
87
|
-
"id": "virtual_server_uuid_96",
|
88
|
-
"state": "scheduling",
|
89
|
-
"image_id": "vertual_server_image_uuid_01",
|
90
|
-
"hostname": "physical_server_uuid_01",
|
91
|
-
"instance_spec_id": "virtual_server_spec_uuid_01",
|
92
|
-
"vif": [],
|
93
|
-
"status": "init",
|
94
|
-
"memory_size": 256,
|
95
|
-
"ha_enabled": 0,
|
96
|
-
"network": [],
|
97
|
-
"arch": "x86_64",
|
98
|
-
"host_node": null,
|
99
|
-
"created_at": "2011-10-18T06:48:47Z",
|
100
|
-
"netfilter_group_id": ["ng-demofgr"],
|
101
|
-
"ssh_key_pair": null,
|
102
|
-
"volume": [],
|
103
|
-
"netfilter_group": ["default"],
|
104
|
-
"cpu_cores": 1
|
105
|
-
}
|
106
|
-
]
|
@@ -1,22 +0,0 @@
|
|
1
|
-
[
|
2
|
-
{
|
3
|
-
"id": "virtual_server_uuid_91",
|
4
|
-
"state": "scheduling",
|
5
|
-
"image_id": "vertual_server_image_uuid_01",
|
6
|
-
"hostname": "physical_server_uuid_01",
|
7
|
-
"instance_spec_id": "virtual_server_spec_uuid_01",
|
8
|
-
"vif": [],
|
9
|
-
"status": "init",
|
10
|
-
"memory_size": 256,
|
11
|
-
"ha_enabled": 0,
|
12
|
-
"network": [],
|
13
|
-
"arch": "x86_64",
|
14
|
-
"host_node": "",
|
15
|
-
"created_at": "2011-10-18T06:48:47Z",
|
16
|
-
"netfilter_group_id": ["ng-demofgr"],
|
17
|
-
"ssh_key_pair": null,
|
18
|
-
"volume": [],
|
19
|
-
"netfilter_group": ["default"],
|
20
|
-
"cpu_cores": 1
|
21
|
-
}
|
22
|
-
]
|
@@ -1 +0,0 @@
|
|
1
|
-
[]
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Tengine::Resource::VirtualServerImage do
|
5
|
-
valid_attributes1 = {
|
6
|
-
:name => "provider1"
|
7
|
-
}.freeze
|
8
|
-
|
9
|
-
context "nameは必須" do
|
10
|
-
it "正常系" do
|
11
|
-
Tengine::Resource::VirtualServerImage.delete_all
|
12
|
-
credential1 = Tengine::Resource::VirtualServerImage.new(valid_attributes1)
|
13
|
-
credential1.valid?.should == true
|
14
|
-
end
|
15
|
-
|
16
|
-
[:name].each do |key|
|
17
|
-
it "#{key}なし" do
|
18
|
-
attrs = valid_attributes1.dup
|
19
|
-
attrs.delete(key)
|
20
|
-
credential1 = Tengine::Resource::VirtualServerImage.new(attrs)
|
21
|
-
credential1.valid?.should == false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
context "nameはユニーク" do
|
28
|
-
before do
|
29
|
-
Tengine::Resource::VirtualServerImage.delete_all
|
30
|
-
@credential1 = Tengine::Resource::VirtualServerImage.create!(valid_attributes1)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "同じ名前で登録されているものが存在する場合エラー" do
|
34
|
-
expect{
|
35
|
-
@credential1 = Tengine::Resource::VirtualServerImage.create!(valid_attributes1)
|
36
|
-
}.to raise_error(Mongoid::Errors::Validations, "Validation failed - Name is already taken.")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "nameはベース名として定義される文字列です" do
|
41
|
-
it "スラッシュ'/’はリソース識別子で使われるのでnameには使用できません" do
|
42
|
-
server1 = Tengine::Resource::VirtualServerImage.new(:name => "foo/bar")
|
43
|
-
server1.valid?.should == false
|
44
|
-
server1.errors[:name].should == [Tengine::Core::Validation::BASE_NAME.message]
|
45
|
-
end
|
46
|
-
|
47
|
-
it "コロン':'はリソース識別子で使われるのでnameには使用できません" do
|
48
|
-
server1 = Tengine::Resource::VirtualServerImage.new(:name => "foo:bar")
|
49
|
-
server1.valid?.should == false
|
50
|
-
server1.errors[:name].should == [Tengine::Core::Validation::BASE_NAME.message]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "nameで検索" do
|
55
|
-
before do
|
56
|
-
Tengine::Resource::VirtualServerImage.delete_all
|
57
|
-
@fixture = GokuAtEc2ApNortheast.new
|
58
|
-
@hadoop_image = @fixture.hadoop_image
|
59
|
-
end
|
60
|
-
|
61
|
-
context "見つかる場合" do
|
62
|
-
it "find_by_name" do
|
63
|
-
found_credential = nil
|
64
|
-
lambda{
|
65
|
-
found_credential = Tengine::Resource::VirtualServerImage.find_by_name(@hadoop_image.name)
|
66
|
-
}.should_not raise_error
|
67
|
-
found_credential.should_not be_nil
|
68
|
-
found_credential.id.should == @hadoop_image.id
|
69
|
-
end
|
70
|
-
|
71
|
-
it "find_by_name!" do
|
72
|
-
found_credential = nil
|
73
|
-
lambda{
|
74
|
-
found_credential = Tengine::Resource::VirtualServerImage.find_by_name!(@hadoop_image.name)
|
75
|
-
}.should_not raise_error
|
76
|
-
found_credential.should_not be_nil
|
77
|
-
found_credential.id.should == @hadoop_image.id
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "見つからない場合" do
|
82
|
-
it "find_by_name" do
|
83
|
-
found_credential = Tengine::Resource::VirtualServerImage.find_by_name("unexist_name").should == nil
|
84
|
-
end
|
85
|
-
|
86
|
-
it "find_by_name!" do
|
87
|
-
lambda{
|
88
|
-
found_credential = Tengine::Resource::VirtualServerImage.find_by_name!("unexist_name")
|
89
|
-
}.should raise_error(Tengine::Core::FindByName::Error)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Tengine::Resource::VirtualServer do
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
@fixture = GokuAtEc2ApNortheast.new
|
8
|
-
end
|
9
|
-
|
10
|
-
context "サーバの状態が変わったとき" do
|
11
|
-
before do
|
12
|
-
@fixture.virtual_servers
|
13
|
-
end
|
14
|
-
|
15
|
-
it "railsサーバが落とされたことを検出したのでサーバに反映できる" do
|
16
|
-
rails1 = @fixture.rails_server(1)
|
17
|
-
rails1.status = "terminated"
|
18
|
-
rails1.save!
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
context "nameで検索" do
|
24
|
-
before do
|
25
|
-
Tengine::Resource::Server.delete_all
|
26
|
-
@fixture = GokuAtEc2ApNortheast.new
|
27
|
-
@physical1 = @fixture.availability_zone(1)
|
28
|
-
@virtual1 = @fixture.hadoop_master_node
|
29
|
-
@virtual2 = @fixture.hadoop_slave_node(1)
|
30
|
-
end
|
31
|
-
|
32
|
-
context "見つかる場合" do
|
33
|
-
it "find_by_name" do
|
34
|
-
found_credential = nil
|
35
|
-
lambda{
|
36
|
-
found_credential = Tengine::Resource::VirtualServer.find_by_name(@virtual1.name)
|
37
|
-
}.should_not raise_error
|
38
|
-
found_credential.should_not be_nil
|
39
|
-
found_credential.id.should == @virtual1.id
|
40
|
-
end
|
41
|
-
|
42
|
-
it "find_by_name!" do
|
43
|
-
found_credential = nil
|
44
|
-
lambda{
|
45
|
-
found_credential = Tengine::Resource::VirtualServer.find_by_name!(@virtual2.name)
|
46
|
-
}.should_not raise_error
|
47
|
-
found_credential.should_not be_nil
|
48
|
-
found_credential.id.should == @virtual2.id
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "見つからない場合" do
|
53
|
-
it "find_by_name" do
|
54
|
-
found_credential = Tengine::Resource::VirtualServer.find_by_name(@physical1).should == nil
|
55
|
-
end
|
56
|
-
|
57
|
-
it "find_by_name!" do
|
58
|
-
lambda{
|
59
|
-
found_credential = Tengine::Resource::VirtualServer.find_by_name!(@physical1)
|
60
|
-
}.should raise_error(Tengine::Core::FindByName::Error)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
describe :launch_mode? do
|
67
|
-
context "launch_countが設定されていたらtrue" do
|
68
|
-
subject{ Tengine::Resource::VirtualServer.new(:launch_count => '1') }
|
69
|
-
its(:launch_count){ should == 1}
|
70
|
-
its(:launch_mode?){ should == true}
|
71
|
-
end
|
72
|
-
|
73
|
-
context "launch_countがnilならばfalse" do
|
74
|
-
subject{ Tengine::Resource::VirtualServer.new(:launch_count => nil) }
|
75
|
-
its(:launch_count){ should == nil}
|
76
|
-
its(:launch_mode?){ should == false}
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe :launch_mode do
|
81
|
-
before do
|
82
|
-
I18n.locale = :ja
|
83
|
-
end
|
84
|
-
|
85
|
-
before "既に重複する名前のモデルが登録されている場合" do
|
86
|
-
Tengine::Resource::VirtualServer.tap do |c|
|
87
|
-
c.delete_all
|
88
|
-
c.create!(:name => "test003", :provided_id => "provided_id_003")
|
89
|
-
c.create!(:name => "test004", :provided_id => "provided_id_004")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
it "testを2台起動しようとした場合" do
|
94
|
-
s = Tengine::Resource::VirtualServer.new(:name => "test", :launch_count => 2)
|
95
|
-
s.valid?
|
96
|
-
s.errors.full_messages.should == []
|
97
|
-
s.errors[:name].should == []
|
98
|
-
end
|
99
|
-
|
100
|
-
it "testを3台起動しようとした場合" do
|
101
|
-
s = Tengine::Resource::VirtualServer.new(:name => "test", :launch_count => 3)
|
102
|
-
s.valid?
|
103
|
-
s.errors[:name].should == ["に指定されたtest003は既に登録されています"]
|
104
|
-
s.errors.full_messages.should == ["Name に指定されたtest003は既に登録されています"]
|
105
|
-
end
|
106
|
-
|
107
|
-
it "testを4台起動しようとした場合" do
|
108
|
-
s = Tengine::Resource::VirtualServer.new(:name => "test", :launch_count => 4)
|
109
|
-
s.valid?
|
110
|
-
s.errors[:name].should == ["に指定されたtest003,test004は既に登録されています"]
|
111
|
-
s.errors.full_messages.should == ["Name に指定されたtest003,test004は既に登録されています"]
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
end
|