Skip to content

Commit 22797e5

Browse files
committed
Fix failing unit tests due to CloudControl schema change.
1 parent bef11f8 commit 22797e5

File tree

5 files changed

+86
-51
lines changed

5 files changed

+86
-51
lines changed

compute/common_contracts.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ type OperatingSystem struct {
7171
DisplayName string `json:"displayName"`
7272
}
7373

74+
// ImageGuestInformation represents guest-related information about a virtual machine image.
75+
type ImageGuestInformation struct {
76+
OperatingSystem OperatingSystem `json:"operatingSystem"`
77+
OSCustomization bool `json:"osCustomization"`
78+
}
79+
7480
// VirtualMachineCPU represents the CPU configuration for a virtual machine.
7581
type VirtualMachineCPU struct {
7682
Count int `json:"count,omitempty"`

compute/customer_images.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type CustomerImage struct {
3131
Name string `json:"name"`
3232
Description string `json:"description"`
3333
DataCenterID string `json:"datacenterId"`
34-
OperatingSystem OperatingSystem `json:"operatingSystem"`
34+
Guest ImageGuestInformation `json:"guest"`
3535
CPU VirtualMachineCPU `json:"cpu"`
3636
MemoryGB int `json:"memoryGb"`
3737
SCSIControllers VirtualMachineSCSIControllers `json:"scsiControllers"`
@@ -88,7 +88,7 @@ func (image *CustomerImage) GetDatacenterID() string {
8888

8989
// GetOS retrieves information about the image's operating system.
9090
func (image *CustomerImage) GetOS() OperatingSystem {
91-
return image.OperatingSystem
91+
return image.Guest.OperatingSystem
9292
}
9393

9494
// ApplyTo applies the CustomerImage to the specified ServerDeploymentConfiguration.

compute/os_images.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type OSImage struct {
1313
Name string `json:"name"`
1414
Description string `json:"description"`
1515
DataCenterID string `json:"datacenterId"`
16-
OperatingSystem OperatingSystem `json:"operatingSystem"`
16+
Guest ImageGuestInformation `json:"guest"`
1717
CPU VirtualMachineCPU `json:"cpu"`
1818
MemoryGB int `json:"memoryGb"`
1919
SCSIControllers VirtualMachineSCSIControllers `json:"scsiController"`
@@ -71,7 +71,7 @@ func (image *OSImage) GetDatacenterID() string {
7171

7272
// GetOS retrieves information about the image's operating system.
7373
func (image *OSImage) GetOS() OperatingSystem {
74-
return image.OperatingSystem
74+
return image.Guest.OperatingSystem
7575
}
7676

7777
// ApplyTo applies the OSImage to the specified ServerDeploymentConfiguration.

compute/os_images_test.go

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,47 @@ var findOSImageTestResponse = `
3838
{
3939
"osImage": [
4040
{
41-
"name": "CentOS 7 64-bit 2 CPU",
42-
"description": "CentOS Release 7.1 64-bit",
43-
"operatingSystem": {
44-
"id": "CENTOS764",
45-
"displayName": "CENTOS7/64",
46-
"family": "UNIX"
47-
},
48-
"cpu": {
49-
"count": 2,
50-
"speed": "STANDARD",
51-
"coresPerSocket": 1
52-
},
53-
"memoryGb": 4,
54-
"disk": [
55-
{
56-
"id": "55f6780c-bcc6-49d5-8e9b-26c26b6381fa",
57-
"scsiId": 0,
58-
"sizeGb": 10,
59-
"speed": "STANDARD"
41+
"name": "CentOS 7 64-bit 2 CPU",
42+
"description": "CentOS Release 7.2 64-bit",
43+
"cpu": {
44+
"count": 2,
45+
"speed": "STANDARD",
46+
"coresPerSocket": 1
47+
},
48+
"memoryGb": 4,
49+
"scsiController": [
50+
{
51+
"id": "eec5a912-0fb0-11e7-b626-001b21cfdbe0",
52+
"adapterType": "LSI_LOGIC_PARALLEL",
53+
"key": 1000,
54+
"disk": [
55+
{
56+
"id": "fab8c94e-5f8a-4617-8be9-6514fc779bf1",
57+
"sizeGb": 10,
58+
"speed": "STANDARD",
59+
"scsiId": 0
60+
}
61+
],
62+
"busNumber": 0
63+
}
64+
],
65+
"sataController": [],
66+
"floppy": [],
67+
"nic": [],
68+
"softwareLabel": [],
69+
"createTime": "2016-08-10T14:05:12.000Z",
70+
"id": "e1b4e0cc-35ba-47be-a2d7-1b5601b87119",
71+
"datacenterId": "AU9",
72+
"osImageKey": "T-CENT-7-64-2-4-10",
73+
"sortOrder": 65,
74+
"guest": {
75+
"operatingSystem": {
76+
"id": "CENTOS764",
77+
"displayName": "CENTOS7/64",
78+
"family": "UNIX"
79+
},
80+
"osCustomization": true
6081
}
61-
],
62-
"softwareLabel": [],
63-
"createTime": "2015-10-26T10:34:40.000Z",
64-
"id": "7e68acb4-bbb8-4206-b30b-0e6c878056bc",
65-
"datacenterId": "AU9",
66-
"osImageKey": "T-CENT-7-64-2-4-10"
6782
}
6883
],
6984
"pageNumber": 1,
@@ -77,26 +92,33 @@ func verifyFindOSImageTestResponse(test *testing.T, image *OSImage) {
7792
expect := expect(test)
7893

7994
expect.NotNil("OSImage", image)
80-
expect.EqualsString("OSImage.ID", "7e68acb4-bbb8-4206-b30b-0e6c878056bc", image.ID)
95+
expect.EqualsString("OSImage.ID", "e1b4e0cc-35ba-47be-a2d7-1b5601b87119", image.ID)
8196
expect.EqualsString("OSImage.Name", "CentOS 7 64-bit 2 CPU", image.Name)
82-
expect.EqualsString("OSImage.Description", "CentOS Release 7.1 64-bit", image.Description)
97+
expect.EqualsString("OSImage.Description", "CentOS Release 7.2 64-bit", image.Description)
8398

84-
expect.EqualsString("OSImage.OperatingSystem.ID", "CENTOS764", image.OperatingSystem.ID)
85-
expect.EqualsString("OSImage.OperatingSystem.DisplayName", "CENTOS7/64", image.OperatingSystem.DisplayName)
86-
expect.EqualsString("OSImage.OperatingSystem.Family", "UNIX", image.OperatingSystem.Family)
99+
expect.EqualsString("OSImage.Guest.OperatingSystem.ID", "CENTOS764", image.Guest.OperatingSystem.ID)
100+
expect.EqualsString("OSImage.Guest.OperatingSystem.DisplayName", "CENTOS7/64", image.Guest.OperatingSystem.DisplayName)
101+
expect.EqualsString("OSImage.Guest.OperatingSystem.Family", "UNIX", image.Guest.OperatingSystem.Family)
87102

88103
expect.EqualsInt("OSImage.CPU.Count", 2, image.CPU.Count)
89104
expect.EqualsString("OSImage.CPU.Speed", "STANDARD", image.CPU.Speed)
90105
expect.EqualsInt("OSImage.CPU.CoresPerSocket", 1, image.CPU.CoresPerSocket)
91106

92-
expect.NotNil("OSImage.Disks", image.Disks)
107+
expect.EqualsInt("OSImage.SCSIControllers.Length", 1, len(image.SCSIControllers))
93108

94-
disk1 := image.Disks[0]
95-
expect.EqualsString("OSImage.Disks[0].ID", "55f6780c-bcc6-49d5-8e9b-26c26b6381fa", disk1.ID)
109+
controller1 := image.SCSIControllers[0]
110+
expect.EqualsString("OSImage.SCSIControllers[0].ID", "eec5a912-0fb0-11e7-b626-001b21cfdbe0", controller1.ID)
111+
expect.EqualsString("OSImage.SCSIControllers[0].AdapterType", StorageControllerAdapterTypeLSILogicParallel, controller1.AdapterType)
112+
expect.EqualsInt("OSImage.SCSIControllers[0].BusNumber", 0, controller1.BusNumber)
113+
114+
expect.EqualsInt("OSImage.SCSIControllers[0].Disks.Length", 1, len(controller1.Disks))
115+
116+
disk1 := controller1.Disks[0]
117+
expect.EqualsString("OSImage.Disks[0].ID", "fab8c94e-5f8a-4617-8be9-6514fc779bf1", disk1.ID)
96118
expect.EqualsInt("OSImage.Disks[0].SCSIUnitID", 0, disk1.SCSIUnitID)
97119
expect.EqualsInt("OSImage.Disks[0].SizeGB", 10, disk1.SizeGB)
98120
expect.EqualsString("OSImage.Disks[0].Speed", "STANDARD", disk1.Speed)
99121

100-
expect.EqualsString("OSImage.CreateTime", "2015-10-26T10:34:40.000Z", image.CreateTime)
122+
expect.EqualsString("OSImage.CreateTime", "2016-08-10T14:05:12.000Z", image.CreateTime)
101123
expect.EqualsString("OSImage.OSImageKey", "T-CENT-7-64-2-4-10", image.OSImageKey)
102124
}

compute/servers_test.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,20 @@ func TestClient_DeployServer_Success(test *testing.T) {
8282
},
8383
},
8484
},
85-
Disks: []VirtualMachineDisk{
86-
VirtualMachineDisk{
87-
SCSIUnitID: 0,
88-
Speed: "STANDARD",
89-
},
90-
VirtualMachineDisk{
91-
SCSIUnitID: 1,
92-
Speed: "HIGHPERFORMANCE",
85+
SCSIControllers: []VirtualMachineSCSIController{
86+
VirtualMachineSCSIController{
87+
BusNumber: 0,
88+
AdapterType: StorageControllerAdapterTypeLSILogicParallel,
89+
Disks: []VirtualMachineDisk{
90+
VirtualMachineDisk{
91+
SCSIUnitID: 0,
92+
Speed: "STANDARD",
93+
},
94+
VirtualMachineDisk{
95+
SCSIUnitID: 1,
96+
Speed: "HIGHPERFORMANCE",
97+
},
98+
},
9399
},
94100
},
95101
}
@@ -401,13 +407,14 @@ func verifyDeployServerTestRequest(test *testing.T, deploymentConfiguration *Ser
401407
expect.EqualsString("ServerDeploymentConfiguration.Network.AdditionalNetworkAdapters[1].AdapterType", "VMXNET3", *network.AdditionalNetworkAdapters[1].AdapterType)
402408

403409
// Disks.
404-
expect.EqualsInt("ServerDeploymentConfiguration.Disks.Length", 2, len(deploymentConfiguration.Disks))
410+
expect.EqualsInt("ServerDeploymentConfiguration.SCSIControllers.Length", 1, len(deploymentConfiguration.SCSIControllers))
411+
expect.EqualsInt("ServerDeploymentConfiguration.SCSIControllers[0].Disks.Length", 2, len(deploymentConfiguration.SCSIControllers[0].Disks))
405412

406-
expect.EqualsInt("ServerDeploymentConfiguration.Disks[0].SCSIUnitID", 0, deploymentConfiguration.Disks[0].SCSIUnitID)
407-
expect.EqualsString("ServerDeploymentConfiguration.Disks[0].Speed", "STANDARD", deploymentConfiguration.Disks[0].Speed)
413+
expect.EqualsInt("ServerDeploymentConfiguration.SCSIControllers[0].Disks[0].SCSIUnitID", 0, deploymentConfiguration.SCSIControllers[0].Disks[0].SCSIUnitID)
414+
expect.EqualsString("ServerDeploymentConfiguration.SCSIControllers[0].Disks[0].Speed", "STANDARD", deploymentConfiguration.SCSIControllers[0].Disks[0].Speed)
408415

409-
expect.EqualsInt("ServerDeploymentConfiguration.Disks[1].SCSIUnitID", 1, deploymentConfiguration.Disks[1].SCSIUnitID)
410-
expect.EqualsString("ServerDeploymentConfiguration.Disks[1].Speed", "HIGHPERFORMANCE", deploymentConfiguration.Disks[1].Speed)
416+
expect.EqualsInt("ServerDeploymentConfiguration.SCSIControllers[0].Disks[1].SCSIUnitID", 1, deploymentConfiguration.SCSIControllers[0].Disks[1].SCSIUnitID)
417+
expect.EqualsString("ServerDeploymentConfiguration.SCSIControllers[0].Disks[1].Speed", "HIGHPERFORMANCE", deploymentConfiguration.SCSIControllers[0].Disks[1].Speed)
411418
}
412419

413420
const addDiskToServerTestRequest = `

0 commit comments

Comments
 (0)