Пример #1
0
func TestVolumesWithAttachmentsMineWithNotMyInstanceID(
	t *testing.T) {
	tc, _, _, _ := newTestConfigAll(t)
	tf := func(config gofig.Config, client types.Client, t *testing.T) {

		ctx := context.Background()
		iidm := types.InstanceIDMap{
			"vfs": &types.InstanceID{ID: "none", Driver: "vfs"},
		}
		ctx = ctx.WithValue(context.AllInstanceIDsKey, iidm)

		reply, err := client.API().Volumes(ctx, types.VolAttReqForInstance)
		if err != nil {
			t.Fatal(err)
		}

		assert.NotNil(t, reply["vfs"]["vfs-000"])
		assert.NotNil(t, reply["vfs"]["vfs-001"])
		assert.NotNil(t, reply["vfs"]["vfs-002"])
		assert.Len(t, reply["vfs"]["vfs-000"].Attachments, 0)
		assert.Len(t, reply["vfs"]["vfs-001"].Attachments, 0)
		assert.Len(t, reply["vfs"]["vfs-002"].Attachments, 0)
	}
	apitests.RunWithClientType(t, types.ControllerClient, vfs.Name, tc, tf)
}
Пример #2
0
func TestVolumeDetachAllWithControllerClient(t *testing.T) {
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		_, err := client.API().VolumeDetachAll(
			nil, &types.VolumeDetachRequest{})
		assert.Error(t, err)
		assert.Equal(t, "unsupported op for client type", err.Error())
	}
	apitests.RunWithClientType(
		t, types.ControllerClient, vfs.Name, newTestConfig(t), tf)
}
Пример #3
0
func TestVolumesWithAttachmentsWithControllerClient(t *testing.T) {
	tc, _, _, _ := newTestConfigAll(t)
	tf := func(config gofig.Config, client types.Client, t *testing.T) {

		_, err := client.API().Volumes(nil, types.VolAttReqTrue)
		assert.Error(t, err)
		assert.Equal(t, "batch processing error", err.Error())
	}

	apitests.RunWithClientType(t, types.ControllerClient, vfs.Name, tc, tf)
}
Пример #4
0
func TestVolumes(t *testing.T) {
	tc, _, vols, _ := newTestConfigAll(t)
	tf := func(config gofig.Config, client types.Client, t *testing.T) {
		reply, err := client.API().Volumes(nil, types.VolAttNone)
		if err != nil {
			t.Fatal(err)
		}
		for volumeID, volume := range vols {
			volume.Attachments = nil
			assert.NotNil(t, reply["vfs"][volumeID])
			assert.EqualValues(t, volume, reply["vfs"][volumeID])
		}
	}
	apitests.Run(t, vfs.Name, tc, tf)
	apitests.RunWithClientType(t, types.ControllerClient, vfs.Name, tc, tf)
}
Пример #5
0
func TestVolumeAttachWithControllerClient(t *testing.T) {
	tf := func(config gofig.Config, client types.Client, t *testing.T) {

		_, err := client.Executor().NextDevice(
			context.Background().WithValue(context.ServiceKey, vfs.Name),
			utils.NewStore())
		assert.Error(t, err)
		assert.Equal(t, "unsupported op for client type", err.Error())

		_, _, err = client.API().VolumeAttach(
			nil, vfs.Name, "vfs-002", &types.VolumeAttachRequest{})
		assert.Error(t, err)
		assert.Equal(t, "unsupported op for client type", err.Error())
	}

	apitests.RunWithClientType(
		t, types.ControllerClient, vfs.Name, newTestConfig(t), tf)
}
Пример #6
0
func TestExecutorsWithControllerClient(t *testing.T) {
	apitests.RunWithClientType(
		t, types.ControllerClient, vfs.Name, newTestConfig(t),
		apitests.TestExecutorsWithControllerClient)
}
Пример #7
0
func TestServicesWithControllerClient(t *testing.T) {
	apitests.RunWithClientType(
		t, types.ControllerClient, vfs.Name, newTestConfig(t), testServicesFunc)
}