|
|
|
|
@ -7,10 +7,10 @@ import (
|
|
|
|
|
"github.com/outscale/osc-go/oapi"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestBlockDevice(t *testing.T) {
|
|
|
|
|
func TestBlockDevice_LaunchDevices(t *testing.T) {
|
|
|
|
|
cases := []struct {
|
|
|
|
|
Config *BlockDevice
|
|
|
|
|
Result *oapi.BlockDeviceMapping
|
|
|
|
|
Result oapi.BlockDeviceMappingVmCreation
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
@ -21,9 +21,9 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.Bsu{
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
SnapshotId: "snap-1234",
|
|
|
|
|
VolumeType: "standard",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
@ -37,9 +37,9 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.Bsu{
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: false,
|
|
|
|
|
},
|
|
|
|
|
@ -54,9 +54,9 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
IOPS: 1000,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.Bsu{
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "io1",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
@ -72,9 +72,9 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.Bsu{
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "gp2",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
@ -89,9 +89,9 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.Bsu{
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "gp2",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
@ -105,9 +105,9 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.Bsu{
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "standard",
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
@ -119,7 +119,7 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
VirtualName: "ephemeral0",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VirtualDeviceName: "ephemeral0",
|
|
|
|
|
},
|
|
|
|
|
@ -130,7 +130,7 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
NoDevice: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: &oapi.BlockDeviceMapping{
|
|
|
|
|
Result: oapi.BlockDeviceMappingVmCreation{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
NoDevice: "",
|
|
|
|
|
},
|
|
|
|
|
@ -138,21 +138,12 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tc := range cases {
|
|
|
|
|
omiBlockDevices := OMIBlockDevices{
|
|
|
|
|
OMIMappings: []BlockDevice{*tc.Config},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
launchBlockDevices := LaunchBlockDevices{
|
|
|
|
|
LaunchMappings: []BlockDevice{*tc.Config},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expected := []*oapi.BlockDeviceMapping{tc.Result}
|
|
|
|
|
|
|
|
|
|
omiResults := omiBlockDevices.BuildOMIDevices()
|
|
|
|
|
if !reflect.DeepEqual(expected, omiResults) {
|
|
|
|
|
t.Fatalf("Bad block device, \nexpected: %#v\n\ngot: %#v",
|
|
|
|
|
expected, omiResults)
|
|
|
|
|
}
|
|
|
|
|
expected := []oapi.BlockDeviceMappingVmCreation{tc.Result}
|
|
|
|
|
|
|
|
|
|
launchResults := launchBlockDevices.BuildLaunchDevices()
|
|
|
|
|
if !reflect.DeepEqual(expected, launchResults) {
|
|
|
|
|
@ -161,3 +152,146 @@ func TestBlockDevice(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBlockDevice_OMI(t *testing.T) {
|
|
|
|
|
cases := []struct {
|
|
|
|
|
Config *BlockDevice
|
|
|
|
|
Result oapi.BlockDeviceMappingImage
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
SnapshotId: "snap-1234",
|
|
|
|
|
VolumeType: "standard",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
SnapshotId: "snap-1234",
|
|
|
|
|
VolumeType: "standard",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VolumeType: "io1",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
IOPS: 1000,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "io1",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
Iops: 1000,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VolumeType: "gp2",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "gp2",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VolumeType: "gp2",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "gp2",
|
|
|
|
|
VolumeSize: 8,
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VolumeType: "standard",
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
Bsu: oapi.BsuToCreate{
|
|
|
|
|
VolumeType: "standard",
|
|
|
|
|
DeleteOnVmDeletion: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VirtualName: "ephemeral0",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
VirtualDeviceName: "ephemeral0",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Config: &BlockDevice{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Result: oapi.BlockDeviceMappingImage{
|
|
|
|
|
DeviceName: "/dev/sdb",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tc := range cases {
|
|
|
|
|
omiBlockDevices := OMIBlockDevices{
|
|
|
|
|
OMIMappings: []BlockDevice{*tc.Config},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expected := []oapi.BlockDeviceMappingImage{tc.Result}
|
|
|
|
|
|
|
|
|
|
omiResults := omiBlockDevices.BuildOMIDevices()
|
|
|
|
|
if !reflect.DeepEqual(expected, omiResults) {
|
|
|
|
|
t.Fatalf("Bad block device, \nexpected: %#v\n\ngot: %#v",
|
|
|
|
|
expected, omiResults)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|