// Test volume attachment by volume ID func volumeAttach( t *testing.T, client types.Client, volumeID string) *types.Volume { log.WithField("volumeID", volumeID).Info("attaching volume") // Get next device name from executor nextDevice, err := client.Executor().NextDevice(context.Background().WithValue(context.ServiceKey, ebs.Name), utils.NewStore()) assert.NoError(t, err) if err != nil { t.Error("error getting next device name from executor") t.FailNow() } reply, token, err := client.API().VolumeAttach( nil, ebs.Name, volumeID, &types.VolumeAttachRequest{ NextDeviceName: &nextDevice, }) assert.NoError(t, err) if err != nil { t.Error("failed volumeAttach") t.FailNow() } apitests.LogAsJSON(reply, t) assert.NotEqual(t, token, "") return reply }
// Test is the APITestFunc for the NextDeviceTest. func (tt *NextDeviceTest) Test( config gofig.Config, client types.Client, t *testing.T) { ctx := context.Background().WithValue(context.ServiceKey, tt.Driver) val, err := client.Executor().NextDevice(ctx, utils.NewStore()) assert.NoError(t, err) assert.Equal(t, tt.Expected, val) }
// Test is the APITestFunc for the InstanceIDTest. func (tt *InstanceIDTest) Test( config gofig.Config, client types.Client, t *testing.T) { expectedBuf, err := json.Marshal(tt.Expected) assert.NoError(t, err) expectedJSON := string(expectedBuf) ctx := context.Background().WithValue(context.ServiceKey, tt.Driver) iid, err := client.Executor().InstanceID(ctx, utils.NewStore()) assert.NoError(t, err) iidBuf, err := json.Marshal(iid) assert.NoError(t, err) iidJSON := string(iidBuf) assert.Equal(t, expectedJSON, iidJSON) }
// Test is the APITestFunc for the LocalDevicesTest. func (tt *LocalDevicesTest) Test( config gofig.Config, client types.Client, t *testing.T) { expectedBuf, err := tt.Expected.MarshalText() assert.NoError(t, err) expectedText := string(expectedBuf) ctx := context.Background().WithValue(context.ServiceKey, tt.Driver) val, err := client.Executor().LocalDevices(ctx, &types.LocalDevicesOpts{ ScanType: types.DeviceScanQuick, Opts: utils.NewStore(), }) assert.NoError(t, err) buf, err := val.MarshalText() assert.NoError(t, err) actualText := string(buf) assert.Equal(t, expectedText, actualText) }