-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
image_tests.rb
105 lines (88 loc) · 2.86 KB
/
image_tests.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Shindo.tests('Fog::Compute[:ibm] | image requests', ['ibm']) do
@image_format = {
'state' => Integer,
'visibility' => String,
'platform' => String,
'owner' => String,
'architecture' => Fog::Nullable::String,
'createdTime' => Integer,
'location' => String,
'productCodes' => Array,
'name' => String,
'id' => String,
'description' => String,
'supportedInstanceTypes' => Array,
'manifest' => Fog::Nullable::String,
'documentation' => Fog::Nullable::String,
}
# TODO: Actually check this format
@product_code_format = {
'detail' => String,
'label' => String,
'price' => @price_format,
'id' => String
}
# TODO: Actually check this format
@price_format = {
'rate' => Float,
'unitOfMeasure' => String,
'effectiveDate' => Integer,
'currencyCode' => String,
'pricePerQuantity' => Integer
}
@images_format = {
'images' => [ @image_format ]
}
@create_image_format = {
"name" => String,
"createdTime" => Integer,
"productCodes"=> Array,
"id" => String,
"description" => String,
"visibility" => String,
"state" => Integer
}
@instance_id = nil
@name = "fog-test-image-instance-" + Time.now.to_i.to_s(32)
@image_id = "20010001"
@instance_type = "BRZ32.1/2048/60*175"
@location = "41"
@id = nil
@cloned_id = nil
@image_name = "fog test create image"
@key_name = "fog-test-key-" + Time.now.to_i.to_s(32)
@key = Fog::Compute[:ibm].keys.create(:name => @key_name)
tests('success') do
tests("#list_images").formats(@images_format) do
Fog::Compute[:ibm].list_images.body
end
tests('#get_image').formats(@image_format) do
Fog::Compute[:ibm].get_image("20010001").body
end
tests('#create_image').formats(@create_image_format) do
response = Fog::Compute[:ibm].create_instance(
@name,
@image_id,
@instance_type,
@location,
:key_name => @key_name
).body
@instance_id = response['instances'][0]['id']
data = Fog::Compute[:ibm].create_image(@instance_id, @image_name, "").body
@id = data['id']
data
end
tests('#clone_image') do
clone_name = 'fog-test-clone-image-' + Time.now.to_i.to_s(32)
data = Fog::Compute[:ibm].clone_image(@image_id, clone_name, "").body
@cloned_id = data['ImageID']
returns(String) { data['ImageID'].class }
end
tests('#delete_image') do
returns(true) { Fog::Compute[:ibm].delete_image(@id).body['success'] }
returns(true) { Fog::Compute[:ibm].delete_image(@cloned_id).body['success'] }
end
@key.wait_for { instance_ids.empty? }
@key.destroy
end
end