Retire mount.Exec for k8s.io/utils/exec

This patch removes mount.Exec entirely and instead uses the common
utility from k8s.io/utils/exec.

The fake exec implementation found in k8s.io/utils/exec differs a bit
than mount.Exec, with the ability to pre-script expected calls to
Command.CombinedOutput(), so tests that previously relied on a callback
mechanism to produce specific output have been updated to use that
mechanism.
This commit is contained in:
Travis Rhoden
2019-10-10 11:27:54 -06:00
parent e7ce8d8a6f
commit 367f879131
53 changed files with 449 additions and 324 deletions

View File

@@ -29,6 +29,8 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/fake"
utiltesting "k8s.io/client-go/util/testing"
"k8s.io/utils/exec/testing"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumetest "k8s.io/kubernetes/pkg/volume/testing"
@@ -164,7 +166,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
fakeManager := newFakeDiskManager()
defer fakeManager.Cleanup()
fakeMounter := mount.NewFakeMounter(nil)
fakeExec := mount.NewFakeExec(nil)
fakeExec := &testingexec.FakeExec{}
mounter, err := plug.(*fcPlugin).newMounterInternal(spec, types.UID("poduid"), fakeManager, fakeMounter, fakeExec)
if err != nil {
t.Errorf("Failed to make a new Mounter: %v", err)
@@ -227,7 +229,7 @@ func doTestPluginNilMounter(t *testing.T, spec *volume.Spec) {
fakeManager := newFakeDiskManager()
defer fakeManager.Cleanup()
fakeMounter := mount.NewFakeMounter(nil)
fakeExec := mount.NewFakeExec(nil)
fakeExec := &testingexec.FakeExec{}
mounter, err := plug.(*fcPlugin).newMounterInternal(spec, types.UID("poduid"), fakeManager, fakeMounter, fakeExec)
if err == nil {
t.Errorf("Error failed to make a new Mounter is expected: %v", err)