2
2
let ( :zone ) { EvmSpecHelper . create_guid_miq_server_zone . last }
3
3
let ( :ems ) { FactoryBot . create ( :ems_ibm_power_vc_with_vcr_authentication , :zone => zone ) }
4
4
5
+ specs = YAML . load_file ( File . join ( __dir__ , 'state.yml' ) )
6
+ specs [ 'resources' ] . each do |key , _value |
7
+ case key [ 'type' ]
8
+ when 'openstack_compute_flavor_v2'
9
+ let ( :flavorid ) { key [ 'instances' ] [ 0 ] [ 'attributes' ] [ 'id' ] }
10
+ when 'openstack_identity_project_v3'
11
+ let ( :tenantid ) { key [ 'instances' ] [ 0 ] [ 'attributes' ] [ 'id' ] }
12
+ when 'openstack_compute_instance_v2'
13
+ let ( :instid ) { key [ 'instances' ] [ 0 ] [ 'attributes' ] [ 'id' ] }
14
+ let ( :azone ) { key [ 'instances' ] [ 0 ] [ 'attributes' ] [ 'availability_zone' ] }
15
+ when 'openstack_images_image_v2'
16
+ let ( :imageid ) { key [ 'instances' ] [ 0 ] [ 'attributes' ] [ 'id' ] }
17
+ when 'openstack_networking_network_v2'
18
+ let ( :networkid ) { key [ 'instances' ] [ 0 ] [ 'attributes' ] [ 'id' ] }
19
+ end
20
+ end
21
+
5
22
describe "#refresh" do
6
23
context "full refresh" do
7
24
it "Performs a full refresh" do
@@ -21,66 +38,67 @@ def assert_ems
21
38
expect ( ems . last_refresh_error ) . to be_nil
22
39
expect ( ems . last_refresh_date ) . not_to be_nil
23
40
24
- expect ( ems . availability_zones . count ) . to eq ( 3 )
25
- expect ( ems . cloud_tenants . count ) . to eq ( 1 )
26
- expect ( ems . flavors . count ) . to eq ( 12 )
27
- expect ( ems . vms . count ) . to eq ( 4 )
41
+ expect ( ems . cloud_tenants . count ) . to be > 1
42
+ expect ( ems . availability_zones . count ) . to be > 2
43
+ expect ( ems . flavors . count ) . to be > 2
44
+ expect ( ems . vms . count ) . to be > 1
28
45
end
29
46
30
47
def assert_specific_availability_zone
31
- az = ems . availability_zones . find_by ( :ems_ref => "Default Group" )
48
+ az = ems . availability_zones . find_by ( :ems_ref => azone )
32
49
expect ( az ) . to have_attributes (
33
- :name => "Default Group" ,
34
- :ems_ref => "Default Group" ,
50
+ :name => azone ,
51
+ :ems_ref => azone ,
35
52
:type => "ManageIQ::Providers::IbmPowerVc::CloudManager::AvailabilityZone" ,
36
53
:provider_services_supported => [ "compute" ]
37
54
)
38
55
end
39
56
40
57
def assert_specific_cloud_tenant
41
- cloud_tenant = ems . cloud_tenants . find_by ( :ems_ref => "676b8977322946c0ab4700d7b908db5b" )
58
+ cloud_tenant = ems . cloud_tenants . find_by ( :ems_ref => tenantid )
42
59
expect ( cloud_tenant ) . to have_attributes (
43
60
:name => "ibm-default" ,
44
61
:description => "IBM Default Tenant" ,
45
62
:enabled => true ,
46
- :ems_ref => "676b8977322946c0ab4700d7b908db5b" ,
63
+ :ems_ref => tenantid
47
64
# TODO: :type => "ManageIQ::Providers::IbmPowerVc::CloudManager::CloudTenant"
48
65
)
49
66
end
50
67
51
68
def assert_specific_flavor
52
- flavor = ems . flavors . find_by ( :ems_ref => "4c7b250adb349d84f638aec9c76f6eba" )
69
+ flavor = ems . flavors . find_by ( :ems_ref => flavorid )
53
70
expect ( flavor ) . to have_attributes (
54
- :name => "4c7b250adb349d84f638aec9c76f6eba" ,
55
- :description => "1 CPUs, 4 GB RAM, 100 GB Root Disk" ,
56
- :cpus => 1 ,
57
- :cpu_cores => nil ,
58
- :memory => 4 . gigabytes ,
59
- :ems_ref => "4c7b250adb349d84f638aec9c76f6eba" ,
60
- :type => "ManageIQ::Providers::IbmPowerVc::CloudManager::Flavor" ,
61
- :root_disk_size => 100 . gigabytes ,
62
- :swap_disk_size => 0 ,
63
- :publicly_available => false
71
+ :name => "small" ,
72
+ :cpu_total_cores => 2 ,
73
+ :cpu_cores_per_socket => nil ,
74
+ :memory => 8_589_934_592 ,
75
+ :ems_ref => flavorid ,
76
+ :type => "ManageIQ::Providers::IbmPowerVc::CloudManager::Flavor" ,
77
+ :ephemeral_disk_size => 0 ,
78
+ :ephemeral_disk_count => 0 ,
79
+ :root_disk_size => 0 ,
80
+ :swap_disk_size => 0 ,
81
+ :publicly_available => true ,
82
+ :cpu_sockets => 1
64
83
)
65
84
end
66
85
67
86
def assert_specific_vm
68
- vm = ems . vms . find_by ( :ems_ref => "42420bf6-e08e-4360-85b0-4dea6e80344f" )
87
+ vm = ems . vms . find_by ( :ems_ref => instid )
69
88
expect ( vm ) . to have_attributes (
70
- :vendor => "ibm_power_vc" ,
71
- :name => "RHEL82_100GB-test" ,
72
- :description => nil ,
73
- :location => "unknown" ,
74
- :uid_ems => "42420bf6-e08e-4360-85b0-4dea6e80344f" ,
75
- :connection_state => "connected" ,
76
- :type => "ManageIQ::Providers::IbmPowerVc::CloudManager::Vm" ,
77
- :ems_ref => "42420bf6-e08e-4360-85b0-4dea6e80344f" ,
78
- :flavor => ems . flavors . find_by ( :ems_ref => "4c7b250adb349d84f638aec9c76f6eba" ) ,
79
- :availability_zone => ems . availability_zones . find_by ( :ems_ref => "Default Group" ) ,
80
- :cloud => true ,
81
- :cloud_tenant => ems . cloud_tenants . find_by ( :ems_ref => "676b8977322946c0ab4700d7b908db5b" ) ,
82
- :raw_power_state => "ACTIVE" ,
83
- :power_state => "on"
89
+ :vendor => "ibm_power_vc" ,
90
+ :name => "miq-testvm" ,
91
+ :description => nil ,
92
+ :location => "unknown" ,
93
+ :uid_ems => instid ,
94
+ :connection_state => "connected" ,
95
+ :type => "ManageIQ::Providers::IbmPowerVc::CloudManager::Vm" ,
96
+ :ems_ref => instid ,
97
+ :flavor => ems . flavors . find_by ( :ems_ref => flavorid ) ,
98
+ :cloud => true ,
99
+ :cloud_tenant => ems . cloud_tenants . find_by ( :ems_ref => tenantid ) ,
100
+ :raw_power_state => "ACTIVE" ,
101
+ :power_state => "on"
84
102
)
85
103
end
86
104
0 commit comments